diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..d92e4b4f90e --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +composer.phar +!dummy +/vendor/ +/data/Smarty/templates_c/* +/data/cache/* +/data/config/config.php +/data/logs/* +/data/upload/csv/* +/html/install/temp/* +/html/upload/graph_image/* +/html/upload/mobile_image/* +/html/upload/save_image/* +/html/upload/temp_image/* +/html/upload/temp_plugin/* +/html/upload/temp_template/* +/phpunit.xml +/tests/tmp/* +/reports/* diff --git a/.travis.yml b/.travis.yml index 99f23b4df0f..ba6656295d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,14 +17,13 @@ before_script: - php composer.phar install --dev --no-interaction - sh -c "if [ '$DB' = 'mysql' ]; then sh ./eccube_install.sh mysql; fi" - sh -c "if [ '$DB' = 'pgsql' ]; then sh ./eccube_install.sh pgsql; fi" - - cp tests/require.php.jenkins tests/require.php - cat ./data/config/config.php - npm install -g grunt-cli - npm install script: - mkdir -p reports/coverage - - phpunit -c phpunit.xml.dist + - vendor/bin/phpunit -c phpunit.xml.dist - grunt after_script: diff --git a/appveyor.yml b/appveyor.yml index 43bb0938f24..f09182eddd4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -59,8 +59,7 @@ build: off before_test: - bash eccube_install.sh mysql - - cp tests/require.php.jenkins tests/require.php - + test_script: - php -i - vendor\bin\phpunit.bat --bootstrap data\config\config.php tests diff --git a/composer.json b/composer.json index 566d4b856ad..2a9a479fdd3 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,49 @@ { + "name": "EC-CUBE/ec-cube", + "description": "EC-CUBE EC open platform.", + "type": "project", + "homepage": "http://www.ec-cube.net/", + "license": [ + "GPL-2.0", + "Commercial" + ], + "support": { + "issues": "https://github.com/EC-CUBE/ec-cube/issues" + }, + "repositories": [ + { + "type": "pear", + "url": "http://pear.php.net/" + } + ], + "require": { + "php": ">=5.3.3", + "smarty/smarty": "~2.6", + "mobiledetect/mobiledetectlib": "~2.8", + "pear-pear.php.net/PEAR" : "*", + "pear-pear.php.net/Archive_Tar" : "*", + "pear-pear.php.net/Mail" : "*", + "pear-pear.php.net/Calendar" : "*", + "pear-pear.php.net/Cache_Lite" : "*", + "pear-pear.php.net/File_SearchReplace" : "*", + "pear-pear.php.net/HTTP_Request" : "*", + "pear-pear.php.net/MDB2_Driver_mysql" : "1.5.0b4", + "pear-pear.php.net/MDB2_Driver_pgsql" : "1.5.0b4", + "pear-pear.php.net/MDB2" : "2.5.0-beta5 as 2.5.0", + "pear-pear.php.net/Net_SMTP" : "*", + "pear-pear.php.net/Net_Socket" : "*", + "pear-pear.php.net/Net_URL" : "*", + "pear-pear.php.net/Net_UserAgent_Mobile" : "*", + "pear-pear.php.net/SOAP" : "*", + "pear-pear.php.net/Services_JSON" : "*", + "pear-pear.php.net/Text_Password" : "*", + "pear-pear.php.net/XML_Parser" : "*", + "pear-pear.php.net/XML_Serializer" : "*", + "pear-pear.php.net/XML_Util" : "*" + }, "require-dev": { "satooshi/php-coveralls": "dev-master", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "3.7.*", + "phing/phing": "2.*" } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000000..3c45ce48454 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1715 @@ +{ + "_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": "05f8c47a64c10e867f5ed142cf64462d", + "packages": [ + { + "name": "mobiledetect/mobiledetectlib", + "version": "2.8.11", + "source": { + "type": "git", + "url": "https://github.com/serbanghita/Mobile-Detect.git", + "reference": "c68901fb09227dcf04872f0d6a27b9f6e75ecf1f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/c68901fb09227dcf04872f0d6a27b9f6e75ecf1f", + "reference": "c68901fb09227dcf04872f0d6a27b9f6e75ecf1f", + "shasum": "" + }, + "require": { + "php": ">=5.0.0" + }, + "require-dev": { + "johnkary/phpunit-speedtrap": "~1.0@dev", + "phpunit/phpunit": "*" + }, + "type": "library", + "autoload": { + "classmap": [ + "Mobile_Detect.php" + ], + "psr-0": { + "Detection": "namespaced/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Serban Ghita", + "email": "serbanghita@gmail.com", + "homepage": "http://mobiledetect.net", + "role": "Developer" + } + ], + "description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.", + "homepage": "https://github.com/serbanghita/Mobile-Detect", + "keywords": [ + "detect mobile devices", + "mobile", + "mobile detect", + "mobile detector", + "php mobile detect" + ], + "time": "2014-11-23 13:08:17" + }, + { + "name": "pear-pear.php.net/Archive_Tar", + "version": "1.3.13", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Archive_Tar-1.3.13.tgz", + "reference": null, + "shasum": null + }, + "require": { + "php": ">=4.3.0.0" + }, + "replace": { + "pear-pear/archive_tar": "== 1.3.13.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "This class provides handling of tar files in PHP.\nIt supports creating, listing, extracting and adding to tar files.\nGzip support is available if PHP has the zlib extension built-in or\nloaded. Bz2 compression is also supported with the bz2 extension loaded." + }, + { + "name": "pear-pear.php.net/Cache_Lite", + "version": "1.7.16", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Cache_Lite-1.7.16.tgz", + "reference": null, + "shasum": null + }, + "require": { + "pear-pear.php.net/pear": "*", + "php": ">=4.0.0.0" + }, + "replace": { + "pear-pear/cache_lite": "== 1.7.16.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "This package is a little cache system optimized for file containers. It is fast and safe (because it\n uses file locking and/or anti-corruption tests)." + }, + { + "name": "pear-pear.php.net/Calendar", + "version": "0.5.5", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Calendar-0.5.5.tgz", + "reference": null, + "shasum": null + }, + "require": { + "php": ">=5.0.0.0" + }, + "replace": { + "pear-pear/calendar": "== 0.5.5.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Calendar provides an API for building Calendar data structures. Using\nthe simple iterator and it's "query" API, a user interface can easily be\nbuilt on top of the calendar data structure, at the same time easily connecting it\nto some kind of underlying data store, where "event" information is\nbeing held.\n\nIt provides different calculation "engines" the default being based on\nUnix timestamps (offering fastest performance) with an alternative using PEAR::Date\nwhich extends the calendar past the limitations of Unix timestamps. Other engines\nshould be implementable for other types of calendar (e.g. a Chinese Calendar based\non lunar cycles)." + }, + { + "name": "pear-pear.php.net/Console_Getopt", + "version": "1.3.1", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Console_Getopt-1.3.1.tgz", + "reference": null, + "shasum": null + }, + "require": { + "php": ">=4.3.0.0" + }, + "replace": { + "pear-pear/console_getopt": "== 1.3.1.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "This is a PHP implementation of "getopt" supporting both\nshort and long options." + }, + { + "name": "pear-pear.php.net/File_SearchReplace", + "version": "1.1.4", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/File_SearchReplace-1.1.4.tgz", + "reference": null, + "shasum": null + }, + "require": { + "php": ">=4.3.0.0" + }, + "replace": { + "pear-pear/file_searchreplace": "== 1.1.4.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Provides various functions to perform replace\non files. Preg/Ereg regex supported along with faster, but more basic str_replace routine." + }, + { + "name": "pear-pear.php.net/HTTP_Request", + "version": "1.4.4", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/HTTP_Request-1.4.4.tgz", + "reference": null, + "shasum": null + }, + "require": { + "pear-pear.php.net/net_socket": ">=1.0.7.0", + "pear-pear.php.net/net_url": ">=1.0.12.0", + "php": ">=4.2.0.0" + }, + "replace": { + "pear-pear/http_request": "== 1.4.4.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Supports GET/POST/HEAD/TRACE/PUT/DELETE, Basic authentication, Proxy,\nProxy Authentication, SSL, file uploads etc." + }, + { + "name": "pear-pear.php.net/MDB2", + "version": "2.5.0b5", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/MDB2-2.5.0b5.tgz", + "reference": null, + "shasum": null + }, + "require": { + "pear-pear.php.net/pear": ">=1.3.6.0", + "php": ">=5.2.0.0" + }, + "replace": { + "pear-pear/mdb2": "== 2.5.0.0-beta5" + }, + "suggest": { + "fbsql-pear-pear.php.net/MDB2_Driver_fbsql": ">=0.3.0.0", + "ibase-pear-pear.php.net/MDB2_Driver_ibase": ">=1.5.0.0", + "mssql-pear-pear.php.net/MDB2_Driver_mssql": ">=1.5.0.0", + "mysql-pear-pear.php.net/MDB2_Driver_mysql": ">=1.5.0.0", + "mysqli-pear-pear.php.net/MDB2_Driver_mysqli": ">=1.5.0.0", + "oci8-pear-pear.php.net/MDB2_Driver_oci8": ">=1.5.0.0", + "odbc-pear-pear.php.net/MDB2_Driver_odbc": ">=0.2.0.0", + "pgsql-pear-pear.php.net/MDB2_Driver_pgsql": ">=1.5.0.0", + "querysim-pear-pear.php.net/MDB2_Driver_querysim": ">=0.7.0.0", + "sqlite-pear-pear.php.net/MDB2_Driver_sqlite": ">=1.5.0.0", + "sqlsrv-pear-pear.php.net/MDB2_Driver_sqlsrv": ">=1.5.0.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "PEAR MDB2 is a merge of the PEAR DB and Metabase php database abstraction layers.\n\nIt provides a common API for all supported RDBMS. The main difference to most\nother DB abstraction packages is that MDB2 goes much further to ensure\nportability. MDB2 provides most of its many features optionally that\ncan be used to construct portable SQL statements:\n* Object-Oriented API\n* A DSN (data source name) or array format for specifying database servers\n* Datatype abstraction and on demand datatype conversion\n* Various optional fetch modes to fix portability issues\n* Portable error codes\n* Sequential and non sequential row fetching as well as bulk fetching\n* Ability to make buffered and unbuffered queries\n* Ordered array and associative array for the fetched rows\n* Prepare/execute (bind) named and unnamed placeholder emulation\n* Sequence/autoincrement emulation\n* Replace emulation\n* Limited sub select emulation\n* Row limit emulation\n* Transactions/savepoint support\n* Large Object support\n* Index/Unique Key/Primary Key support\n* Pattern matching abstraction\n* Module framework to load advanced functionality on demand\n* Ability to read the information schema\n* RDBMS management methods (creating, dropping, altering)\n* Reverse engineering schemas from an existing database\n* SQL function call abstraction\n* Full integration into the PEAR Framework\n* PHPDoc API documentation" + }, + { + "name": "pear-pear.php.net/MDB2_Driver_mysql", + "version": "1.5.0b4", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/MDB2_Driver_mysql-1.5.0b4.tgz", + "reference": null, + "shasum": null + }, + "require": { + "ext-mysql": "*", + "pear-pear.php.net/mdb2": ">=2.5.0.0", + "php": ">=5.2.0.0" + }, + "replace": { + "pear-pear/mdb2_driver_mysql": "== 1.5.0.0-beta4" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "This is the MySQL MDB2 driver." + }, + { + "name": "pear-pear.php.net/MDB2_Driver_pgsql", + "version": "1.5.0b4", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/MDB2_Driver_pgsql-1.5.0b4.tgz", + "reference": null, + "shasum": null + }, + "require": { + "ext-pgsql": "*", + "pear-pear.php.net/mdb2": ">=2.5.0.0", + "php": ">=5.2.0.0" + }, + "replace": { + "pear-pear/mdb2_driver_pgsql": "== 1.5.0.0-beta4" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "This is the PostgreSQL MDB2 driver." + }, + { + "name": "pear-pear.php.net/Mail", + "version": "1.2.0", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Mail-1.2.0.tgz", + "reference": null, + "shasum": null + }, + "require": { + "php": ">=4.4.9.0" + }, + "replace": { + "pear-pear/mail": "== 1.2.0.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "PEAR's Mail package defines an interface for implementing mailers under the PEAR hierarchy. It also provides supporting functions useful to multiple mailer backends. Currently supported backends include: PHP's native mail() function, sendmail, and SMTP. This package also provides a RFC822 email address list validation utility class." + }, + { + "name": "pear-pear.php.net/Net_SMTP", + "version": "1.6.2", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Net_SMTP-1.6.2.tgz", + "reference": null, + "shasum": null + }, + "require": { + "pear-pear.php.net/net_socket": ">=1.0.7.0", + "php": ">=4.0.5.0" + }, + "replace": { + "pear-pear/net_smtp": "== 1.6.2.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Provides an implementation of the SMTP protocol using PEAR's Net_Socket class." + }, + { + "name": "pear-pear.php.net/Net_Socket", + "version": "1.0.14", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Net_Socket-1.0.14.tgz", + "reference": null, + "shasum": null + }, + "require": { + "php": ">=4.3.0.0" + }, + "replace": { + "pear-pear/net_socket": "== 1.0.14.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Net_Socket is a class interface to TCP sockets. It provides blocking\n and non-blocking operation, with different reading and writing modes\n (byte-wise, block-wise, line-wise and special formats like network\n byte-order ip addresses)." + }, + { + "name": "pear-pear.php.net/Net_URL", + "version": "1.0.15", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Net_URL-1.0.15.tgz", + "reference": null, + "shasum": null + }, + "require": { + "php": ">=4.0.0.0" + }, + "replace": { + "pear-pear/net_url": "== 1.0.15.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Provides easy parsing of URLs and their constituent parts." + }, + { + "name": "pear-pear.php.net/Net_UserAgent_Mobile", + "version": "1.0.0", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Net_UserAgent_Mobile-1.0.0.tgz", + "reference": null, + "shasum": null + }, + "require": { + "ext-pcre": "*", + "pear-pear.php.net/pear": ">=1.4.3.0", + "php": ">=4.3.0.0" + }, + "replace": { + "pear-pear/net_useragent_mobile": "== 1.0.0.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Net_UserAgent_Mobile parses HTTP_USER_AGENT strings of (mainly Japanese) mobile HTTP user agents. It'll be useful in page dispatching by user agents.\nThis package was ported from Perl's HTTP::MobileAgent.\nSee http://search.cpan.org/search?mode=module&query=HTTP-MobileAgent" + }, + { + "name": "pear-pear.php.net/PEAR", + "version": "1.9.5", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/PEAR-1.9.5.tgz", + "reference": null, + "shasum": null + }, + "require": { + "ext-pcre": "*", + "ext-xml": "*", + "pear-pear.php.net/archive_tar": ">=1.3.11.0", + "pear-pear.php.net/console_getopt": ">=1.2.0.0", + "pear-pear.php.net/structures_graph": ">=1.0.2.0", + "pear-pear.php.net/xml_util": ">=1.2.0.0", + "php": ">=4.4.0.0,!=5.0.0.0,!=5.1.0.0,!=5.1.1.0,!=5.1.2.0,!=5.1.3.0,!=5.1.4.0,!=5.1.5.0" + }, + "conflict": { + "pear-pear.php.net/pear_frontend_gtk": "<0.4.0.0", + "pear-pear.php.net/pear_frontend_web": "<=0.4.0.0" + }, + "replace": { + "pear-pear/pear": "== 1.9.5.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "The PEAR package contains:\n * the PEAR installer, for creating, distributing\n and installing packages\n * the PEAR_Exception PHP5 error handling mechanism\n * the PEAR_ErrorStack advanced error handling mechanism\n * the PEAR_Error error handling mechanism\n * the OS_Guess class for retrieving info about the OS\n where PHP is running on\n * the System class for quick handling of common operations\n with files and directories\n * the PEAR base class\n Features in a nutshell:\n * full support for channels\n * pre-download dependency validation\n * new package.xml 2.0 format allows tremendous flexibility while maintaining BC\n * support for optional dependency groups and limited support for sub-packaging\n * robust dependency support\n * full dependency validation on uninstall\n * remote install for hosts with only ftp access - no more problems with\n restricted host installation\n * full support for mirroring\n * support for bundling several packages into a single tarball\n * support for static dependencies on a url-based package\n * support for custom file roles and installation tasks" + }, + { + "name": "pear-pear.php.net/SOAP", + "version": "0.13.0", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/SOAP-0.13.0.tgz", + "reference": null, + "shasum": null + }, + "require": { + "pear-pear.php.net/http_request": "*", + "pear-pear.php.net/pear": "*", + "php": ">=5.0.0.0" + }, + "replace": { + "pear-pear/soap": "== 0.13.0.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Implementation of SOAP protocol and services" + }, + { + "name": "pear-pear.php.net/Services_JSON", + "version": "1.0.3", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Services_JSON-1.0.3.tgz", + "reference": null, + "shasum": null + }, + "require": { + "php": ">=4.3.0.0" + }, + "replace": { + "pear-pear/services_json": "== 1.0.3.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "JSON (JavaScript Object Notation, http://json.org) is a lightweight data-interchange format. \n It is easy for humans to read and write. It is easy for machines to parse and generate. \n It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. \n This feature can also be found in Python. JSON is a text format that is completely language independent \n but uses conventions that are familiar to programmers of the C-family of languages, including\n C, C++, C#, Java, JavaScript, Perl, TCL, and many others. These properties make JSON an ideal\n data-interchange language.\n\n This package provides a simple encoder and decoder for JSON notation. It is intended for use\n with client-side Javascript applications that make use of HTTPRequest to perform server \n communication functions - data can be encoded into JSON notation for use in a client-side\n javascript, or decoded from incoming Javascript requests. JSON format is native to Javascript, \n and can be directly eval()'ed with no further parsing overhead." + }, + { + "name": "pear-pear.php.net/Structures_Graph", + "version": "1.0.4", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Structures_Graph-1.0.4.tgz", + "reference": null, + "shasum": null + }, + "require": { + "php": ">=4.2.0.0" + }, + "replace": { + "pear-pear/structures_graph": "== 1.0.4.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Structures_Graph is a package for creating and manipulating graph datastructures. It allows building of directed\nand undirected graphs, with data and metadata stored in nodes. The library provides functions for graph traversing\nas well as for characteristic extraction from the graph topology." + }, + { + "name": "pear-pear.php.net/Text_Password", + "version": "1.1.1", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/Text_Password-1.1.1.tgz", + "reference": null, + "shasum": null + }, + "require": { + "php": ">=4.2.0.0" + }, + "replace": { + "pear-pear/text_password": "== 1.1.1.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Text_Password allows one to create pronounceable and unpronounceable\npasswords. The full functional range is explained in the manual at\nhttp://pear.php.net/manual/." + }, + { + "name": "pear-pear.php.net/XML_Parser", + "version": "1.3.4", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/XML_Parser-1.3.4.tgz", + "reference": null, + "shasum": null + }, + "require": { + "pear-pear.php.net/pear": "*", + "php": ">=4.2.0.0" + }, + "replace": { + "pear-pear/xml_parser": "== 1.3.4.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "This is an XML parser based on PHPs built-in xml extension.\nIt supports two basic modes of operation: &quot;func&quot; and &quot;event&quot;. In &quot;func&quot; mode, it will look for a function named after each element (xmltag_ELEMENT for start tags and xmltag_ELEMENT_ for end tags), and in &quot;event&quot; mode it uses a set of generic callbacks.\n\nSince version 1.2.0 there's a new XML_Parser_Simple class that makes parsing of most XML documents easier, by automatically providing a stack for the elements.\nFurthermore its now possible to split the parser from the handler object, so you do not have to extend XML_Parser anymore in order to parse a document with it." + }, + { + "name": "pear-pear.php.net/XML_Serializer", + "version": "0.20.2", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/XML_Serializer-0.20.2.tgz", + "reference": null, + "shasum": null + }, + "require": { + "ext-xml": "*", + "pear-pear.php.net/pear": "*", + "pear-pear.php.net/xml_parser": ">=1.2.6.0", + "pear-pear.php.net/xml_util": ">=1.1.1.0", + "php": ">=4.2.0.0" + }, + "replace": { + "pear-pear/xml_serializer": "== 0.20.2.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "XML_Serializer serializes complex data structures like arrays or object as XML documents.\nThis class helps you generating any XML document you require without the need for DOM.\nFurthermore this package can be used as a replacement to serialize() and unserialize() as it comes with a matching XML_Unserializer that is able to create PHP data structures (like arrays and objects) from XML documents, if type hints are available.\nIf you use the XML_Unserializer on standard XML files, it will try to guess how it has to be unserialized. In most cases it does exactly what you expect it to do.\nTry reading a RSS file with XML_Unserializer and you have the whole RSS file in a structured array or even a collection of objects, similar to XML_RSS.\n\nSince version 0.8.0 the package is able to treat XML documents similar to the simplexml extension of PHP 5." + }, + { + "name": "pear-pear.php.net/XML_Util", + "version": "1.2.3", + "dist": { + "type": "file", + "url": "http://pear.php.net/get/XML_Util-1.2.3.tgz", + "reference": null, + "shasum": null + }, + "require": { + "ext-pcre": "*", + "php": ">=4.3.0.0" + }, + "replace": { + "pear-pear/xml_util": "== 1.2.3.0" + }, + "type": "pear-library", + "autoload": { + "classmap": [ + "" + ] + }, + "include-path": [ + "/" + ], + "description": "Selection of methods that are often needed when working with XML documents. Functionality includes creating of attribute lists from arrays, creation of tags, validation of XML names and more." + }, + { + "name": "smarty/smarty", + "version": "v2.6.28", + "source": { + "type": "git", + "url": "https://github.com/smarty-php/smarty.git", + "reference": "0ecdd6c41d0de08cba846087abd02a9adb5218e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/smarty-php/smarty/zipball/0ecdd6c41d0de08cba846087abd02a9adb5218e5", + "reference": "0ecdd6c41d0de08cba846087abd02a9adb5218e5", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6.x-dev" + } + }, + "autoload": { + "classmap": [ + "libs/Smarty.class.php", + "libs/Smarty_Compiler.class.php", + "libs/Config_File.class.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0" + ], + "authors": [ + { + "name": "Monte Ohrt", + "email": "monte@ohrt.com" + }, + { + "name": "Uwe Tews", + "email": "uwe.tews@googlemail.com" + } + ], + "description": "Smarty - the compiling PHP template engine", + "homepage": "http://www.smarty.net", + "keywords": [ + "templating" + ], + "time": "2014-10-31 00:07:20" + } + ], + "packages-dev": [ + { + "name": "guzzle/guzzle", + "version": "v3.9.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle3.git", + "reference": "54991459675c1a2924122afbb0e5609ade581155" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/54991459675c1a2924122afbb0e5609ade581155", + "reference": "54991459675c1a2924122afbb0e5609ade581155", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.3", + "symfony/event-dispatcher": "~2.1" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-error-response": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" + }, + "require-dev": { + "doctrine/cache": "~1.3", + "monolog/monolog": "~1.0", + "phpunit/phpunit": "3.7.*", + "psr/log": "~1.0", + "symfony/class-loader": "~2.1", + "zendframework/zend-cache": "2.*,<2.3", + "zendframework/zend-log": "2.*,<2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.9-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2014-08-11 04:32:36" + }, + { + "name": "phing/phing", + "version": "2.9.1", + "source": { + "type": "git", + "url": "https://github.com/phingofficial/phing.git", + "reference": "393edeffa8a85d43636ce0c9b4deb1ff9ac60a5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phingofficial/phing/zipball/393edeffa8a85d43636ce0c9b4deb1ff9ac60a5c", + "reference": "393edeffa8a85d43636ce0c9b4deb1ff9ac60a5c", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "ext-pdo_sqlite": "*", + "lastcraft/simpletest": "@dev", + "pdepend/pdepend": "1.x", + "pear-pear.php.net/http_request2": "2.2.x", + "pear-pear.php.net/net_growl": "2.7.x", + "pear-pear.php.net/pear_packagefilemanager": "1.7.x", + "pear-pear.php.net/pear_packagefilemanager2": "1.0.x", + "pear-pear.php.net/xml_serializer": "0.20.x", + "pear/pear_exception": "@dev", + "pear/versioncontrol_git": "@dev", + "pear/versioncontrol_svn": "@dev", + "phpdocumentor/phpdocumentor": "2.x", + "phploc/phploc": "2.x", + "phpunit/phpunit": ">=3.7", + "sebastian/phpcpd": "2.x", + "squizlabs/php_codesniffer": "1.5.x" + }, + "suggest": { + "pdepend/pdepend": "PHP version of JDepend", + "pear/archive_tar": "Tar file management class", + "pear/versioncontrol_git": "A library that provides OO interface to handle Git repository", + "pear/versioncontrol_svn": "A simple OO-style interface for Subversion, the free/open-source version control system", + "phpdocumentor/phpdocumentor": "Documentation Generator for PHP", + "phploc/phploc": "A tool for quickly measuring the size of a PHP project", + "phpmd/phpmd": "PHP version of PMD tool", + "phpunit/php-code-coverage": "Library that provides collection, processing, and rendering functionality for PHP code coverage information", + "phpunit/phpunit": "The PHP Unit Testing Framework", + "sebastian/phpcpd": "Copy/Paste Detector (CPD) for PHP code", + "tedivm/jshrink": "Javascript Minifier built in PHP" + }, + "bin": [ + "bin/phing" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.9.x-dev" + } + }, + "autoload": { + "classmap": [ + "classes/phing/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "classes" + ], + "license": [ + "LGPL-3.0" + ], + "authors": [ + { + "name": "Phing Community", + "homepage": "http://www.phing.info/trac/wiki/Development/Contributors" + }, + { + "name": "Michiel Rook", + "email": "mrook@php.net" + } + ], + "description": "PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.", + "homepage": "http://www.phing.info/", + "keywords": [ + "build", + "phing", + "task", + "tool" + ], + "time": "2014-12-03 09:18:46" + }, + { + "name": "phpunit/php-code-coverage", + "version": "1.2.18", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", + "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": ">=1.3.0@stable", + "phpunit/php-text-template": ">=1.2.0@stable", + "phpunit/php-token-stream": ">=1.1.3,<1.3.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@dev" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.0.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2014-09-02 10:13:14" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32", + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2014-03-03 05:10:30" + }, + { + "name": "phpunit/phpunit", + "version": "3.7.38", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/38709dc22d519a3d1be46849868aa2ddf822bcf6", + "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~1.2", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.1", + "phpunit/php-timer": "~1.0", + "phpunit/phpunit-mock-objects": "~1.2", + "symfony/yaml": "~2.0" + }, + "require-dev": { + "pear-pear.php.net/pear": "1.9.4" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "composer/bin/phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPUnit/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "", + "../../symfony/yaml/" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "http://www.phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2014-10-17 09:04:17" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-text-template": ">=1.1.1@stable" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHPUnit/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2013-01-13 10:24:48" + }, + { + "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": "satooshi/php-coveralls", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/satooshi/php-coveralls.git", + "reference": "2fbf803803d179ab1082807308a67bbd5a760c70" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/2fbf803803d179ab1082807308a67bbd5a760c70", + "reference": "2fbf803803d179ab1082807308a67bbd5a760c70", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-simplexml": "*", + "guzzle/guzzle": ">=2.7", + "php": ">=5.3", + "psr/log": "1.0.0", + "symfony/config": ">=2.0", + "symfony/console": ">=2.0", + "symfony/stopwatch": ">=2.2", + "symfony/yaml": ">=2.0" + }, + "require-dev": { + "apigen/apigen": "2.8.*@stable", + "pdepend/pdepend": "dev-master as 2.0.0", + "phpmd/phpmd": "dev-master", + "phpunit/php-invoker": ">=1.1.0,<1.2.0", + "phpunit/phpunit": "3.7.*@stable", + "sebastian/finder-facade": "dev-master", + "sebastian/phpcpd": "1.4.*@stable", + "squizlabs/php_codesniffer": "1.4.*@stable", + "theseer/fdomdocument": "dev-master" + }, + "suggest": { + "symfony/http-kernel": "Allows Symfony integration" + }, + "bin": [ + "composer/bin/coveralls" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.7-dev" + } + }, + "autoload": { + "psr-0": { + "Satooshi\\Component": "src/", + "Satooshi\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kitamura Satoshi", + "email": "with.no.parachute@gmail.com", + "homepage": "https://www.facebook.com/satooshi.jp" + } + ], + "description": "PHP client library for Coveralls API", + "homepage": "https://github.com/satooshi/php-coveralls", + "keywords": [ + "ci", + "coverage", + "github", + "test" + ], + "time": "2014-11-11 15:35:34" + }, + { + "name": "symfony/config", + "version": "v2.6.1", + "target-dir": "Symfony/Component/Config", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "84c0c150c1520995f09ea9e47e817068b353cb0f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/84c0c150c1520995f09ea9e47e817068b353cb0f", + "reference": "84c0c150c1520995f09ea9e47e817068b353cb0f", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/filesystem": "~2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Config\\": "" + } + }, + "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 Config Component", + "homepage": "http://symfony.com", + "time": "2014-12-02 20:19:20" + }, + { + "name": "symfony/console", + "version": "v2.6.1", + "target-dir": "Symfony/Component/Console", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "ef825fd9f809d275926547c9e57cbf14968793e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/ef825fd9f809d275926547c9e57cbf14968793e8", + "reference": "ef825fd9f809d275926547c9e57cbf14968793e8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1", + "symfony/process": "~2.1" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Console\\": "" + } + }, + "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 Console Component", + "homepage": "http://symfony.com", + "time": "2014-12-02 20:19:20" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.6.1", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "720fe9bca893df7ad1b4546649473b5afddf0216" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/720fe9bca893df7ad1b4546649473b5afddf0216", + "reference": "720fe9bca893df7ad1b4546649473b5afddf0216", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0", + "symfony/dependency-injection": "~2.6", + "symfony/expression-language": "~2.6", + "symfony/stopwatch": "~2.2" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "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 EventDispatcher Component", + "homepage": "http://symfony.com", + "time": "2014-12-02 20:19:20" + }, + { + "name": "symfony/filesystem", + "version": "v2.6.1", + "target-dir": "Symfony/Component/Filesystem", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "ff6efc95256cb33031933729e68b01d720b5436b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/ff6efc95256cb33031933729e68b01d720b5436b", + "reference": "ff6efc95256cb33031933729e68b01d720b5436b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "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 Filesystem Component", + "homepage": "http://symfony.com", + "time": "2014-12-02 20:19:20" + }, + { + "name": "symfony/stopwatch", + "version": "v2.6.1", + "target-dir": "Symfony/Component/Stopwatch", + "source": { + "type": "git", + "url": "https://github.com/symfony/Stopwatch.git", + "reference": "261abd360cfb6ac65ea93ffd82073e2011d034fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/261abd360cfb6ac65ea93ffd82073e2011d034fc", + "reference": "261abd360cfb6ac65ea93ffd82073e2011d034fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Stopwatch\\": "" + } + }, + "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 Stopwatch Component", + "homepage": "http://symfony.com", + "time": "2014-12-02 20:19:20" + }, + { + "name": "symfony/yaml", + "version": "v2.6.1", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "3346fc090a3eb6b53d408db2903b241af51dcb20" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/3346fc090a3eb6b53d408db2903b241af51dcb20", + "reference": "3346fc090a3eb6b53d408db2903b241af51dcb20", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-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-12-02 20:19:20" + } + ], + "aliases": [ + { + "alias": "2.5.0", + "alias_normalized": "2.5.0.0", + "version": "2.5.0.0-beta5", + "package": "pear-pear.php.net/mdb2" + } + ], + "minimum-stability": "stable", + "stability-flags": { + "pear-pear.php.net/mdb2_driver_mysql": 10, + "pear-pear.php.net/mdb2_driver_pgsql": 10, + "pear-pear.php.net/mdb2": 10, + "satooshi/php-coveralls": 20 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.3.3" + }, + "platform-dev": [] +} diff --git a/data/app_initial.php b/data/app_initial.php index 51398aff3b7..a4fcede646d 100644 --- a/data/app_initial.php +++ b/data/app_initial.php @@ -40,6 +40,7 @@ require_once(CLASS_EX_REALDIR . 'helper_extends/SC_Helper_Plugin_Ex.php'); // クラスのオートローディングを定義する +require_once __DIR__.'/../vendor/autoload.php'; require_once(CLASS_EX_REALDIR . 'SC_ClassAutoloader_Ex.php'); spl_autoload_register(array('SC_ClassAutoloader_Ex', 'autoload')); diff --git a/data/class/SC_Cache.php b/data/class/SC_Cache.php index 2be0cf4f48b..73d2171078b 100644 --- a/data/class/SC_Cache.php +++ b/data/class/SC_Cache.php @@ -21,8 +21,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -require DATA_REALDIR . 'module/Cache/Lite.php'; - /** * Cache controll using PEAR::Cache_Lite. */ diff --git a/data/class/SC_View.php b/data/class/SC_View.php index aaf3d317926..36b6f5fb291 100644 --- a/data/class/SC_View.php +++ b/data/class/SC_View.php @@ -21,8 +21,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -require_once realpath(dirname(__FILE__)) . '/../module/Smarty/libs/Smarty.class.php'; - class SC_View { public $_smarty; diff --git a/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php b/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php index 442d0c5a064..3dab7c7b00b 100644 --- a/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php +++ b/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php @@ -21,7 +21,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -define('CALENDAR_ROOT', DATA_REALDIR.'module/Calendar'.DIRECTORY_SEPARATOR); require_once CLASS_EX_REALDIR . 'page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_Ex.php'; /** diff --git a/data/module/Archive/Tar.php b/data/module/Archive/Tar.php deleted file mode 100644 index 570b39c05ff..00000000000 --- a/data/module/Archive/Tar.php +++ /dev/null @@ -1,2422 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category File_Formats - * @package Archive_Tar - * @author Vincent Blavet - * @copyright 1997-2010 The Authors - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/Archive_Tar - */ - -require_once 'PEAR.php'; - -define('ARCHIVE_TAR_ATT_SEPARATOR', 90001); -define('ARCHIVE_TAR_END_BLOCK', pack("a512", '')); - -if (!function_exists('gzopen') && function_exists('gzopen64')) { - function gzopen($filename, $mode, $use_include_path = 0) - { - gzopen64($filename, $mode, $use_include_path); - } -} - -if (!function_exists('gztell') && function_exists('gztell64')) { - function gztell($zp) - { - gztell64($zp); - } -} - -if (!function_exists('gzseek') && function_exists('gzseek64')) { - function gzseek($zp, $offset, $whence = SEEK_SET) - { - gzseek64($zp, $offset, $whence); - } -} - -/** - * Creates a (compressed) Tar archive - * - * @package Archive_Tar - * @author Vincent Blavet - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version $Revision$ - */ -class Archive_Tar extends PEAR -{ - /** - * @var string Name of the Tar - */ - var $_tarname = ''; - - /** - * @var boolean if true, the Tar file will be gzipped - */ - var $_compress = false; - - /** - * @var string Type of compression : 'none', 'gz', 'bz2' or 'lzma2' - */ - var $_compress_type = 'none'; - - /** - * @var string Explode separator - */ - var $_separator = ' '; - - /** - * @var file descriptor - */ - var $_file = 0; - - /** - * @var string Local Tar name of a remote Tar (http:// or ftp://) - */ - var $_temp_tarname = ''; - - /** - * @var string regular expression for ignoring files or directories - */ - var $_ignore_regexp = ''; - - /** - * @var object PEAR_Error object - */ - var $error_object = null; - - // {{{ constructor - /** - * Archive_Tar Class constructor. This flavour of the constructor only - * declare a new Archive_Tar object, identifying it by the name of the - * tar file. - * If the compress argument is set the tar will be read or created as a - * gzip or bz2 compressed TAR file. - * - * @param string $p_tarname The name of the tar archive to create - * @param string $p_compress can be null, 'gz', 'bz2' or 'lzma2'. This - * parameter indicates if gzip, bz2 or lzma2 compression - * is required. For compatibility reason the - * boolean value 'true' means 'gz'. - * - * @access public - */ - function Archive_Tar($p_tarname, $p_compress = null) - { - if (version_compare(PHP_VERSION, '5.0.0', '<')) { - $this->PEAR(); - } - $this->_compress = false; - $this->_compress_type = 'none'; - if (($p_compress === null) || ($p_compress == '')) { - if (@file_exists($p_tarname)) { - if ($fp = @fopen($p_tarname, "rb")) { - // look for gzip magic cookie - $data = fread($fp, 2); - fclose($fp); - if ($data == "\37\213") { - $this->_compress = true; - $this->_compress_type = 'gz'; - // No sure it's enought for a magic code .... - } elseif ($data == "BZ") { - $this->_compress = true; - $this->_compress_type = 'bz2'; - } elseif (file_get_contents($p_tarname, false, null, 1, 4) == '7zXZ') { - $this->_compress = true; - $this->_compress_type = 'lzma2'; - } - } - } else { - // probably a remote file or some file accessible - // through a stream interface - if (substr($p_tarname, -2) == 'gz') { - $this->_compress = true; - $this->_compress_type = 'gz'; - } elseif ((substr($p_tarname, -3) == 'bz2') || - (substr($p_tarname, -2) == 'bz') - ) { - $this->_compress = true; - $this->_compress_type = 'bz2'; - } else { - if (substr($p_tarname, -2) == 'xz') { - $this->_compress = true; - $this->_compress_type = 'lzma2'; - } - } - } - } else { - if (($p_compress === true) || ($p_compress == 'gz')) { - $this->_compress = true; - $this->_compress_type = 'gz'; - } else { - if ($p_compress == 'bz2') { - $this->_compress = true; - $this->_compress_type = 'bz2'; - } else { - if ($p_compress == 'lzma2') { - $this->_compress = true; - $this->_compress_type = 'lzma2'; - } else { - $this->_error( - "Unsupported compression type '$p_compress'\n" . - "Supported types are 'gz', 'bz2' and 'lzma2'.\n" - ); - return false; - } - } - } - } - $this->_tarname = $p_tarname; - if ($this->_compress) { // assert zlib or bz2 or xz extension support - if ($this->_compress_type == 'gz') { - $extname = 'zlib'; - } else { - if ($this->_compress_type == 'bz2') { - $extname = 'bz2'; - } else { - if ($this->_compress_type == 'lzma2') { - $extname = 'xz'; - } - } - } - - if (!extension_loaded($extname)) { - PEAR::loadExtension($extname); - } - if (!extension_loaded($extname)) { - $this->_error( - "The extension '$extname' couldn't be found.\n" . - "Please make sure your version of PHP was built " . - "with '$extname' support.\n" - ); - return false; - } - } - } - - // }}} - - // {{{ destructor - function _Archive_Tar() - { - $this->_close(); - // ----- Look for a local copy to delete - if ($this->_temp_tarname != '') { - @unlink($this->_temp_tarname); - } - $this->_PEAR(); - } - - // }}} - - // {{{ PHP5-compatible destructor - function __destruct() - { - $this->_Archive_Tar(); - } - - // }}} - - // {{{ create() - /** - * This method creates the archive file and add the files / directories - * that are listed in $p_filelist. - * If a file with the same name exist and is writable, it is replaced - * by the new tar. - * The method return false and a PEAR error text. - * The $p_filelist parameter can be an array of string, each string - * representing a filename or a directory name with their path if - * needed. It can also be a single string with names separated by a - * single blank. - * For each directory added in the archive, the files and - * sub-directories are also added. - * See also createModify() method for more details. - * - * @param array $p_filelist An array of filenames and directory names, or a - * single string with names separated by a single - * blank space. - * - * @return true on success, false on error. - * @see createModify() - * @access public - */ - function create($p_filelist) - { - return $this->createModify($p_filelist, '', ''); - } - - // }}} - - // {{{ add() - /** - * This method add the files / directories that are listed in $p_filelist in - * the archive. If the archive does not exist it is created. - * The method return false and a PEAR error text. - * The files and directories listed are only added at the end of the archive, - * even if a file with the same name is already archived. - * See also createModify() method for more details. - * - * @param array $p_filelist An array of filenames and directory names, or a - * single string with names separated by a single - * blank space. - * - * @return true on success, false on error. - * @see createModify() - * @access public - */ - function add($p_filelist) - { - return $this->addModify($p_filelist, '', ''); - } - - // }}} - - // {{{ extract() - function extract($p_path = '', $p_preserve = false) - { - return $this->extractModify($p_path, '', $p_preserve); - } - - // }}} - - // {{{ listContent() - function listContent() - { - $v_list_detail = array(); - - if ($this->_openRead()) { - if (!$this->_extractList('', $v_list_detail, "list", '', '')) { - unset($v_list_detail); - $v_list_detail = 0; - } - $this->_close(); - } - - return $v_list_detail; - } - - // }}} - - // {{{ createModify() - /** - * This method creates the archive file and add the files / directories - * that are listed in $p_filelist. - * If the file already exists and is writable, it is replaced by the - * new tar. It is a create and not an add. If the file exists and is - * read-only or is a directory it is not replaced. The method return - * false and a PEAR error text. - * The $p_filelist parameter can be an array of string, each string - * representing a filename or a directory name with their path if - * needed. It can also be a single string with names separated by a - * single blank. - * The path indicated in $p_remove_dir will be removed from the - * memorized path of each file / directory listed when this path - * exists. By default nothing is removed (empty path '') - * The path indicated in $p_add_dir will be added at the beginning of - * the memorized path of each file / directory listed. However it can - * be set to empty ''. The adding of a path is done after the removing - * of path. - * The path add/remove ability enables the user to prepare an archive - * for extraction in a different path than the origin files are. - * See also addModify() method for file adding properties. - * - * @param array $p_filelist An array of filenames and directory names, - * or a single string with names separated by - * a single blank space. - * @param string $p_add_dir A string which contains a path to be added - * to the memorized path of each element in - * the list. - * @param string $p_remove_dir A string which contains a path to be - * removed from the memorized path of each - * element in the list, when relevant. - * - * @return boolean true on success, false on error. - * @access public - * @see addModify() - */ - function createModify($p_filelist, $p_add_dir, $p_remove_dir = '') - { - $v_result = true; - - if (!$this->_openWrite()) { - return false; - } - - if ($p_filelist != '') { - if (is_array($p_filelist)) { - $v_list = $p_filelist; - } elseif (is_string($p_filelist)) { - $v_list = explode($this->_separator, $p_filelist); - } else { - $this->_cleanFile(); - $this->_error('Invalid file list'); - return false; - } - - $v_result = $this->_addList($v_list, $p_add_dir, $p_remove_dir); - } - - if ($v_result) { - $this->_writeFooter(); - $this->_close(); - } else { - $this->_cleanFile(); - } - - return $v_result; - } - - // }}} - - // {{{ addModify() - /** - * This method add the files / directories listed in $p_filelist at the - * end of the existing archive. If the archive does not yet exists it - * is created. - * The $p_filelist parameter can be an array of string, each string - * representing a filename or a directory name with their path if - * needed. It can also be a single string with names separated by a - * single blank. - * The path indicated in $p_remove_dir will be removed from the - * memorized path of each file / directory listed when this path - * exists. By default nothing is removed (empty path '') - * The path indicated in $p_add_dir will be added at the beginning of - * the memorized path of each file / directory listed. However it can - * be set to empty ''. The adding of a path is done after the removing - * of path. - * The path add/remove ability enables the user to prepare an archive - * for extraction in a different path than the origin files are. - * If a file/dir is already in the archive it will only be added at the - * end of the archive. There is no update of the existing archived - * file/dir. However while extracting the archive, the last file will - * replace the first one. This results in a none optimization of the - * archive size. - * If a file/dir does not exist the file/dir is ignored. However an - * error text is send to PEAR error. - * If a file/dir is not readable the file/dir is ignored. However an - * error text is send to PEAR error. - * - * @param array $p_filelist An array of filenames and directory - * names, or a single string with names - * separated by a single blank space. - * @param string $p_add_dir A string which contains a path to be - * added to the memorized path of each - * element in the list. - * @param string $p_remove_dir A string which contains a path to be - * removed from the memorized path of - * each element in the list, when - * relevant. - * - * @return true on success, false on error. - * @access public - */ - function addModify($p_filelist, $p_add_dir, $p_remove_dir = '') - { - $v_result = true; - - if (!$this->_isArchive()) { - $v_result = $this->createModify( - $p_filelist, - $p_add_dir, - $p_remove_dir - ); - } else { - if (is_array($p_filelist)) { - $v_list = $p_filelist; - } elseif (is_string($p_filelist)) { - $v_list = explode($this->_separator, $p_filelist); - } else { - $this->_error('Invalid file list'); - return false; - } - - $v_result = $this->_append($v_list, $p_add_dir, $p_remove_dir); - } - - return $v_result; - } - - // }}} - - // {{{ addString() - /** - * This method add a single string as a file at the - * end of the existing archive. If the archive does not yet exists it - * is created. - * - * @param string $p_filename A string which contains the full - * filename path that will be associated - * with the string. - * @param string $p_string The content of the file added in - * the archive. - * @param int $p_datetime A custom date/time (unix timestamp) - * for the file (optional). - * @param array $p_params An array of optional params: - * stamp => the datetime (replaces - * datetime above if it exists) - * mode => the permissions on the - * file (600 by default) - * type => is this a link? See the - * tar specification for details. - * (default = regular file) - * uid => the user ID of the file - * (default = 0 = root) - * gid => the group ID of the file - * (default = 0 = root) - * - * @return true on success, false on error. - * @access public - */ - function addString($p_filename, $p_string, $p_datetime = false, $p_params = array()) - { - $p_stamp = @$p_params["stamp"] ? $p_params["stamp"] : ($p_datetime ? $p_datetime : time()); - $p_mode = @$p_params["mode"] ? $p_params["mode"] : 0600; - $p_type = @$p_params["type"] ? $p_params["type"] : ""; - $p_uid = @$p_params["uid"] ? $p_params["uid"] : ""; - $p_gid = @$p_params["gid"] ? $p_params["gid"] : ""; - $v_result = true; - - if (!$this->_isArchive()) { - if (!$this->_openWrite()) { - return false; - } - $this->_close(); - } - - if (!$this->_openAppend()) { - return false; - } - - // Need to check the get back to the temporary file ? .... - $v_result = $this->_addString($p_filename, $p_string, $p_datetime, $p_params); - - $this->_writeFooter(); - - $this->_close(); - - return $v_result; - } - - // }}} - - // {{{ extractModify() - /** - * This method extract all the content of the archive in the directory - * indicated by $p_path. When relevant the memorized path of the - * files/dir can be modified by removing the $p_remove_path path at the - * beginning of the file/dir path. - * While extracting a file, if the directory path does not exists it is - * created. - * While extracting a file, if the file already exists it is replaced - * without looking for last modification date. - * While extracting a file, if the file already exists and is write - * protected, the extraction is aborted. - * While extracting a file, if a directory with the same name already - * exists, the extraction is aborted. - * While extracting a directory, if a file with the same name already - * exists, the extraction is aborted. - * While extracting a file/directory if the destination directory exist - * and is write protected, or does not exist but can not be created, - * the extraction is aborted. - * If after extraction an extracted file does not show the correct - * stored file size, the extraction is aborted. - * When the extraction is aborted, a PEAR error text is set and false - * is returned. However the result can be a partial extraction that may - * need to be manually cleaned. - * - * @param string $p_path The path of the directory where the - * files/dir need to by extracted. - * @param string $p_remove_path Part of the memorized path that can be - * removed if present at the beginning of - * the file/dir path. - * @param boolean $p_preserve Preserve user/group ownership of files - * - * @return boolean true on success, false on error. - * @access public - * @see extractList() - */ - function extractModify($p_path, $p_remove_path, $p_preserve = false) - { - $v_result = true; - $v_list_detail = array(); - - if ($v_result = $this->_openRead()) { - $v_result = $this->_extractList( - $p_path, - $v_list_detail, - "complete", - 0, - $p_remove_path, - $p_preserve - ); - $this->_close(); - } - - return $v_result; - } - - // }}} - - // {{{ extractInString() - /** - * This method extract from the archive one file identified by $p_filename. - * The return value is a string with the file content, or NULL on error. - * - * @param string $p_filename The path of the file to extract in a string. - * - * @return a string with the file content or NULL. - * @access public - */ - function extractInString($p_filename) - { - if ($this->_openRead()) { - $v_result = $this->_extractInString($p_filename); - $this->_close(); - } else { - $v_result = null; - } - - return $v_result; - } - - // }}} - - // {{{ extractList() - /** - * This method extract from the archive only the files indicated in the - * $p_filelist. These files are extracted in the current directory or - * in the directory indicated by the optional $p_path parameter. - * If indicated the $p_remove_path can be used in the same way as it is - * used in extractModify() method. - * - * @param array $p_filelist An array of filenames and directory names, - * or a single string with names separated - * by a single blank space. - * @param string $p_path The path of the directory where the - * files/dir need to by extracted. - * @param string $p_remove_path Part of the memorized path that can be - * removed if present at the beginning of - * the file/dir path. - * @param boolean $p_preserve Preserve user/group ownership of files - * - * @return true on success, false on error. - * @access public - * @see extractModify() - */ - function extractList($p_filelist, $p_path = '', $p_remove_path = '', $p_preserve = false) - { - $v_result = true; - $v_list_detail = array(); - - if (is_array($p_filelist)) { - $v_list = $p_filelist; - } elseif (is_string($p_filelist)) { - $v_list = explode($this->_separator, $p_filelist); - } else { - $this->_error('Invalid string list'); - return false; - } - - if ($v_result = $this->_openRead()) { - $v_result = $this->_extractList( - $p_path, - $v_list_detail, - "partial", - $v_list, - $p_remove_path, - $p_preserve - ); - $this->_close(); - } - - return $v_result; - } - - // }}} - - // {{{ setAttribute() - /** - * This method set specific attributes of the archive. It uses a variable - * list of parameters, in the format attribute code + attribute values : - * $arch->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ','); - * - * @param mixed $argv variable list of attributes and values - * - * @return true on success, false on error. - * @access public - */ - function setAttribute() - { - $v_result = true; - - // ----- Get the number of variable list of arguments - if (($v_size = func_num_args()) == 0) { - return true; - } - - // ----- Get the arguments - $v_att_list = & func_get_args(); - - // ----- Read the attributes - $i = 0; - while ($i < $v_size) { - - // ----- Look for next option - switch ($v_att_list[$i]) { - // ----- Look for options that request a string value - case ARCHIVE_TAR_ATT_SEPARATOR : - // ----- Check the number of parameters - if (($i + 1) >= $v_size) { - $this->_error( - 'Invalid number of parameters for ' - . 'attribute ARCHIVE_TAR_ATT_SEPARATOR' - ); - return false; - } - - // ----- Get the value - $this->_separator = $v_att_list[$i + 1]; - $i++; - break; - - default : - $this->_error('Unknow attribute code ' . $v_att_list[$i] . ''); - return false; - } - - // ----- Next attribute - $i++; - } - - return $v_result; - } - - // }}} - - // {{{ setIgnoreRegexp() - /** - * This method sets the regular expression for ignoring files and directories - * at import, for example: - * $arch->setIgnoreRegexp("#CVS|\.svn#"); - * - * @param string $regexp regular expression defining which files or directories to ignore - * - * @access public - */ - function setIgnoreRegexp($regexp) - { - $this->_ignore_regexp = $regexp; - } - - // }}} - - // {{{ setIgnoreList() - /** - * This method sets the regular expression for ignoring all files and directories - * matching the filenames in the array list at import, for example: - * $arch->setIgnoreList(array('CVS', '.svn', 'bin/tool')); - * - * @param array $list a list of file or directory names to ignore - * - * @access public - */ - function setIgnoreList($list) - { - $regexp = str_replace(array('#', '.', '^', '$'), array('\#', '\.', '\^', '\$'), $list); - $regexp = '#/' . join('$|/', $list) . '#'; - $this->setIgnoreRegexp($regexp); - } - - // }}} - - // {{{ _error() - function _error($p_message) - { - $this->error_object = & $this->raiseError($p_message); - } - - // }}} - - // {{{ _warning() - function _warning($p_message) - { - $this->error_object = & $this->raiseError($p_message); - } - - // }}} - - // {{{ _isArchive() - function _isArchive($p_filename = null) - { - if ($p_filename == null) { - $p_filename = $this->_tarname; - } - clearstatcache(); - return @is_file($p_filename) && !@is_link($p_filename); - } - - // }}} - - // {{{ _openWrite() - function _openWrite() - { - if ($this->_compress_type == 'gz' && function_exists('gzopen')) { - $this->_file = @gzopen($this->_tarname, "wb9"); - } else { - if ($this->_compress_type == 'bz2' && function_exists('bzopen')) { - $this->_file = @bzopen($this->_tarname, "w"); - } else { - if ($this->_compress_type == 'lzma2' && function_exists('xzopen')) { - $this->_file = @xzopen($this->_tarname, 'w'); - } else { - if ($this->_compress_type == 'none') { - $this->_file = @fopen($this->_tarname, "wb"); - } else { - $this->_error( - 'Unknown or missing compression type (' - . $this->_compress_type . ')' - ); - return false; - } - } - } - } - - if ($this->_file == 0) { - $this->_error( - 'Unable to open in write mode \'' - . $this->_tarname . '\'' - ); - return false; - } - - return true; - } - - // }}} - - // {{{ _openRead() - function _openRead() - { - if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') { - - // ----- Look if a local copy need to be done - if ($this->_temp_tarname == '') { - $this->_temp_tarname = uniqid('tar') . '.tmp'; - if (!$v_file_from = @fopen($this->_tarname, 'rb')) { - $this->_error( - 'Unable to open in read mode \'' - . $this->_tarname . '\'' - ); - $this->_temp_tarname = ''; - return false; - } - if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { - $this->_error( - 'Unable to open in write mode \'' - . $this->_temp_tarname . '\'' - ); - $this->_temp_tarname = ''; - return false; - } - while ($v_data = @fread($v_file_from, 1024)) { - @fwrite($v_file_to, $v_data); - } - @fclose($v_file_from); - @fclose($v_file_to); - } - - // ----- File to open if the local copy - $v_filename = $this->_temp_tarname; - - } else // ----- File to open if the normal Tar file - { - $v_filename = $this->_tarname; - } - - if ($this->_compress_type == 'gz' && function_exists('gzopen')) { - $this->_file = @gzopen($v_filename, "rb"); - } else { - if ($this->_compress_type == 'bz2' && function_exists('bzopen')) { - $this->_file = @bzopen($v_filename, "r"); - } else { - if ($this->_compress_type == 'lzma2' && function_exists('xzopen')) { - $this->_file = @xzopen($v_filename, "r"); - } else { - if ($this->_compress_type == 'none') { - $this->_file = @fopen($v_filename, "rb"); - } else { - $this->_error( - 'Unknown or missing compression type (' - . $this->_compress_type . ')' - ); - return false; - } - } - } - } - - if ($this->_file == 0) { - $this->_error('Unable to open in read mode \'' . $v_filename . '\''); - return false; - } - - return true; - } - - // }}} - - // {{{ _openReadWrite() - function _openReadWrite() - { - if ($this->_compress_type == 'gz') { - $this->_file = @gzopen($this->_tarname, "r+b"); - } else { - if ($this->_compress_type == 'bz2') { - $this->_error( - 'Unable to open bz2 in read/write mode \'' - . $this->_tarname . '\' (limitation of bz2 extension)' - ); - return false; - } else { - if ($this->_compress_type == 'lzma2') { - $this->_error( - 'Unable to open lzma2 in read/write mode \'' - . $this->_tarname . '\' (limitation of lzma2 extension)' - ); - return false; - } else { - if ($this->_compress_type == 'none') { - $this->_file = @fopen($this->_tarname, "r+b"); - } else { - $this->_error( - 'Unknown or missing compression type (' - . $this->_compress_type . ')' - ); - return false; - } - } - } - } - - if ($this->_file == 0) { - $this->_error( - 'Unable to open in read/write mode \'' - . $this->_tarname . '\'' - ); - return false; - } - - return true; - } - - // }}} - - // {{{ _close() - function _close() - { - //if (isset($this->_file)) { - if (is_resource($this->_file)) { - if ($this->_compress_type == 'gz') { - @gzclose($this->_file); - } else { - if ($this->_compress_type == 'bz2') { - @bzclose($this->_file); - } else { - if ($this->_compress_type == 'lzma2') { - @xzclose($this->_file); - } else { - if ($this->_compress_type == 'none') { - @fclose($this->_file); - } else { - $this->_error( - 'Unknown or missing compression type (' - . $this->_compress_type . ')' - ); - } - } - } - } - - $this->_file = 0; - } - - // ----- Look if a local copy need to be erase - // Note that it might be interesting to keep the url for a time : ToDo - if ($this->_temp_tarname != '') { - @unlink($this->_temp_tarname); - $this->_temp_tarname = ''; - } - - return true; - } - - // }}} - - // {{{ _cleanFile() - function _cleanFile() - { - $this->_close(); - - // ----- Look for a local copy - if ($this->_temp_tarname != '') { - // ----- Remove the local copy but not the remote tarname - @unlink($this->_temp_tarname); - $this->_temp_tarname = ''; - } else { - // ----- Remove the local tarname file - @unlink($this->_tarname); - } - $this->_tarname = ''; - - return true; - } - - // }}} - - // {{{ _writeBlock() - function _writeBlock($p_binary_data, $p_len = null) - { - if (is_resource($this->_file)) { - if ($p_len === null) { - if ($this->_compress_type == 'gz') { - @gzputs($this->_file, $p_binary_data); - } else { - if ($this->_compress_type == 'bz2') { - @bzwrite($this->_file, $p_binary_data); - } else { - if ($this->_compress_type == 'lzma2') { - @xzwrite($this->_file, $p_binary_data); - } else { - if ($this->_compress_type == 'none') { - @fputs($this->_file, $p_binary_data); - } else { - $this->_error( - 'Unknown or missing compression type (' - . $this->_compress_type . ')' - ); - } - } - } - } - } else { - if ($this->_compress_type == 'gz') { - @gzputs($this->_file, $p_binary_data, $p_len); - } else { - if ($this->_compress_type == 'bz2') { - @bzwrite($this->_file, $p_binary_data, $p_len); - } else { - if ($this->_compress_type == 'lzma2') { - @xzwrite($this->_file, $p_binary_data, $p_len); - } else { - if ($this->_compress_type == 'none') { - @fputs($this->_file, $p_binary_data, $p_len); - } else { - $this->_error( - 'Unknown or missing compression type (' - . $this->_compress_type . ')' - ); - } - } - } - } - - } - } - return true; - } - - // }}} - - // {{{ _readBlock() - function _readBlock() - { - $v_block = null; - if (is_resource($this->_file)) { - if ($this->_compress_type == 'gz') { - $v_block = @gzread($this->_file, 512); - } else { - if ($this->_compress_type == 'bz2') { - $v_block = @bzread($this->_file, 512); - } else { - if ($this->_compress_type == 'lzma2') { - $v_block = @xzread($this->_file, 512); - } else { - if ($this->_compress_type == 'none') { - $v_block = @fread($this->_file, 512); - } else { - $this->_error( - 'Unknown or missing compression type (' - . $this->_compress_type . ')' - ); - } - } - } - } - } - return $v_block; - } - - // }}} - - // {{{ _jumpBlock() - function _jumpBlock($p_len = null) - { - if (is_resource($this->_file)) { - if ($p_len === null) { - $p_len = 1; - } - - if ($this->_compress_type == 'gz') { - @gzseek($this->_file, gztell($this->_file) + ($p_len * 512)); - } else { - if ($this->_compress_type == 'bz2') { - // ----- Replace missing bztell() and bzseek() - for ($i = 0; $i < $p_len; $i++) { - $this->_readBlock(); - } - } else { - if ($this->_compress_type == 'lzma2') { - // ----- Replace missing xztell() and xzseek() - for ($i = 0; $i < $p_len; $i++) { - $this->_readBlock(); - } - } else { - if ($this->_compress_type == 'none') { - @fseek($this->_file, $p_len * 512, SEEK_CUR); - } else { - $this->_error( - 'Unknown or missing compression type (' - . $this->_compress_type . ')' - ); - } - } - } - } - - } - return true; - } - - // }}} - - // {{{ _writeFooter() - function _writeFooter() - { - if (is_resource($this->_file)) { - // ----- Write the last 0 filled block for end of archive - $v_binary_data = pack('a1024', ''); - $this->_writeBlock($v_binary_data); - } - return true; - } - - // }}} - - // {{{ _addList() - function _addList($p_list, $p_add_dir, $p_remove_dir) - { - $v_result = true; - $v_header = array(); - - // ----- Remove potential windows directory separator - $p_add_dir = $this->_translateWinPath($p_add_dir); - $p_remove_dir = $this->_translateWinPath($p_remove_dir, false); - - if (!$this->_file) { - $this->_error('Invalid file descriptor'); - return false; - } - - if (sizeof($p_list) == 0) { - return true; - } - - foreach ($p_list as $v_filename) { - if (!$v_result) { - break; - } - - // ----- Skip the current tar name - if ($v_filename == $this->_tarname) { - continue; - } - - if ($v_filename == '') { - continue; - } - - // ----- ignore files and directories matching the ignore regular expression - if ($this->_ignore_regexp && preg_match($this->_ignore_regexp, '/' . $v_filename)) { - $this->_warning("File '$v_filename' ignored"); - continue; - } - - if (!file_exists($v_filename) && !is_link($v_filename)) { - $this->_warning("File '$v_filename' does not exist"); - continue; - } - - // ----- Add the file or directory header - if (!$this->_addFile($v_filename, $v_header, $p_add_dir, $p_remove_dir)) { - return false; - } - - if (@is_dir($v_filename) && !@is_link($v_filename)) { - if (!($p_hdir = opendir($v_filename))) { - $this->_warning("Directory '$v_filename' can not be read"); - continue; - } - while (false !== ($p_hitem = readdir($p_hdir))) { - if (($p_hitem != '.') && ($p_hitem != '..')) { - if ($v_filename != ".") { - $p_temp_list[0] = $v_filename . '/' . $p_hitem; - } else { - $p_temp_list[0] = $p_hitem; - } - - $v_result = $this->_addList( - $p_temp_list, - $p_add_dir, - $p_remove_dir - ); - } - } - - unset($p_temp_list); - unset($p_hdir); - unset($p_hitem); - } - } - - return $v_result; - } - - // }}} - - // {{{ _addFile() - function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $v_stored_filename = null) - { - if (!$this->_file) { - $this->_error('Invalid file descriptor'); - return false; - } - - if ($p_filename == '') { - $this->_error('Invalid file name'); - return false; - } - - if (is_null($v_stored_filename)) { - // ----- Calculate the stored filename - $p_filename = $this->_translateWinPath($p_filename, false);; - $v_stored_filename = $p_filename; - - if (strcmp($p_filename, $p_remove_dir) == 0) { - return true; - } - - if ($p_remove_dir != '') { - if (substr($p_remove_dir, -1) != '/') { - $p_remove_dir .= '/'; - } - - if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir) { - $v_stored_filename = substr($p_filename, strlen($p_remove_dir)); - } - } - - $v_stored_filename = $this->_translateWinPath($v_stored_filename); - if ($p_add_dir != '') { - if (substr($p_add_dir, -1) == '/') { - $v_stored_filename = $p_add_dir . $v_stored_filename; - } else { - $v_stored_filename = $p_add_dir . '/' . $v_stored_filename; - } - } - - $v_stored_filename = $this->_pathReduction($v_stored_filename); - } - - if ($this->_isArchive($p_filename)) { - if (($v_file = @fopen($p_filename, "rb")) == 0) { - $this->_warning( - "Unable to open file '" . $p_filename - . "' in binary read mode" - ); - return true; - } - - if (!$this->_writeHeader($p_filename, $v_stored_filename)) { - return false; - } - - while (($v_buffer = fread($v_file, 512)) != '') { - $v_binary_data = pack("a512", "$v_buffer"); - $this->_writeBlock($v_binary_data); - } - - fclose($v_file); - - } else { - // ----- Only header for dir - if (!$this->_writeHeader($p_filename, $v_stored_filename)) { - return false; - } - } - - return true; - } - - // }}} - - // {{{ _addString() - function _addString($p_filename, $p_string, $p_datetime = false, $p_params = array()) - { - $p_stamp = @$p_params["stamp"] ? $p_params["stamp"] : ($p_datetime ? $p_datetime : time()); - $p_mode = @$p_params["mode"] ? $p_params["mode"] : 0600; - $p_type = @$p_params["type"] ? $p_params["type"] : ""; - $p_uid = @$p_params["uid"] ? $p_params["uid"] : 0; - $p_gid = @$p_params["gid"] ? $p_params["gid"] : 0; - if (!$this->_file) { - $this->_error('Invalid file descriptor'); - return false; - } - - if ($p_filename == '') { - $this->_error('Invalid file name'); - return false; - } - - // ----- Calculate the stored filename - $p_filename = $this->_translateWinPath($p_filename, false);; - - // ----- If datetime is not specified, set current time - if ($p_datetime === false) { - $p_datetime = time(); - } - - if (!$this->_writeHeaderBlock( - $p_filename, - strlen($p_string), - $p_stamp, - $p_mode, - $p_type, - $p_uid, - $p_gid - ) - ) { - return false; - } - - $i = 0; - while (($v_buffer = substr($p_string, (($i++) * 512), 512)) != '') { - $v_binary_data = pack("a512", $v_buffer); - $this->_writeBlock($v_binary_data); - } - - return true; - } - - // }}} - - // {{{ _writeHeader() - function _writeHeader($p_filename, $p_stored_filename) - { - if ($p_stored_filename == '') { - $p_stored_filename = $p_filename; - } - $v_reduce_filename = $this->_pathReduction($p_stored_filename); - - if (strlen($v_reduce_filename) > 99) { - if (!$this->_writeLongHeader($v_reduce_filename)) { - return false; - } - } - - $v_info = lstat($p_filename); - $v_uid = sprintf("%07s", DecOct($v_info[4])); - $v_gid = sprintf("%07s", DecOct($v_info[5])); - $v_perms = sprintf("%07s", DecOct($v_info['mode'] & 000777)); - - $v_mtime = sprintf("%011s", DecOct($v_info['mtime'])); - - $v_linkname = ''; - - if (@is_link($p_filename)) { - $v_typeflag = '2'; - $v_linkname = readlink($p_filename); - $v_size = sprintf("%011s", DecOct(0)); - } elseif (@is_dir($p_filename)) { - $v_typeflag = "5"; - $v_size = sprintf("%011s", DecOct(0)); - } else { - $v_typeflag = '0'; - clearstatcache(); - $v_size = sprintf("%011s", DecOct($v_info['size'])); - } - - $v_magic = 'ustar '; - - $v_version = ' '; - - if (function_exists('posix_getpwuid')) { - $userinfo = posix_getpwuid($v_info[4]); - $groupinfo = posix_getgrgid($v_info[5]); - - $v_uname = $userinfo['name']; - $v_gname = $groupinfo['name']; - } else { - $v_uname = ''; - $v_gname = ''; - } - - $v_devmajor = ''; - - $v_devminor = ''; - - $v_prefix = ''; - - $v_binary_data_first = pack( - "a100a8a8a8a12a12", - $v_reduce_filename, - $v_perms, - $v_uid, - $v_gid, - $v_size, - $v_mtime - ); - $v_binary_data_last = pack( - "a1a100a6a2a32a32a8a8a155a12", - $v_typeflag, - $v_linkname, - $v_magic, - $v_version, - $v_uname, - $v_gname, - $v_devmajor, - $v_devminor, - $v_prefix, - '' - ); - - // ----- Calculate the checksum - $v_checksum = 0; - // ..... First part of the header - for ($i = 0; $i < 148; $i++) { - $v_checksum += ord(substr($v_binary_data_first, $i, 1)); - } - // ..... Ignore the checksum value and replace it by ' ' (space) - for ($i = 148; $i < 156; $i++) { - $v_checksum += ord(' '); - } - // ..... Last part of the header - for ($i = 156, $j = 0; $i < 512; $i++, $j++) { - $v_checksum += ord(substr($v_binary_data_last, $j, 1)); - } - - // ----- Write the first 148 bytes of the header in the archive - $this->_writeBlock($v_binary_data_first, 148); - - // ----- Write the calculated checksum - $v_checksum = sprintf("%06s ", DecOct($v_checksum)); - $v_binary_data = pack("a8", $v_checksum); - $this->_writeBlock($v_binary_data, 8); - - // ----- Write the last 356 bytes of the header in the archive - $this->_writeBlock($v_binary_data_last, 356); - - return true; - } - - // }}} - - // {{{ _writeHeaderBlock() - function _writeHeaderBlock( - $p_filename, - $p_size, - $p_mtime = 0, - $p_perms = 0, - $p_type = '', - $p_uid = 0, - $p_gid = 0 - ) { - $p_filename = $this->_pathReduction($p_filename); - - if (strlen($p_filename) > 99) { - if (!$this->_writeLongHeader($p_filename)) { - return false; - } - } - - if ($p_type == "5") { - $v_size = sprintf("%011s", DecOct(0)); - } else { - $v_size = sprintf("%011s", DecOct($p_size)); - } - - $v_uid = sprintf("%07s", DecOct($p_uid)); - $v_gid = sprintf("%07s", DecOct($p_gid)); - $v_perms = sprintf("%07s", DecOct($p_perms & 000777)); - - $v_mtime = sprintf("%11s", DecOct($p_mtime)); - - $v_linkname = ''; - - $v_magic = 'ustar '; - - $v_version = ' '; - - if (function_exists('posix_getpwuid')) { - $userinfo = posix_getpwuid($p_uid); - $groupinfo = posix_getgrgid($p_gid); - - $v_uname = $userinfo['name']; - $v_gname = $groupinfo['name']; - } else { - $v_uname = ''; - $v_gname = ''; - } - - $v_devmajor = ''; - - $v_devminor = ''; - - $v_prefix = ''; - - $v_binary_data_first = pack( - "a100a8a8a8a12A12", - $p_filename, - $v_perms, - $v_uid, - $v_gid, - $v_size, - $v_mtime - ); - $v_binary_data_last = pack( - "a1a100a6a2a32a32a8a8a155a12", - $p_type, - $v_linkname, - $v_magic, - $v_version, - $v_uname, - $v_gname, - $v_devmajor, - $v_devminor, - $v_prefix, - '' - ); - - // ----- Calculate the checksum - $v_checksum = 0; - // ..... First part of the header - for ($i = 0; $i < 148; $i++) { - $v_checksum += ord(substr($v_binary_data_first, $i, 1)); - } - // ..... Ignore the checksum value and replace it by ' ' (space) - for ($i = 148; $i < 156; $i++) { - $v_checksum += ord(' '); - } - // ..... Last part of the header - for ($i = 156, $j = 0; $i < 512; $i++, $j++) { - $v_checksum += ord(substr($v_binary_data_last, $j, 1)); - } - - // ----- Write the first 148 bytes of the header in the archive - $this->_writeBlock($v_binary_data_first, 148); - - // ----- Write the calculated checksum - $v_checksum = sprintf("%06s ", DecOct($v_checksum)); - $v_binary_data = pack("a8", $v_checksum); - $this->_writeBlock($v_binary_data, 8); - - // ----- Write the last 356 bytes of the header in the archive - $this->_writeBlock($v_binary_data_last, 356); - - return true; - } - - // }}} - - // {{{ _writeLongHeader() - function _writeLongHeader($p_filename) - { - $v_size = sprintf("%11s ", DecOct(strlen($p_filename))); - - $v_typeflag = 'L'; - - $v_linkname = ''; - - $v_magic = ''; - - $v_version = ''; - - $v_uname = ''; - - $v_gname = ''; - - $v_devmajor = ''; - - $v_devminor = ''; - - $v_prefix = ''; - - $v_binary_data_first = pack( - "a100a8a8a8a12a12", - '././@LongLink', - 0, - 0, - 0, - $v_size, - 0 - ); - $v_binary_data_last = pack( - "a1a100a6a2a32a32a8a8a155a12", - $v_typeflag, - $v_linkname, - $v_magic, - $v_version, - $v_uname, - $v_gname, - $v_devmajor, - $v_devminor, - $v_prefix, - '' - ); - - // ----- Calculate the checksum - $v_checksum = 0; - // ..... First part of the header - for ($i = 0; $i < 148; $i++) { - $v_checksum += ord(substr($v_binary_data_first, $i, 1)); - } - // ..... Ignore the checksum value and replace it by ' ' (space) - for ($i = 148; $i < 156; $i++) { - $v_checksum += ord(' '); - } - // ..... Last part of the header - for ($i = 156, $j = 0; $i < 512; $i++, $j++) { - $v_checksum += ord(substr($v_binary_data_last, $j, 1)); - } - - // ----- Write the first 148 bytes of the header in the archive - $this->_writeBlock($v_binary_data_first, 148); - - // ----- Write the calculated checksum - $v_checksum = sprintf("%06s ", DecOct($v_checksum)); - $v_binary_data = pack("a8", $v_checksum); - $this->_writeBlock($v_binary_data, 8); - - // ----- Write the last 356 bytes of the header in the archive - $this->_writeBlock($v_binary_data_last, 356); - - // ----- Write the filename as content of the block - $i = 0; - while (($v_buffer = substr($p_filename, (($i++) * 512), 512)) != '') { - $v_binary_data = pack("a512", "$v_buffer"); - $this->_writeBlock($v_binary_data); - } - - return true; - } - - // }}} - - // {{{ _readHeader() - function _readHeader($v_binary_data, &$v_header) - { - if (strlen($v_binary_data) == 0) { - $v_header['filename'] = ''; - return true; - } - - if (strlen($v_binary_data) != 512) { - $v_header['filename'] = ''; - $this->_error('Invalid block size : ' . strlen($v_binary_data)); - return false; - } - - if (!is_array($v_header)) { - $v_header = array(); - } - // ----- Calculate the checksum - $v_checksum = 0; - // ..... First part of the header - for ($i = 0; $i < 148; $i++) { - $v_checksum += ord(substr($v_binary_data, $i, 1)); - } - // ..... Ignore the checksum value and replace it by ' ' (space) - for ($i = 148; $i < 156; $i++) { - $v_checksum += ord(' '); - } - // ..... Last part of the header - for ($i = 156; $i < 512; $i++) { - $v_checksum += ord(substr($v_binary_data, $i, 1)); - } - - if (version_compare(PHP_VERSION, "5.5.0-dev") < 0) { - $fmt = "a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" . - "a8checksum/a1typeflag/a100link/a6magic/a2version/" . - "a32uname/a32gname/a8devmajor/a8devminor/a131prefix"; - } else { - $fmt = "Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/" . - "Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/" . - "Z32uname/Z32gname/Z8devmajor/Z8devminor/Z131prefix"; - } - $v_data = unpack($fmt, $v_binary_data); - - if (strlen($v_data["prefix"]) > 0) { - $v_data["filename"] = "$v_data[prefix]/$v_data[filename]"; - } - - // ----- Extract the checksum - $v_header['checksum'] = OctDec(trim($v_data['checksum'])); - if ($v_header['checksum'] != $v_checksum) { - $v_header['filename'] = ''; - - // ----- Look for last block (empty block) - if (($v_checksum == 256) && ($v_header['checksum'] == 0)) { - return true; - } - - $this->_error( - 'Invalid checksum for file "' . $v_data['filename'] - . '" : ' . $v_checksum . ' calculated, ' - . $v_header['checksum'] . ' expected' - ); - return false; - } - - // ----- Extract the properties - $v_header['filename'] = $v_data['filename']; - if ($this->_maliciousFilename($v_header['filename'])) { - $this->_error( - 'Malicious .tar detected, file "' . $v_header['filename'] . - '" will not install in desired directory tree' - ); - return false; - } - $v_header['mode'] = OctDec(trim($v_data['mode'])); - $v_header['uid'] = OctDec(trim($v_data['uid'])); - $v_header['gid'] = OctDec(trim($v_data['gid'])); - $v_header['size'] = OctDec(trim($v_data['size'])); - $v_header['mtime'] = OctDec(trim($v_data['mtime'])); - if (($v_header['typeflag'] = $v_data['typeflag']) == "5") { - $v_header['size'] = 0; - } - $v_header['link'] = trim($v_data['link']); - /* ----- All these fields are removed form the header because - they do not carry interesting info - $v_header[magic] = trim($v_data[magic]); - $v_header[version] = trim($v_data[version]); - $v_header[uname] = trim($v_data[uname]); - $v_header[gname] = trim($v_data[gname]); - $v_header[devmajor] = trim($v_data[devmajor]); - $v_header[devminor] = trim($v_data[devminor]); - */ - - return true; - } - - // }}} - - // {{{ _maliciousFilename() - /** - * Detect and report a malicious file name - * - * @param string $file - * - * @return bool - * @access private - */ - function _maliciousFilename($file) - { - if (strpos($file, '/../') !== false) { - return true; - } - if (strpos($file, '../') === 0) { - return true; - } - return false; - } - - // }}} - - // {{{ _readLongHeader() - function _readLongHeader(&$v_header) - { - $v_filename = ''; - $n = floor($v_header['size'] / 512); - for ($i = 0; $i < $n; $i++) { - $v_content = $this->_readBlock(); - $v_filename .= $v_content; - } - if (($v_header['size'] % 512) != 0) { - $v_content = $this->_readBlock(); - $v_filename .= trim($v_content); - } - - // ----- Read the next header - $v_binary_data = $this->_readBlock(); - - if (!$this->_readHeader($v_binary_data, $v_header)) { - return false; - } - - $v_filename = trim($v_filename); - $v_header['filename'] = $v_filename; - if ($this->_maliciousFilename($v_filename)) { - $this->_error( - 'Malicious .tar detected, file "' . $v_filename . - '" will not install in desired directory tree' - ); - return false; - } - - return true; - } - - // }}} - - // {{{ _extractInString() - /** - * This method extract from the archive one file identified by $p_filename. - * The return value is a string with the file content, or null on error. - * - * @param string $p_filename The path of the file to extract in a string. - * - * @return a string with the file content or null. - * @access private - */ - function _extractInString($p_filename) - { - $v_result_str = ""; - - While (strlen($v_binary_data = $this->_readBlock()) != 0) { - if (!$this->_readHeader($v_binary_data, $v_header)) { - return null; - } - - if ($v_header['filename'] == '') { - continue; - } - - // ----- Look for long filename - if ($v_header['typeflag'] == 'L') { - if (!$this->_readLongHeader($v_header)) { - return null; - } - } - - if ($v_header['filename'] == $p_filename) { - if ($v_header['typeflag'] == "5") { - $this->_error( - 'Unable to extract in string a directory ' - . 'entry {' . $v_header['filename'] . '}' - ); - return null; - } else { - $n = floor($v_header['size'] / 512); - for ($i = 0; $i < $n; $i++) { - $v_result_str .= $this->_readBlock(); - } - if (($v_header['size'] % 512) != 0) { - $v_content = $this->_readBlock(); - $v_result_str .= substr( - $v_content, - 0, - ($v_header['size'] % 512) - ); - } - return $v_result_str; - } - } else { - $this->_jumpBlock(ceil(($v_header['size'] / 512))); - } - } - - return null; - } - - // }}} - - // {{{ _extractList() - function _extractList( - $p_path, - &$p_list_detail, - $p_mode, - $p_file_list, - $p_remove_path, - $p_preserve = false - ) { - $v_result = true; - $v_nb = 0; - $v_extract_all = true; - $v_listing = false; - - $p_path = $this->_translateWinPath($p_path, false); - if ($p_path == '' || (substr($p_path, 0, 1) != '/' - && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':')) - ) { - $p_path = "./" . $p_path; - } - $p_remove_path = $this->_translateWinPath($p_remove_path); - - // ----- Look for path to remove format (should end by /) - if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) { - $p_remove_path .= '/'; - } - $p_remove_path_size = strlen($p_remove_path); - - switch ($p_mode) { - case "complete" : - $v_extract_all = true; - $v_listing = false; - break; - case "partial" : - $v_extract_all = false; - $v_listing = false; - break; - case "list" : - $v_extract_all = false; - $v_listing = true; - break; - default : - $this->_error('Invalid extract mode (' . $p_mode . ')'); - return false; - } - - clearstatcache(); - - while (strlen($v_binary_data = $this->_readBlock()) != 0) { - $v_extract_file = false; - $v_extraction_stopped = 0; - - if (!$this->_readHeader($v_binary_data, $v_header)) { - return false; - } - - if ($v_header['filename'] == '') { - continue; - } - - // ----- Look for long filename - if ($v_header['typeflag'] == 'L') { - if (!$this->_readLongHeader($v_header)) { - return false; - } - } - - // ignore extended / pax headers - if ($v_header['typeflag'] == 'x' || $v_header['typeflag'] == 'g') { - $this->_jumpBlock(ceil(($v_header['size'] / 512))); - continue; - } - - if ((!$v_extract_all) && (is_array($p_file_list))) { - // ----- By default no unzip if the file is not found - $v_extract_file = false; - - for ($i = 0; $i < sizeof($p_file_list); $i++) { - // ----- Look if it is a directory - if (substr($p_file_list[$i], -1) == '/') { - // ----- Look if the directory is in the filename path - if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) - && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) - == $p_file_list[$i]) - ) { - $v_extract_file = true; - break; - } - } // ----- It is a file, so compare the file names - elseif ($p_file_list[$i] == $v_header['filename']) { - $v_extract_file = true; - break; - } - } - } else { - $v_extract_file = true; - } - - // ----- Look if this file need to be extracted - if (($v_extract_file) && (!$v_listing)) { - if (($p_remove_path != '') - && (substr($v_header['filename'] . '/', 0, $p_remove_path_size) - == $p_remove_path) - ) { - $v_header['filename'] = substr( - $v_header['filename'], - $p_remove_path_size - ); - if ($v_header['filename'] == '') { - continue; - } - } - if (($p_path != './') && ($p_path != '/')) { - while (substr($p_path, -1) == '/') { - $p_path = substr($p_path, 0, strlen($p_path) - 1); - } - - if (substr($v_header['filename'], 0, 1) == '/') { - $v_header['filename'] = $p_path . $v_header['filename']; - } else { - $v_header['filename'] = $p_path . '/' . $v_header['filename']; - } - } - if (file_exists($v_header['filename'])) { - if ((@is_dir($v_header['filename'])) - && ($v_header['typeflag'] == '') - ) { - $this->_error( - 'File ' . $v_header['filename'] - . ' already exists as a directory' - ); - return false; - } - if (($this->_isArchive($v_header['filename'])) - && ($v_header['typeflag'] == "5") - ) { - $this->_error( - 'Directory ' . $v_header['filename'] - . ' already exists as a file' - ); - return false; - } - if (!is_writeable($v_header['filename'])) { - $this->_error( - 'File ' . $v_header['filename'] - . ' already exists and is write protected' - ); - return false; - } - if (filemtime($v_header['filename']) > $v_header['mtime']) { - // To be completed : An error or silent no replace ? - } - } // ----- Check the directory availability and create it if necessary - elseif (($v_result - = $this->_dirCheck( - ($v_header['typeflag'] == "5" - ? $v_header['filename'] - : dirname($v_header['filename'])) - )) != 1 - ) { - $this->_error('Unable to create path for ' . $v_header['filename']); - return false; - } - - if ($v_extract_file) { - if ($v_header['typeflag'] == "5") { - if (!@file_exists($v_header['filename'])) { - if (!@mkdir($v_header['filename'], 0777)) { - $this->_error( - 'Unable to create directory {' - . $v_header['filename'] . '}' - ); - return false; - } - } - } elseif ($v_header['typeflag'] == "2") { - if (@file_exists($v_header['filename'])) { - @unlink($v_header['filename']); - } - if (!@symlink($v_header['link'], $v_header['filename'])) { - $this->_error( - 'Unable to extract symbolic link {' - . $v_header['filename'] . '}' - ); - return false; - } - } else { - if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { - $this->_error( - 'Error while opening {' . $v_header['filename'] - . '} in write binary mode' - ); - return false; - } else { - $n = floor($v_header['size'] / 512); - for ($i = 0; $i < $n; $i++) { - $v_content = $this->_readBlock(); - fwrite($v_dest_file, $v_content, 512); - } - if (($v_header['size'] % 512) != 0) { - $v_content = $this->_readBlock(); - fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); - } - - @fclose($v_dest_file); - - if ($p_preserve) { - @chown($v_header['filename'], $v_header['uid']); - @chgrp($v_header['filename'], $v_header['gid']); - } - - // ----- Change the file mode, mtime - @touch($v_header['filename'], $v_header['mtime']); - if ($v_header['mode'] & 0111) { - // make file executable, obey umask - $mode = fileperms($v_header['filename']) | (~umask() & 0111); - @chmod($v_header['filename'], $mode); - } - } - - // ----- Check the file size - clearstatcache(); - if (!is_file($v_header['filename'])) { - $this->_error( - 'Extracted file ' . $v_header['filename'] - . 'does not exist. Archive may be corrupted.' - ); - return false; - } - - $filesize = filesize($v_header['filename']); - if ($filesize != $v_header['size']) { - $this->_error( - 'Extracted file ' . $v_header['filename'] - . ' does not have the correct file size \'' - . $filesize - . '\' (' . $v_header['size'] - . ' expected). Archive may be corrupted.' - ); - return false; - } - } - } else { - $this->_jumpBlock(ceil(($v_header['size'] / 512))); - } - } else { - $this->_jumpBlock(ceil(($v_header['size'] / 512))); - } - - /* TBC : Seems to be unused ... - if ($this->_compress) - $v_end_of_file = @gzeof($this->_file); - else - $v_end_of_file = @feof($this->_file); - */ - - if ($v_listing || $v_extract_file || $v_extraction_stopped) { - // ----- Log extracted files - if (($v_file_dir = dirname($v_header['filename'])) - == $v_header['filename'] - ) { - $v_file_dir = ''; - } - if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) { - $v_file_dir = '/'; - } - - $p_list_detail[$v_nb++] = $v_header; - if (is_array($p_file_list) && (count($p_list_detail) == count($p_file_list))) { - return true; - } - } - } - - return true; - } - - // }}} - - // {{{ _openAppend() - function _openAppend() - { - if (filesize($this->_tarname) == 0) { - return $this->_openWrite(); - } - - if ($this->_compress) { - $this->_close(); - - if (!@rename($this->_tarname, $this->_tarname . ".tmp")) { - $this->_error( - 'Error while renaming \'' . $this->_tarname - . '\' to temporary file \'' . $this->_tarname - . '.tmp\'' - ); - return false; - } - - if ($this->_compress_type == 'gz') { - $v_temp_tar = @gzopen($this->_tarname . ".tmp", "rb"); - } elseif ($this->_compress_type == 'bz2') { - $v_temp_tar = @bzopen($this->_tarname . ".tmp", "r"); - } elseif ($this->_compress_type == 'lzma2') { - $v_temp_tar = @xzopen($this->_tarname . ".tmp", "r"); - } - - - if ($v_temp_tar == 0) { - $this->_error( - 'Unable to open file \'' . $this->_tarname - . '.tmp\' in binary read mode' - ); - @rename($this->_tarname . ".tmp", $this->_tarname); - return false; - } - - if (!$this->_openWrite()) { - @rename($this->_tarname . ".tmp", $this->_tarname); - return false; - } - - if ($this->_compress_type == 'gz') { - $end_blocks = 0; - - while (!@gzeof($v_temp_tar)) { - $v_buffer = @gzread($v_temp_tar, 512); - if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) { - $end_blocks++; - // do not copy end blocks, we will re-make them - // after appending - continue; - } elseif ($end_blocks > 0) { - for ($i = 0; $i < $end_blocks; $i++) { - $this->_writeBlock(ARCHIVE_TAR_END_BLOCK); - } - $end_blocks = 0; - } - $v_binary_data = pack("a512", $v_buffer); - $this->_writeBlock($v_binary_data); - } - - @gzclose($v_temp_tar); - } elseif ($this->_compress_type == 'bz2') { - $end_blocks = 0; - - while (strlen($v_buffer = @bzread($v_temp_tar, 512)) > 0) { - if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) { - $end_blocks++; - // do not copy end blocks, we will re-make them - // after appending - continue; - } elseif ($end_blocks > 0) { - for ($i = 0; $i < $end_blocks; $i++) { - $this->_writeBlock(ARCHIVE_TAR_END_BLOCK); - } - $end_blocks = 0; - } - $v_binary_data = pack("a512", $v_buffer); - $this->_writeBlock($v_binary_data); - } - - @bzclose($v_temp_tar); - } elseif ($this->_compress_type == 'lzma2') { - $end_blocks = 0; - - while (strlen($v_buffer = @xzread($v_temp_tar, 512)) > 0) { - if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) { - $end_blocks++; - // do not copy end blocks, we will re-make them - // after appending - continue; - } elseif ($end_blocks > 0) { - for ($i = 0; $i < $end_blocks; $i++) { - $this->_writeBlock(ARCHIVE_TAR_END_BLOCK); - } - $end_blocks = 0; - } - $v_binary_data = pack("a512", $v_buffer); - $this->_writeBlock($v_binary_data); - } - - @xzclose($v_temp_tar); - } - - if (!@unlink($this->_tarname . ".tmp")) { - $this->_error( - 'Error while deleting temporary file \'' - . $this->_tarname . '.tmp\'' - ); - } - - } else { - // ----- For not compressed tar, just add files before the last - // one or two 512 bytes block - if (!$this->_openReadWrite()) { - return false; - } - - clearstatcache(); - $v_size = filesize($this->_tarname); - - // We might have zero, one or two end blocks. - // The standard is two, but we should try to handle - // other cases. - fseek($this->_file, $v_size - 1024); - if (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) { - fseek($this->_file, $v_size - 1024); - } elseif (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) { - fseek($this->_file, $v_size - 512); - } - } - - return true; - } - - // }}} - - // {{{ _append() - function _append($p_filelist, $p_add_dir = '', $p_remove_dir = '') - { - if (!$this->_openAppend()) { - return false; - } - - if ($this->_addList($p_filelist, $p_add_dir, $p_remove_dir)) { - $this->_writeFooter(); - } - - $this->_close(); - - return true; - } - - // }}} - - // {{{ _dirCheck() - - /** - * Check if a directory exists and create it (including parent - * dirs) if not. - * - * @param string $p_dir directory to check - * - * @return bool true if the directory exists or was created - */ - function _dirCheck($p_dir) - { - clearstatcache(); - if ((@is_dir($p_dir)) || ($p_dir == '')) { - return true; - } - - $p_parent_dir = dirname($p_dir); - - if (($p_parent_dir != $p_dir) && - ($p_parent_dir != '') && - (!$this->_dirCheck($p_parent_dir)) - ) { - return false; - } - - if (!@mkdir($p_dir, 0777)) { - $this->_error("Unable to create directory '$p_dir'"); - return false; - } - - return true; - } - - // }}} - - // {{{ _pathReduction() - - /** - * Compress path by changing for example "/dir/foo/../bar" to "/dir/bar", - * rand emove double slashes. - * - * @param string $p_dir path to reduce - * - * @return string reduced path - * - * @access private - * - */ - function _pathReduction($p_dir) - { - $v_result = ''; - - // ----- Look for not empty path - if ($p_dir != '') { - // ----- Explode path by directory names - $v_list = explode('/', $p_dir); - - // ----- Study directories from last to first - for ($i = sizeof($v_list) - 1; $i >= 0; $i--) { - // ----- Look for current path - if ($v_list[$i] == ".") { - // ----- Ignore this directory - // Should be the first $i=0, but no check is done - } else { - if ($v_list[$i] == "..") { - // ----- Ignore it and ignore the $i-1 - $i--; - } else { - if (($v_list[$i] == '') - && ($i != (sizeof($v_list) - 1)) - && ($i != 0) - ) { - // ----- Ignore only the double '//' in path, - // but not the first and last / - } else { - $v_result = $v_list[$i] . ($i != (sizeof($v_list) - 1) ? '/' - . $v_result : ''); - } - } - } - } - } - - if (defined('OS_WINDOWS') && OS_WINDOWS) { - $v_result = strtr($v_result, '\\', '/'); - } - - return $v_result; - } - - // }}} - - // {{{ _translateWinPath() - function _translateWinPath($p_path, $p_remove_disk_letter = true) - { - if (defined('OS_WINDOWS') && OS_WINDOWS) { - // ----- Look for potential disk letter - if (($p_remove_disk_letter) - && (($v_position = strpos($p_path, ':')) != false) - ) { - $p_path = substr($p_path, $v_position + 1); - } - // ----- Change potential windows directory separator - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { - $p_path = strtr($p_path, '\\', '/'); - } - } - return $p_path; - } - // }}} - -} - -?> diff --git a/data/module/Cache/Lite.php b/data/module/Cache/Lite.php deleted file mode 100644 index 0ca762d380f..00000000000 --- a/data/module/Cache/Lite.php +++ /dev/null @@ -1,886 +0,0 @@ - -* -* Nota : A chinese documentation (thanks to RainX ) is -* available at : -* http://rainx.phpmore.com/manual/cache_lite.html -* -* @package Cache_Lite -* @category Caching -* @author Fabien MARTY -* @author Markus Tacker -*/ - -define('CACHE_LITE_ERROR_RETURN', 1); -define('CACHE_LITE_ERROR_DIE', 8); - -class Cache_Lite -{ - - // --- Private properties --- - - /** - * Directory where to put the cache files - * (make sure to add a trailing slash) - * - * @var string $_cacheDir - */ - var $_cacheDir = '/tmp/'; - - /** - * Enable / disable caching - * - * (can be very usefull for the debug of cached scripts) - * - * @var boolean $_caching - */ - var $_caching = true; - - /** - * Cache lifetime (in seconds) - * - * If null, the cache is valid forever. - * - * @var int $_lifeTime - */ - var $_lifeTime = 3600; - - /** - * Enable / disable fileLocking - * - * (can avoid cache corruption under bad circumstances) - * - * @var boolean $_fileLocking - */ - var $_fileLocking = true; - - /** - * Timestamp of the last valid cache - * - * @var int $_refreshTime - */ - var $_refreshTime; - - /** - * File name (with path) - * - * @var string $_file - */ - var $_file; - - /** - * File name (without path) - * - * @var string $_fileName - */ - var $_fileName; - - /** - * Enable / disable write control (the cache is read just after writing to detect corrupt entries) - * - * Enable write control will lightly slow the cache writing but not the cache reading - * Write control can detect some corrupt cache files but maybe it's not a perfect control - * - * @var boolean $_writeControl - */ - var $_writeControl = true; - - /** - * Enable / disable read control - * - * If enabled, a control key is embeded in cache file and this key is compared with the one - * calculated after the reading. - * - * @var boolean $_writeControl - */ - var $_readControl = true; - - /** - * Type of read control (only if read control is enabled) - * - * Available values are : - * 'md5' for a md5 hash control (best but slowest) - * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice) - * 'strlen' for a length only test (fastest) - * - * @var boolean $_readControlType - */ - var $_readControlType = 'crc32'; - - /** - * Pear error mode (when raiseError is called) - * - * (see PEAR doc) - * - * @see setToDebug() - * @var int $_pearErrorMode - */ - var $_pearErrorMode = CACHE_LITE_ERROR_RETURN; - - /** - * Current cache id - * - * @var string $_id - */ - var $_id; - - /** - * Current cache group - * - * @var string $_group - */ - var $_group; - - /** - * Enable / Disable "Memory Caching" - * - * NB : There is no lifetime for memory caching ! - * - * @var boolean $_memoryCaching - */ - var $_memoryCaching = false; - - /** - * Enable / Disable "Only Memory Caching" - * (be carefull, memory caching is "beta quality") - * - * @var boolean $_onlyMemoryCaching - */ - var $_onlyMemoryCaching = false; - - /** - * Memory caching array - * - * @var array $_memoryCachingArray - */ - var $_memoryCachingArray = array(); - - /** - * Memory caching counter - * - * @var int $memoryCachingCounter - */ - var $_memoryCachingCounter = 0; - - /** - * Memory caching limit - * - * @var int $memoryCachingLimit - */ - var $_memoryCachingLimit = 1000; - - /** - * File Name protection - * - * if set to true, you can use any cache id or group name - * if set to false, it can be faster but cache ids and group names - * will be used directly in cache file names so be carefull with - * special characters... - * - * @var boolean $fileNameProtection - */ - var $_fileNameProtection = true; - - /** - * Enable / disable automatic serialization - * - * it can be used to save directly datas which aren't strings - * (but it's slower) - * - * @var boolean $_serialize - */ - var $_automaticSerialization = false; - - /** - * Disable / Tune the automatic cleaning process - * - * The automatic cleaning process destroy too old (for the given life time) - * cache files when a new cache file is written. - * 0 => no automatic cache cleaning - * 1 => systematic cache cleaning - * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write - * - * @var int $_automaticCleaning - */ - var $_automaticCleaningFactor = 0; - - /** - * Nested directory level - * - * Set the hashed directory structure level. 0 means "no hashed directory - * structure", 1 means "one level of directory", 2 means "two levels"... - * This option can speed up Cache_Lite only when you have many thousands of - * cache file. Only specific benchs can help you to choose the perfect value - * for you. Maybe, 1 or 2 is a good start. - * - * @var int $_hashedDirectoryLevel - */ - var $_hashedDirectoryLevel = 0; - - /** - * Umask for hashed directory structure - * - * @var int $_hashedDirectoryUmask - */ - var $_hashedDirectoryUmask = 0700; - - /** - * API break for error handling in CACHE_LITE_ERROR_RETURN mode - * - * In CACHE_LITE_ERROR_RETURN mode, error handling was not good because - * for example save() method always returned a boolean (a PEAR_Error object - * would be better in CACHE_LITE_ERROR_RETURN mode). To correct this without - * breaking the API, this option (false by default) can change this handling. - * - * @var boolean - */ - var $_errorHandlingAPIBreak = false; - - var $_hashedDirectoryGroup = NULL; - - var $_cacheFileMode = NULL; - - var $_cacheFileGroup = NULL; - - // --- Public methods --- - - /** - * Constructor - * - * $options is an assoc. Available options are : - * $options = array( - * 'cacheDir' => directory where to put the cache files (string), - * 'caching' => enable / disable caching (boolean), - * 'lifeTime' => cache lifetime in seconds (int), - * 'fileLocking' => enable / disable fileLocking (boolean), - * 'writeControl' => enable / disable write control (boolean), - * 'readControl' => enable / disable read control (boolean), - * 'readControlType' => type of read control 'crc32', 'md5', 'strlen' (string), - * 'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int), - * 'memoryCaching' => enable / disable memory caching (boolean), - * 'onlyMemoryCaching' => enable / disable only memory caching (boolean), - * 'memoryCachingLimit' => max nbr of records to store into memory caching (int), - * 'fileNameProtection' => enable / disable automatic file name protection (boolean), - * 'automaticSerialization' => enable / disable automatic serialization (boolean), - * 'automaticCleaningFactor' => distable / tune automatic cleaning process (int), - * 'hashedDirectoryLevel' => level of the hashed directory system (int), - * 'hashedDirectoryUmask' => umask for hashed directory structure (int), - * 'errorHandlingAPIBreak' => API break for better error handling ? (boolean) - * 'hashedDirectoryGroup' => group of hashed directory structure (int | string) (see function chgrp) - * 'cacheFileMode' => filesystem mode of newly created cache files (int) - * 'cacheFileGroup' => group of newly created cache files (int | string) (see function chgrp) - * ); - * - * If sys_get_temp_dir() is available and the - * 'cacheDir' option is not provided in the - * constructor options array its output is used - * to determine the suitable temporary directory. - * - * @see http://de.php.net/sys_get_temp_dir - * @see http://pear.php.net/bugs/bug.php?id=18328 - * - * @param array $options options - * @access public - */ - function Cache_Lite($options = array(NULL)) - { - foreach($options as $key => $value) { - $this->setOption($key, $value); - } - if (!isset($options['cacheDir']) && function_exists('sys_get_temp_dir')) { - $this->setOption('cacheDir', sys_get_temp_dir() . DIRECTORY_SEPARATOR); - } - } - - /** - * Generic way to set a Cache_Lite option - * - * see Cache_Lite constructor for available options - * - * @var string $name name of the option - * @var mixed $value value of the option - * @access public - */ - function setOption($name, $value) - { - $availableOptions = array('errorHandlingAPIBreak', 'hashedDirectoryUmask', 'hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode', 'hashedDirectoryGroup', 'cacheFileMode', 'cacheFileGroup'); - if (in_array($name, $availableOptions)) { - $property = '_'.$name; - $this->$property = $value; - } - } - - /** - * Test if a cache is available and (if yes) return it - * - * @param string $id cache id - * @param string $group name of the cache group - * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested - * @return string data of the cache (else : false) - * @access public - */ - function get($id, $group = 'default', $doNotTestCacheValidity = false) - { - $this->_id = $id; - $this->_group = $group; - $data = false; - if ($this->_caching) { - $this->_setRefreshTime(); - $this->_setFileName($id, $group); - clearstatcache(); - if ($this->_memoryCaching) { - if (isset($this->_memoryCachingArray[$this->_file])) { - if ($this->_automaticSerialization) { - return unserialize($this->_memoryCachingArray[$this->_file]); - } - return $this->_memoryCachingArray[$this->_file]; - } - if ($this->_onlyMemoryCaching) { - return false; - } - } - if (($doNotTestCacheValidity) || (is_null($this->_refreshTime))) { - if (file_exists($this->_file)) { - $data = $this->_read(); - } - } else { - if ((file_exists($this->_file)) && (@filemtime($this->_file) > $this->_refreshTime)) { - $data = $this->_read(); - } - } - if (($data) and ($this->_memoryCaching)) { - $this->_memoryCacheAdd($data); - } - if (($this->_automaticSerialization) and (is_string($data))) { - $data = unserialize($data); - } - return $data; - } - return false; - } - - /** - * Save some data in a cache file - * - * @param string $data data to put in cache (can be another type than strings if automaticSerialization is on) - * @param string $id cache id - * @param string $group name of the cache group - * @return boolean true if no problem (else : false or a PEAR_Error object) - * @access public - */ - function save($data, $id = NULL, $group = 'default') - { - if ($this->_caching) { - if ($this->_automaticSerialization) { - $data = serialize($data); - } - if (isset($id)) { - $this->_setFileName($id, $group); - } - if ($this->_memoryCaching) { - $this->_memoryCacheAdd($data); - if ($this->_onlyMemoryCaching) { - return true; - } - } - if ($this->_automaticCleaningFactor>0 && ($this->_automaticCleaningFactor==1 || mt_rand(1, $this->_automaticCleaningFactor)==1)) { - $this->clean(false, 'old'); - } - if ($this->_writeControl) { - $res = $this->_writeAndControl($data); - if (is_bool($res)) { - if ($res) { - return true; - } - // if $res if false, we need to invalidate the cache - @touch($this->_file, time() - 2*abs($this->_lifeTime)); - return false; - } - } else { - $res = $this->_write($data); - } - if (is_object($res)) { - // $res is a PEAR_Error object - if (!($this->_errorHandlingAPIBreak)) { - return false; // we return false (old API) - } - } - return $res; - } - return false; - } - - /** - * Remove a cache file - * - * @param string $id cache id - * @param string $group name of the cache group - * @param boolean $checkbeforeunlink check if file exists before removing it - * @return boolean true if no problem - * @access public - */ - function remove($id, $group = 'default', $checkbeforeunlink = false) - { - $this->_setFileName($id, $group); - if ($this->_memoryCaching) { - if (isset($this->_memoryCachingArray[$this->_file])) { - unset($this->_memoryCachingArray[$this->_file]); - $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1; - } - if ($this->_onlyMemoryCaching) { - return true; - } - } - if ( $checkbeforeunlink ) { - if (!file_exists($this->_file)) return true; - } - return $this->_unlink($this->_file); - } - - /** - * Clean the cache - * - * if no group is specified all cache files will be destroyed - * else only cache files of the specified group will be destroyed - * - * @param string $group name of the cache group - * @param string $mode flush cache mode : 'old', 'ingroup', 'notingroup', - * 'callback_myFunction' - * @return boolean true if no problem - * @access public - */ - function clean($group = false, $mode = 'ingroup') - { - return $this->_cleanDir($this->_cacheDir, $group, $mode); - } - - /** - * Set to debug mode - * - * When an error is found, the script will stop and the message will be displayed - * (in debug mode only). - * - * @access public - */ - function setToDebug() - { - $this->setOption('pearErrorMode', CACHE_LITE_ERROR_DIE); - } - - /** - * Set a new life time - * - * @param int $newLifeTime new life time (in seconds) - * @access public - */ - function setLifeTime($newLifeTime) - { - $this->_lifeTime = $newLifeTime; - $this->_setRefreshTime(); - } - - /** - * Save the state of the caching memory array into a cache file cache - * - * @param string $id cache id - * @param string $group name of the cache group - * @access public - */ - function saveMemoryCachingState($id, $group = 'default') - { - if ($this->_caching) { - $array = array( - 'counter' => $this->_memoryCachingCounter, - 'array' => $this->_memoryCachingArray - ); - $data = serialize($array); - $this->save($data, $id, $group); - } - } - - /** - * Load the state of the caching memory array from a given cache file cache - * - * @param string $id cache id - * @param string $group name of the cache group - * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested - * @access public - */ - function getMemoryCachingState($id, $group = 'default', $doNotTestCacheValidity = false) - { - if ($this->_caching) { - if ($data = $this->get($id, $group, $doNotTestCacheValidity)) { - $array = unserialize($data); - $this->_memoryCachingCounter = $array['counter']; - $this->_memoryCachingArray = $array['array']; - } - } - } - - /** - * Return the cache last modification time - * - * BE CAREFUL : THIS METHOD IS FOR HACKING ONLY ! - * - * @return int last modification time - */ - function lastModified() - { - return @filemtime($this->_file); - } - - /** - * Trigger a PEAR error - * - * To improve performances, the PEAR.php file is included dynamically. - * The file is so included only when an error is triggered. So, in most - * cases, the file isn't included and perfs are much better. - * - * @param string $msg error message - * @param int $code error code - * @access public - */ - function raiseError($msg, $code) - { - include_once('PEAR.php'); - return PEAR::raiseError($msg, $code, $this->_pearErrorMode); - } - - /** - * Extend the life of a valid cache file - * - * see http://pear.php.net/bugs/bug.php?id=6681 - * - * @access public - */ - function extendLife() - { - @touch($this->_file); - } - - // --- Private methods --- - - /** - * Compute & set the refresh time - * - * @access private - */ - function _setRefreshTime() - { - if (is_null($this->_lifeTime)) { - $this->_refreshTime = null; - } else { - $this->_refreshTime = time() - $this->_lifeTime; - } - } - - /** - * Remove a file - * - * @param string $file complete file path and name - * @return boolean true if no problem - * @access private - */ - function _unlink($file) - { - if (!@unlink($file)) { - return $this->raiseError('Cache_Lite : Unable to remove cache !', -3); - } - return true; - } - - /** - * Recursive function for cleaning cache file in the given directory - * - * @param string $dir directory complete path (with a trailing slash) - * @param string $group name of the cache group - * @param string $mode flush cache mode : 'old', 'ingroup', 'notingroup', - 'callback_myFunction' - * @return boolean true if no problem - * @access private - */ - function _cleanDir($dir, $group = false, $mode = 'ingroup') - { - if ($this->_fileNameProtection) { - $motif = ($group) ? 'cache_'.md5($group).'_' : 'cache_'; - } else { - $motif = ($group) ? 'cache_'.$group.'_' : 'cache_'; - } - if ($this->_memoryCaching) { - foreach($this->_memoryCachingArray as $key => $v) { - if (strpos($key, $motif) !== false) { - unset($this->_memoryCachingArray[$key]); - $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1; - } - } - if ($this->_onlyMemoryCaching) { - return true; - } - } - if (!($dh = opendir($dir))) { - return $this->raiseError('Cache_Lite : Unable to open cache directory !', -4); - } - $result = true; - while (($file = readdir($dh)) !== false) { - if (($file != '.') && ($file != '..')) { - if (substr($file, 0, 6)=='cache_') { - $file2 = $dir . $file; - if (is_file($file2)) { - switch (substr($mode, 0, 9)) { - case 'old': - // files older than lifeTime get deleted from cache - if (!is_null($this->_lifeTime)) { - if ((time() - @filemtime($file2)) > $this->_lifeTime) { - $result = ($result and ($this->_unlink($file2))); - } - } - break; - case 'notingrou': - if (strpos($file2, $motif) === false) { - $result = ($result and ($this->_unlink($file2))); - } - break; - case 'callback_': - $func = substr($mode, 9, strlen($mode) - 9); - if ($func($file2, $group)) { - $result = ($result and ($this->_unlink($file2))); - } - break; - case 'ingroup': - default: - if (strpos($file2, $motif) !== false) { - $result = ($result and ($this->_unlink($file2))); - } - break; - } - } - if ((is_dir($file2)) and ($this->_hashedDirectoryLevel>0)) { - $result = ($result and ($this->_cleanDir($file2 . '/', $group, $mode))); - } - } - } - } - return $result; - } - - /** - * Touch the cache file while are recreating it to avoid - * launch this task more then once when necessary - * When the cache recreated and Added in Cache Memory - * @return void - * @access private - */ - function _touchCacheFile(){ - if (file_exists($this->_file)) { - @touch($this->_file); - } - } - /** - * Add some date in the memory caching array - * - * @param string $data data to cache - * @access private - */ - function _memoryCacheAdd($data) - { - $this->_touchCacheFile(); - $this->_memoryCachingArray[$this->_file] = $data; - if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { - list($key, ) = each($this->_memoryCachingArray); - unset($this->_memoryCachingArray[$key]); - } else { - $this->_memoryCachingCounter = $this->_memoryCachingCounter + 1; - } - } - - /** - * Make a file name (with path) - * - * @param string $id cache id - * @param string $group name of the group - * @access private - */ - function _setFileName($id, $group) - { - - if ($this->_fileNameProtection) { - $suffix = 'cache_'.md5($group).'_'.md5($id); - } else { - $suffix = 'cache_'.$group.'_'.$id; - } - $root = $this->_cacheDir; - if ($this->_hashedDirectoryLevel>0) { - $hash = md5($suffix); - for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) { - $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/'; - } - } - $this->_fileName = $suffix; - $this->_file = $root.$suffix; - } - - /** - * Read the cache file and return the content - * - * @return string content of the cache file (else : false or a PEAR_Error object) - * @access private - */ - function _read() - { - $fp = @fopen($this->_file, "rb"); - if ($fp) { - if ($this->_fileLocking) @flock($fp, LOCK_SH); - clearstatcache(); - $length = @filesize($this->_file); - $mqr = get_magic_quotes_runtime(); - if ($mqr) { - set_magic_quotes_runtime(0); - } - if ($this->_readControl) { - $hashControl = @fread($fp, 32); - $length = $length - 32; - } - - if ($length) { - $data = ''; - // See https://bugs.php.net/bug.php?id=30936 - // The 8192 magic number is the chunk size used internally by PHP. - while(!feof($fp)) $data .= fread($fp, 8192); - } else { - $data = ''; - } - if ($mqr) { - set_magic_quotes_runtime($mqr); - } - if ($this->_fileLocking) @flock($fp, LOCK_UN); - @fclose($fp); - if ($this->_readControl) { - $hashData = $this->_hash($data, $this->_readControlType); - if ($hashData != $hashControl) { - if (!(is_null($this->_lifeTime))) { - @touch($this->_file, time() - 2*abs($this->_lifeTime)); - } else { - @unlink($this->_file); - } - return false; - } - } - return $data; - } - return $this->raiseError('Cache_Lite : Unable to read cache !', -2); - } - - /** - * Write the given data in the cache file - * - * @param string $data data to put in cache - * @return boolean true if ok (a PEAR_Error object else) - * @access private - */ - function _write($data) - { - if ($this->_hashedDirectoryLevel > 0) { - $hash = md5($this->_fileName); - $root = $this->_cacheDir; - for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) { - $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/'; - if (!(@is_dir($root))) { - if (@mkdir($root)) - { - @chmod($root, $this->_hashedDirectoryUmask); - if (! is_null($this->_hashedDirectoryGroup)) - @chgrp($root, $this->_hashedDirectoryGroup); - } - } - } - } - // if both _cacheFileMode and _cacheFileGroup is null, then we don't need to call - // file_exists (see below: if ($is_newfile) ...) - $is_newfile = (! is_null($this->_cacheFileMode) || !is_null($this->_cacheFileGroup)) - && ! @file_exists($this->_file); - $fp = @fopen($this->_file, "wb"); - if ($fp) { - if ($this->_fileLocking) @flock($fp, LOCK_EX); - if ($is_newfile) - { - if (! is_null($this->_cacheFileMode)) - @chmod($this->_file, $this->_cacheFileMode); - if (! is_null($this->_cacheFileGroup)) - @chgrp($this->_file, $this->_cacheFileGroup); - } - if ($this->_readControl) { - @fwrite($fp, $this->_hash($data, $this->_readControlType), 32); - } - $mqr = get_magic_quotes_runtime(); - if ($mqr) { - set_magic_quotes_runtime(0); - } - @fwrite($fp, $data); - if ($mqr) { - set_magic_quotes_runtime($mqr); - } - if ($this->_fileLocking) @flock($fp, LOCK_UN); - @fclose($fp); - return true; - } - return $this->raiseError('Cache_Lite : Unable to write cache file : '.$this->_file, -1); - } - - /** - * Write the given data in the cache file and control it just after to avoir corrupted cache entries - * - * @param string $data data to put in cache - * @return boolean true if the test is ok (else : false or a PEAR_Error object) - * @access private - */ - function _writeAndControl($data) - { - $result = $this->_write($data); - if (is_object($result)) { - return $result; # We return the PEAR_Error object - } - $dataRead = $this->_read(); - if (is_object($dataRead)) { - return $dataRead; # We return the PEAR_Error object - } - if ((is_bool($dataRead)) && (!$dataRead)) { - return false; - } - return ($dataRead==$data); - } - - /** - * Make a control key with the string containing datas - * - * @param string $data data - * @param string $controlType type of control 'md5', 'crc32' or 'strlen' - * @return string control key - * @access private - */ - function _hash($data, $controlType) - { - switch ($controlType) { - case 'md5': - return md5($data); - case 'crc32': - return sprintf('% 32d', crc32($data)); - case 'strlen': - return sprintf('% 32d', strlen($data)); - default: - return $this->raiseError('Unknown controlType ! (available values are only \'md5\', \'crc32\', \'strlen\')', -5); - } - } - -} diff --git a/data/module/Cache/Lite/File.php b/data/module/Cache/Lite/File.php deleted file mode 100644 index 2cb2758b0b6..00000000000 --- a/data/module/Cache/Lite/File.php +++ /dev/null @@ -1,90 +0,0 @@ - -*/ - -require_once('Cache/Lite.php'); - -class Cache_Lite_File extends Cache_Lite -{ - - // --- Private properties --- - - /** - * Complete path of the file used for controlling the cache lifetime - * - * @var string $_masterFile - */ - var $_masterFile = ''; - - /** - * Masterfile mtime - * - * @var int $_masterFile_mtime - */ - var $_masterFile_mtime = 0; - - // --- Public methods ---- - - /** - * Constructor - * - * $options is an assoc. To have a look at availables options, - * see the constructor of the Cache_Lite class in 'Cache_Lite.php' - * - * Comparing to Cache_Lite constructor, there is another option : - * $options = array( - * (...) see Cache_Lite constructor - * 'masterFile' => complete path of the file used for controlling the cache lifetime(string) - * ); - * - * @param array $options options - * @access public - */ - function Cache_Lite_File($options = array(NULL)) - { - $options['lifetime'] = 0; - $this->Cache_Lite($options); - if (isset($options['masterFile'])) { - $this->_masterFile = $options['masterFile']; - } else { - return $this->raiseError('Cache_Lite_File : masterFile option must be set !'); - } - if (!($this->_masterFile_mtime = @filemtime($this->_masterFile))) { - return $this->raiseError('Cache_Lite_File : Unable to read masterFile : '.$this->_masterFile, -3); - } - } - - /** - * Test if a cache is available and (if yes) return it - * - * @param string $id cache id - * @param string $group name of the cache group - * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested - * @return string data of the cache (else : false) - * @access public - */ - function get($id, $group = 'default', $doNotTestCacheValidity = false) - { - if ($data = parent::get($id, $group, true)) { - if ($filemtime = $this->lastModified()) { - if ($filemtime > $this->_masterFile_mtime) { - return $data; - } - } - } - return false; - } - -} diff --git a/data/module/Cache/Lite/Function.php b/data/module/Cache/Lite/Function.php deleted file mode 100644 index 6c4861a4386..00000000000 --- a/data/module/Cache/Lite/Function.php +++ /dev/null @@ -1,208 +0,0 @@ - -* @author Fabien MARTY -*/ - -require_once('Cache/Lite.php'); - -class Cache_Lite_Function extends Cache_Lite -{ - - // --- Private properties --- - - /** - * Default cache group for function caching - * - * @var string $_defaultGroup - */ - var $_defaultGroup = 'Cache_Lite_Function'; - - /** - * Don't cache the method call when its output contains the string "NOCACHE" - * - * if set to true, the output of the method will never be displayed (because the output is used - * to control the cache) - * - * @var boolean $_dontCacheWhenTheOutputContainsNOCACHE - */ - var $_dontCacheWhenTheOutputContainsNOCACHE = false; - - /** - * Don't cache the method call when its result is false - * - * @var boolean $_dontCacheWhenTheResultIsFalse - */ - var $_dontCacheWhenTheResultIsFalse = false; - - /** - * Don't cache the method call when its result is null - * - * @var boolean $_dontCacheWhenTheResultIsNull - */ - var $_dontCacheWhenTheResultIsNull = false; - - /** - * Debug the Cache_Lite_Function caching process - * - * @var boolean $_debugCacheLiteFunction - */ - var $_debugCacheLiteFunction = false; - - // --- Public methods ---- - - /** - * Constructor - * - * $options is an assoc. To have a look at availables options, - * see the constructor of the Cache_Lite class in 'Cache_Lite.php' - * - * Comparing to Cache_Lite constructor, there is another option : - * $options = array( - * (...) see Cache_Lite constructor - * 'debugCacheLiteFunction' => (bool) debug the caching process, - * 'defaultGroup' => default cache group for function caching (string), - * 'dontCacheWhenTheOutputContainsNOCACHE' => (bool) don't cache when the function output contains "NOCACHE", - * 'dontCacheWhenTheResultIsFalse' => (bool) don't cache when the function result is false, - * 'dontCacheWhenTheResultIsNull' => (bool don't cache when the function result is null - * ); - * - * @param array $options options - * @access public - */ - function Cache_Lite_Function($options = array(NULL)) - { - $availableOptions = array('debugCacheLiteFunction', 'defaultGroup', 'dontCacheWhenTheOutputContainsNOCACHE', 'dontCacheWhenTheResultIsFalse', 'dontCacheWhenTheResultIsNull'); - while (list($name, $value) = each($options)) { - if (in_array($name, $availableOptions)) { - $property = '_'.$name; - $this->$property = $value; - } - } - reset($options); - $this->Cache_Lite($options); - } - - /** - * Calls a cacheable function or method (or not if there is already a cache for it) - * - * Arguments of this method are read with func_get_args. So it doesn't appear - * in the function definition. Synopsis : - * call('functionName', $arg1, $arg2, ...) - * (arg1, arg2... are arguments of 'functionName') - * - * @return mixed result of the function/method - * @access public - */ - function call() - { - $arguments = func_get_args(); - $id = $this->_makeId($arguments); - $data = $this->get($id, $this->_defaultGroup); - if ($data !== false) { - if ($this->_debugCacheLiteFunction) { - echo "Cache hit !\n"; - } - $array = unserialize($data); - $output = $array['output']; - $result = $array['result']; - } else { - if ($this->_debugCacheLiteFunction) { - echo "Cache missed !\n"; - } - ob_start(); - ob_implicit_flush(false); - $target = array_shift($arguments); - if (is_array($target)) { - // in this case, $target is for example array($obj, 'method') - $object = $target[0]; - $method = $target[1]; - $result = call_user_func_array(array(&$object, $method), $arguments); - } else { - if (strstr($target, '::')) { // classname::staticMethod - list($class, $method) = explode('::', $target); - $result = call_user_func_array(array($class, $method), $arguments); - } else if (strstr($target, '->')) { // object->method - // use a stupid name ($objet_123456789 because) of problems where the object - // name is the same as this var name - list($object_123456789, $method) = explode('->', $target); - global $$object_123456789; - $result = call_user_func_array(array($$object_123456789, $method), $arguments); - } else { // function - $result = call_user_func_array($target, $arguments); - } - } - $output = ob_get_contents(); - ob_end_clean(); - if ($this->_dontCacheWhenTheResultIsFalse) { - if ((is_bool($result)) && (!($result))) { - echo($output); - return $result; - } - } - if ($this->_dontCacheWhenTheResultIsNull) { - if (is_null($result)) { - echo($output); - return $result; - } - } - if ($this->_dontCacheWhenTheOutputContainsNOCACHE) { - if (strpos($output, 'NOCACHE') > -1) { - return $result; - } - } - $array['output'] = $output; - $array['result'] = $result; - $this->save(serialize($array), $id, $this->_defaultGroup); - } - echo($output); - return $result; - } - - /** - * Drop a cache file - * - * Arguments of this method are read with func_get_args. So it doesn't appear - * in the function definition. Synopsis : - * remove('functionName', $arg1, $arg2, ...) - * (arg1, arg2... are arguments of 'functionName') - * - * @return boolean true if no problem - * @access public - */ - function drop() - { - $id = $this->_makeId(func_get_args()); - return $this->remove($id, $this->_defaultGroup); - } - - /** - * Make an id for the cache - * - * @var array result of func_get_args for the call() or the remove() method - * @return string id - * @access private - */ - function _makeId($arguments) - { - $id = serialize($arguments); // Generate a cache id - if (!$this->_fileNameProtection) { - $id = md5($id); - // if fileNameProtection is set to false, then the id has to be hashed - // because it's a very bad file name in most cases - } - return $id; - } - -} diff --git a/data/module/Cache/Lite/NestedOutput.php b/data/module/Cache/Lite/NestedOutput.php deleted file mode 100644 index 81ece30d630..00000000000 --- a/data/module/Cache/Lite/NestedOutput.php +++ /dev/null @@ -1,56 +0,0 @@ - -*/ - -require_once('Cache/Lite/Output.php'); - -class Cache_Lite_NestedOutput extends Cache_Lite_Output -{ - private $nestedIds = array(); - private $nestedGroups = array(); - - /** - * Start the cache - * - * @param string $id cache id - * @param string $group name of the cache group - * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested - * @return boolean|string false if the cache is not hit else the data - * @access public - */ - function start($id, $group = 'default', $doNotTestCacheValidity = false) - { - $this->nestedIds[] = $id; - $this->nestedGroups[] = $group; - $data = $this->get($id, $group, $doNotTestCacheValidity); - if ($data !== false) { - return $data; - } - ob_start(); - ob_implicit_flush(false); - return false; - } - - /** - * Stop the cache - * - * @param boolen - * @return string return contents of cache - */ - function end() - { - $data = ob_get_contents(); - ob_end_clean(); - $id = array_pop($this->nestedIds); - $group = array_pop($this->nestedGroups); - $this->save($data, $id, $group); - return $data; - } - -} diff --git a/data/module/Cache/Lite/Output.php b/data/module/Cache/Lite/Output.php deleted file mode 100644 index 87d7c19d8ea..00000000000 --- a/data/module/Cache/Lite/Output.php +++ /dev/null @@ -1,68 +0,0 @@ - -*/ - -require_once('Cache/Lite.php'); - -class Cache_Lite_Output extends Cache_Lite -{ - - // --- Public methods --- - - /** - * Constructor - * - * $options is an assoc. To have a look at availables options, - * see the constructor of the Cache_Lite class in 'Cache_Lite.php' - * - * @param array $options options - * @access public - */ - function Cache_Lite_Output($options) - { - $this->Cache_Lite($options); - } - - /** - * Start the cache - * - * @param string $id cache id - * @param string $group name of the cache group - * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested - * @return boolean true if the cache is hit (false else) - * @access public - */ - function start($id, $group = 'default', $doNotTestCacheValidity = false) - { - $data = $this->get($id, $group, $doNotTestCacheValidity); - if ($data !== false) { - echo($data); - return true; - } - ob_start(); - ob_implicit_flush(false); - return false; - } - - /** - * Stop the cache - * - * @access public - */ - function end() - { - $data = ob_get_contents(); - ob_end_clean(); - $this->save($data, $this->_id, $this->_group); - echo($data); - } - -} diff --git a/data/module/Calendar/Calendar.php b/data/module/Calendar/Calendar.php deleted file mode 100644 index e4cd5898c1c..00000000000 --- a/data/module/Calendar/Calendar.php +++ /dev/null @@ -1,685 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Calendar.php,v 1.3 2005/10/22 10:07:11 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Calendar.php,v 1.3 2005/10/22 10:07:11 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Constant which defines the calculation engine to use - */ -if (!defined('CALENDAR_ENGINE')) { - define('CALENDAR_ENGINE', 'UnixTS'); -} - -/** - * Define Calendar Month states - */ -define('CALENDAR_USE_MONTH', 1); -define('CALENDAR_USE_MONTH_WEEKDAYS', 2); -define('CALENDAR_USE_MONTH_WEEKS', 3); - -/** - * Contains a factory method to return a Singleton instance of a class - * implementing the Calendar_Engine_Interface.
- * Note: this class must be modified to "register" alternative - * Calendar_Engines. The engine used can be controlled with the constant - * CALENDAR_ENGINE - * @see Calendar_Engine_Interface - * @package Calendar - * @access protected - */ -class Calendar_Engine_Factory -{ - /** - * Returns an instance of the engine - * @return object instance of a calendar calculation engine - * @access protected - */ - function & getEngine() - { - static $engine = false; - switch (CALENDAR_ENGINE) { - case 'PearDate': - $class = 'Calendar_Engine_PearDate'; - break; - case 'UnixTS': - default: - $class = 'Calendar_Engine_UnixTS'; - break; - } - if (!$engine) { - if (!class_exists($class)) { - require_once CALENDAR_ROOT.'Engine'.DIRECTORY_SEPARATOR.CALENDAR_ENGINE.'.php'; - } - $engine = new $class; - } - return $engine; - } -} - -/** - * Base class for Calendar API. This class should not be instantiated - * directly. - * @abstract - * @package Calendar - */ -class Calendar -{ - /** - * Instance of class implementing calendar engine interface - * @var object - * @access private - */ - var $cE; - - /** - * Instance of Calendar_Validator (lazy initialized when isValid() or - * getValidor() is called - * @var Calendar_Validator - * @access private - */ - var $validator; - - /** - * Year for this calendar object e.g. 2003 - * @access private - * @var int - */ - var $year; - - /** - * Month for this calendar object e.g. 9 - * @access private - * @var int - */ - var $month; - - /** - * Day of month for this calendar object e.g. 23 - * @access private - * @var int - */ - var $day; - - /** - * Hour of day for this calendar object e.g. 13 - * @access private - * @var int - */ - var $hour; - - /** - * Minute of hour this calendar object e.g. 46 - * @access private - * @var int - */ - var $minute; - - /** - * Second of minute this calendar object e.g. 34 - * @access private - * @var int - */ - var $second; - - /** - * Marks this calendar object as selected (e.g. 'today') - * @access private - * @var boolean - */ - var $selected = false; - - /** - * Collection of child calendar objects created from subclasses - * of Calendar. Type depends on the object which created them. - * @access private - * @var array - */ - var $children = array(); - - /** - * Constructs the Calendar - * @param int year - * @param int month - * @param int day - * @param int hour - * @param int minute - * @param int second - * @access protected - */ - function Calendar($y = 2000, $m = 1, $d = 1, $h = 0, $i = 0, $s = 0) - { - static $cE = null; - if (!isset($cE)) { - $cE = & Calendar_Engine_Factory::getEngine(); - } - $this->cE = & $cE; - $this->year = (int)$y; - $this->month = (int)$m; - $this->day = (int)$d; - $this->hour = (int)$h; - $this->minute = (int)$i; - $this->second = (int)$s; - } - - /** - * Defines the calendar by a timestamp (Unix or ISO-8601), replacing values - * passed to the constructor - * @param int|string Unix or ISO-8601 timestamp - * @return void - * @access public - */ - function setTimestamp($ts) - { - $this->year = $this->cE->stampToYear($ts); - $this->month = $this->cE->stampToMonth($ts); - $this->day = $this->cE->stampToDay($ts); - $this->hour = $this->cE->stampToHour($ts); - $this->minute = $this->cE->stampToMinute($ts); - $this->second = $this->cE->stampToSecond($ts); - } - - /** - * Returns a timestamp from the current date / time values. Format of - * timestamp depends on Calendar_Engine implementation being used - * @return int|string timestamp - * @access public - */ - function getTimestamp() - { - return $this->cE->dateToStamp( - $this->year, $this->month, $this->day, - $this->hour, $this->minute, $this->second); - } - - /** - * Defines calendar object as selected (e.g. for today) - * @param boolean state whether Calendar subclass - * @return void - * @access public - */ - function setSelected($state = true) - { - $this->selected = $state; - } - - /** - * True if the calendar subclass object is selected (e.g. today) - * @return boolean - * @access public - */ - function isSelected() - { - return $this->selected; - } - - /** - * Adjusts the date (helper method) - * @return void - * @access public - */ - function adjust() - { - $stamp = $this->getTimeStamp(); - $this->year = $this->cE->stampToYear($stamp); - $this->month = $this->cE->stampToMonth($stamp); - $this->day = $this->cE->stampToDay($stamp); - $this->hour = $this->cE->stampToHour($stamp); - $this->minute = $this->cE->stampToMinute($stamp); - $this->second = $this->cE->stampToSecond($stamp); - } - - /** - * Returns the date as an associative array (helper method) - * @param mixed timestamp (leave empty for current timestamp) - * @return array - * @access public - */ - function toArray($stamp=null) - { - if (is_null($stamp)) { - $stamp = $this->getTimeStamp(); - } - return array( - 'year' => $this->cE->stampToYear($stamp), - 'month' => $this->cE->stampToMonth($stamp), - 'day' => $this->cE->stampToDay($stamp), - 'hour' => $this->cE->stampToHour($stamp), - 'minute' => $this->cE->stampToMinute($stamp), - 'second' => $this->cE->stampToSecond($stamp) - ); - } - - /** - * Returns the value as an associative array (helper method) - * @param string type of date object that return value represents - * @param string $format ['int' | 'array' | 'timestamp' | 'object'] - * @param mixed timestamp (depending on Calendar engine being used) - * @param int integer default value (i.e. give me the answer quick) - * @return mixed - * @access private - */ - function returnValue($returnType, $format, $stamp, $default) - { - switch (strtolower($format)) { - case 'int': - return $default; - case 'array': - return $this->toArray($stamp); - break; - case 'object': - require_once CALENDAR_ROOT.'Factory.php'; - return Calendar_Factory::createByTimestamp($returnType,$stamp); - break; - case 'timestamp': - default: - return $stamp; - break; - } - } - - /** - * Abstract method for building the children of a calendar object. - * Implemented by Calendar subclasses - * @param array containing Calendar objects to select (optional) - * @return boolean - * @access public - * @abstract - */ - function build($sDates = array()) - { - require_once 'PEAR.php'; - PEAR::raiseError( - 'Calendar::build is abstract', null, PEAR_ERROR_TRIGGER, - E_USER_NOTICE, 'Calendar::build()'); - return false; - } - - /** - * Abstract method for selected data objects called from build - * @param array - * @return boolean - * @access public - * @abstract - */ - function setSelection($sDates) - { - require_once 'PEAR.php'; - PEAR::raiseError( - 'Calendar::setSelection is abstract', null, PEAR_ERROR_TRIGGER, - E_USER_NOTICE, 'Calendar::setSelection()'); - return false; - } - - /** - * Iterator method for fetching child Calendar subclass objects - * (e.g. a minute from an hour object). On reaching the end of - * the collection, returns false and resets the collection for - * further iteratations. - * @return mixed either an object subclass of Calendar or false - * @access public - */ - function fetch() - { - $child = each($this->children); - if ($child) { - return $child['value']; - } else { - reset($this->children); - return false; - } - } - - /** - * Fetches all child from the current collection of children - * @return array - * @access public - */ - function fetchAll() - { - return $this->children; - } - - /** - * Get the number Calendar subclass objects stored in the internal - * collection. - * @return int - * @access public - */ - function size() - { - return count($this->children); - } - - /** - * Determine whether this date is valid, with the bounds determined by - * the Calendar_Engine. The call is passed on to - * Calendar_Validator::isValid - * @return boolean - * @access public - */ - function isValid() - { - $validator = & $this->getValidator(); - return $validator->isValid(); - } - - /** - * Returns an instance of Calendar_Validator - * @return Calendar_Validator - * @access public - */ - function & getValidator() - { - if (!isset($this->validator)) { - require_once CALENDAR_ROOT.'Validator.php'; - $this->validator = & new Calendar_Validator($this); - } - return $this->validator; - } - - /** - * Returns a reference to the current Calendar_Engine being used. Useful - * for Calendar_Table_Helper and Calendar_Validator - * @return object implementing Calendar_Engine_Inteface - * @access protected - */ - function & getEngine() - { - return $this->cE; - } - - /** - * Set the CALENDAR_FIRST_DAY_OF_WEEK constant to the $firstDay value - * if the constant is not set yet. - * @throws E_USER_WARNING this method throws a WARNING if the - * CALENDAR_FIRST_DAY_OF_WEEK constant is already defined and - * the $firstDay parameter is set to a different value - * @param integer $firstDay first day of the week (0=sunday, 1=monday, ...) - * @return integer - * @access protected - */ - function defineFirstDayOfWeek($firstDay = null) - { - if (defined('CALENDAR_FIRST_DAY_OF_WEEK')) { - if (!is_null($firstDay) && ($firstDay != CALENDAR_FIRST_DAY_OF_WEEK)) { - $msg = 'CALENDAR_FIRST_DAY_OF_WEEK constant already defined.' - .' The $firstDay parameter will be ignored.'; - trigger_error($msg, E_USER_WARNING); - } - return CALENDAR_FIRST_DAY_OF_WEEK; - } - if (is_null($firstDay)) { - $firstDay = $this->cE->getFirstDayOfWeek( - $this->thisYear(), - $this->thisMonth(), - $this->thisDay() - ); - } - define ('CALENDAR_FIRST_DAY_OF_WEEK', $firstDay); - return CALENDAR_FIRST_DAY_OF_WEEK; - } - - /** - * Returns the value for the previous year - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 2002 or timestamp - * @access public - */ - function prevYear($format = 'int') - { - $ts = $this->cE->dateToStamp($this->year-1, 1, 1, 0, 0, 0); - return $this->returnValue('Year', $format, $ts, $this->year-1); - } - - /** - * Returns the value for this year - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 2003 or timestamp - * @access public - */ - function thisYear($format = 'int') - { - $ts = $this->cE->dateToStamp($this->year, 1, 1, 0, 0, 0); - return $this->returnValue('Year', $format, $ts, $this->year); - } - - /** - * Returns the value for next year - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 2004 or timestamp - * @access public - */ - function nextYear($format = 'int') - { - $ts = $this->cE->dateToStamp($this->year+1, 1, 1, 0, 0, 0); - return $this->returnValue('Year', $format, $ts, $this->year+1); - } - - /** - * Returns the value for the previous month - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 4 or Unix timestamp - * @access public - */ - function prevMonth($format = 'int') - { - $ts = $this->cE->dateToStamp($this->year, $this->month-1, 1, 0, 0, 0); - return $this->returnValue('Month', $format, $ts, $this->cE->stampToMonth($ts)); - } - - /** - * Returns the value for this month - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 5 or timestamp - * @access public - */ - function thisMonth($format = 'int') - { - $ts = $this->cE->dateToStamp($this->year, $this->month, 1, 0, 0, 0); - return $this->returnValue('Month', $format, $ts, $this->month); - } - - /** - * Returns the value for next month - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 6 or timestamp - * @access public - */ - function nextMonth($format = 'int') - { - $ts = $this->cE->dateToStamp($this->year, $this->month+1, 1, 0, 0, 0); - return $this->returnValue('Month', $format, $ts, $this->cE->stampToMonth($ts)); - } - - /** - * Returns the value for the previous day - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 10 or timestamp - * @access public - */ - function prevDay($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day-1, 0, 0, 0); - return $this->returnValue('Day', $format, $ts, $this->cE->stampToDay($ts)); - } - - /** - * Returns the value for this day - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 11 or timestamp - * @access public - */ - function thisDay($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day, 0, 0, 0); - return $this->returnValue('Day', $format, $ts, $this->day); - } - - /** - * Returns the value for the next day - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 12 or timestamp - * @access public - */ - function nextDay($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day+1, 0, 0, 0); - return $this->returnValue('Day', $format, $ts, $this->cE->stampToDay($ts)); - } - - /** - * Returns the value for the previous hour - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 13 or timestamp - * @access public - */ - function prevHour($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day, $this->hour-1, 0, 0); - return $this->returnValue('Hour', $format, $ts, $this->cE->stampToHour($ts)); - } - - /** - * Returns the value for this hour - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 14 or timestamp - * @access public - */ - function thisHour($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day, $this->hour, 0, 0); - return $this->returnValue('Hour', $format, $ts, $this->hour); - } - - /** - * Returns the value for the next hour - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 14 or timestamp - * @access public - */ - function nextHour($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day, $this->hour+1, 0, 0); - return $this->returnValue('Hour', $format, $ts, $this->cE->stampToHour($ts)); - } - - /** - * Returns the value for the previous minute - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 23 or timestamp - * @access public - */ - function prevMinute($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day, - $this->hour, $this->minute-1, 0); - return $this->returnValue('Minute', $format, $ts, $this->cE->stampToMinute($ts)); - } - - /** - * Returns the value for this minute - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 24 or timestamp - * @access public - */ - function thisMinute($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day, - $this->hour, $this->minute, 0); - return $this->returnValue('Minute', $format, $ts, $this->minute); - } - - /** - * Returns the value for the next minute - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 25 or timestamp - * @access public - */ - function nextMinute($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day, - $this->hour, $this->minute+1, 0); - return $this->returnValue('Minute', $format, $ts, $this->cE->stampToMinute($ts)); - } - - /** - * Returns the value for the previous second - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 43 or timestamp - * @access public - */ - function prevSecond($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day, - $this->hour, $this->minute, $this->second-1); - return $this->returnValue('Second', $format, $ts, $this->cE->stampToSecond($ts)); - } - - /** - * Returns the value for this second - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 44 or timestamp - * @access public - */ - function thisSecond($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day, - $this->hour, $this->minute, $this->second); - return $this->returnValue('Second', $format, $ts, $this->second); - } - - /** - * Returns the value for the next second - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 45 or timestamp - * @access public - */ - function nextSecond($format = 'int') - { - $ts = $this->cE->dateToStamp( - $this->year, $this->month, $this->day, - $this->hour, $this->minute, $this->second+1); - return $this->returnValue('Second', $format, $ts, $this->cE->stampToSecond($ts)); - } -} -?> diff --git a/data/module/Calendar/Day.php b/data/module/Calendar/Day.php deleted file mode 100644 index c2fdb113751..00000000000 --- a/data/module/Calendar/Day.php +++ /dev/null @@ -1,197 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Day.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Day.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar base class - */ -require_once CALENDAR_ROOT.'Calendar.php'; - -/** - * Represents a Day and builds Hours. - * - * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Day.php'; - * $Day = & new Calendar_Day(2003, 10, 21); // Oct 21st 2003 - * while ($Hour = & $Day->fetch()) { - * echo $Hour->thisHour().'
'; - * } - *
- * @package Calendar - * @access public - */ -class Calendar_Day extends Calendar -{ - /** - * Marks the Day at the beginning of a week - * @access private - * @var boolean - */ - var $first = false; - - /** - * Marks the Day at the end of a week - * @access private - * @var boolean - */ - var $last = false; - - - /** - * Used for tabular calendars - * @access private - * @var boolean - */ - var $empty = false; - - /** - * Constructs Calendar_Day - * @param int year e.g. 2003 - * @param int month e.g. 8 - * @param int day e.g. 15 - * @access public - */ - function Calendar_Day($y, $m, $d) - { - Calendar::Calendar($y, $m, $d); - } - - /** - * Builds the Hours of the Day - * @param array (optional) Caledar_Hour objects representing selected dates - * @return boolean - * @access public - */ - function build($sDates = array()) - { - require_once CALENDAR_ROOT.'Hour.php'; - - $hID = $this->cE->getHoursInDay($this->year, $this->month, $this->day); - for ($i=0; $i < $hID; $i++) { - $this->children[$i]= - new Calendar_Hour($this->year, $this->month, $this->day, $i); - } - if (count($sDates) > 0) { - $this->setSelection($sDates); - } - return true; - } - - /** - * Called from build() - * @param array - * @return void - * @access private - */ - function setSelection($sDates) - { - foreach ($sDates as $sDate) { - if ($this->year == $sDate->thisYear() - && $this->month == $sDate->thisMonth() - && $this->day == $sDate->thisDay()) - { - $key = (int)$sDate->thisHour(); - if (isset($this->children[$key])) { - $sDate->setSelected(); - $this->children[$key] = $sDate; - } - } - } - } - - /** - * Defines Day object as first in a week - * Only used by Calendar_Month_Weekdays::build() - * @param boolean state - * @return void - * @access private - */ - function setFirst ($state = true) - { - $this->first = $state; - } - - /** - * Defines Day object as last in a week - * Used only following Calendar_Month_Weekdays::build() - * @param boolean state - * @return void - * @access private - */ - function setLast($state = true) - { - $this->last = $state; - } - - /** - * Returns true if Day object is first in a Week - * Only relevant when Day is created by Calendar_Month_Weekdays::build() - * @return boolean - * @access public - */ - function isFirst() { - return $this->first; - } - - /** - * Returns true if Day object is last in a Week - * Only relevant when Day is created by Calendar_Month_Weekdays::build() - * @return boolean - * @access public - */ - function isLast() - { - return $this->last; - } - - /** - * Defines Day object as empty - * Only used by Calendar_Month_Weekdays::build() - * @param boolean state - * @return void - * @access private - */ - function setEmpty ($state = true) - { - $this->empty = $state; - } - - /** - * @return boolean - * @access public - */ - function isEmpty() - { - return $this->empty; - } -} -?> diff --git a/data/module/Calendar/Decorator.php b/data/module/Calendar/Decorator.php deleted file mode 100644 index 93babb91701..00000000000 --- a/data/module/Calendar/Decorator.php +++ /dev/null @@ -1,558 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Decorator.php,v 1.3 2005/10/22 10:29:46 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Decorator.php,v 1.3 2005/10/22 10:29:46 quipo Exp $ - */ -/** - * Decorates any calendar class. - * Create a subclass of this class for your own "decoration". - * Used for "selections" - * - * class DayDecorator extends Calendar_Decorator - * { - * function thisDay($format = 'int') - * { -.* $day = parent::thisDay('timestamp'); -.* return date('D', $day); - * } - * } - * $Day = & new Calendar_Day(2003, 10, 25); - * $DayDecorator = & new DayDecorator($Day); - * echo $DayDecorator->thisDay(); // Outputs "Sat" - * - * @abstract - * @package Calendar - */ -class Calendar_Decorator -{ - /** - * Subclass of Calendar being decorated - * @var object - * @access private - */ - var $calendar; - - /** - * Constructs the Calendar_Decorator - * @param object subclass to Calendar to decorate - */ - function Calendar_Decorator(& $calendar) - { - $this->calendar = & $calendar; - } - - /** - * Defines the calendar by a Unix timestamp, replacing values - * passed to the constructor - * @param int Unix timestamp - * @return void - * @access public - */ - function setTimestamp($ts) - { - $this->calendar->setTimestamp($ts); - } - - /** - * Returns a timestamp from the current date / time values. Format of - * timestamp depends on Calendar_Engine implementation being used - * @return int timestamp - * @access public - */ - function getTimestamp() - { - return $this->calendar->getTimeStamp(); - } - - /** - * Defines calendar object as selected (e.g. for today) - * @param boolean state whether Calendar subclass - * @return void - * @access public - */ - function setSelected($state = true) - { - $this->calendar->setSelected($state = true); - } - - /** - * True if the calendar subclass object is selected (e.g. today) - * @return boolean - * @access public - */ - function isSelected() - { - return $this->calendar->isSelected(); - } - - /** - * Adjusts the date (helper method) - * @return void - * @access public - */ - function adjust() - { - $this->calendar->adjust(); - } - - /** - * Returns the date as an associative array (helper method) - * @param mixed timestamp (leave empty for current timestamp) - * @return array - * @access public - */ - function toArray($stamp=null) - { - return $this->calendar->toArray($stamp); - } - - /** - * Returns the value as an associative array (helper method) - * @param string type of date object that return value represents - * @param string $format ['int' | 'array' | 'timestamp' | 'object'] - * @param mixed timestamp (depending on Calendar engine being used) - * @param int integer default value (i.e. give me the answer quick) - * @return mixed - * @access private - */ - function returnValue($returnType, $format, $stamp, $default) - { - return $this->calendar->returnValue($returnType, $format, $stamp, $default); - } - - /** - * Defines Day object as first in a week - * Only used by Calendar_Month_Weekdays::build() - * @param boolean state - * @return void - * @access private - */ - function setFirst ($state = true) - { - if ( method_exists($this->calendar,'setFirst') ) { - $this->calendar->setFirst($state); - } - } - - /** - * Defines Day object as last in a week - * Used only following Calendar_Month_Weekdays::build() - * @param boolean state - * @return void - * @access private - */ - function setLast($state = true) - { - if ( method_exists($this->calendar,'setLast') ) { - $this->calendar->setLast($state); - } - } - - /** - * Returns true if Day object is first in a Week - * Only relevant when Day is created by Calendar_Month_Weekdays::build() - * @return boolean - * @access public - */ - function isFirst() { - if ( method_exists($this->calendar,'isFirst') ) { - return $this->calendar->isFirst(); - } - } - - /** - * Returns true if Day object is last in a Week - * Only relevant when Day is created by Calendar_Month_Weekdays::build() - * @return boolean - * @access public - */ - function isLast() - { - if ( method_exists($this->calendar,'isLast') ) { - return $this->calendar->isLast(); - } - } - - /** - * Defines Day object as empty - * Only used by Calendar_Month_Weekdays::build() - * @param boolean state - * @return void - * @access private - */ - function setEmpty ($state = true) - { - if ( method_exists($this->calendar,'setEmpty') ) { - $this->calendar->setEmpty($state); - } - } - - /** - * @return boolean - * @access public - */ - function isEmpty() - { - if ( method_exists($this->calendar,'isEmpty') ) { - return $this->calendar->isEmpty(); - } - } - - /** - * Build the children - * @param array containing Calendar objects to select (optional) - * @return boolean - * @access public - * @abstract - */ - function build($sDates = array()) - { - $this->calendar->build($sDates); - } - - /** - * Iterator method for fetching child Calendar subclass objects - * (e.g. a minute from an hour object). On reaching the end of - * the collection, returns false and resets the collection for - * further iteratations. - * @return mixed either an object subclass of Calendar or false - * @access public - */ - function fetch() - { - return $this->calendar->fetch(); - } - - /** - * Fetches all child from the current collection of children - * @return array - * @access public - */ - function fetchAll() - { - return $this->calendar->fetchAll(); - } - - /** - * Get the number Calendar subclass objects stored in the internal - * collection. - * @return int - * @access public - */ - function size() - { - return $this->calendar->size(); - } - - /** - * Determine whether this date is valid, with the bounds determined by - * the Calendar_Engine. The call is passed on to - * Calendar_Validator::isValid - * @return boolean - * @access public - */ - function isValid() - { - return $this->calendar->isValid(); - } - - /** - * Returns an instance of Calendar_Validator - * @return Calendar_Validator - * @access public - */ - function & getValidator() - { - $validator = $this->calendar->getValidator(); - return $validator; - } - - /** - * Returns a reference to the current Calendar_Engine being used. Useful - * for Calendar_Table_Helper and Calendar_Validator - * @return object implementing Calendar_Engine_Inteface - * @access private - */ - function & getEngine() - { - return $this->calendar->getEngine(); - } - - /** - * Returns the value for the previous year - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 2002 or timestamp - * @access public - */ - function prevYear($format = 'int') - { - return $this->calendar->prevYear($format); - } - - /** - * Returns the value for this year - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 2003 or timestamp - * @access public - */ - function thisYear($format = 'int') - { - return $this->calendar->thisYear($format); - } - - /** - * Returns the value for next year - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 2004 or timestamp - * @access public - */ - function nextYear($format = 'int') - { - return $this->calendar->nextYear($format); - } - - /** - * Returns the value for the previous month - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 4 or Unix timestamp - * @access public - */ - function prevMonth($format = 'int') - { - return $this->calendar->prevMonth($format); - } - - /** - * Returns the value for this month - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 5 or timestamp - * @access public - */ - function thisMonth($format = 'int') - { - return $this->calendar->thisMonth($format); - } - - /** - * Returns the value for next month - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 6 or timestamp - * @access public - */ - function nextMonth($format = 'int') - { - return $this->calendar->nextMonth($format); - } - - /** - * Returns the value for the previous week - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 4 or Unix timestamp - * @access public - */ - function prevWeek($format = 'n_in_month') - { - if ( method_exists($this->calendar,'prevWeek') ) { - return $this->calendar->prevWeek($format); - } else { - require_once 'PEAR.php'; - PEAR::raiseError( - 'Cannot call prevWeek on Calendar object of type: '. - get_class($this->calendar), 133, PEAR_ERROR_TRIGGER, - E_USER_NOTICE, 'Calendar_Decorator::prevWeek()'); - return false; - } - } - - /** - * Returns the value for this week - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 5 or timestamp - * @access public - */ - function thisWeek($format = 'n_in_month') - { - if ( method_exists($this->calendar,'thisWeek') ) { - return $this->calendar->thisWeek($format); - } else { - require_once 'PEAR.php'; - PEAR::raiseError( - 'Cannot call thisWeek on Calendar object of type: '. - get_class($this->calendar), 133, PEAR_ERROR_TRIGGER, - E_USER_NOTICE, 'Calendar_Decorator::thisWeek()'); - return false; - } - } - - /** - * Returns the value for next week - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 6 or timestamp - * @access public - */ - function nextWeek($format = 'n_in_month') - { - if ( method_exists($this->calendar,'nextWeek') ) { - return $this->calendar->nextWeek($format); - } else { - require_once 'PEAR.php'; - PEAR::raiseError( - 'Cannot call thisWeek on Calendar object of type: '. - get_class($this->calendar), 133, PEAR_ERROR_TRIGGER, - E_USER_NOTICE, 'Calendar_Decorator::nextWeek()'); - return false; - } - } - - /** - * Returns the value for the previous day - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 10 or timestamp - * @access public - */ - function prevDay($format = 'int') { - return $this->calendar->prevDay($format); - } - - /** - * Returns the value for this day - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 11 or timestamp - * @access public - */ - function thisDay($format = 'int') - { - return $this->calendar->thisDay($format); - } - - /** - * Returns the value for the next day - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 12 or timestamp - * @access public - */ - function nextDay($format = 'int') - { - return $this->calendar->nextDay($format); - } - - /** - * Returns the value for the previous hour - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 13 or timestamp - * @access public - */ - function prevHour($format = 'int') - { - return $this->calendar->prevHour($format); - } - - /** - * Returns the value for this hour - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 14 or timestamp - * @access public - */ - function thisHour($format = 'int') - { - return $this->calendar->thisHour($format); - } - - /** - * Returns the value for the next hour - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 14 or timestamp - * @access public - */ - function nextHour($format = 'int') - { - return $this->calendar->nextHour($format); - } - - /** - * Returns the value for the previous minute - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 23 or timestamp - * @access public - */ - function prevMinute($format = 'int') - { - return $this->calendar->prevMinute($format); - } - - /** - * Returns the value for this minute - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 24 or timestamp - * @access public - */ - function thisMinute($format = 'int') - { - return $this->calendar->thisMinute($format); - } - - /** - * Returns the value for the next minute - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 25 or timestamp - * @access public - */ - function nextMinute($format = 'int') - { - return $this->calendar->nextMinute($format); - } - - /** - * Returns the value for the previous second - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 43 or timestamp - * @access public - */ - function prevSecond($format = 'int') - { - return $this->calendar->prevSecond($format); - } - - /** - * Returns the value for this second - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 44 or timestamp - * @access public - */ - function thisSecond($format = 'int') - { - return $this->calendar->thisSecond($format); - } - - /** - * Returns the value for the next second - * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] - * @return int e.g. 45 or timestamp - * @access public - */ - function nextSecond($format = 'int') - { - return $this->calendar->nextSecond($format); - } -} -?> diff --git a/data/module/Calendar/Decorator/Textual.php b/data/module/Calendar/Decorator/Textual.php deleted file mode 100644 index 251e9d4bbf6..00000000000 --- a/data/module/Calendar/Decorator/Textual.php +++ /dev/null @@ -1,169 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Textual.php,v 1.3 2004/08/16 13:02:44 hfuecks Exp $ -// -/** - * @package Calendar - * @version $Id: Textual.php,v 1.3 2004/08/16 13:02:44 hfuecks Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar decorator base class - */ -require_once CALENDAR_ROOT.'Decorator.php'; - -/** - * Load the Uri utility - */ -require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Textual.php'; - -/** - * Decorator to help with fetching textual representations of months and - * days of the week. - * Note: for performance you should prefer Calendar_Util_Textual unless you - * have a specific need to use a decorator - * @package Calendar - * @access public - */ -class Calendar_Decorator_Textual extends Calendar_Decorator -{ - /** - * Constructs Calendar_Decorator_Textual - * @param object subclass of Calendar - * @access public - */ - function Calendar_Decorator_Textual(&$Calendar) - { - parent::Calendar_Decorator($Calendar); - } - - /** - * Returns an array of 12 month names (first index = 1) - * @param string (optional) format of returned months (one,two,short or long) - * @return array - * @access public - * @static - */ - function monthNames($format='long') - { - return Calendar_Util_Textual::monthNames($format); - } - - /** - * Returns an array of 7 week day names (first index = 0) - * @param string (optional) format of returned days (one,two,short or long) - * @return array - * @access public - * @static - */ - function weekdayNames($format='long') - { - return Calendar_Util_Textual::weekdayNames($format); - } - - /** - * Returns textual representation of the previous month of the decorated calendar object - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - */ - function prevMonthName($format='long') - { - return Calendar_Util_Textual::prevMonthName($this->calendar,$format); - } - - /** - * Returns textual representation of the month of the decorated calendar object - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - */ - function thisMonthName($format='long') - { - return Calendar_Util_Textual::thisMonthName($this->calendar,$format); - } - - /** - * Returns textual representation of the next month of the decorated calendar object - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - */ - function nextMonthName($format='long') - { - return Calendar_Util_Textual::nextMonthName($this->calendar,$format); - } - - /** - * Returns textual representation of the previous day of week of the decorated calendar object - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - */ - function prevDayName($format='long') - { - return Calendar_Util_Textual::prevDayName($this->calendar,$format); - } - - /** - * Returns textual representation of the day of week of the decorated calendar object - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - */ - function thisDayName($format='long') - { - return Calendar_Util_Textual::thisDayName($this->calendar,$format); - } - - /** - * Returns textual representation of the next day of week of the decorated calendar object - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - */ - function nextDayName($format='long') - { - return Calendar_Util_Textual::nextDayName($this->calendar,$format); - } - - /** - * Returns the days of the week using the order defined in the decorated - * calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks - * and Calendar_Week. Otherwise the returned array will begin on Sunday - * @param string (optional) format of returned months (one,two,short or long) - * @return array ordered array of week day names - * @access public - */ - function orderedWeekdays($format='long') - { - return Calendar_Util_Textual::orderedWeekdays($this->calendar,$format); - } -} -?> diff --git a/data/module/Calendar/Decorator/Uri.php b/data/module/Calendar/Decorator/Uri.php deleted file mode 100644 index 13d20b33758..00000000000 --- a/data/module/Calendar/Decorator/Uri.php +++ /dev/null @@ -1,151 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $ -// -/** - * @package Calendar - * @version $Id: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar decorator base class - */ -require_once CALENDAR_ROOT.'Decorator.php'; - -/** - * Load the Uri utility - */ -require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Uri.php'; - -/** - * Decorator to help with building HTML links for navigating the calendar
- * Note: for performance you should prefer Calendar_Util_Uri unless you - * have a specific need to use a decorator - * - * $Day = new Calendar_Day(2003, 10, 23); - * $Uri = & new Calendar_Decorator_Uri($Day); - * $Uri->setFragments('year', 'month', 'day'); - * echo $Uri->getPrev(); // Displays year=2003&month=10&day=22 - * - * @see Calendar_Util_Uri - * @package Calendar - * @access public - */ -class Calendar_Decorator_Uri extends Calendar_Decorator -{ - - /** - * @var Calendar_Util_Uri - * @access private - */ - var $Uri; - - /** - * Constructs Calendar_Decorator_Uri - * @param object subclass of Calendar - * @access public - */ - function Calendar_Decorator_Uri(&$Calendar) - { - parent::Calendar_Decorator($Calendar); - } - - /** - * Sets the URI fragment names - * @param string URI fragment for year - * @param string (optional) URI fragment for month - * @param string (optional) URI fragment for day - * @param string (optional) URI fragment for hour - * @param string (optional) URI fragment for minute - * @param string (optional) URI fragment for second - * @return void - * @access public - */ - function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null) { - $this->Uri = & new Calendar_Util_Uri($y, $m, $d, $h, $i, $s); - } - - /** - * Sets the separator string between fragments - * @param string separator e.g. / - * @return void - * @access public - */ - function setSeparator($separator) - { - $this->Uri->separator = $separator; - } - - /** - * Puts Uri decorator into "scalar mode" - URI variable names are not - * returned - * @param boolean (optional) - * @return void - * @access public - */ - function setScalar($state=true) - { - $this->Uri->scalar = $state; - } - - /** - * Gets the URI string for the previous calendar unit - * @param string calendar unit to fetch uri for (year,month,week or day etc) - * @return string - * @access public - */ - function prev($method) - { - return $this->Uri->prev($this, $method); - } - - /** - * Gets the URI string for the current calendar unit - * @param string calendar unit to fetch uri for (year,month,week or day etc) - * @return string - * @access public - */ - function this($method) - { - return $this->Uri->this($this, $method); - } - - /** - * Gets the URI string for the next calendar unit - * @param string calendar unit to fetch uri for (year,month,week or day etc) - * @return string - * @access public - */ - function next($method) - { - return $this->Uri->next($this, $method); - } - -} -?> diff --git a/data/module/Calendar/Decorator/Weekday.php b/data/module/Calendar/Decorator/Weekday.php deleted file mode 100644 index dbba03e41f7..00000000000 --- a/data/module/Calendar/Decorator/Weekday.php +++ /dev/null @@ -1,148 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Weekday.php,v 1.3 2004/08/16 12:25:15 hfuecks Exp $ -// -/** - * @package Calendar - * @version $Id: Weekday.php,v 1.3 2004/08/16 12:25:15 hfuecks Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar decorator base class - */ -require_once CALENDAR_ROOT.'Decorator.php'; - -/** - * Load a Calendar_Day - */ -require_once CALENDAR_ROOT.'Day.php'; -/** - * Decorator for fetching the day of the week - * - * $Day = new Calendar_Day(2003, 10, 23); - * $Weekday = & new Calendar_Decorator_Weekday($Day); - * $Weekday->setFirstDay(0); // Set first day of week to Sunday (default Mon) - * echo $Weekday->thisWeekDay(); // Displays 5 - fifth day of week relative to Sun - * - * @package Calendar - * @access public - */ -class Calendar_Decorator_Weekday extends Calendar_Decorator -{ - /** - * First day of week - * @var int (default = 1 for Monday) - * @access private - */ - var $firstDay = 1; - - /** - * Constructs Calendar_Decorator_Weekday - * @param object subclass of Calendar - * @access public - */ - function Calendar_Decorator_Weekday(& $Calendar) - { - parent::Calendar_Decorator($Calendar); - } - - /** - * Sets the first day of the week (0 = Sunday, 1 = Monday (default) etc) - * @param int first day of week - * @return void - * @access public - */ - function setFirstDay($firstDay) { - $this->firstDay = (int)$firstDay; - } - - /** - * Returns the previous weekday - * @param string (default = 'int') return value format - * @return int numeric day of week or timestamp - * @access public - */ - function prevWeekDay($format = 'int') - { - $ts = $this->calendar->prevDay('timestamp'); - $Day = new Calendar_Day(2000,1,1); - $Day->setTimeStamp($ts); - $day = $this->calendar->cE->getDayOfWeek($Day->thisYear(),$Day->thisMonth(),$Day->thisDay()); - $day = $this->adjustWeekScale($day); - return $this->returnValue('Day', $format, $ts, $day); - } - - /** - * Returns the current weekday - * @param string (default = 'int') return value format - * @return int numeric day of week or timestamp - * @access public - */ - function thisWeekDay($format = 'int') - { - $ts = $this->calendar->thisDay('timestamp'); - $day = $this->calendar->cE->getDayOfWeek($this->calendar->year,$this->calendar->month,$this->calendar->day); - $day = $this->adjustWeekScale($day); - return $this->returnValue('Day', $format, $ts, $day); - } - - /** - * Returns the next weekday - * @param string (default = 'int') return value format - * @return int numeric day of week or timestamp - * @access public - */ - function nextWeekDay($format = 'int') - { - $ts = $this->calendar->nextDay('timestamp'); - $Day = new Calendar_Day(2000,1,1); - $Day->setTimeStamp($ts); - $day = $this->calendar->cE->getDayOfWeek($Day->thisYear(),$Day->thisMonth(),$Day->thisDay()); - $day = $this->adjustWeekScale($day); - return $this->returnValue('Day', $format, $ts, $day); - } - - /** - * Adjusts the day of the week relative to the first day of the week - * @param int day of week calendar from Calendar_Engine - * @return int day of week adjusted to first day - * @access private - */ - function adjustWeekScale($dayOfWeek) { - $dayOfWeek = $dayOfWeek - $this->firstDay; - if ( $dayOfWeek >= 0 ) { - return $dayOfWeek; - } else { - return $this->calendar->cE->getDaysInWeek( - $this->calendar->year,$this->calendar->month,$this->calendar->day - ) + $dayOfWeek; - } - } -} -?> diff --git a/data/module/Calendar/Decorator/Wrapper.php b/data/module/Calendar/Decorator/Wrapper.php deleted file mode 100644 index f456d10cee2..00000000000 --- a/data/module/Calendar/Decorator/Wrapper.php +++ /dev/null @@ -1,90 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Wrapper.php,v 1.2 2005/11/03 20:35:03 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Wrapper.php,v 1.2 2005/11/03 20:35:03 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar decorator base class - */ -require_once CALENDAR_ROOT.'Decorator.php'; - -/** - * Decorator to help with wrapping built children in another decorator - * @package Calendar - * @access public - */ -class Calendar_Decorator_Wrapper extends Calendar_Decorator -{ - /** - * Constructs Calendar_Decorator_Wrapper - * @param object subclass of Calendar - * @access public - */ - function Calendar_Decorator_Wrapper(&$Calendar) - { - parent::Calendar_Decorator($Calendar); - } - - /** - * Wraps objects returned from fetch in the named Decorator class - * @param string name of Decorator class to wrap with - * @return object instance of named decorator - * @access public - */ - function & fetch($decorator) - { - $Calendar = parent::fetch(); - if ($Calendar) { - $ret =& new $decorator($Calendar); - } else { - $ret = false; - } - return $ret; - } - - /** - * Wraps the returned calendar objects from fetchAll in the named decorator - * @param string name of Decorator class to wrap with - * @return array - * @access public - */ - function fetchAll($decorator) - { - $children = parent::fetchAll(); - foreach ($children as $key => $Calendar) { - $children[$key] = & new $decorator($Calendar); - } - return $children; - } -} -?> diff --git a/data/module/Calendar/Engine/Interface.php b/data/module/Calendar/Engine/Interface.php deleted file mode 100644 index 6b2eafdbfc1..00000000000 --- a/data/module/Calendar/Engine/Interface.php +++ /dev/null @@ -1,293 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Interface.php,v 1.5 2004/08/16 12:29:18 hfuecks Exp $ -// -/** - * @package Calendar - * @version $Id: Interface.php,v 1.5 2004/08/16 12:29:18 hfuecks Exp $ - */ -/** - * The methods the classes implementing the Calendar_Engine must implement. - * Note this class is not used but simply to help development - * @package Calendar - * @access protected - */ -class Calendar_Engine_Interface -{ - /** - * Provides a mechansim to make sure parsing of timestamps - * into human dates is only performed once per timestamp. - * Typically called "internally" by methods like stampToYear. - * Return value can vary, depending on the specific implementation - * @param int timestamp (depending on implementation) - * @return mixed - * @access protected - */ - function stampCollection($stamp) - { - } - - /** - * Returns a numeric year given a timestamp - * @param int timestamp (depending on implementation) - * @return int year (e.g. 2003) - * @access protected - */ - function stampToYear($stamp) - { - } - - /** - * Returns a numeric month given a timestamp - * @param int timestamp (depending on implementation) - * @return int month (e.g. 9) - * @access protected - */ - function stampToMonth($stamp) - { - } - - /** - * Returns a numeric day given a timestamp - * @param int timestamp (depending on implementation) - * @return int day (e.g. 15) - * @access protected - */ - function stampToDay($stamp) - { - } - - /** - * Returns a numeric hour given a timestamp - * @param int timestamp (depending on implementation) - * @return int hour (e.g. 13) - * @access protected - */ - function stampToHour($stamp) - { - } - - /** - * Returns a numeric minute given a timestamp - * @param int timestamp (depending on implementation) - * @return int minute (e.g. 34) - * @access protected - */ - function stampToMinute($stamp) - { - } - - /** - * Returns a numeric second given a timestamp - * @param int timestamp (depending on implementation) - * @return int second (e.g. 51) - * @access protected - */ - function stampToSecond($stamp) - { - } - - /** - * Returns a timestamp. Can be worth "caching" generated - * timestamps in a static variable, identified by the - * params this method accepts, to timestamp will only - * be calculated once. - * @param int year (e.g. 2003) - * @param int month (e.g. 9) - * @param int day (e.g. 13) - * @param int hour (e.g. 13) - * @param int minute (e.g. 34) - * @param int second (e.g. 53) - * @return int (depends on implementation) - * @access protected - */ - function dateToStamp($y,$m,$d,$h,$i,$s) - { - } - - /** - * The upper limit on years that the Calendar Engine can work with - * @return int (e.g. 2037) - * @access protected - */ - function getMaxYears() - { - } - - /** - * The lower limit on years that the Calendar Engine can work with - * @return int (e.g 1902) - * @access protected - */ - function getMinYears() - { - } - - /** - * Returns the number of months in a year - * @param int (optional) year to get months for - * @return int (e.g. 12) - * @access protected - */ - function getMonthsInYear($y=null) - { - } - - /** - * Returns the number of days in a month, given year and month - * @param int year (e.g. 2003) - * @param int month (e.g. 9) - * @return int days in month - * @access protected - */ - function getDaysInMonth($y, $m) - { - } - - /** - * Returns numeric representation of the day of the week in a month, - * given year and month - * @param int year (e.g. 2003) - * @param int month (e.g. 9) - * @return int - * @access protected - */ - function getFirstDayInMonth ($y, $m) - { - } - - /** - * Returns the number of days in a week - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int (e.g. 7) - * @access protected - */ - function getDaysInWeek($y=NULL, $m=NULL, $d=NULL) - { - } - - /** - * Returns the number of the week in the year (ISO-8601), given a date - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int week number - * @access protected - */ - function getWeekNInYear($y, $m, $d) - { - } - - /** - * Returns the number of the week in the month, given a date - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @param int first day of the week (default: 1 - monday) - * @return int week number - * @access protected - */ - function getWeekNInMonth($y, $m, $d, $firstDay=1) - { - } - - /** - * Returns the number of weeks in the month - * @param int year (2003) - * @param int month (9) - * @param int first day of the week (default: 1 - monday) - * @return int weeks number - * @access protected - */ - function getWeeksInMonth($y, $m) - { - } - - /** - * Returns the number of the day of the week (0=sunday, 1=monday...) - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int weekday number - * @access protected - */ - function getDayOfWeek($y, $m, $d) - { - } - - /** - * Returns the numeric values of the days of the week. - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return array list of numeric values of days in week, beginning 0 - * @access protected - */ - function getWeekDays($y=NULL, $m=NULL, $d=NULL) - { - } - - /** - * Returns the default first day of the week as an integer. Must be a - * member of the array returned from getWeekDays - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int (e.g. 1 for Monday) - * @see getWeekDays - * @access protected - */ - function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL) - { - } - - /** - * Returns the number of hours in a day
- * @param int (optional) day to get hours for - * @return int (e.g. 24) - * @access protected - */ - function getHoursInDay($y=null,$m=null,$d=null) - { - } - - /** - * Returns the number of minutes in an hour - * @param int (optional) hour to get minutes for - * @return int - * @access protected - */ - function getMinutesInHour($y=null,$m=null,$d=null,$h=null) - { - } - - /** - * Returns the number of seconds in a minutes - * @param int (optional) minute to get seconds for - * @return int - * @access protected - */ - function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null) - { - } -} -?> diff --git a/data/module/Calendar/Engine/PearDate.php b/data/module/Calendar/Engine/PearDate.php deleted file mode 100644 index eba2be63f5c..00000000000 --- a/data/module/Calendar/Engine/PearDate.php +++ /dev/null @@ -1,407 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: PearDate.php,v 1.8 2004/08/20 20:00:55 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: PearDate.php,v 1.8 2004/08/20 20:00:55 quipo Exp $ - */ -/** - * Load PEAR::Date class - */ -require_once 'Date.php'; - -/** - * Performs calendar calculations based on the PEAR::Date class - * Timestamps are in the ISO-8601 format (YYYY-MM-DD HH:MM:SS) - * @package Calendar - * @access protected - */ -class Calendar_Engine_PearDate /* implements Calendar_Engine_Interface */ -{ - /** - * Makes sure a given timestamp is only ever parsed once - * Uses a static variable to prevent date() being used twice - * for a date which is already known - * @param mixed Any timestamp format recognized by Pear::Date - * @return object Pear::Date object - * @access protected - */ - function stampCollection($stamp) - { - static $stamps = array(); - if (!isset($stamps[$stamp])) { - $stamps[$stamp] = new Date($stamp); - } - return $stamps[$stamp]; - } - - /** - * Returns a numeric year given a iso-8601 datetime - * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) - * @return int year (e.g. 2003) - * @access protected - */ - function stampToYear($stamp) - { - $date = Calendar_Engine_PearDate::stampCollection($stamp); - return (int)$date->year; - } - - /** - * Returns a numeric month given a iso-8601 datetime - * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) - * @return int month (e.g. 9) - * @access protected - */ - function stampToMonth($stamp) - { - $date = Calendar_Engine_PearDate::stampCollection($stamp); - return (int)$date->month; - } - - /** - * Returns a numeric day given a iso-8601 datetime - * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) - * @return int day (e.g. 15) - * @access protected - */ - function stampToDay($stamp) - { - $date = Calendar_Engine_PearDate::stampCollection($stamp); - return (int)$date->day; - } - - /** - * Returns a numeric hour given a iso-8601 datetime - * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) - * @return int hour (e.g. 13) - * @access protected - */ - function stampToHour($stamp) - { - $date = Calendar_Engine_PearDate::stampCollection($stamp); - return (int)$date->hour; - } - - /** - * Returns a numeric minute given a iso-8601 datetime - * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) - * @return int minute (e.g. 34) - * @access protected - */ - function stampToMinute($stamp) - { - $date = Calendar_Engine_PearDate::stampCollection($stamp); - return (int)$date->minute; - } - - /** - * Returns a numeric second given a iso-8601 datetime - * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS) - * @return int second (e.g. 51) - * @access protected - */ - function stampToSecond($stamp) - { - $date = Calendar_Engine_PearDate::stampCollection($stamp); - return (int)$date->second; - } - - /** - * Returns a iso-8601 datetime - * @param int year (2003) - * @param int month (9) - * @param int day (13) - * @param int hour (13) - * @param int minute (34) - * @param int second (53) - * @return string iso-8601 datetime - * @access protected - */ - function dateToStamp($y, $m, $d, $h=0, $i=0, $s=0) - { - $r = array(); - Calendar_Engine_PearDate::adjustDate($y, $m, $d, $h, $i, $s); - $key = $y.$m.$d.$h.$i.$s; - if (!isset($r[$key])) { - $r[$key] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", - $y, $m, $d, $h, $i, $s); - } - return $r[$key]; - } - - /** - * Set the correct date values (useful for math operations on dates) - * @param int year (2003) - * @param int month (9) - * @param int day (13) - * @param int hour (13) - * @param int minute (34) - * @param int second (53) - * @access protected - */ - function adjustDate(&$y, &$m, &$d, &$h, &$i, &$s) - { - if ($s < 0) { - $m -= floor($s / 60); - $s = -$s % 60; - } - if ($s > 60) { - $m += floor($s / 60); - $s %= 60; - } - if ($i < 0) { - $h -= floor($i / 60); - $i = -$i % 60; - } - if ($i > 60) { - $h += floor($i / 60); - $i %= 60; - } - if ($h < 0) { - $d -= floor($h / 24); - $h = -$h % 24; - } - if ($h > 24) { - $d += floor($h / 24); - $h %= 24; - } - for(; $m < 1; $y--, $m+=12); - for(; $m > 12; $y++, $m-=12); - - while ($d < 1) { - if ($m > 1) { - $m--; - } else { - $m = 12; - $y--; - } - $d += Date_Calc::daysInMonth($m, $y); - } - for ($max_days = Date_Calc::daysInMonth($m, $y); $d > $max_days; ) { - $d -= $max_days; - if ($m < 12) { - $m++; - } else { - $m = 1; - $y++; - } - } - } - - /** - * The upper limit on years that the Calendar Engine can work with - * @return int 9999 - * @access protected - */ - function getMaxYears() - { - return 9999; - } - - /** - * The lower limit on years that the Calendar Engine can work with - * @return int 0 - * @access protected - */ - function getMinYears() - { - return 0; - } - - /** - * Returns the number of months in a year - * @return int (12) - * @access protected - */ - function getMonthsInYear($y=null) - { - return 12; - } - - /** - * Returns the number of days in a month, given year and month - * @param int year (2003) - * @param int month (9) - * @return int days in month - * @access protected - */ - function getDaysInMonth($y, $m) - { - return (int)Date_Calc::daysInMonth($m, $y); - } - - /** - * Returns numeric representation of the day of the week in a month, - * given year and month - * @param int year (2003) - * @param int month (9) - * @return int from 0 to 7 - * @access protected - */ - function getFirstDayInMonth($y, $m) - { - return (int)Date_Calc::dayOfWeek(1, $m, $y); - } - - /** - * Returns the number of days in a week - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int (7) - * @access protected - */ - function getDaysInWeek($y=NULL, $m=NULL, $d=NULL) - { - return 7; - } - - /** - * Returns the number of the week in the year (ISO-8601), given a date - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int week number - * @access protected - */ - function getWeekNInYear($y, $m, $d) - { - return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard! - } - - /** - * Returns the number of the week in the month, given a date - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @param int first day of the week (default: monday) - * @return int week number - * @access protected - */ - function getWeekNInMonth($y, $m, $d, $firstDay=1) - { - $weekEnd = ($firstDay == 0) ? $this->getDaysInWeek()-1 : $firstDay-1; - $end_of_week = (int)Date_Calc::nextDayOfWeek($weekEnd, 1, $m, $y, '%e', true); - $w = 1; - while ($d > $end_of_week) { - ++$w; - $end_of_week += $this->getDaysInWeek(); - } - return $w; - } - - /** - * Returns the number of weeks in the month - * @param int year (2003) - * @param int month (9) - * @param int first day of the week (default: monday) - * @return int weeks number - * @access protected - */ - function getWeeksInMonth($y, $m, $firstDay=1) - { - $FDOM = Date_Calc::firstOfMonthWeekday($m, $y); - if ($FDOM == 0) { - $FDOM = $this->getDaysInWeek(); - } - if ($FDOM > $firstDay) { - $daysInTheFirstWeek = $this->getDaysInWeek() - $FDOM + $firstDay; - $weeks = 1; - } else { - $daysInTheFirstWeek = $firstDay - $FDOM; - $weeks = 0; - } - $daysInTheFirstWeek %= $this->getDaysInWeek(); - return (int)(ceil(($this->getDaysInMonth($y, $m) - $daysInTheFirstWeek) / - $this->getDaysInWeek()) + $weeks); - } - - /** - * Returns the number of the day of the week (0=sunday, 1=monday...) - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int weekday number - * @access protected - */ - function getDayOfWeek($y, $m, $d) - { - return Date_Calc::dayOfWeek($d, $m, $y); - } - - /** - * Returns a list of integer days of the week beginning 0 - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return array (0, 1, 2, 3, 4, 5, 6) 1 = Monday - * @access protected - */ - function getWeekDays($y=NULL, $m=NULL, $d=NULL) - { - return array(0, 1, 2, 3, 4, 5, 6); - } - - /** - * Returns the default first day of the week - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int (default 1 = Monday) - * @access protected - */ - function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL) - { - return 1; - } - - /** - * Returns the number of hours in a day - * @return int (24) - * @access protected - */ - function getHoursInDay($y=null,$m=null,$d=null) - { - return 24; - } - - /** - * Returns the number of minutes in an hour - * @return int (60) - * @access protected - */ - function getMinutesInHour($y=null,$m=null,$d=null,$h=null) - { - return 60; - } - - /** - * Returns the number of seconds in a minutes - * @return int (60) - * @access protected - */ - function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null) - { - return 60; - } -} -?> diff --git a/data/module/Calendar/Engine/UnixTS.php b/data/module/Calendar/Engine/UnixTS.php deleted file mode 100644 index a9a372bc303..00000000000 --- a/data/module/Calendar/Engine/UnixTS.php +++ /dev/null @@ -1,365 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: UnixTS.php,v 1.9 2004/08/20 20:00:55 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: UnixTS.php,v 1.9 2004/08/20 20:00:55 quipo Exp $ - */ -/** - * Performs calendar calculations based on the PHP date() function and - * Unix timestamps (using PHP's mktime() function). - * @package Calendar - * @access protected - */ -class Calendar_Engine_UnixTS /* implements Calendar_Engine_Interface */ -{ - /** - * Makes sure a given timestamp is only ever parsed once - *
-     * array (
-     *  [0] => year (e.g 2003),
-     *  [1] => month (e.g 9),
-     *  [2] => day (e.g 6),
-     *  [3] => hour (e.g 14),
-     *  [4] => minute (e.g 34),
-     *  [5] => second (e.g 45),
-     *  [6] => num days in month (e.g. 31),
-     *  [7] => week in year (e.g. 50),
-     *  [8] => day in week (e.g. 0 for Sunday)
-     * )
-     * 
- * Uses a static variable to prevent date() being used twice - * for a date which is already known - * @param int Unix timestamp - * @return array - * @access protected - */ - function stampCollection($stamp) - { - static $stamps = array(); - if ( !isset($stamps[$stamp]) ) { - $date = @date('Y n j H i s t W w',$stamp); - $stamps[$stamp] = sscanf($date, "%d %d %d %d %d %d %d %d %d"); - } - return $stamps[$stamp]; - } - - /** - * Returns a numeric year given a timestamp - * @param int Unix timestamp - * @return int year (e.g. 2003) - * @access protected - */ - function stampToYear($stamp) - { - $date = Calendar_Engine_UnixTS::stampCollection($stamp); - return (int)$date[0]; - } - - /** - * Returns a numeric month given a timestamp - * @param int Unix timestamp - * @return int month (e.g. 9) - * @access protected - */ - function stampToMonth($stamp) - { - $date = Calendar_Engine_UnixTS::stampCollection($stamp); - return (int)$date[1]; - } - - /** - * Returns a numeric day given a timestamp - * @param int Unix timestamp - * @return int day (e.g. 15) - * @access protected - */ - function stampToDay($stamp) - { - $date = Calendar_Engine_UnixTS::stampCollection($stamp); - return (int)$date[2]; - } - - /** - * Returns a numeric hour given a timestamp - * @param int Unix timestamp - * @return int hour (e.g. 13) - * @access protected - */ - function stampToHour($stamp) - { - $date = Calendar_Engine_UnixTS::stampCollection($stamp); - return (int)$date[3]; - } - - /** - * Returns a numeric minute given a timestamp - * @param int Unix timestamp - * @return int minute (e.g. 34) - * @access protected - */ - function stampToMinute($stamp) - { - $date = Calendar_Engine_UnixTS::stampCollection($stamp); - return (int)$date[4]; - } - - /** - * Returns a numeric second given a timestamp - * @param int Unix timestamp - * @return int second (e.g. 51) - * @access protected - */ - function stampToSecond($stamp) - { - $date = Calendar_Engine_UnixTS::stampCollection($stamp); - return (int)$date[5]; - } - - /** - * Returns a timestamp - * @param int year (2003) - * @param int month (9) - * @param int day (13) - * @param int hour (13) - * @param int minute (34) - * @param int second (53) - * @return int Unix timestamp - * @access protected - */ - function dateToStamp($y, $m, $d, $h=0, $i=0, $s=0) - { - static $dates = array(); - if ( !isset($dates[$y][$m][$d][$h][$i][$s]) ) { - $dates[$y][$m][$d][$h][$i][$s] = @mktime($h, $i, $s, $m, $d, $y); - } - return $dates[$y][$m][$d][$h][$i][$s]; - } - - /** - * The upper limit on years that the Calendar Engine can work with - * @return int (2037) - * @access protected - */ - function getMaxYears() - { - return 2037; - } - - /** - * The lower limit on years that the Calendar Engine can work with - * @return int (1970 if it's Windows and 1902 for all other OSs) - * @access protected - */ - function getMinYears() - { - return $min = strpos(PHP_OS, 'WIN') === false ? 1902 : 1970; - } - - /** - * Returns the number of months in a year - * @return int (12) - * @access protected - */ - function getMonthsInYear($y=null) - { - return 12; - } - - /** - * Returns the number of days in a month, given year and month - * @param int year (2003) - * @param int month (9) - * @return int days in month - * @access protected - */ - function getDaysInMonth($y, $m) - { - $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,1); - $date = Calendar_Engine_UnixTS::stampCollection($stamp); - return $date[6]; - } - - /** - * Returns numeric representation of the day of the week in a month, - * given year and month - * @param int year (2003) - * @param int month (9) - * @return int from 0 to 6 - * @access protected - */ - function getFirstDayInMonth($y, $m) - { - $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,1); - $date = Calendar_Engine_UnixTS::stampCollection($stamp); - return $date[8]; - } - - /** - * Returns the number of days in a week - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int (7) - * @access protected - */ - function getDaysInWeek($y=NULL, $m=NULL, $d=NULL) - { - return 7; - } - - /** - * Returns the number of the week in the year (ISO-8601), given a date - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int week number - * @access protected - */ - function getWeekNInYear($y, $m, $d) - { - $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,$d); - $date = Calendar_Engine_UnixTS::stampCollection($stamp); - return $date[7]; - } - - /** - * Returns the number of the week in the month, given a date - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @param int first day of the week (default: monday) - * @return int week number - * @access protected - */ - function getWeekNInMonth($y, $m, $d, $firstDay=1) - { - $weekEnd = ($firstDay == 0) ? $this->getDaysInWeek()-1 : $firstDay-1; - $end_of_week = 1; - while (@date('w', @mktime(0, 0, 0, $m, $end_of_week, $y)) != $weekEnd) { - ++$end_of_week; //find first weekend of the month - } - $w = 1; - while ($d > $end_of_week) { - ++$w; - $end_of_week += $this->getDaysInWeek(); - } - return $w; - } - - /** - * Returns the number of weeks in the month - * @param int year (2003) - * @param int month (9) - * @param int first day of the week (default: monday) - * @return int weeks number - * @access protected - */ - function getWeeksInMonth($y, $m, $firstDay=1) - { - $FDOM = $this->getFirstDayInMonth($y, $m); - if ($FDOM == 0) { - $FDOM = $this->getDaysInWeek(); - } - if ($FDOM > $firstDay) { - $daysInTheFirstWeek = $this->getDaysInWeek() - $FDOM + $firstDay; - $weeks = 1; - } else { - $daysInTheFirstWeek = $firstDay - $FDOM; - $weeks = 0; - } - $daysInTheFirstWeek %= $this->getDaysInWeek(); - return (int)(ceil(($this->getDaysInMonth($y, $m) - $daysInTheFirstWeek) / - $this->getDaysInWeek()) + $weeks); - } - - /** - * Returns the number of the day of the week (0=sunday, 1=monday...) - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int weekday number - * @access protected - */ - function getDayOfWeek($y, $m, $d) - { - $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,$d); - $date = Calendar_Engine_UnixTS::stampCollection($stamp); - return $date[8]; - } - - /** - * Returns a list of integer days of the week beginning 0 - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return array (0,1,2,3,4,5,6) 1 = Monday - * @access protected - */ - function getWeekDays($y=NULL, $m=NULL, $d=NULL) - { - return array(0, 1, 2, 3, 4, 5, 6); - } - - /** - * Returns the default first day of the week - * @param int year (2003) - * @param int month (9) - * @param int day (4) - * @return int (default 1 = Monday) - * @access protected - */ - function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL) - { - return 1; - } - - /** - * Returns the number of hours in a day - * @return int (24) - * @access protected - */ - function getHoursInDay($y=null,$m=null,$d=null) - { - return 24; - } - - /** - * Returns the number of minutes in an hour - * @return int (60) - * @access protected - */ - function getMinutesInHour($y=null,$m=null,$d=null,$h=null) - { - return 60; - } - - /** - * Returns the number of seconds in a minutes - * @return int (60) - * @access protected - */ - function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null) - { - return 60; - } -} -?> diff --git a/data/module/Calendar/Factory.php b/data/module/Calendar/Factory.php deleted file mode 100644 index f15992c5b7a..00000000000 --- a/data/module/Calendar/Factory.php +++ /dev/null @@ -1,145 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Factory.php,v 1.3 2005/10/22 10:08:47 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Factory.php,v 1.3 2005/10/22 10:08:47 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar base class - */ -require_once CALENDAR_ROOT.'Calendar.php'; - -/** - * Contains a factory method to return a Singleton instance of a class - * implementing the Calendar_Engine_Interface.
- * For Month objects, to control type of month returned, use CALENDAR_MONTH_STATE - * constact e.g.; - * - * require_once 'Calendar/Factory.php'; - * define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKDAYS); // Use Calendar_Month_Weekdays - * // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKS); // Use Calendar_Month_Weeks - * // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH); // Use Calendar_Month - * - * It defaults to building Calendar_Month objects.
- * Use the constract CALENDAR_FIRST_DAY_OF_WEEK to control the first day of the week - * for Month or Week objects (e.g. 0 = Sunday, 6 = Saturday) - * @package Calendar - * @access protected - */ -class Calendar_Factory -{ - /** - * Creates a calendar object given the type and units - * @param string class of calendar object to create - * @param int year - * @param int month - * @param int day - * @param int hour - * @param int minute - * @param int second - * @return object subclass of Calendar - * @access public - * @static - */ - function create($type, $y = 2000, $m = 1, $d = 1, $h = 0, $i = 0, $s = 0) - { - $firstDay = defined('CALENDAR_FIRST_DAY_OF_WEEK') ? CALENDAR_FIRST_DAY_OF_WEEK : 1; - switch ($type) { - case 'Day': - require_once CALENDAR_ROOT.'Day.php'; - return new Calendar_Day($y,$m,$d); - case 'Month': - // Set default state for which month type to build - if (!defined('CALENDAR_MONTH_STATE')) { - define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH); - } - switch (CALENDAR_MONTH_STATE) { - case CALENDAR_USE_MONTH_WEEKDAYS: - require_once CALENDAR_ROOT.'Month/Weekdays.php'; - $class = 'Calendar_Month_Weekdays'; - break; - case CALENDAR_USE_MONTH_WEEKS: - require_once CALENDAR_ROOT.'Month/Weeks.php'; - $class = 'Calendar_Month_Weeks'; - break; - case CALENDAR_USE_MONTH: - default: - require_once CALENDAR_ROOT.'Month.php'; - $class = 'Calendar_Month'; - break; - } - return new $class($y, $m, $firstDay); - case 'Week': - require_once CALENDAR_ROOT.'Week.php'; - return new Calendar_Week($y, $m, $d, $firstDay); - case 'Hour': - require_once CALENDAR_ROOT.'Hour.php'; - return new Calendar_Hour($y, $m, $d, $h); - case 'Minute': - require_once CALENDAR_ROOT.'Minute.php'; - return new Calendar_Minute($y, $m, $d, $h, $i); - case 'Second': - require_once CALENDAR_ROOT.'Second.php'; - return new Calendar_Second($y,$m,$d,$h,$i,$s); - case 'Year': - require_once CALENDAR_ROOT.'Year.php'; - return new Calendar_Year($y); - default: - require_once 'PEAR.php'; - PEAR::raiseError( - 'Calendar_Factory::create() unrecognised type: '.$type, null, PEAR_ERROR_TRIGGER, - E_USER_NOTICE, 'Calendar_Factory::create()'); - return false; - } - } - /** - * Creates an instance of a calendar object, given a type and timestamp - * @param string type of object to create - * @param mixed timestamp (depending on Calendar engine being used) - * @return object subclass of Calendar - * @access public - * @static - */ - function & createByTimestamp($type, $stamp) - { - $cE = & Calendar_Engine_Factory::getEngine(); - $y = $cE->stampToYear($stamp); - $m = $cE->stampToMonth($stamp); - $d = $cE->stampToDay($stamp); - $h = $cE->stampToHour($stamp); - $i = $cE->stampToMinute($stamp); - $s = $cE->stampToSecond($stamp); - $cal = Calendar_Factory::create($type, $y, $m, $d, $h, $i, $s); - return $cal; - } -} -?> diff --git a/data/module/Calendar/Hour.php b/data/module/Calendar/Hour.php deleted file mode 100644 index 515faabcdcb..00000000000 --- a/data/module/Calendar/Hour.php +++ /dev/null @@ -1,113 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Hour.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Hour.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar base class - */ -require_once CALENDAR_ROOT.'Calendar.php'; - -/** - * Represents an Hour and builds Minutes - * - * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Hour.php'; - * $Hour = & new Calendar_Hour(2003, 10, 21, 15); // Oct 21st 2003, 3pm - * $Hour->build(); // Build Calendar_Minute objects - * while ($Minute = & $Hour->fetch()) { - * echo $Minute->thisMinute().'
'; - * } - *
- * @package Calendar - * @access public - */ -class Calendar_Hour extends Calendar -{ - /** - * Constructs Calendar_Hour - * @param int year e.g. 2003 - * @param int month e.g. 5 - * @param int day e.g. 11 - * @param int hour e.g. 13 - * @access public - */ - function Calendar_Hour($y, $m, $d, $h) - { - Calendar::Calendar($y, $m, $d, $h); - } - - /** - * Builds the Minutes in the Hour - * @param array (optional) Calendar_Minute objects representing selected dates - * @return boolean - * @access public - */ - function build($sDates=array()) - { - require_once CALENDAR_ROOT.'Minute.php'; - $mIH = $this->cE->getMinutesInHour($this->year, $this->month, $this->day, - $this->hour); - for ($i=0; $i < $mIH; $i++) { - $this->children[$i]= - new Calendar_Minute($this->year, $this->month, $this->day, - $this->hour, $i); - } - if (count($sDates) > 0) { - $this->setSelection($sDates); - } - return true; - } - - /** - * Called from build() - * @param array - * @return void - * @access private - */ - function setSelection($sDates) - { - foreach ($sDates as $sDate) { - if ($this->year == $sDate->thisYear() - && $this->month == $sDate->thisMonth() - && $this->day == $sDate->thisDay() - && $this->hour == $sDate->thisHour()) - { - $key = (int)$sDate->thisMinute(); - if (isset($this->children[$key])) { - $sDate->setSelected(); - $this->children[$key] = $sDate; - } - } - } - } -} -?> diff --git a/data/module/Calendar/Minute.php b/data/module/Calendar/Minute.php deleted file mode 100644 index 09bba705aef..00000000000 --- a/data/module/Calendar/Minute.php +++ /dev/null @@ -1,114 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Minute.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Minute.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar base class - */ -require_once CALENDAR_ROOT.'Calendar.php'; - -/** - * Represents a Minute and builds Seconds - * - * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Minute.php'; - * $Minute = & new Calendar_Minute(2003, 10, 21, 15, 31); // Oct 21st 2003, 3:31pm - * $Minute->build(); // Build Calendar_Second objects - * while ($Second = & $Minute->fetch()) { - * echo $Second->thisSecond().'
'; - * } - *
- * @package Calendar - * @access public - */ -class Calendar_Minute extends Calendar -{ - /** - * Constructs Minute - * @param int year e.g. 2003 - * @param int month e.g. 5 - * @param int day e.g. 11 - * @param int hour e.g. 13 - * @param int minute e.g. 31 - * @access public - */ - function Calendar_Minute($y, $m, $d, $h, $i) - { - Calendar::Calendar($y, $m, $d, $h, $i); - } - - /** - * Builds the Calendar_Second objects - * @param array (optional) Calendar_Second objects representing selected dates - * @return boolean - * @access public - */ - function build($sDates=array()) - { - require_once CALENDAR_ROOT.'Second.php'; - $sIM = $this->cE->getSecondsInMinute($this->year, $this->month, - $this->day, $this->hour, $this->minute); - for ($i=0; $i < $sIM; $i++) { - $this->children[$i] = new Calendar_Second($this->year, $this->month, - $this->day, $this->hour, $this->minute, $i); - } - if (count($sDates) > 0) { - $this->setSelection($sDates); - } - return true; - } - - /** - * Called from build() - * @param array - * @return void - * @access private - */ - function setSelection($sDates) - { - foreach ($sDates as $sDate) { - if ($this->year == $sDate->thisYear() - && $this->month == $sDate->thisMonth() - && $this->day == $sDate->thisDay() - && $this->hour == $sDate->thisHour() - && $this->minute == $sDate->thisMinute()) - { - $key = (int)$sDate->thisSecond(); - if (isset($this->children[$key])) { - $sDate->setSelected(); - $this->children[$key] = $sDate; - } - } - } - } -} -?> diff --git a/data/module/Calendar/Month.php b/data/module/Calendar/Month.php deleted file mode 100644 index 4479d562aee..00000000000 --- a/data/module/Calendar/Month.php +++ /dev/null @@ -1,114 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Month.php,v 1.3 2005/10/22 10:10:26 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Month.php,v 1.3 2005/10/22 10:10:26 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar base class - */ -require_once CALENDAR_ROOT.'Calendar.php'; - -/** - * Represents a Month and builds Days - * - * require_once 'Calendar/Month.php'; - * $Month = & new Calendar_Month(2003, 10); // Oct 2003 - * $Month->build(); // Build Calendar_Day objects - * while ($Day = & $Month->fetch()) { - * echo $Day->thisDay().'
'; - * } - *
- * @package Calendar - * @access public - */ -class Calendar_Month extends Calendar -{ - /** - * Constructs Calendar_Month - * @param int $y year e.g. 2003 - * @param int $m month e.g. 5 - * @param int $firstDay first day of the week [optional] - * @access public - */ - function Calendar_Month($y, $m, $firstDay=null) - { - Calendar::Calendar($y, $m); - $this->firstDay = $this->defineFirstDayOfWeek($firstDay); - } - - /** - * Builds Day objects for this Month. Creates as many Calendar_Day objects - * as there are days in the month - * @param array (optional) Calendar_Day objects representing selected dates - * @return boolean - * @access public - */ - function build($sDates=array()) - { - require_once CALENDAR_ROOT.'Day.php'; - $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); - for ($i=1; $i<=$daysInMonth; $i++) { - $this->children[$i] = new Calendar_Day($this->year, $this->month, $i); - } - if (count($sDates) > 0) { - $this->setSelection($sDates); - } - return true; - } - - /** - * Called from build() - * @param array - * @return void - * @access private - */ - function setSelection($sDates) - { - foreach ($sDates as $sDate) { - if ($this->year == $sDate->thisYear() - && $this->month == $sDate->thisMonth() - ) { - $key = $sDate->thisDay(); - if (isset($this->children[$key])) { - $sDate->setSelected(); - $class = strtolower(get_class($sDate)); - if ($class == 'calendar_day' || $class == 'calendar_decorator') { - $sDate->setFirst($this->children[$key]->isFirst()); - $sDate->setLast($this->children[$key]->isLast()); - } - $this->children[$key] = $sDate; - } - } - } - } -} -?> diff --git a/data/module/Calendar/Month/Weekdays.php b/data/module/Calendar/Month/Weekdays.php deleted file mode 100644 index 6a8ecec57df..00000000000 --- a/data/module/Calendar/Month/Weekdays.php +++ /dev/null @@ -1,189 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Weekdays.php,v 1.4 2005/10/22 10:28:49 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Weekdays.php,v 1.4 2005/10/22 10:28:49 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar base class - */ -require_once CALENDAR_ROOT.'Calendar.php'; - -/** - * Load base month - */ -require_once CALENDAR_ROOT.'Month.php'; - -/** - * Represents a Month and builds Days in tabular form
- * - * require_once 'Calendar/Month/Weekdays.php'; - * $Month = & new Calendar_Month_Weekdays(2003, 10); // Oct 2003 - * $Month->build(); // Build Calendar_Day objects - * while ($Day = & $Month->fetch()) { - * if ($Day->isFirst()) { - * echo ''; - * } - * if ($Day->isEmpty()) { - * echo ' '; - * } else { - * echo ''.$Day->thisDay().''; - * } - * if ($Day->isLast()) { - * echo ''; - * } - * } - * - * @package Calendar - * @access public - */ -class Calendar_Month_Weekdays extends Calendar_Month -{ - /** - * Instance of Calendar_Table_Helper - * @var Calendar_Table_Helper - * @access private - */ - var $tableHelper; - - /** - * First day of the week - * @access private - * @var string - */ - var $firstDay; - - /** - * Constructs Calendar_Month_Weekdays - * @param int year e.g. 2003 - * @param int month e.g. 5 - * @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.) - * @access public - */ - function Calendar_Month_Weekdays($y, $m, $firstDay=null) - { - Calendar_Month::Calendar_Month($y, $m, $firstDay); - } - - /** - * Builds Day objects in tabular form, to allow display of calendar month - * with empty cells if the first day of the week does not fall on the first - * day of the month. - * @see Calendar_Day::isEmpty() - * @see Calendar_Day_Base::isFirst() - * @see Calendar_Day_Base::isLast() - * @param array (optional) Calendar_Day objects representing selected dates - * @return boolean - * @access public - */ - function build($sDates=array()) - { - require_once CALENDAR_ROOT.'Table/Helper.php'; - $this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay); - Calendar_Month::build($sDates); - $this->buildEmptyDaysBefore(); - $this->shiftDays(); - $this->buildEmptyDaysAfter(); - $this->setWeekMarkers(); - return true; - } - - /** - * Prepends empty days before the real days in the month - * @return void - * @access private - */ - function buildEmptyDaysBefore() - { - $eBefore = $this->tableHelper->getEmptyDaysBefore(); - for ($i=0; $i < $eBefore; $i++) { - $stamp = $this->cE->dateToStamp($this->year, $this->month, -$i); - $Day = new Calendar_Day( - $this->cE->stampToYear($stamp), - $this->cE->stampToMonth($stamp), - $this->cE->stampToDay($stamp)); - $Day->setEmpty(); - $Day->adjust(); - array_unshift($this->children, $Day); - } - } - - /** - * Shifts the array of children forward, if necessary - * @return void - * @access private - */ - function shiftDays() - { - if (isset ($this->children[0])) { - array_unshift($this->children, null); - unset($this->children[0]); - } - } - - /** - * Appends empty days after the real days in the month - * @return void - * @access private - */ - function buildEmptyDaysAfter() - { - $eAfter = $this->tableHelper->getEmptyDaysAfter(); - $sDOM = $this->tableHelper->getNumTableDaysInMonth(); - for ($i = 1; $i <= $sDOM-$eAfter; $i++) { - $Day = new Calendar_Day($this->year, $this->month+1, $i); - $Day->setEmpty(); - $Day->adjust(); - array_push($this->children, $Day); - } - } - - /** - * Sets the "markers" for the beginning and of a of week, in the - * built Calendar_Day children - * @return void - * @access private - */ - function setWeekMarkers() - { - $dIW = $this->cE->getDaysInWeek( - $this->thisYear(), - $this->thisMonth(), - $this->thisDay() - ); - $sDOM = $this->tableHelper->getNumTableDaysInMonth(); - for ($i=1; $i <= $sDOM; $i+= $dIW) { - $this->children[$i]->setFirst(); - $this->children[$i+($dIW-1)]->setLast(); - } - } -} -?> diff --git a/data/module/Calendar/Month/Weeks.php b/data/module/Calendar/Month/Weeks.php deleted file mode 100644 index bfaeba90b98..00000000000 --- a/data/module/Calendar/Month/Weeks.php +++ /dev/null @@ -1,139 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Weeks.php,v 1.3 2005/10/22 10:28:49 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Weeks.php,v 1.3 2005/10/22 10:28:49 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar base class - */ -require_once CALENDAR_ROOT.'Calendar.php'; - -/** - * Load base month - */ -require_once CALENDAR_ROOT.'Month.php'; - -/** - * Represents a Month and builds Weeks - * - * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Month'.DIRECTORY_SEPARATOR.'Weeks.php'; - * $Month = & new Calendar_Month_Weeks(2003, 10); // Oct 2003 - * $Month->build(); // Build Calendar_Day objects - * while ($Week = & $Month->fetch()) { - * echo $Week->thisWeek().'
'; - * } - *
- * @package Calendar - * @access public - */ -class Calendar_Month_Weeks extends Calendar_Month -{ - /** - * Instance of Calendar_Table_Helper - * @var Calendar_Table_Helper - * @access private - */ - var $tableHelper; - - /** - * First day of the week - * @access private - * @var string - */ - var $firstDay; - - /** - * Constructs Calendar_Month_Weeks - * @param int year e.g. 2003 - * @param int month e.g. 5 - * @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.) - * @access public - */ - function Calendar_Month_Weeks($y, $m, $firstDay=null) - { - Calendar_Month::Calendar_Month($y, $m, $firstDay); - } - - /** - * Builds Calendar_Week objects for the Month. Note that Calendar_Week - * builds Calendar_Day object in tabular form (with Calendar_Day->empty) - * @param array (optional) Calendar_Week objects representing selected dates - * @return boolean - * @access public - */ - function build($sDates=array()) - { - require_once CALENDAR_ROOT.'Table/Helper.php'; - $this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay); - require_once CALENDAR_ROOT.'Week.php'; - $numWeeks = $this->tableHelper->getNumWeeks(); - for ($i=1, $d=1; $i<=$numWeeks; $i++, - $d+=$this->cE->getDaysInWeek( - $this->thisYear(), - $this->thisMonth(), - $this->thisDay()) ) { - $this->children[$i] = new Calendar_Week( - $this->year, $this->month, $d, $this->tableHelper->getFirstDay()); - } - //used to set empty days - $this->children[1]->setFirst(true); - $this->children[$numWeeks]->setLast(true); - - // Handle selected weeks here - if (count($sDates) > 0) { - $this->setSelection($sDates); - } - return true; - } - - /** - * Called from build() - * @param array - * @return void - * @access private - */ - function setSelection($sDates) - { - foreach ($sDates as $sDate) { - if ($this->year == $sDate->thisYear() - && $this->month == $sDate->thisMonth()) - { - $key = $sDate->thisWeek('n_in_month'); - if (isset($this->children[$key])) { - $this->children[$key]->setSelected(); - } - } - } - } -} -?> diff --git a/data/module/Calendar/Second.php b/data/module/Calendar/Second.php deleted file mode 100644 index d00de624d80..00000000000 --- a/data/module/Calendar/Second.php +++ /dev/null @@ -1,98 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Second.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Second.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar base class - */ -require_once CALENDAR_ROOT.'Calendar.php'; - -/** - * Represents a Second
- * Note: Seconds do not build other objects - * so related methods are overridden to return NULL - * @package Calendar - */ -class Calendar_Second extends Calendar -{ - /** - * Constructs Second - * @param int year e.g. 2003 - * @param int month e.g. 5 - * @param int day e.g. 11 - * @param int hour e.g. 13 - * @param int minute e.g. 31 - * @param int second e.g. 45 - */ - function Calendar_Second($y, $m, $d, $h, $i, $s) - { - Calendar::Calendar($y, $m, $d, $h, $i, $s); - } - - /** - * Overwrite build - * @return NULL - */ - function build() - { - return null; - } - - /** - * Overwrite fetch - * @return NULL - */ - function fetch() - { - return null; - } - - /** - * Overwrite fetchAll - * @return NULL - */ - function fetchAll() - { - return null; - } - - /** - * Overwrite size - * @return NULL - */ - function size() - { - return null; - } -} -?> diff --git a/data/module/Calendar/Table/Helper.php b/data/module/Calendar/Table/Helper.php deleted file mode 100644 index b0f28c20001..00000000000 --- a/data/module/Calendar/Table/Helper.php +++ /dev/null @@ -1,280 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Helper.php,v 1.5 2005/10/22 09:51:53 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Helper.php,v 1.5 2005/10/22 09:51:53 quipo Exp $ - */ - -/** - * Used by Calendar_Month_Weekdays, Calendar_Month_Weeks and Calendar_Week to - * help with building the calendar in tabular form - * @package Calendar - * @access protected - */ -class Calendar_Table_Helper -{ - /** - * Instance of the Calendar object being helped. - * @var object - * @access private - */ - var $calendar; - - /** - * Instance of the Calendar_Engine - * @var object - * @access private - */ - var $cE; - - /** - * First day of the week - * @access private - * @var string - */ - var $firstDay; - - /** - * The seven days of the week named - * @access private - * @var array - */ - var $weekDays; - - /** - * Days of the week ordered with $firstDay at the beginning - * @access private - * @var array - */ - var $daysOfWeek = array(); - - /** - * Days of the month built from days of the week - * @access private - * @var array - */ - var $daysOfMonth = array(); - - /** - * Number of weeks in month - * @var int - * @access private - */ - var $numWeeks = null; - - /** - * Number of emtpy days before real days begin in month - * @var int - * @access private - */ - var $emptyBefore = 0; - - /** - * Constructs Calendar_Table_Helper - * @param object Calendar_Month_Weekdays, Calendar_Month_Weeks, Calendar_Week - * @param int (optional) first day of the week e.g. 1 for Monday - * @access protected - */ - function Calendar_Table_Helper(& $calendar, $firstDay=null) - { - $this->calendar = & $calendar; - $this->cE = & $calendar->getEngine(); - if (is_null($firstDay)) { - $firstDay = $this->cE->getFirstDayOfWeek( - $this->calendar->thisYear(), - $this->calendar->thisMonth(), - $this->calendar->thisDay() - ); - } - $this->firstDay = $firstDay; - $this->setFirstDay(); - $this->setDaysOfMonth(); - } - - /** - * Constructs $this->daysOfWeek based on $this->firstDay - * @return void - * @access private - */ - function setFirstDay() - { - $weekDays = $this->cE->getWeekDays( - $this->calendar->thisYear(), - $this->calendar->thisMonth(), - $this->calendar->thisDay() - ); - $endDays = array(); - $tmpDays = array(); - $begin = false; - foreach ($weekDays as $day) { - if ($begin) { - $endDays[] = $day; - } else if ($day === $this->firstDay) { - $begin = true; - $endDays[] = $day; - } else { - $tmpDays[] = $day; - } - } - $this->daysOfWeek = array_merge($endDays, $tmpDays); - } - - /** - * Constructs $this->daysOfMonth - * @return void - * @access private - */ - function setDaysOfMonth() - { - $this->daysOfMonth = $this->daysOfWeek; - $daysInMonth = $this->cE->getDaysInMonth( - $this->calendar->thisYear(), $this->calendar->thisMonth()); - $firstDayInMonth = $this->cE->getFirstDayInMonth( - $this->calendar->thisYear(), $this->calendar->thisMonth()); - $this->emptyBefore=0; - foreach ($this->daysOfMonth as $dayOfWeek) { - if ($firstDayInMonth == $dayOfWeek) { - break; - } - $this->emptyBefore++; - } - $this->numWeeks = ceil( - ($daysInMonth + $this->emptyBefore) - / - $this->cE->getDaysInWeek( - $this->calendar->thisYear(), - $this->calendar->thisMonth(), - $this->calendar->thisDay() - ) - ); - for ($i=1; $i < $this->numWeeks; $i++) { - $this->daysOfMonth = - array_merge($this->daysOfMonth, $this->daysOfWeek); - } - } - - /** - * Returns the first day of the month - * @see Calendar_Engine_Interface::getFirstDayOfWeek() - * @return int - * @access protected - */ - function getFirstDay() - { - return $this->firstDay; - } - - /** - * Returns the order array of days in a week - * @return int - * @access protected - */ - function getDaysOfWeek() - { - return $this->daysOfWeek; - } - - /** - * Returns the number of tabular weeks in a month - * @return int - * @access protected - */ - function getNumWeeks() - { - return $this->numWeeks; - } - - /** - * Returns the number of real days + empty days - * @return int - * @access protected - */ - function getNumTableDaysInMonth() - { - return count($this->daysOfMonth); - } - - /** - * Returns the number of empty days before the real days begin - * @return int - * @access protected - */ - function getEmptyDaysBefore() - { - return $this->emptyBefore; - } - - /** - * Returns the index of the last real day in the month - * @todo Potential performance optimization with static - * @return int - * @access protected - */ - function getEmptyDaysAfter() - { - // Causes bug when displaying more than one month -// static $index; -// if (!isset($index)) { - $index = $this->getEmptyDaysBefore() + $this->cE->getDaysInMonth( - $this->calendar->thisYear(), $this->calendar->thisMonth()); -// } - return $index; - } - - /** - * Returns the index of the last real day in the month, relative to the - * beginning of the tabular week it is part of - * @return int - * @access protected - */ - function getEmptyDaysAfterOffset() - { - $eAfter = $this->getEmptyDaysAfter(); - return $eAfter - ( - $this->cE->getDaysInWeek( - $this->calendar->thisYear(), - $this->calendar->thisMonth(), - $this->calendar->thisDay() - ) * ($this->numWeeks-1) ); - } - - /** - * Returns the timestamp of the first day of the current week - */ - function getWeekStart($y, $m, $d, $firstDay=1) - { - $dow = $this->cE->getDayOfWeek($y, $m, $d); - if ($dow > $firstDay) { - $d -= ($dow - $firstDay); - } - if ($dow < $firstDay) { - $d -= ( - $this->cE->getDaysInWeek( - $this->calendar->thisYear(), - $this->calendar->thisMonth(), - $this->calendar->thisDay() - ) - $firstDay + $dow); - } - return $this->cE->dateToStamp($y, $m, $d); - } -} -?> diff --git a/data/module/Calendar/Util/Textual.php b/data/module/Calendar/Util/Textual.php deleted file mode 100644 index cb35e5b3311..00000000000 --- a/data/module/Calendar/Util/Textual.php +++ /dev/null @@ -1,239 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Textual.php,v 1.2 2004/08/16 13:13:09 hfuecks Exp $ -// -/** - * @package Calendar - * @version $Id: Textual.php,v 1.2 2004/08/16 13:13:09 hfuecks Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar decorator base class - */ -require_once CALENDAR_ROOT.'Decorator.php'; - -/** - * Static utlities to help with fetching textual representations of months and - * days of the week. - * @package Calendar - * @access public - */ -class Calendar_Util_Textual -{ - - /** - * Returns an array of 12 month names (first index = 1) - * @param string (optional) format of returned months (one,two,short or long) - * @return array - * @access public - * @static - */ - function monthNames($format='long') - { - $formats = array('one'=>'%b', 'two'=>'%b', 'short'=>'%b', 'long'=>'%B'); - if (!array_key_exists($format,$formats)) { - $format = 'long'; - } - $months = array(); - for ($i=1; $i<=12; $i++) { - $stamp = mktime(0, 0, 0, $i, 1, 2003); - $month = strftime($formats[$format], $stamp); - switch($format) { - case 'one': - $month = substr($month, 0, 1); - break; - case 'two': - $month = substr($month, 0, 2); - break; - } - $months[$i] = $month; - } - return $months; - } - - /** - * Returns an array of 7 week day names (first index = 0) - * @param string (optional) format of returned days (one,two,short or long) - * @return array - * @access public - * @static - */ - function weekdayNames($format='long') - { - $formats = array('one'=>'%a', 'two'=>'%a', 'short'=>'%a', 'long'=>'%A'); - if (!array_key_exists($format,$formats)) { - $format = 'long'; - } - $days = array(); - for ($i=0; $i<=6; $i++) { - $stamp = mktime(0, 0, 0, 11, $i+2, 2003); - $day = strftime($formats[$format], $stamp); - switch($format) { - case 'one': - $day = substr($day, 0, 1); - break; - case 'two': - $day = substr($day, 0, 2); - break; - } - $days[$i] = $day; - } - return $days; - } - - /** - * Returns textual representation of the previous month of the decorated calendar object - * @param object subclass of Calendar e.g. Calendar_Month - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - * @static - */ - function prevMonthName($Calendar, $format='long') - { - $months = Calendar_Util_Textual::monthNames($format); - return $months[$Calendar->prevMonth()]; - } - - /** - * Returns textual representation of the month of the decorated calendar object - * @param object subclass of Calendar e.g. Calendar_Month - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - * @static - */ - function thisMonthName($Calendar, $format='long') - { - $months = Calendar_Util_Textual::monthNames($format); - return $months[$Calendar->thisMonth()]; - } - - /** - * Returns textual representation of the next month of the decorated calendar object - * @param object subclass of Calendar e.g. Calendar_Month - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - * @static - */ - function nextMonthName($Calendar, $format='long') - { - $months = Calendar_Util_Textual::monthNames($format); - return $months[$Calendar->nextMonth()]; - } - - /** - * Returns textual representation of the previous day of week of the decorated calendar object - * Note: Requires PEAR::Date - * @param object subclass of Calendar e.g. Calendar_Month - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - * @static - */ - function prevDayName($Calendar, $format='long') - { - $days = Calendar_Util_Textual::weekdayNames($format); - $stamp = $Calendar->prevDay('timestamp'); - $cE = $Calendar->getEngine(); - require_once 'Date/Calc.php'; - $day = Date_Calc::dayOfWeek($cE->stampToDay($stamp), - $cE->stampToMonth($stamp), $cE->stampToYear($stamp)); - return $days[$day]; - } - - /** - * Returns textual representation of the day of week of the decorated calendar object - * Note: Requires PEAR::Date - * @param object subclass of Calendar e.g. Calendar_Month - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - * @static - */ - function thisDayName($Calendar, $format='long') - { - $days = Calendar_Util_Textual::weekdayNames($format); - require_once 'Date/Calc.php'; - $day = Date_Calc::dayOfWeek($Calendar->thisDay(), $Calendar->thisMonth(), $Calendar->thisYear()); - return $days[$day]; - } - - /** - * Returns textual representation of the next day of week of the decorated calendar object - * @param object subclass of Calendar e.g. Calendar_Month - * @param string (optional) format of returned months (one,two,short or long) - * @return string - * @access public - * @static - */ - function nextDayName($Calendar, $format='long') - { - $days = Calendar_Util_Textual::weekdayNames($format); - $stamp = $Calendar->nextDay('timestamp'); - $cE = $Calendar->getEngine(); - require_once 'Date/Calc.php'; - $day = Date_Calc::dayOfWeek($cE->stampToDay($stamp), - $cE->stampToMonth($stamp), $cE->stampToYear($stamp)); - return $days[$day]; - } - - /** - * Returns the days of the week using the order defined in the decorated - * calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks - * and Calendar_Week. Otherwise the returned array will begin on Sunday - * @param object subclass of Calendar e.g. Calendar_Month - * @param string (optional) format of returned months (one,two,short or long) - * @return array ordered array of week day names - * @access public - * @static - */ - function orderedWeekdays($Calendar, $format='long') - { - $days = Calendar_Util_Textual::weekdayNames($format); - - // Not so good - need methods to access this information perhaps... - if (isset($Calendar->tableHelper)) { - $ordereddays = $Calendar->tableHelper->daysOfWeek; - } else { - $ordereddays = array(0, 1, 2, 3, 4, 5, 6); - } - - $ordereddays = array_flip($ordereddays); - $i = 0; - $returndays = array(); - foreach ($ordereddays as $key => $value) { - $returndays[$i] = $days[$key]; - $i++; - } - return $returndays; - } -} -?> diff --git a/data/module/Calendar/Util/Uri.php b/data/module/Calendar/Util/Uri.php deleted file mode 100644 index a926a44ffbd..00000000000 --- a/data/module/Calendar/Util/Uri.php +++ /dev/null @@ -1,169 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Uri.php,v 1.1 2004/08/16 09:03:55 hfuecks Exp $ -// -/** - * @package Calendar - * @version $Id: Uri.php,v 1.1 2004/08/16 09:03:55 hfuecks Exp $ - */ - -/** - * Utility to help building HTML links for navigating the calendar
- * - * $Day = new Calendar_Day(2003, 10, 23); - * $Uri = & new Calendar_Util_Uri('year', 'month', 'day'); - * echo $Uri->prev($Day,'month'); // Displays year=2003&month=10 - * echo $Uri->prev($Day,'day'); // Displays year=2003&month=10&day=22 - * $Uri->seperator = '/'; - * $Uri->scalar = true; - * echo $Uri->prev($Day,'month'); // Displays 2003/10 - * echo $Uri->prev($Day,'day'); // Displays 2003/10/22 - * - * @package Calendar - * @access public - */ -class Calendar_Util_Uri -{ - /** - * Uri fragments for year, month, day etc. - * @var array - * @access private - */ - var $uris = array(); - - /** - * String to separate fragments with. - * Set to just & for HTML. - * For a scalar URL you might use / as the seperator - * @var string (default XHTML &) - * @access public - */ - var $separator = '&'; - - /** - * To output a "scalar" string - variable names omitted. - * Used for urls like index.php/2004/8/12 - * @var boolean (default false) - * @access public - */ - var $scalar = false; - - /** - * Constructs Calendar_Decorator_Uri - * The term "fragment" means name of a calendar GET variables in the URL - * @param string URI fragment for year - * @param string (optional) URI fragment for month - * @param string (optional) URI fragment for day - * @param string (optional) URI fragment for hour - * @param string (optional) URI fragment for minute - * @param string (optional) URI fragment for second - * @access public - */ - function Calendar_Util_Uri($y, $m=null, $d=null, $h=null, $i=null, $s=null) - { - $this->setFragments($y, $m, $d, $h, $i, $s); - } - - /** - * Sets the URI fragment names - * @param string URI fragment for year - * @param string (optional) URI fragment for month - * @param string (optional) URI fragment for day - * @param string (optional) URI fragment for hour - * @param string (optional) URI fragment for minute - * @param string (optional) URI fragment for second - * @return void - * @access public - */ - function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null) { - if (!is_null($y)) $this->uris['Year'] = $y; - if (!is_null($m)) $this->uris['Month'] = $m; - if (!is_null($d)) $this->uris['Day'] = $d; - if (!is_null($h)) $this->uris['Hour'] = $h; - if (!is_null($i)) $this->uris['Minute'] = $i; - if (!is_null($s)) $this->uris['Second'] = $s; - } - - /** - * Gets the URI string for the previous calendar unit - * @param object subclassed from Calendar e.g. Calendar_Month - * @param string calendar unit ( must be year, month, week, day, hour, minute or second) - * @return string - * @access public - */ - function prev($Calendar, $unit) - { - $method = 'prev'.$unit; - $stamp = $Calendar->{$method}('timestamp'); - return $this->buildUriString($Calendar, $method, $stamp); - } - - /** - * Gets the URI string for the current calendar unit - * @param object subclassed from Calendar e.g. Calendar_Month - * @param string calendar unit ( must be year, month, week, day, hour, minute or second) - * @return string - * @access public - */ - function this($Calendar, $unit) - { - $method = 'this'.$unit; - $stamp = $Calendar->{$method}('timestamp'); - return $this->buildUriString($Calendar, $method, $stamp); - } - - /** - * Gets the URI string for the next calendar unit - * @param object subclassed from Calendar e.g. Calendar_Month - * @param string calendar unit ( must be year, month, week, day, hour, minute or second) - * @return string - * @access public - */ - function next($Calendar, $unit) - { - $method = 'next'.$unit; - $stamp = $Calendar->{$method}('timestamp'); - return $this->buildUriString($Calendar, $method, $stamp); - } - - /** - * Build the URI string - * @param string method substring - * @param int timestamp - * @return string build uri string - * @access private - */ - function buildUriString($Calendar, $method, $stamp) - { - $uriString = ''; - $cE = & $Calendar->getEngine(); - $separator = ''; - foreach ($this->uris as $unit => $uri) { - $call = 'stampTo'.$unit; - $uriString .= $separator; - if (!$this->scalar) $uriString .= $uri.'='; - $uriString .= $cE->{$call}($stamp); - $separator = $this->separator; - } - return $uriString; - } -} -?> diff --git a/data/module/Calendar/Validator.php b/data/module/Calendar/Validator.php deleted file mode 100644 index 7e746cee6a3..00000000000 --- a/data/module/Calendar/Validator.php +++ /dev/null @@ -1,335 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Validator.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Validator.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ - */ - -/** - * Validation Error Messages - */ -if (!defined('CALENDAR_VALUE_TOOSMALL')) { - define('CALENDAR_VALUE_TOOSMALL', 'Too small: min = '); -} -if (!defined('CALENDAR_VALUE_TOOLARGE')) { - define('CALENDAR_VALUE_TOOLARGE', 'Too large: max = '); -} - -/** - * Used to validate any given Calendar date object. Instances of this class - * can be obtained from any data object using the getValidator method - * @see Calendar::getValidator() - * @package Calendar - * @access public - */ -class Calendar_Validator -{ - /** - * Instance of the Calendar date object to validate - * @var object - * @access private - */ - var $calendar; - - /** - * Instance of the Calendar_Engine - * @var object - * @access private - */ - var $cE; - - /** - * Array of errors for validation failures - * @var array - * @access private - */ - var $errors = array(); - - /** - * Constructs Calendar_Validator - * @param object subclass of Calendar - * @access public - */ - function Calendar_Validator(& $calendar) - { - $this->calendar = & $calendar; - $this->cE = & $calendar->getEngine(); - } - - /** - * Calls all the other isValidXXX() methods in the validator - * @return boolean - * @access public - */ - function isValid() - { - $checks = array('isValidYear', 'isValidMonth', 'isValidDay', - 'isValidHour', 'isValidMinute', 'isValidSecond'); - $valid = true; - foreach ($checks as $check) { - if (!$this->{$check}()) { - $valid = false; - } - } - return $valid; - } - - /** - * Check whether this is a valid year - * @return boolean - * @access public - */ - function isValidYear() - { - $y = $this->calendar->thisYear(); - $min = $this->cE->getMinYears(); - if ($min > $y) { - $this->errors[] = new Calendar_Validation_Error( - 'Year', $y, CALENDAR_VALUE_TOOSMALL.$min); - return false; - } - $max = $this->cE->getMaxYears(); - if ($y > $max) { - $this->errors[] = new Calendar_Validation_Error( - 'Year', $y, CALENDAR_VALUE_TOOLARGE.$max); - return false; - } - return true; - } - - /** - * Check whether this is a valid month - * @return boolean - * @access public - */ - function isValidMonth() - { - $m = $this->calendar->thisMonth(); - $min = 1; - if ($min > $m) { - $this->errors[] = new Calendar_Validation_Error( - 'Month', $m, CALENDAR_VALUE_TOOSMALL.$min); - return false; - } - $max = $this->cE->getMonthsInYear($this->calendar->thisYear()); - if ($m > $max) { - $this->errors[] = new Calendar_Validation_Error( - 'Month', $m, CALENDAR_VALUE_TOOLARGE.$max); - return false; - } - return true; - } - - /** - * Check whether this is a valid day - * @return boolean - * @access public - */ - function isValidDay() - { - $d = $this->calendar->thisDay(); - $min = 1; - if ($min > $d) { - $this->errors[] = new Calendar_Validation_Error( - 'Day', $d, CALENDAR_VALUE_TOOSMALL.$min); - return false; - } - $max = $this->cE->getDaysInMonth( - $this->calendar->thisYear(), $this->calendar->thisMonth()); - if ($d > $max) { - $this->errors[] = new Calendar_Validation_Error( - 'Day', $d, CALENDAR_VALUE_TOOLARGE.$max); - return false; - } - return true; - } - - /** - * Check whether this is a valid hour - * @return boolean - * @access public - */ - function isValidHour() - { - $h = $this->calendar->thisHour(); - $min = 0; - if ($min > $h) { - $this->errors[] = new Calendar_Validation_Error( - 'Hour', $h, CALENDAR_VALUE_TOOSMALL.$min); - return false; - } - $max = ($this->cE->getHoursInDay($this->calendar->thisDay())-1); - if ($h > $max) { - $this->errors[] = new Calendar_Validation_Error( - 'Hour', $h, CALENDAR_VALUE_TOOLARGE.$max); - return false; - } - return true; - } - - /** - * Check whether this is a valid minute - * @return boolean - * @access public - */ - function isValidMinute() - { - $i = $this->calendar->thisMinute(); - $min = 0; - if ($min > $i) { - $this->errors[] = new Calendar_Validation_Error( - 'Minute', $i, CALENDAR_VALUE_TOOSMALL.$min); - return false; - } - $max = ($this->cE->getMinutesInHour($this->calendar->thisHour())-1); - if ($i > $max) { - $this->errors[] = new Calendar_Validation_Error( - 'Minute', $i, CALENDAR_VALUE_TOOLARGE.$max); - return false; - } - return true; - } - - /** - * Check whether this is a valid second - * @return boolean - * @access public - */ - function isValidSecond() - { - $s = $this->calendar->thisSecond(); - $min = 0; - if ($min > $s) { - $this->errors[] = new Calendar_Validation_Error( - 'Second', $s, CALENDAR_VALUE_TOOSMALL.$min); - return false; - } - $max = ($this->cE->getSecondsInMinute($this->calendar->thisMinute())-1); - if ($s > $max) { - $this->errors[] = new Calendar_Validation_Error( - 'Second', $s, CALENDAR_VALUE_TOOLARGE.$max); - return false; - } - return true; - } - - /** - * Iterates over any validation errors - * @return mixed either Calendar_Validation_Error or false - * @access public - */ - function fetch() - { - $error = each ($this->errors); - if ($error) { - return $error['value']; - } else { - reset($this->errors); - return false; - } - } -} - -/** - * For Validation Error messages - * @see Calendar::fetch() - * @package Calendar - * @access public - */ -class Calendar_Validation_Error -{ - /** - * Date unit (e.g. month,hour,second) which failed test - * @var string - * @access private - */ - var $unit; - - /** - * Value of unit which failed test - * @var int - * @access private - */ - var $value; - - /** - * Validation error message - * @var string - * @access private - */ - var $message; - - /** - * Constructs Calendar_Validation_Error - * @param string Date unit (e.g. month,hour,second) - * @param int Value of unit which failed test - * @param string Validation error message - * @access protected - */ - function Calendar_Validation_Error($unit,$value,$message) - { - $this->unit = $unit; - $this->value = $value; - $this->message = $message; - } - - /** - * Returns the Date unit - * @return string - * @access public - */ - function getUnit() - { - return $this->unit; - } - - /** - * Returns the value of the unit - * @return int - * @access public - */ - function getValue() - { - return $this->value; - } - - /** - * Returns the validation error message - * @return string - * @access public - */ - function getMessage() - { - return $this->message; - } - - /** - * Returns a string containing the unit, value and error message - * @return string - * @access public - */ - function toString () - { - return $this->unit.' = '.$this->value.' ['.$this->message.']'; - } -} -?> diff --git a/data/module/Calendar/Week.php b/data/module/Calendar/Week.php deleted file mode 100644 index 3413e9779f8..00000000000 --- a/data/module/Calendar/Week.php +++ /dev/null @@ -1,394 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Week.php,v 1.7 2005/10/22 10:26:49 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Week.php,v 1.7 2005/10/22 10:26:49 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar base class - */ -require_once CALENDAR_ROOT.'Calendar.php'; - -/** - * Represents a Week and builds Days in tabular format
- * - * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Week.php'; - * $Week = & new Calendar_Week(2003, 10, 1); Oct 2003, 1st tabular week - * echo ''; - * while ($Day = & $Week->fetch()) { - * if ($Day->isEmpty()) { - * echo ' '; - * } else { - * echo ''.$Day->thisDay().''; - * } - * } - * echo ''; - * - * @package Calendar - * @access public - */ -class Calendar_Week extends Calendar -{ - /** - * Instance of Calendar_Table_Helper - * @var Calendar_Table_Helper - * @access private - */ - var $tableHelper; - - /** - * Stores the timestamp of the first day of this week - * @access private - * @var object - */ - var $thisWeek; - - /** - * Stores the timestamp of first day of previous week - * @access private - * @var object - */ - var $prevWeek; - - /** - * Stores the timestamp of first day of next week - * @access private - * @var object - */ - var $nextWeek; - - /** - * Used by build() to set empty days - * @access private - * @var boolean - */ - var $firstWeek = false; - - /** - * Used by build() to set empty days - * @access private - * @var boolean - */ - var $lastWeek = false; - - /** - * First day of the week (0=sunday, 1=monday...) - * @access private - * @var boolean - */ - var $firstDay = 1; - - /** - * Constructs Week - * @param int year e.g. 2003 - * @param int month e.g. 5 - * @param int a day of the desired week - * @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.) - * @access public - */ - function Calendar_Week($y, $m, $d, $firstDay=null) - { - require_once CALENDAR_ROOT.'Table/Helper.php'; - Calendar::Calendar($y, $m, $d); - $this->firstDay = $this->defineFirstDayOfWeek($firstDay); - $this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay); - $this->thisWeek = $this->tableHelper->getWeekStart($y, $m, $d, $this->firstDay); - $this->prevWeek = $this->tableHelper->getWeekStart($y, $m, $d - $this->cE->getDaysInWeek( - $this->thisYear(), - $this->thisMonth(), - $this->thisDay()), $this->firstDay); - $this->nextWeek = $this->tableHelper->getWeekStart($y, $m, $d + $this->cE->getDaysInWeek( - $this->thisYear(), - $this->thisMonth(), - $this->thisDay()), $this->firstDay); - } - - /** - * Defines the calendar by a timestamp (Unix or ISO-8601), replacing values - * passed to the constructor - * @param int|string Unix or ISO-8601 timestamp - * @return void - * @access public - */ - function setTimestamp($ts) - { - parent::setTimestamp($ts); - $this->thisWeek = $this->tableHelper->getWeekStart( - $this->year, $this->month, $this->day, $this->firstDay - ); - $this->prevWeek = $this->tableHelper->getWeekStart( - $this->year, $this->month, $this->day - $this->cE->getDaysInWeek( - $this->thisYear(), - $this->thisMonth(), - $this->thisDay()), $this->firstDay - ); - $this->nextWeek = $this->tableHelper->getWeekStart( - $this->year, $this->month, $this->day + $this->cE->getDaysInWeek( - $this->thisYear(), - $this->thisMonth(), - $this->thisDay()), $this->firstDay - ); - } - - /** - * Builds Calendar_Day objects for this Week - * @param array (optional) Calendar_Day objects representing selected dates - * @return boolean - * @access public - */ - function build($sDates = array()) - { - require_once CALENDAR_ROOT.'Day.php'; - $year = $this->cE->stampToYear($this->thisWeek); - $month = $this->cE->stampToMonth($this->thisWeek); - $day = $this->cE->stampToDay($this->thisWeek); - $end = $this->cE->getDaysInWeek( - $this->thisYear(), - $this->thisMonth(), - $this->thisDay() - ); - - for ($i=1; $i <= $end; $i++) { - $stamp = $this->cE->dateToStamp($year, $month, $day++); - $this->children[$i] = new Calendar_Day( - $this->cE->stampToYear($stamp), - $this->cE->stampToMonth($stamp), - $this->cE->stampToDay($stamp)); - } - - //set empty days (@see Calendar_Month_Weeks::build()) - if ($this->firstWeek) { - $eBefore = $this->tableHelper->getEmptyDaysBefore(); - for ($i=1; $i <= $eBefore; $i++) { - $this->children[$i]->setEmpty(); - } - } - if ($this->lastWeek) { - $eAfter = $this->tableHelper->getEmptyDaysAfterOffset(); - for ($i = $eAfter+1; $i <= $end; $i++) { - $this->children[$i]->setEmpty(); - } - } - - if (count($sDates) > 0) { - $this->setSelection($sDates); - } - return true; - } - - /** - * @param boolean - * @return void - * @access private - */ - function setFirst($state=true) - { - $this->firstWeek = $state; - } - - /** - * @param boolean - * @return void - * @access private - */ - function setLast($state=true) - { - $this->lastWeek = $state; - } - - /** - * Called from build() - * @param array - * @return void - * @access private - */ - function setSelection($sDates) - { - foreach ($sDates as $sDate) { - foreach ($this->children as $key => $child) { - if ($child->thisDay() == $sDate->thisDay() && - $child->thisMonth() == $sDate->thisMonth() && - $child->thisYear() == $sDate->thisYear() - ) { - $this->children[$key] = $sDate; - $this->children[$key]->setSelected(); - } - } - } - reset($this->children); - } - - /** - * Gets the value of the previous week, according to the requested format - * - * @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array'] - * @return mixed - * @access public - */ - function prevWeek($format = 'n_in_month') - { - switch (strtolower($format)) { - case 'int': - case 'n_in_month': - return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') -1; - break; - case 'n_in_year': - return $this->cE->getWeekNInYear( - $this->cE->stampToYear($this->prevWeek), - $this->cE->stampToMonth($this->prevWeek), - $this->cE->stampToDay($this->prevWeek)); - break; - case 'array': - return $this->toArray($this->prevWeek); - break; - case 'object': - require_once CALENDAR_ROOT.'Factory.php'; - return Calendar_Factory::createByTimestamp('Week', $this->prevWeek); - break; - case 'timestamp': - default: - return $this->prevWeek; - break; - } - } - - /** - * Gets the value of the current week, according to the requested format - * - * @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array'] - * @return mixed - * @access public - */ - function thisWeek($format = 'n_in_month') - { - switch (strtolower($format)) { - case 'int': - case 'n_in_month': - if ($this->firstWeek) { - return 1; - } - if ($this->lastWeek) { - return $this->cE->getWeeksInMonth( - $this->thisYear(), - $this->thisMonth(), - $this->firstDay); - } - return $this->cE->getWeekNInMonth( - $this->thisYear(), - $this->thisMonth(), - $this->thisDay(), - $this->firstDay); - break; - case 'n_in_year': - return $this->cE->getWeekNInYear( - $this->cE->stampToYear($this->thisWeek), - $this->cE->stampToMonth($this->thisWeek), - $this->cE->stampToDay($this->thisWeek)); - break; - case 'array': - return $this->toArray($this->thisWeek); - break; - case 'object': - require_once CALENDAR_ROOT.'Factory.php'; - return Calendar_Factory::createByTimestamp('Week', $this->thisWeek); - break; - case 'timestamp': - default: - return $this->thisWeek; - break; - } - } - - /** - * Gets the value of the following week, according to the requested format - * - * @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array'] - * @return mixed - * @access public - */ - function nextWeek($format = 'n_in_month') - { - switch (strtolower($format)) { - case 'int': - case 'n_in_month': - return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') +1; - break; - case 'n_in_year': - return $this->cE->getWeekNInYear( - $this->cE->stampToYear($this->nextWeek), - $this->cE->stampToMonth($this->nextWeek), - $this->cE->stampToDay($this->nextWeek)); - break; - case 'array': - return $this->toArray($this->nextWeek); - break; - case 'object': - require_once CALENDAR_ROOT.'Factory.php'; - return Calendar_Factory::createByTimestamp('Week', $this->nextWeek); - break; - case 'timestamp': - default: - return $this->nextWeek; - break; - } - } - - /** - * Returns the instance of Calendar_Table_Helper. - * Called from Calendar_Validator::isValidWeek - * @return Calendar_Table_Helper - * @access protected - */ - function & getHelper() - { - return $this->tableHelper; - } - - /** - * Makes sure theres a value for $this->day - * @return void - * @access private - */ - function findFirstDay() - { - if (!count($this->children) > 0) { - $this->build(); - foreach ($this->children as $Day) { - if (!$Day->isEmpty()) { - $this->day = $Day->thisDay(); - break; - } - } - } - } -} -?> diff --git a/data/module/Calendar/Year.php b/data/module/Calendar/Year.php deleted file mode 100644 index ea4b25b7e9c..00000000000 --- a/data/module/Calendar/Year.php +++ /dev/null @@ -1,113 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Year.php,v 1.4 2005/10/22 10:25:39 quipo Exp $ -// -/** - * @package Calendar - * @version $Id: Year.php,v 1.4 2005/10/22 10:25:39 quipo Exp $ - */ - -/** - * Allows Calendar include path to be redefined - * @ignore - */ -if (!defined('CALENDAR_ROOT')) { - define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); -} - -/** - * Load Calendar base class - */ -require_once CALENDAR_ROOT.'Calendar.php'; - -/** - * Represents a Year and builds Months
- * - * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Year.php'; - * $Year = & new Calendar_Year(2003, 10, 21); // 21st Oct 2003 - * $Year->build(); // Build Calendar_Month objects - * while ($Month = & $Year->fetch()) { - * echo $Month->thisMonth().'
'; - * } - *
- * @package Calendar - * @access public - */ -class Calendar_Year extends Calendar -{ - /** - * Constructs Calendar_Year - * @param int year e.g. 2003 - * @access public - */ - function Calendar_Year($y) - { - Calendar::Calendar($y); - } - - /** - * Builds the Months of the Year.
- * Note: by defining the constant CALENDAR_MONTH_STATE you can - * control what class of Calendar_Month is built e.g.; - * - * require_once 'Calendar/Calendar_Year.php'; - * define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKDAYS); // Use Calendar_Month_Weekdays - * // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKS); // Use Calendar_Month_Weeks - * // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH); // Use Calendar_Month - * - * It defaults to building Calendar_Month objects. - * @param array (optional) array of Calendar_Month objects representing selected dates - * @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.) - * @return boolean - * @access public - */ - function build($sDates = array(), $firstDay = null) - { - require_once CALENDAR_ROOT.'Factory.php'; - $this->firstDay = $this->defineFirstDayOfWeek($firstDay); - $monthsInYear = $this->cE->getMonthsInYear($this->thisYear()); - for ($i=1; $i <= $monthsInYear; $i++) { - $this->children[$i] = Calendar_Factory::create('Month', $this->year, $i); - } - if (count($sDates) > 0) { - $this->setSelection($sDates); - } - return true; - } - - /** - * Called from build() - * @param array - * @return void - * @access private - */ - function setSelection($sDates) { - foreach ($sDates as $sDate) { - if ($this->year == $sDate->thisYear()) { - $key = $sDate->thisMonth(); - if (isset($this->children[$key])) { - $sDate->setSelected(); - $this->children[$key] = $sDate; - } - } - } - } -} -?> diff --git a/data/module/Calendar/docs/Readme b/data/module/Calendar/docs/Readme deleted file mode 100644 index bba1ed66d1e..00000000000 --- a/data/module/Calendar/docs/Readme +++ /dev/null @@ -1,3 +0,0 @@ -Readme - -See the PEAR manual at http://pear.php.net/manual/en/package.datetime.calendar.php for details. \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/1.php b/data/module/Calendar/docs/examples/1.php deleted file mode 100644 index f001833cebb..00000000000 --- a/data/module/Calendar/docs/examples/1.php +++ /dev/null @@ -1,92 +0,0 @@ -' ); -echo ( 'The time is now: '.date('Y M d H:i:s',$c->getTimestamp()).'
' ); - -$i = 1; -echo ( '

First Iteration

' ); -echo ( '

The first iteration is more "expensive", the calendar data - structures having to be built.

' ); -$start = getmicrotime(); -$c->build(); -while ( $e = $c->fetch() ) { - $class = strtolower(get_class($e)); - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); - $method = 'this'.str_replace('calendar_','',$class); - echo ( "".$e->{$method}()." : " ); - if ( ($i % 10) == 0 ) { - echo ( '
' ); - } - $i++; -} -echo ( '

Took: '.(getmicrotime()-$start).' seconds

' ); - -$i = 1; -echo ( '

Second Iteration

' ); -echo ( '

This second iteration is faster, the data structures - being re-used

' ); -$start = getmicrotime(); -while ( $e = $c->fetch() ) { - $class = strtolower(get_class($e)); - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); - $method = 'this'.str_replace('calendar_','',$class); - echo ( "".$e->{$method}()." : " ); - if ( ($i % 10) == 0 ) { - echo ( '
' ); - } - $i++; -} -echo ( '

Took: '.(getmicrotime()-$start).' seconds

' ); -?> diff --git a/data/module/Calendar/docs/examples/1.phps b/data/module/Calendar/docs/examples/1.phps deleted file mode 100644 index 8c53b6ee102..00000000000 --- a/data/module/Calendar/docs/examples/1.phps +++ /dev/null @@ -1,92 +0,0 @@ -' ); -echo ( 'The time is now: '.date('Y M d H:i:s',$c->getTimestamp()).'
' ); - -$i = 1; -echo ( '

First Iteration

' ); -echo ( '

The first iteration is more "expensive", the calendar data - structures having to be built.

' ); -$start = getmicrotime(); -$c->build(); -while ( $e = $c->fetch() ) { - $class = strtolower(get_class($e)); - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); - $method = 'this'.str_replace('calendar_','',$class); - echo ( "".$e->{$method}()." : " ); - if ( ($i % 10) == 0 ) { - echo ( '
' ); - } - $i++; -} -echo ( '

Took: '.(getmicrotime()-$start).' seconds

' ); - -$i = 1; -echo ( '

Second Iteration

' ); -echo ( '

This second iteration is faster, the data structures - being re-used

' ); -$start = getmicrotime(); -while ( $e = $c->fetch() ) { - $class = strtolower(get_class($e)); - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); - $method = 'this'.str_replace('calendar_','',$class); - echo ( "".$e->{$method}()." : " ); - if ( ($i % 10) == 0 ) { - echo ( '
' ); - } - $i++; -} -echo ( '

Took: '.(getmicrotime()-$start).' seconds

' ); -?> \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/10.php b/data/module/Calendar/docs/examples/10.php deleted file mode 100644 index 290af3a3350..00000000000 --- a/data/module/Calendar/docs/examples/10.php +++ /dev/null @@ -1,93 +0,0 @@ -build(); -?> - - - - - A Simple Decorator - - -

A Simple Decorator

- - -fetch() ) { - if ( $Day->isFirst() ) { - echo ( "\n\n" ); - } - if ( $Day->isEmpty() ) { - echo ( "" ); - } else { - echo ( "" ); - } - if ( $Day->isLast() ) { - echo ( "\n\n" ); - } -} -?> - - - - - -
thisMonth() ); ?>
 ".$Day->thisDay()."
Prev Next
- - diff --git a/data/module/Calendar/docs/examples/10.phps b/data/module/Calendar/docs/examples/10.phps deleted file mode 100644 index ebe1c0a9945..00000000000 --- a/data/module/Calendar/docs/examples/10.phps +++ /dev/null @@ -1,93 +0,0 @@ -build(); -?> - - - - - A Simple Decorator - - -

A Simple Decorator

- - -fetch() ) { - if ( $Day->isFirst() ) { - echo ( "\n\n" ); - } - if ( $Day->isEmpty() ) { - echo ( "" ); - } else { - echo ( "" ); - } - if ( $Day->isLast() ) { - echo ( "\n\n" ); - } -} -?> - - - - - -
thisMonth() ); ?>
 ".$Day->thisDay()."
Prev Next
- - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/11.php b/data/module/Calendar/docs/examples/11.php deleted file mode 100644 index 58ab276996c..00000000000 --- a/data/module/Calendar/docs/examples/11.php +++ /dev/null @@ -1,109 +0,0 @@ -entry = $entry; - } - function getEntry() { - return $this->entry; - } -} - -// Create a day to view the hours for -$Day = & new Calendar_Day(2003,10,24); - -// A sample query to get the data for today (NOT ACTUALLY USED HERE) -$sql = " - SELECT - * - FROM - diary - WHERE - eventtime >= '".$Day->thisDay(TRUE)."' - AND - eventtime < '".$Day->nextDay(TRUE)."';"; - -// An array simulating data from a database -$result = array ( - array('eventtime'=>mktime(9,0,0,10,24,2003),'entry'=>'Meeting with sales team'), - array('eventtime'=>mktime(11,0,0,10,24,2003),'entry'=>'Conference call with Widget Inc.'), - array('eventtime'=>mktime(15,0,0,10,24,2003),'entry'=>'Presentation to board of directors') - ); - -// An array to place selected hours in -$selection = array(); - -// Loop through the "database result" -foreach ( $result as $row ) { - $Hour = new Calendar_Hour(2000,1,1,1); // Create Hour with dummy values - $Hour->setTimeStamp($row['eventtime']); // Set the real time with setTimeStamp - - // Create the decorator, passing it the Hour - $DiaryEvent = new DiaryEvent($Hour); - - // Attach the payload - $DiaryEvent->setEntry($row['entry']); - - // Add the decorator to the selection - $selection[] = $DiaryEvent; -} - -// Build the hours in that day, passing the selection -$Day->build($selection); -?> - - - - Passing a Selection Payload with a Decorator - - -

Passing a Selection "Payload" using a Decorator

- - - - - - -fetch() ) { - - $hour = $Hour->thisHour(); - $minute = $Hour->thisMinute(); - - // Office hours only... - if ( $hour >= 8 && $hour <= 18 ) { - echo ( "\n" ); - echo ( "\n" ); - - // If the hour is selected, call the decorator method... - if ( $Hour->isSelected() ) { - echo ( "\n" ); - } else { - echo ( "\n" ); - } - echo ( "\n" ); - } -} -?> -
Your Schedule for thisDay(TRUE)) ); ?>
TimeEntry
$hour:$minute".$Hour->getEntry()." 
-

The query to fetch this data, with help from PEAR::Calendar, might be;

-
-
-
- - diff --git a/data/module/Calendar/docs/examples/11.phps b/data/module/Calendar/docs/examples/11.phps deleted file mode 100644 index 4f604d5aa60..00000000000 --- a/data/module/Calendar/docs/examples/11.phps +++ /dev/null @@ -1,109 +0,0 @@ -entry = $entry; - } - function getEntry() { - return $this->entry; - } -} - -// Create a day to view the hours for -$Day = & new Calendar_Day(2003,10,24); - -// A sample query to get the data for today (NOT ACTUALLY USED HERE) -$sql = " - SELECT - * - FROM - diary - WHERE - eventtime >= '".$Day->thisDay(TRUE)."' - AND - eventtime < '".$Day->nextDay(TRUE)."';"; - -// An array simulating data from a database -$result = array ( - array('eventtime'=>mktime(9,0,0,10,24,2003),'entry'=>'Meeting with sales team'), - array('eventtime'=>mktime(11,0,0,10,24,2003),'entry'=>'Conference call with Widget Inc.'), - array('eventtime'=>mktime(15,0,0,10,24,2003),'entry'=>'Presentation to board of directors') - ); - -// An array to place selected hours in -$selection = array(); - -// Loop through the "database result" -foreach ( $result as $row ) { - $Hour = new Calendar_Hour(2000,1,1,1); // Create Hour with dummy values - $Hour->setTimeStamp($row['eventtime']); // Set the real time with setTimeStamp - - // Create the decorator, passing it the Hour - $DiaryEvent = new DiaryEvent($Hour); - - // Attach the payload - $DiaryEvent->setEntry($row['entry']); - - // Add the decorator to the selection - $selection[] = $DiaryEvent; -} - -// Build the hours in that day, passing the selection -$Day->build($selection); -?> - - - - Passing a Selection Payload with a Decorator - - -

Passing a Selection "Payload" using a Decorator

- - - - - - -fetch() ) { - - $hour = $Hour->thisHour(); - $minute = $Hour->thisMinute(); - - // Office hours only... - if ( $hour >= 8 && $hour <= 18 ) { - echo ( "\n" ); - echo ( "\n" ); - - // If the hour is selected, call the decorator method... - if ( $Hour->isSelected() ) { - echo ( "\n" ); - } else { - echo ( "\n" ); - } - echo ( "\n" ); - } -} -?> -
Your Schedule for thisDay(TRUE)) ); ?>
TimeEntry
$hour:$minute".$Hour->getEntry()." 
-

The query to fetch this data, with help from PEAR::Calendar, might be;

-
-
-
- - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/12.php b/data/module/Calendar/docs/examples/12.php deleted file mode 100644 index f48191d01ec..00000000000 --- a/data/module/Calendar/docs/examples/12.php +++ /dev/null @@ -1,116 +0,0 @@ -build(); -?> - - - - <?php echo ( $Year->thisYear() ); ?> - - - - - -fetch() ) { - - switch ( $i ) { - case 0: - echo ( "\n" ); - break; - case 3: - case 6: - case 9: - echo ( "\n\n" ); - break; - case 12: - echo ( "\n" ); - break; - } - - echo ( "\n" ); - - $i++; -} -?> -
-thisYear() ); ?> - - -
\n\n" ); - echo ( "" ); - echo ( "\n\n" ); - $Month->build(); - while ( $Day = $Month->fetch() ) { - if ( $Day->isFirst() ) { - echo ( "\n" ); - } - if ( $Day->isEmpty() ) { - echo ( "\n" ); - } else { - echo ( "\n" ); - } - if ( $Day->isLast() ) { - echo ( "\n" ); - } - } - echo ( "
".date('F',$Month->thisMonth(TRUE))."
MTWTFSS
 ".$Day->thisDay()."
\n
-

Took:

- - diff --git a/data/module/Calendar/docs/examples/12.phps b/data/module/Calendar/docs/examples/12.phps deleted file mode 100644 index a322e77bb77..00000000000 --- a/data/module/Calendar/docs/examples/12.phps +++ /dev/null @@ -1,116 +0,0 @@ -build(); -?> - - - - <?php echo ( $Year->thisYear() ); ?> - - - - - -fetch() ) { - - switch ( $i ) { - case 0: - echo ( "\n" ); - break; - case 3: - case 6: - case 9: - echo ( "\n\n" ); - break; - case 12: - echo ( "\n" ); - break; - } - - echo ( "\n" ); - - $i++; -} -?> -
-thisYear() ); ?> - - -
\n\n" ); - echo ( "" ); - echo ( "\n\n" ); - $Month->build(); - while ( $Day = $Month->fetch() ) { - if ( $Day->isFirst() ) { - echo ( "\n" ); - } - if ( $Day->isEmpty() ) { - echo ( "\n" ); - } else { - echo ( "\n" ); - } - if ( $Day->isLast() ) { - echo ( "\n" ); - } - } - echo ( "
".date('F',$Month->thisMonth(TRUE))."
MTWTFSS
 ".$Day->thisDay()."
\n
-

Took:

- - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/13.php b/data/module/Calendar/docs/examples/13.php deleted file mode 100644 index c6ed371eb7e..00000000000 --- a/data/module/Calendar/docs/examples/13.php +++ /dev/null @@ -1,99 +0,0 @@ -getTimestamp()); - -echo ( '

Using PEAR::Date engine

' ); -echo ( 'Viewing: '.@$_GET['view'].'
' ); -echo ( 'The time is now: '.$date->format('%Y %a %e %T').'
' ); - -$i = 1; -echo ( '

First Iteration

' ); -echo ( '

The first iteration is more "expensive", the calendar data - structures having to be built.

' ); -$start = getmicrotime(); -$c->build(); -while ( $e = $c->fetch() ) { - $class = strtolower(get_class($e)); - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); - $method = 'this'.str_replace('calendar_','',$class); - echo ( "".$e->{$method}()." : " ); - if ( ($i % 10) == 0 ) { - echo ( '
' ); - } - $i++; -} -echo ( '

Took: '.(getmicrotime()-$start).' seconds

' ); - -$i = 1; -echo ( '

Second Iteration

' ); -echo ( '

This second iteration is faster, the data structures - being re-used

' ); -$start = getmicrotime(); -while ( $e = $c->fetch() ) { - $class = strtolower(get_class($e)); - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); - $method = 'this'.str_replace('calendar_','',$class); - echo ( "".$e->{$method}()." : " ); - if ( ($i % 10) == 0 ) { - echo ( '
' ); - } - $i++; -} -echo ( '

Took: '.(getmicrotime()-$start).' seconds

' ); -?> diff --git a/data/module/Calendar/docs/examples/13.phps b/data/module/Calendar/docs/examples/13.phps deleted file mode 100644 index 8cb29a5b692..00000000000 --- a/data/module/Calendar/docs/examples/13.phps +++ /dev/null @@ -1,99 +0,0 @@ -getTimestamp()); - -echo ( '

Using PEAR::Date engine

' ); -echo ( 'Viewing: '.@$_GET['view'].'
' ); -echo ( 'The time is now: '.$date->format('%Y %a %e %T').'
' ); - -$i = 1; -echo ( '

First Iteration

' ); -echo ( '

The first iteration is more "expensive", the calendar data - structures having to be built.

' ); -$start = getmicrotime(); -$c->build(); -while ( $e = $c->fetch() ) { - $class = strtolower(get_class($e)); - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); - $method = 'this'.str_replace('calendar_','',$class); - echo ( "".$e->{$method}()." : " ); - if ( ($i % 10) == 0 ) { - echo ( '
' ); - } - $i++; -} -echo ( '

Took: '.(getmicrotime()-$start).' seconds

' ); - -$i = 1; -echo ( '

Second Iteration

' ); -echo ( '

This second iteration is faster, the data structures - being re-used

' ); -$start = getmicrotime(); -while ( $e = $c->fetch() ) { - $class = strtolower(get_class($e)); - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); - $method = 'this'.str_replace('calendar_','',$class); - echo ( "".$e->{$method}()." : " ); - if ( ($i % 10) == 0 ) { - echo ( '
' ); - } - $i++; -} -echo ( '

Took: '.(getmicrotime()-$start).' seconds

' ); -?> \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/14.php b/data/module/Calendar/docs/examples/14.php deleted file mode 100644 index 5d93adad1c2..00000000000 --- a/data/module/Calendar/docs/examples/14.php +++ /dev/null @@ -1,141 +0,0 @@ -build($selectedDays); - -// Construct strings for next/previous links -$PMonth = $month->prevMonth('object'); // Get previous month as object -$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay(); -$NMonth = $month->nextMonth('object'); -$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay(); - -$thisDate = new Date($month->thisMonth('timestamp')); -?> - - - - Calendar using PEAR::Date Engine - - - - - -

Calendar using PEAR::Date Engine

- - - - - - - - - - - -fetch()) { - // Build a link string for each day - $link = $_SERVER['PHP_SELF']. - '?y='.$day->thisYear(). - '&m='.$day->thisMonth(). - '&d='.$day->thisDay(); - - // isFirst() to find start of week - if ($day->isFirst()) - echo "\n"; - - if ($day->isSelected()) { - echo ''."\n"; - } else if ($day->isEmpty()) { - echo ''."\n"; - } else { - echo ''."\n"; - } - - // isLast() to find end of week - if ($day->isLast()) { - echo "\n"; - } -} -?> - - - - - -
-format('%B %Y'); ?> -
MTWTFSS
'.$day->thisDay().' '.$day->thisDay().'
-<< -  - >> -
-Took: '.(getmicrotime()-$start).' seconds

'; -?> - - diff --git a/data/module/Calendar/docs/examples/14.phps b/data/module/Calendar/docs/examples/14.phps deleted file mode 100644 index 4ec9571e8e8..00000000000 --- a/data/module/Calendar/docs/examples/14.phps +++ /dev/null @@ -1,141 +0,0 @@ -build($selectedDays); - -// Construct strings for next/previous links -$PMonth = $month->prevMonth('object'); // Get previous month as object -$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay(); -$NMonth = $month->nextMonth('object'); -$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay(); - -$thisDate = new Date($month->thisMonth('timestamp')); -?> - - - - Calendar using PEAR::Date Engine - - - - - -

Calendar using PEAR::Date Engine

- - - - - - - - - - - -fetch()) { - // Build a link string for each day - $link = $_SERVER['PHP_SELF']. - '?y='.$day->thisYear(). - '&m='.$day->thisMonth(). - '&d='.$day->thisDay(); - - // isFirst() to find start of week - if ($day->isFirst()) - echo "\n"; - - if ($day->isSelected()) { - echo ''."\n"; - } else if ($day->isEmpty()) { - echo ''."\n"; - } else { - echo ''."\n"; - } - - // isLast() to find end of week - if ($day->isLast()) { - echo "\n"; - } -} -?> - - - - - -
-format('%B %Y'); ?> -
MTWTFSS
'.$day->thisDay().' '.$day->thisDay().'
-<< -  - >> -
-Took: '.(getmicrotime()-$start).' seconds

'; -?> - - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/15.php b/data/module/Calendar/docs/examples/15.php deleted file mode 100644 index 272d9453e96..00000000000 --- a/data/module/Calendar/docs/examples/15.php +++ /dev/null @@ -1,58 +0,0 @@ -getValidator(); -if (!$Validator->isValidWeek()) { - die ('Please enter a valid week!'); -} -*/ -?> - - - - Paging Weeks - - -

Paging Weeks

-

Week: thisWeek().' '.date('F Y',$Week->thisMonth(true)); ?>

-build(); -while ($Day = $Week->fetch()) { - echo '

'.date('jS F',$Day->thisDay(true))."

\n"; -} -$days = $Week->fetchAll(); - -$prevWeek = $Week->prevWeek('array'); -$prevWeekLink = $_SERVER['PHP_SELF']. - '?y='.$prevWeek['year']. - '&m='.$prevWeek['month']. - '&d='.$prevWeek['day']; - -$nextWeek = $Week->nextWeek('array'); -$nextWeekLink = $_SERVER['PHP_SELF']. - '?y='.$nextWeek['year']. - '&m='.$nextWeek['month']. - '&d='.$nextWeek['day']; -?> -

<< | >>

- - diff --git a/data/module/Calendar/docs/examples/15.phps b/data/module/Calendar/docs/examples/15.phps deleted file mode 100644 index 35c5e5b1c5e..00000000000 --- a/data/module/Calendar/docs/examples/15.phps +++ /dev/null @@ -1,58 +0,0 @@ -getValidator(); -if (!$Validator->isValidWeek()) { - die ('Please enter a valid week!'); -} -*/ -?> - - - - Paging Weeks - - -

Paging Weeks

-

Week: thisWeek().' '.date('F Y',$Week->thisMonth(true)); ?>

-build(); -while ($Day = $Week->fetch()) { - echo '

'.date('jS F',$Day->thisDay(true))."

\n"; -} -$days = $Week->fetchAll(); - -$prevWeek = $Week->prevWeek('array'); -$prevWeekLink = $_SERVER['PHP_SELF']. - '?y='.$prevWeek['year']. - '&m='.$prevWeek['month']. - '&d='.$prevWeek['day']; - -$nextWeek = $Week->nextWeek('array'); -$nextWeekLink = $_SERVER['PHP_SELF']. - '?y='.$nextWeek['year']. - '&m='.$nextWeek['month']. - '&d='.$nextWeek['day']; -?> -

<< | >>

- - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/16.php b/data/module/Calendar/docs/examples/16.php deleted file mode 100644 index bd0c5c34a00..00000000000 --- a/data/module/Calendar/docs/examples/16.php +++ /dev/null @@ -1,31 +0,0 @@ -The current month is ' - .$Calendar->thisMonth().' of year '.$Calendar->thisYear().'

'); - -$Uri = & new Calendar_Decorator_Uri($Calendar); -$Uri->setFragments('jahr','monat'); -// $Uri->setSeperator('/'); // Default is & -// $Uri->setScalar(); // Omit variable names -echo ( "
Previous Uri:\t".$Uri->prev('month')."\n" );
-echo ( "This Uri:\t".$Uri->this('month')."\n" );
-echo ( "Next Uri:\t".$Uri->next('month')."\n
" ); -?> -

-Prev : -Next -

diff --git a/data/module/Calendar/docs/examples/16.phps b/data/module/Calendar/docs/examples/16.phps deleted file mode 100644 index 5b75dfb7cf3..00000000000 --- a/data/module/Calendar/docs/examples/16.phps +++ /dev/null @@ -1,31 +0,0 @@ -The current month is ' - .$Calendar->thisMonth().' of year '.$Calendar->thisYear().'

'); - -$Uri = & new Calendar_Decorator_Uri($Calendar); -$Uri->setFragments('jahr','monat'); -// $Uri->setSeperator('/'); // Default is & -// $Uri->setScalar(); // Omit variable names -echo ( "
Previous Uri:\t".$Uri->prev('month')."\n" );
-echo ( "This Uri:\t".$Uri->this('month')."\n" );
-echo ( "Next Uri:\t".$Uri->next('month')."\n
" ); -?> -

-Prev : -Next -

\ No newline at end of file diff --git a/data/module/Calendar/docs/examples/17.php b/data/module/Calendar/docs/examples/17.php deleted file mode 100644 index f2aae56da65..00000000000 --- a/data/module/Calendar/docs/examples/17.php +++ /dev/null @@ -1,71 +0,0 @@ -Calling: Calendar_Decorator_Textual::monthNames('long');
";
-print_r(Calendar_Decorator_Textual::monthNames('long'));
-echo '
'; - -echo "
Calling: Calendar_Decorator_Textual::weekdayNames('two');
";
-print_r(Calendar_Decorator_Textual::weekdayNames('two'));
-echo '
'; - -echo "
Creating: new Calendar_Day(date('Y'), date('n'), date('d'));
"; -$Calendar = new Calendar_Day(date('Y'), date('n'), date('d')); - -// Decorate -$Textual = & new Calendar_Decorator_Textual($Calendar); - -echo '
Previous month is: '.$Textual->prevMonthName('two').'
'; -echo 'This month is: '.$Textual->thisMonthName('short').'
'; -echo 'Next month is: '.$Textual->nextMonthName().'

'; -echo 'Previous day is: '.$Textual->prevDayName().'
'; -echo 'This day is: '.$Textual->thisDayName('short').'
'; -echo 'Next day is: '.$Textual->nextDayName('one').'

'; - -echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week
"; -$Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - -// Decorate -$Textual = & new Calendar_Decorator_Textual($Calendar); -?> -

Rendering calendar....

- - - -orderedWeekdays('short'); -foreach ($dayheaders as $dayheader) { - echo ''; -} -?> - -build(); -while ($Day = $Calendar->fetch()) { - if ($Day->isFirst()) { - echo "\n"; - } - if ($Day->isEmpty()) { - echo ''; - } else { - echo ''; - } - if ($Day->isLast()) { - echo "\n"; - } -} -?> -
thisMonthName().' '.$Textual->thisYear(); ?>
'.$dayheader.'
 '.$Day->thisDay().'
diff --git a/data/module/Calendar/docs/examples/17.phps b/data/module/Calendar/docs/examples/17.phps deleted file mode 100644 index 32373528beb..00000000000 --- a/data/module/Calendar/docs/examples/17.phps +++ /dev/null @@ -1,71 +0,0 @@ -Calling: Calendar_Decorator_Textual::monthNames('long');
";
-print_r(Calendar_Decorator_Textual::monthNames('long'));
-echo '
'; - -echo "
Calling: Calendar_Decorator_Textual::weekdayNames('two');
";
-print_r(Calendar_Decorator_Textual::weekdayNames('two'));
-echo '
'; - -echo "
Creating: new Calendar_Day(date('Y'), date('n'), date('d'));
"; -$Calendar = new Calendar_Day(date('Y'), date('n'), date('d')); - -// Decorate -$Textual = & new Calendar_Decorator_Textual($Calendar); - -echo '
Previous month is: '.$Textual->prevMonthName('two').'
'; -echo 'This month is: '.$Textual->thisMonthName('short').'
'; -echo 'Next month is: '.$Textual->nextMonthName().'

'; -echo 'Previous day is: '.$Textual->prevDayName().'
'; -echo 'This day is: '.$Textual->thisDayName('short').'
'; -echo 'Next day is: '.$Textual->nextDayName('one').'

'; - -echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week
"; -$Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - -// Decorate -$Textual = & new Calendar_Decorator_Textual($Calendar); -?> -

Rendering calendar....

- - - -orderedWeekdays('short'); -foreach ($dayheaders as $dayheader) { - echo ''; -} -?> - -build(); -while ($Day = $Calendar->fetch()) { - if ($Day->isFirst()) { - echo "\n"; - } - if ($Day->isEmpty()) { - echo ''; - } else { - echo ''; - } - if ($Day->isLast()) { - echo "\n"; - } -} -?> -
thisMonthName().' '.$Textual->thisYear(); ?>
'.$dayheader.'
 '.$Day->thisDay().'
\ No newline at end of file diff --git a/data/module/Calendar/docs/examples/18.php b/data/module/Calendar/docs/examples/18.php deleted file mode 100644 index cf84de7ba71..00000000000 --- a/data/module/Calendar/docs/examples/18.php +++ /dev/null @@ -1,36 +0,0 @@ -'.parent::thisDay().''; - } -} - -$Month = new Calendar_Month(date('Y'), date('n')); - -$Wrapper = & new Calendar_Decorator_Wrapper($Month); -$Wrapper->build(); - -echo '

The Wrapper decorator

'; -echo 'Day numbers are rendered in bold

'; -while ($DecoratedDay = $Wrapper->fetch('MyBoldDecorator')) { - echo $DecoratedDay->thisDay().'
'; -} -?> diff --git a/data/module/Calendar/docs/examples/18.phps b/data/module/Calendar/docs/examples/18.phps deleted file mode 100644 index 150b0603a7c..00000000000 --- a/data/module/Calendar/docs/examples/18.phps +++ /dev/null @@ -1,36 +0,0 @@ -'.parent::thisDay().''; - } -} - -$Month = new Calendar_Month(date('Y'), date('n')); - -$Wrapper = & new Calendar_Decorator_Wrapper($Month); -$Wrapper->build(); - -echo '

The Wrapper decorator

'; -echo 'Day numbers are rendered in bold

'; -while ($DecoratedDay = $Wrapper->fetch('MyBoldDecorator')) { - echo $DecoratedDay->thisDay().'
'; -} -?> \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/19.php b/data/module/Calendar/docs/examples/19.php deleted file mode 100644 index 8dad37a4be4..00000000000 --- a/data/module/Calendar/docs/examples/19.php +++ /dev/null @@ -1,24 +0,0 @@ -setFirstDay(0); // Make Sunday first Day - -echo 'Yesterday: '.$WeekDay->prevWeekDay().'
'; -echo 'Today: '.$WeekDay->thisWeekDay().'
'; -echo 'Tomorrow: '.$WeekDay->nextWeekDay().'
'; - -$WeekDay->build(); -echo 'Hours today:
'; -while ( $Hour = $WeekDay->fetch() ) { - echo $Hour->thisHour().'
'; -} -?> diff --git a/data/module/Calendar/docs/examples/19.phps b/data/module/Calendar/docs/examples/19.phps deleted file mode 100644 index 7ba8d85a62f..00000000000 --- a/data/module/Calendar/docs/examples/19.phps +++ /dev/null @@ -1,24 +0,0 @@ -setFirstDay(0); // Make Sunday first Day - -echo 'Yesterday: '.$WeekDay->prevWeekDay().'
'; -echo 'Today: '.$WeekDay->thisWeekDay().'
'; -echo 'Tomorrow: '.$WeekDay->nextWeekDay().'
'; - -$WeekDay->build(); -echo 'Hours today:
'; -while ( $Hour = $WeekDay->fetch() ) { - echo $Hour->thisHour().'
'; -} -?> \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/2.php b/data/module/Calendar/docs/examples/2.php deleted file mode 100644 index c5c298b989d..00000000000 --- a/data/module/Calendar/docs/examples/2.php +++ /dev/null @@ -1,142 +0,0 @@ -build(); - -// Construct strings for next/previous links -$PMonth = $Month->prevMonth('object'); // Get previous month as object -$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay(); -$NMonth = $Month->nextMonth('object'); -$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay(); -?> - - - - Calendar - - - - -

Build with Calendar_Month_Weeks::build() then Calendar_Week::build()

- - - - - - - - - - - -fetch()) { - echo "\n"; - // Build the days in the week, passing the selected days - $Week->build($selectedDays); - while ($Day = $Week->fetch()) { - - // Build a link string for each day - $link = $_SERVER['PHP_SELF']. - '?y='.$Day->thisYear(). - '&m='.$Day->thisMonth(). - '&d='.$Day->thisDay(); - - // Check to see if day is selected - if ($Day->isSelected()) { - echo ''."\n"; - // Check to see if day is empty - } else if ($Day->isEmpty()) { - echo ''."\n"; - } else { - echo ''."\n"; - } - } - echo ''."\n"; -} -?> - - - - - -
-getTimeStamp()); ?> -
MTWTFSS
'.$Day->thisDay().''.$Day->thisDay().''.$Day->thisDay().'
-<< -  - >> -
-Took: '.(getmicrotime()-$start).' seconds

'; -?> - - diff --git a/data/module/Calendar/docs/examples/2.phps b/data/module/Calendar/docs/examples/2.phps deleted file mode 100644 index 0b487dae4d9..00000000000 --- a/data/module/Calendar/docs/examples/2.phps +++ /dev/null @@ -1,142 +0,0 @@ -build(); - -// Construct strings for next/previous links -$PMonth = $Month->prevMonth('object'); // Get previous month as object -$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay(); -$NMonth = $Month->nextMonth('object'); -$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay(); -?> - - - - Calendar - - - - -

Build with Calendar_Month_Weeks::build() then Calendar_Week::build()

- - - - - - - - - - - -fetch()) { - echo "\n"; - // Build the days in the week, passing the selected days - $Week->build($selectedDays); - while ($Day = $Week->fetch()) { - - // Build a link string for each day - $link = $_SERVER['PHP_SELF']. - '?y='.$Day->thisYear(). - '&m='.$Day->thisMonth(). - '&d='.$Day->thisDay(); - - // Check to see if day is selected - if ($Day->isSelected()) { - echo ''."\n"; - // Check to see if day is empty - } else if ($Day->isEmpty()) { - echo ''."\n"; - } else { - echo ''."\n"; - } - } - echo ''."\n"; -} -?> - - - - - -
-getTimeStamp()); ?> -
MTWTFSS
'.$Day->thisDay().''.$Day->thisDay().''.$Day->thisDay().'
-<< -  - >> -
-Took: '.(getmicrotime()-$start).' seconds

'; -?> - - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/20.php b/data/module/Calendar/docs/examples/20.php deleted file mode 100644 index c995ef27d3c..00000000000 --- a/data/module/Calendar/docs/examples/20.php +++ /dev/null @@ -1,240 +0,0 @@ -entries[] = $entry; - } - - function getEntry() { - $entry = each($this->entries); - if ($entry) { - return $entry['value']; - } else { - reset($this->entries); - return false; - } - } -} - -class MonthPayload_Decorator extends Calendar_Decorator -{ - //Calendar engine - var $cE; - var $tableHelper; - - var $year; - var $month; - var $firstDay = false; - - function build($events=array()) - { - require_once CALENDAR_ROOT . 'Day.php'; - require_once CALENDAR_ROOT . 'Table/Helper.php'; - - $this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay); - $this->cE = & $this->getEngine(); - $this->year = $this->thisYear(); - $this->month = $this->thisMonth(); - - $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); - for ($i=1; $i<=$daysInMonth; $i++) { - $Day = new Calendar_Day(2000,1,1); // Create Day with dummy values - $Day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $i)); - $this->children[$i] = new DiaryEvent($Day); - } - if (count($events) > 0) { - $this->setSelection($events); - } - Calendar_Month_Weekdays::buildEmptyDaysBefore(); - Calendar_Month_Weekdays::shiftDays(); - Calendar_Month_Weekdays::buildEmptyDaysAfter(); - Calendar_Month_Weekdays::setWeekMarkers(); - return true; - } - - function setSelection($events) - { - $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); - for ($i=1; $i<=$daysInMonth; $i++) { - $stamp1 = $this->cE->dateToStamp($this->year, $this->month, $i); - $stamp2 = $this->cE->dateToStamp($this->year, $this->month, $i+1); - foreach ($events as $event) { - if (($stamp1 >= $event['start'] && $stamp1 < $event['end']) || - ($stamp2 >= $event['start'] && $stamp2 < $event['end']) || - ($stamp1 <= $event['start'] && $stamp2 > $event['end']) - ) { - $this->children[$i]->addEntry($event); - $this->children[$i]->setSelected(); - } - } - } - } - - function fetch() - { - $child = each($this->children); - if ($child) { - return $child['value']; - } else { - reset($this->children); - return false; - } - } -} - -// Calendar instance used to get the dates in the preferred format: -// you can switch Calendar Engine and the example still works -$cal = new Calendar; - -$events = array(); -//add some events -$events[] = array( - 'start' => $cal->cE->dateToStamp(2004, 6, 1, 10), - 'end' => $cal->cE->dateToStamp(2004, 6, 1, 12), - 'desc' => 'Important meeting' -); -$events[] = array( - 'start' => $cal->cE->dateToStamp(2004, 6, 1, 21), - 'end' => $cal->cE->dateToStamp(2004, 6, 1, 23, 59), - 'desc' => 'Dinner with the boss' -); -$events[] = array( - 'start' => $cal->cE->dateToStamp(2004, 6, 5), - 'end' => $cal->cE->dateToStamp(2004, 6, 10, 23, 59), - 'desc' => 'Holidays!' -); - - - -$Month = & new Calendar_Month_Weekdays(2004, 6); -$MonthDecorator = new MonthPayload_Decorator($Month); -$MonthDecorator->build($events); - -?> - - - - Calendar - - - - - -

Sample Calendar Payload Decorator (using engine)

- - - - - - - - - - - -fetch()) { - - if ($Day->isFirst()) { - echo "\n"; - } - - echo ''; - - if ($Day->isLast()) { - echo "\n"; - } -} -?> -
- thisMonth().' / '.$MonthDecorator->thisYear(); ?> -
MondayTuesdayWednesdayThursdayFridaySaturdaySunday
'; - echo '
'.$Day->thisDay().'
'; - - if ($Day->isEmpty()) { - echo ' '; - } else { - echo '
    '; - while ($entry = $Day->getEntry()) { - echo '
  • '.$entry['desc'].'
  • '; - //you can print the time range as well - } - echo '
'; - } - echo '
- - diff --git a/data/module/Calendar/docs/examples/20.phps b/data/module/Calendar/docs/examples/20.phps deleted file mode 100644 index a6cb0bb499b..00000000000 --- a/data/module/Calendar/docs/examples/20.phps +++ /dev/null @@ -1,240 +0,0 @@ -entries[] = $entry; - } - - function getEntry() { - $entry = each($this->entries); - if ($entry) { - return $entry['value']; - } else { - reset($this->entries); - return false; - } - } -} - -class MonthPayload_Decorator extends Calendar_Decorator -{ - //Calendar engine - var $cE; - var $tableHelper; - - var $year; - var $month; - var $firstDay = false; - - function build($events=array()) - { - require_once CALENDAR_ROOT . 'Day.php'; - require_once CALENDAR_ROOT . 'Table/Helper.php'; - - $this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay); - $this->cE = & $this->getEngine(); - $this->year = $this->thisYear(); - $this->month = $this->thisMonth(); - - $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); - for ($i=1; $i<=$daysInMonth; $i++) { - $Day = new Calendar_Day(2000,1,1); // Create Day with dummy values - $Day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $i)); - $this->children[$i] = new DiaryEvent($Day); - } - if (count($events) > 0) { - $this->setSelection($events); - } - Calendar_Month_Weekdays::buildEmptyDaysBefore(); - Calendar_Month_Weekdays::shiftDays(); - Calendar_Month_Weekdays::buildEmptyDaysAfter(); - Calendar_Month_Weekdays::setWeekMarkers(); - return true; - } - - function setSelection($events) - { - $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); - for ($i=1; $i<=$daysInMonth; $i++) { - $stamp1 = $this->cE->dateToStamp($this->year, $this->month, $i); - $stamp2 = $this->cE->dateToStamp($this->year, $this->month, $i+1); - foreach ($events as $event) { - if (($stamp1 >= $event['start'] && $stamp1 < $event['end']) || - ($stamp2 >= $event['start'] && $stamp2 < $event['end']) || - ($stamp1 <= $event['start'] && $stamp2 > $event['end']) - ) { - $this->children[$i]->addEntry($event); - $this->children[$i]->setSelected(); - } - } - } - } - - function fetch() - { - $child = each($this->children); - if ($child) { - return $child['value']; - } else { - reset($this->children); - return false; - } - } -} - -// Calendar instance used to get the dates in the preferred format: -// you can switch Calendar Engine and the example still works -$cal = new Calendar; - -$events = array(); -//add some events -$events[] = array( - 'start' => $cal->cE->dateToStamp(2004, 6, 1, 10), - 'end' => $cal->cE->dateToStamp(2004, 6, 1, 12), - 'desc' => 'Important meeting' -); -$events[] = array( - 'start' => $cal->cE->dateToStamp(2004, 6, 1, 21), - 'end' => $cal->cE->dateToStamp(2004, 6, 1, 23, 59), - 'desc' => 'Dinner with the boss' -); -$events[] = array( - 'start' => $cal->cE->dateToStamp(2004, 6, 5), - 'end' => $cal->cE->dateToStamp(2004, 6, 10, 23, 59), - 'desc' => 'Holidays!' -); - - - -$Month = & new Calendar_Month_Weekdays(2004, 6); -$MonthDecorator = new MonthPayload_Decorator($Month); -$MonthDecorator->build($events); - -?> - - - - Calendar - - - - - -

Sample Calendar Payload Decorator (using engine)

- - - - - - - - - - - -fetch()) { - - if ($Day->isFirst()) { - echo "\n"; - } - - echo ''; - - if ($Day->isLast()) { - echo "\n"; - } -} -?> -
- thisMonth().' / '.$MonthDecorator->thisYear(); ?> -
MondayTuesdayWednesdayThursdayFridaySaturdaySunday
'; - echo '
'.$Day->thisDay().'
'; - - if ($Day->isEmpty()) { - echo ' '; - } else { - echo '
    '; - while ($entry = $Day->getEntry()) { - echo '
  • '.$entry['desc'].'
  • '; - //you can print the time range as well - } - echo '
'; - } - echo '
- - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/21.php b/data/module/Calendar/docs/examples/21.php deleted file mode 100644 index 122b9760a4c..00000000000 --- a/data/module/Calendar/docs/examples/21.php +++ /dev/null @@ -1,139 +0,0 @@ -build(); -?> - - - - <?php echo $Year->thisYear(); ?> - - - - - -fetch()) { - - switch ($i) { - case 0: - echo "\n"; - break; - case 3: - case 6: - case 9: - echo "\n\n"; - break; - case 12: - echo "\n"; - break; - } - - echo "\n"; - - $i++; -} -?> -
-thisYear(); ?> - - - -
\n\n"; - echo ''; - echo ''."\n"; - echo "\n\n"; - $Month->build(); - while ($Week = $Month->fetch()) { - echo "\n"; - echo '\n"; - $Week->build(); - - while ($Day = $Week->fetch()) { - if ($Day->isEmpty()) { - echo "\n"; - } else { - echo "\n"; - } - } - } - echo "
'.date('F', $Month->thisMonth(TRUE)).'
WeekMTWTFSS
'.$Week->thisWeek($_GET['week_type'])." ".$Day->thisDay()."
\n
-

Took:

- - diff --git a/data/module/Calendar/docs/examples/21.phps b/data/module/Calendar/docs/examples/21.phps deleted file mode 100644 index 5dbd21b991c..00000000000 --- a/data/module/Calendar/docs/examples/21.phps +++ /dev/null @@ -1,139 +0,0 @@ -build(); -?> - - - - <?php echo $Year->thisYear(); ?> - - - - - -fetch()) { - - switch ($i) { - case 0: - echo "\n"; - break; - case 3: - case 6: - case 9: - echo "\n\n"; - break; - case 12: - echo "\n"; - break; - } - - echo "\n"; - - $i++; -} -?> -
-thisYear(); ?> - - - -
\n\n"; - echo ''; - echo ''."\n"; - echo "\n\n"; - $Month->build(); - while ($Week = $Month->fetch()) { - echo "\n"; - echo '\n"; - $Week->build(); - - while ($Day = $Week->fetch()) { - if ($Day->isEmpty()) { - echo "\n"; - } else { - echo "\n"; - } - } - } - echo "
'.date('F', $Month->thisMonth(TRUE)).'
WeekMTWTFSS
'.$Week->thisWeek($_GET['week_type'])." ".$Day->thisDay()."
\n
-

Took:

- - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/22.php b/data/module/Calendar/docs/examples/22.php deleted file mode 100644 index a4f86eb8124..00000000000 --- a/data/module/Calendar/docs/examples/22.php +++ /dev/null @@ -1,46 +0,0 @@ -The current month is ' - .$Calendar->thisMonth().' of year '.$Calendar->thisYear().'

'); - -$Uri = & new Calendar_Util_Uri('jahr','monat'); -$Uri->setFragments('jahr','monat'); - -echo "\"Vector\" URIs
";
-echo ( "Previous Uri:\t".htmlentities($Uri->prev($Calendar, 'month'))."\n" );
-echo ( "This Uri:\t".htmlentities($Uri->this($Calendar,  'month'))."\n" );
-echo ( "Next Uri:\t".htmlentities($Uri->next($Calendar, 'month'))."\n" );
-echo "
"; - -// Switch to scalar URIs -$Uri->separator = '/'; // Default is & -$Uri->scalar = true; // Omit variable names - -echo "\"Scalar\" URIs
";
-echo ( "Previous Uri:\t".$Uri->prev($Calendar, 'month')."\n" );
-echo ( "This Uri:\t".$Uri->this($Calendar,  'month')."\n" );
-echo ( "Next Uri:\t".$Uri->next($Calendar, 'month')."\n" );
-echo "
"; - -// Restore the vector URIs -$Uri->separator = '&'; -$Uri->scalar = false; -?> -

-Prev : -Next -

diff --git a/data/module/Calendar/docs/examples/22.phps b/data/module/Calendar/docs/examples/22.phps deleted file mode 100644 index 55f726374f8..00000000000 --- a/data/module/Calendar/docs/examples/22.phps +++ /dev/null @@ -1,46 +0,0 @@ -The current month is ' - .$Calendar->thisMonth().' of year '.$Calendar->thisYear().'

'); - -$Uri = & new Calendar_Util_Uri('jahr','monat'); -$Uri->setFragments('jahr','monat'); - -echo "\"Vector\" URIs
";
-echo ( "Previous Uri:\t".htmlentities($Uri->prev($Calendar, 'month'))."\n" );
-echo ( "This Uri:\t".htmlentities($Uri->this($Calendar,  'month'))."\n" );
-echo ( "Next Uri:\t".htmlentities($Uri->next($Calendar, 'month'))."\n" );
-echo "
"; - -// Switch to scalar URIs -$Uri->separator = '/'; // Default is & -$Uri->scalar = true; // Omit variable names - -echo "\"Scalar\" URIs
";
-echo ( "Previous Uri:\t".$Uri->prev($Calendar, 'month')."\n" );
-echo ( "This Uri:\t".$Uri->this($Calendar,  'month')."\n" );
-echo ( "Next Uri:\t".$Uri->next($Calendar, 'month')."\n" );
-echo "
"; - -// Restore the vector URIs -$Uri->separator = '&'; -$Uri->scalar = false; -?> -

-Prev : -Next -

\ No newline at end of file diff --git a/data/module/Calendar/docs/examples/23.php b/data/module/Calendar/docs/examples/23.php deleted file mode 100644 index 28e3a26edb8..00000000000 --- a/data/module/Calendar/docs/examples/23.php +++ /dev/null @@ -1,66 +0,0 @@ -Calling: Calendar_Util_Textual::monthNames('long');
";
-print_r(Calendar_Util_Textual::monthNames('long'));
-echo '
'; - -echo "
Calling: Calendar_Util_Textual::weekdayNames('two');
";
-print_r(Calendar_Util_Textual::weekdayNames('two'));
-echo '
'; - -echo "
Creating: new Calendar_Day(date('Y'), date('n'), date('d'));
"; -$Calendar = new Calendar_Day(date('Y'), date('n'), date('d')); - -echo '
Previous month is: '.Calendar_Util_Textual::prevMonthName($Calendar,'two').'
'; -echo 'This month is: '.Calendar_Util_Textual::thisMonthName($Calendar,'short').'
'; -echo 'Next month is: '.Calendar_Util_Textual::nextMonthName($Calendar).'

'; -echo 'Previous day is: '.Calendar_Util_Textual::prevDayName($Calendar).'
'; -echo 'This day is: '.Calendar_Util_Textual::thisDayName($Calendar,'short').'
'; -echo 'Next day is: '.Calendar_Util_Textual::nextDayName($Calendar,'one').'

'; - -echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week
"; -$Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - -?> -

Rendering calendar....

- - - -'.$dayheader.''; -} -?> - -build(); -while ($Day = $Calendar->fetch()) { - if ($Day->isFirst()) { - echo "\n"; - } - if ($Day->isEmpty()) { - echo ''; - } else { - echo ''; - } - if ($Day->isLast()) { - echo "\n"; - } -} -?> -
thisYear(); ?>
 '.$Day->thisDay().'
diff --git a/data/module/Calendar/docs/examples/23.phps b/data/module/Calendar/docs/examples/23.phps deleted file mode 100644 index 6fb453fbc87..00000000000 --- a/data/module/Calendar/docs/examples/23.phps +++ /dev/null @@ -1,66 +0,0 @@ -Calling: Calendar_Util_Textual::monthNames('long');
";
-print_r(Calendar_Util_Textual::monthNames('long'));
-echo '
'; - -echo "
Calling: Calendar_Util_Textual::weekdayNames('two');
";
-print_r(Calendar_Util_Textual::weekdayNames('two'));
-echo '
'; - -echo "
Creating: new Calendar_Day(date('Y'), date('n'), date('d'));
"; -$Calendar = new Calendar_Day(date('Y'), date('n'), date('d')); - -echo '
Previous month is: '.Calendar_Util_Textual::prevMonthName($Calendar,'two').'
'; -echo 'This month is: '.Calendar_Util_Textual::thisMonthName($Calendar,'short').'
'; -echo 'Next month is: '.Calendar_Util_Textual::nextMonthName($Calendar).'

'; -echo 'Previous day is: '.Calendar_Util_Textual::prevDayName($Calendar).'
'; -echo 'This day is: '.Calendar_Util_Textual::thisDayName($Calendar,'short').'
'; -echo 'Next day is: '.Calendar_Util_Textual::nextDayName($Calendar,'one').'

'; - -echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week
"; -$Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - -?> -

Rendering calendar....

- - - -'.$dayheader.''; -} -?> - -build(); -while ($Day = $Calendar->fetch()) { - if ($Day->isFirst()) { - echo "\n"; - } - if ($Day->isEmpty()) { - echo ''; - } else { - echo ''; - } - if ($Day->isLast()) { - echo "\n"; - } -} -?> -
thisYear(); ?>
 '.$Day->thisDay().'
\ No newline at end of file diff --git a/data/module/Calendar/docs/examples/3.php b/data/module/Calendar/docs/examples/3.php deleted file mode 100644 index c8924c3ea30..00000000000 --- a/data/module/Calendar/docs/examples/3.php +++ /dev/null @@ -1,134 +0,0 @@ -prevMonth('object'); // Get previous month as object -$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay(); -$NMonth = $Month->nextMonth('object'); -$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay(); -?> - - - - Calendar - - - - - -build($selectedDays); -?> -

Built with Calendar_Month_Weekday::build()

- - - - - - - - - - - -fetch() ) { - - // Build a link string for each day - $link = $_SERVER['PHP_SELF']. - '?y='.$Day->thisYear(). - '&m='.$Day->thisMonth(). - '&d='.$Day->thisDay(); - - // isFirst() to find start of week - if ( $Day->isFirst() ) - echo ( "\n" ); - - if ( $Day->isSelected() ) { - echo ( "\n" ); - } else if ( $Day->isEmpty() ) { - echo ( "\n" ); - } else { - echo ( "\n" ); - } - - // isLast() to find end of week - if ( $Day->isLast() ) - echo ( "\n" ); -} -?> - - - - - -
-getTimeStamp())); ?> -
MTWTFSS
".$Day->thisDay()." ".$Day->thisDay()."
-<< -  - >> -
-Took: '.(getmicrotime()-$start).' seconds

' ); -?> - - diff --git a/data/module/Calendar/docs/examples/3.phps b/data/module/Calendar/docs/examples/3.phps deleted file mode 100644 index 7dd1d805d8a..00000000000 --- a/data/module/Calendar/docs/examples/3.phps +++ /dev/null @@ -1,134 +0,0 @@ -prevMonth('object'); // Get previous month as object -$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay(); -$NMonth = $Month->nextMonth('object'); -$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay(); -?> - - - - Calendar - - - - - -build($selectedDays); -?> -

Built with Calendar_Month_Weekday::build()

- - - - - - - - - - - -fetch() ) { - - // Build a link string for each day - $link = $_SERVER['PHP_SELF']. - '?y='.$Day->thisYear(). - '&m='.$Day->thisMonth(). - '&d='.$Day->thisDay(); - - // isFirst() to find start of week - if ( $Day->isFirst() ) - echo ( "\n" ); - - if ( $Day->isSelected() ) { - echo ( "\n" ); - } else if ( $Day->isEmpty() ) { - echo ( "\n" ); - } else { - echo ( "\n" ); - } - - // isLast() to find end of week - if ( $Day->isLast() ) - echo ( "\n" ); -} -?> - - - - - -
-getTimeStamp())); ?> -
MTWTFSS
".$Day->thisDay()." ".$Day->thisDay()."
-<< -  - >> -
-Took: '.(getmicrotime()-$start).' seconds

' ); -?> - - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/4.php b/data/module/Calendar/docs/examples/4.php deleted file mode 100644 index 0cd6b280ffe..00000000000 --- a/data/module/Calendar/docs/examples/4.php +++ /dev/null @@ -1,49 +0,0 @@ -Result: '.$Unit->thisYear().'-'.$Unit->thisMonth().'-'.$Unit->thisDay(). - ' '.$Unit->thisHour().':'.$Unit->thisMinute().':'.$Unit->thisSecond(); -if ($Unit->isValid()) { - echo ' is valid!

'; -} else { - $V= & $Unit->getValidator(); - echo ' is invalid:

'; - while ($error = $V->fetch()) { - echo $error->toString() .'
'; - } -} -?> -

Enter a date / time to validate:

-
-Year:
-Month:
-Day:
-Hour:
-Minute:
-Second:
- -
-

Note: Error messages can be controlled with the constants CALENDAR_VALUE_TOOSMALL and CALENDAR_VALUE_TOOLARGE - see Calendar_Validator.php

- -Took: '.(getmicrotime()-$start).' seconds

'; ?> diff --git a/data/module/Calendar/docs/examples/4.phps b/data/module/Calendar/docs/examples/4.phps deleted file mode 100644 index 71e2844cf86..00000000000 --- a/data/module/Calendar/docs/examples/4.phps +++ /dev/null @@ -1,49 +0,0 @@ -Result: '.$Unit->thisYear().'-'.$Unit->thisMonth().'-'.$Unit->thisDay(). - ' '.$Unit->thisHour().':'.$Unit->thisMinute().':'.$Unit->thisSecond(); -if ($Unit->isValid()) { - echo ' is valid!

'; -} else { - $V= & $Unit->getValidator(); - echo ' is invalid:

'; - while ($error = $V->fetch()) { - echo $error->toString() .'
'; - } -} -?> -

Enter a date / time to validate:

-
-Year:
-Month:
-Day:
-Hour:
-Minute:
-Second:
- -
-

Note: Error messages can be controlled with the constants CALENDAR_VALUE_TOOSMALL and CALENDAR_VALUE_TOOLARGE - see Calendar_Validator.php

- -Took: '.(getmicrotime()-$start).' seconds

'; ?> \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/5.php b/data/module/Calendar/docs/examples/5.php deleted file mode 100644 index 1352907b421..00000000000 --- a/data/module/Calendar/docs/examples/5.php +++ /dev/null @@ -1,132 +0,0 @@ - - - - - Select and Update - - -

Select and Update

-isValid() ) { - $V= & $Second->getValidator(); - echo ('

Validation failed:

' ); - while ( $error = $V->fetch() ) { - echo ( $error->toString() .'
' ); - } - } else { - echo ('

Validation success.

' ); - echo ( '

New timestamp is: '.$Second->getTimeStamp().' which could be used to update a database, for example'); - } -} else { -$Year = new Calendar_Year($_POST['y']); -$Month = new Calendar_Month($_POST['y'],$_POST['m']); -$Day = new Calendar_Day($_POST['y'],$_POST['m'],$_POST['d']); -$Hour = new Calendar_Hour($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h']); -$Minute = new Calendar_Minute($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i']); -$Second = new Calendar_Second($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i'],$_POST['s']); -?> -

Set the alarm clock

-
-Year:   -Month:  -Day:  -Hour:  -Minute:  -Second:  -
- -Took: '.(getmicrotime()-$start).' seconds

' ); ?> - - diff --git a/data/module/Calendar/docs/examples/5.phps b/data/module/Calendar/docs/examples/5.phps deleted file mode 100644 index db6f1087f29..00000000000 --- a/data/module/Calendar/docs/examples/5.phps +++ /dev/null @@ -1,132 +0,0 @@ - - - - - Select and Update - - -

Select and Update

-isValid() ) { - $V= & $Second->getValidator(); - echo ('

Validation failed:

' ); - while ( $error = $V->fetch() ) { - echo ( $error->toString() .'
' ); - } - } else { - echo ('

Validation success.

' ); - echo ( '

New timestamp is: '.$Second->getTimeStamp().' which could be used to update a database, for example'); - } -} else { -$Year = new Calendar_Year($_POST['y']); -$Month = new Calendar_Month($_POST['y'],$_POST['m']); -$Day = new Calendar_Day($_POST['y'],$_POST['m'],$_POST['d']); -$Hour = new Calendar_Hour($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h']); -$Minute = new Calendar_Minute($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i']); -$Second = new Calendar_Second($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i'],$_POST['s']); -?> -

Set the alarm clock

- -Year:   -Month:  -Day:  -Hour:  -Minute:  -Second:  -
- -Took: '.(getmicrotime()-$start).' seconds

' ); ?> - - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/6.php b/data/module/Calendar/docs/examples/6.php deleted file mode 100644 index 53e7fdccfd7..00000000000 --- a/data/module/Calendar/docs/examples/6.php +++ /dev/null @@ -1,210 +0,0 @@ -' ); -?> - - -Personal Planner Rendered with WML - -

Viewing getTimeStamp()) ); ?>

-

- -Back to Month View -"/> - -

- -build(); - while ( $Hour = & $Day->fetch() ) { - echo ( "\n" ); - echo ( "\n" ); - echo ( "\n" ); - } -?> -
".date('g a',$Hour->getTimeStamp())."Free time!
- -

getTimeStamp()) ); ?>

- - - - -build($selection); -while ( $Day = $Month->fetch() ) { - if ( $Day->isFirst() ) { - echo ( "\n" ); - } - if ( $Day->isEmpty() ) { - echo ( "\n" ); - } else if ( $Day->isSelected() ) { - echo ( "\n" ); - } else { - echo ( "\n" ); - } - if ( $Day->isLast() ) { - echo ( "\n" ); - } -} -?> - - - - - -
MTWTFSS
".$Day->thisDay()."\nthisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay(). - "&mime=wml\" />\n".$Day->thisDay()."\nthisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay(). - "&mime=wml\" />
- -<< -"/> - - - ->> -"/> - -
- - -

Back to HTML

-Took: '.(getmicrotime()-$start).' seconds

' ); ?> -
- - - - - HTML (+WML) Personal Planner - - -

Personal Planner Rendered with HTML

-

To view in WML, click here or place a ?mime=wml at the end of any URL. -Note that Opera supports WML natively and Mozilla / Firefox has the WMLBrowser -plugin: wmlbrowser.mozdev.org

- -

Viewing getTimeStamp()) ); ?>

-

- -Back to Month View -

- -build(); - while ( $Hour = & $Day->fetch() ) { - echo ( "\n" ); - echo ( "\n" ); - echo ( "\n" ); - } -?> -
".date('g a',$Hour->getTimeStamp())."Free time!
- -

getTimeStamp()) ); ?>

- - - - -build($selection); -while ( $Day = $Month->fetch() ) { - if ( $Day->isFirst() ) { - echo ( "\n" ); - } - if ( $Day->isEmpty() ) { - echo ( "\n" ); - } else if ( $Day->isSelected() ) { - echo ( "\n" ); - } else { - echo ( "\n" ); - } - if ( $Day->isLast() ) { - echo ( "\n" ); - } -} -?> - - - - - -
MTWTFSS
thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay(). - "&wml\">".$Day->thisDay()."thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay(). - "\">".$Day->thisDay()."
- -<< - ->> -
- - - - -Took: '.(getmicrotime()-$start).' seconds

' ); ?> - - - diff --git a/data/module/Calendar/docs/examples/6.phps b/data/module/Calendar/docs/examples/6.phps deleted file mode 100644 index 77d9caba3f3..00000000000 --- a/data/module/Calendar/docs/examples/6.phps +++ /dev/null @@ -1,210 +0,0 @@ -' ); -?> - - -Personal Planner Rendered with WML - -

Viewing getTimeStamp()) ); ?>

-

- -Back to Month View -"/> - -

- -build(); - while ( $Hour = & $Day->fetch() ) { - echo ( "\n" ); - echo ( "\n" ); - echo ( "\n" ); - } -?> -
".date('g a',$Hour->getTimeStamp())."Free time!
- -

getTimeStamp()) ); ?>

- - - - -build($selection); -while ( $Day = $Month->fetch() ) { - if ( $Day->isFirst() ) { - echo ( "\n" ); - } - if ( $Day->isEmpty() ) { - echo ( "\n" ); - } else if ( $Day->isSelected() ) { - echo ( "\n" ); - } else { - echo ( "\n" ); - } - if ( $Day->isLast() ) { - echo ( "\n" ); - } -} -?> - - - - - -
MTWTFSS
".$Day->thisDay()."\nthisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay(). - "&mime=wml\" />\n".$Day->thisDay()."\nthisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay(). - "&mime=wml\" />
- -<< -"/> - - - ->> -"/> - -
- - -

Back to HTML

-Took: '.(getmicrotime()-$start).' seconds

' ); ?> -
- - - - - HTML (+WML) Personal Planner - - -

Personal Planner Rendered with HTML

-

To view in WML, click here or place a ?mime=wml at the end of any URL. -Note that Opera supports WML natively and Mozilla / Firefox has the WMLBrowser -plugin: wmlbrowser.mozdev.org

- -

Viewing getTimeStamp()) ); ?>

-

- -Back to Month View -

- -build(); - while ( $Hour = & $Day->fetch() ) { - echo ( "\n" ); - echo ( "\n" ); - echo ( "\n" ); - } -?> -
".date('g a',$Hour->getTimeStamp())."Free time!
- -

getTimeStamp()) ); ?>

- - - - -build($selection); -while ( $Day = $Month->fetch() ) { - if ( $Day->isFirst() ) { - echo ( "\n" ); - } - if ( $Day->isEmpty() ) { - echo ( "\n" ); - } else if ( $Day->isSelected() ) { - echo ( "\n" ); - } else { - echo ( "\n" ); - } - if ( $Day->isLast() ) { - echo ( "\n" ); - } -} -?> - - - - - -
MTWTFSS
thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay(). - "&wml\">".$Day->thisDay()."thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay(). - "\">".$Day->thisDay()."
- -<< - ->> -
- - - - -Took: '.(getmicrotime()-$start).' seconds

' ); ?> - - - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/7.php b/data/module/Calendar/docs/examples/7.php deleted file mode 100644 index 83057e645be..00000000000 --- a/data/module/Calendar/docs/examples/7.php +++ /dev/null @@ -1,92 +0,0 @@ -__dispatch_map['getMonth'] = - array('in' => array('year' => 'int', 'month'=>'int'), - 'out' => array('month' => '{urn:PEAR_SOAP_Calendar}Month'), - ); - $this->__typedef['Month'] = array ( - 'monthname' => 'string', - 'days' => '{urn:PEAR_SOAP_Calendar}MonthDays' - ); - $this->__typedef['MonthDays'] = array (array ('{urn:PEAR_SOAP_Calendar}Day')); - $this->__typedef['Day'] = array ( - 'isFirst' => 'int', - 'isLast' => 'int', - 'isEmpty' => 'int', - 'day' => 'int' ); - } - - function __dispatch($methodname) - { - if (isset($this->__dispatch_map[$methodname])) - return $this->__dispatch_map[$methodname]; - return NULL; - } - - function getMonth($year, $month) - { - require_once(CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php'); - $Month = & new Calendar_Month_Weekdays($year,$month); - if (!$Month->isValid()) { - $V = & $Month->getValidator(); - $errorMsg = ''; - while ($error = $V->fetch()) { - $errorMsg .= $error->toString()."\n"; - } - return new SOAP_Fault($errorMsg, 'Client'); - } else { - $monthname = date('F Y', $Month->getTimeStamp()); - $days = array(); - $Month->build(); - while ($Day = & $Month->fetch()) { - $day = array( - 'isFirst' => (int)$Day->isFirst(), - 'isLast' => (int)$Day->isLast(), - 'isEmpty' => (int)$Day->isEmpty(), - 'day' => (int)$Day->thisDay(), - ); - $days[] = $day; - } - return array('monthname' => $monthname, 'days' => $days); - } - } -} - -$server = new SOAP_Server(); -$server->_auto_translation = true; -$calendar = new Calendar_Server(); -$server->addObjectMap($calendar, 'urn:PEAR_SOAP_Calendar'); - -if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') { - $server->service($GLOBALS['HTTP_RAW_POST_DATA']); -} else { - require_once 'SOAP'.DIRECTORY_SEPARATOR.'Disco.php'; - $disco = new SOAP_DISCO_Server($server, "PEAR_SOAP_Calendar"); - if (isset($_SERVER['QUERY_STRING']) && - strcasecmp($_SERVER['QUERY_STRING'], 'wsdl')==0) { - header("Content-type: text/xml"); - echo $disco->getWSDL(); - } else { - echo 'This is a PEAR::SOAP Calendar Server. For client try here
'; - echo 'For WSDL try here'; - } - exit; -} -?> diff --git a/data/module/Calendar/docs/examples/7.phps b/data/module/Calendar/docs/examples/7.phps deleted file mode 100644 index 5d527ffdf4b..00000000000 --- a/data/module/Calendar/docs/examples/7.phps +++ /dev/null @@ -1,92 +0,0 @@ -__dispatch_map['getMonth'] = - array('in' => array('year' => 'int', 'month'=>'int'), - 'out' => array('month' => '{urn:PEAR_SOAP_Calendar}Month'), - ); - $this->__typedef['Month'] = array ( - 'monthname' => 'string', - 'days' => '{urn:PEAR_SOAP_Calendar}MonthDays' - ); - $this->__typedef['MonthDays'] = array (array ('{urn:PEAR_SOAP_Calendar}Day')); - $this->__typedef['Day'] = array ( - 'isFirst' => 'int', - 'isLast' => 'int', - 'isEmpty' => 'int', - 'day' => 'int' ); - } - - function __dispatch($methodname) - { - if (isset($this->__dispatch_map[$methodname])) - return $this->__dispatch_map[$methodname]; - return NULL; - } - - function getMonth($year, $month) - { - require_once(CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php'); - $Month = & new Calendar_Month_Weekdays($year,$month); - if (!$Month->isValid()) { - $V = & $Month->getValidator(); - $errorMsg = ''; - while ($error = $V->fetch()) { - $errorMsg .= $error->toString()."\n"; - } - return new SOAP_Fault($errorMsg, 'Client'); - } else { - $monthname = date('F Y', $Month->getTimeStamp()); - $days = array(); - $Month->build(); - while ($Day = & $Month->fetch()) { - $day = array( - 'isFirst' => (int)$Day->isFirst(), - 'isLast' => (int)$Day->isLast(), - 'isEmpty' => (int)$Day->isEmpty(), - 'day' => (int)$Day->thisDay(), - ); - $days[] = $day; - } - return array('monthname' => $monthname, 'days' => $days); - } - } -} - -$server = new SOAP_Server(); -$server->_auto_translation = true; -$calendar = new Calendar_Server(); -$server->addObjectMap($calendar, 'urn:PEAR_SOAP_Calendar'); - -if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') { - $server->service($GLOBALS['HTTP_RAW_POST_DATA']); -} else { - require_once 'SOAP'.DIRECTORY_SEPARATOR.'Disco.php'; - $disco = new SOAP_DISCO_Server($server, "PEAR_SOAP_Calendar"); - if (isset($_SERVER['QUERY_STRING']) && - strcasecmp($_SERVER['QUERY_STRING'], 'wsdl')==0) { - header("Content-type: text/xml"); - echo $disco->getWSDL(); - } else { - echo 'This is a PEAR::SOAP Calendar Server. For client try here
'; - echo 'For WSDL try here'; - } - exit; -} -?> \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/8.php b/data/module/Calendar/docs/examples/8.php deleted file mode 100644 index 50babb1121b..00000000000 --- a/data/module/Calendar/docs/examples/8.php +++ /dev/null @@ -1,70 +0,0 @@ -") ) { - die('PHP 5 has problems with PEAR::SOAP Client (8.0RC3) - - remove @ before include below to see why'); -} - -if (!@include('SOAP'.DIRECTORY_SEPARATOR.'Client.php')) { - die('You must have PEAR::SOAP installed'); -} - -// Just to save manaul modification... -$basePath = explode('/', $_SERVER['SCRIPT_NAME']); -array_pop($basePath); -$basePath = implode('/', $basePath); -$url = 'http://'.$_SERVER['SERVER_NAME'].$basePath.'/7.php?wsdl'; - -if (!isset($_GET['y'])) $_GET['y'] = date('Y'); -if (!isset($_GET['m'])) $_GET['m'] = date('n'); - -$wsdl = new SOAP_WSDL ($url); - -echo ( '
'.$wsdl->generateProxyCode().'
' ); - -$calendarClient = $wsdl->getProxy(); - -$month = $calendarClient->getMonth((int)$_GET['y'],(int)$_GET['m']); - -if ( PEAR::isError($month) ) { - die ( $month->toString() ); -} -?> - - - - Calendar over the Wire - - -

Calendar Over the Wire (featuring PEAR::SOAP)

- - - - - -days as $day ) { - - if ( $day->isFirst === 1 ) - echo ( "\n" ); - if ( $day->isEmpty === 1 ) { - echo ( "" ); - } else { - echo ( "" ); - } - if ( $day->isLast === 1 ) - echo ( "\n" ); -} -?> - -
monthname );?>
MTWTFSS
".$day->day."
-

Enter Year and Month to View:

- -Year:   -Month:   - - - - diff --git a/data/module/Calendar/docs/examples/8.phps b/data/module/Calendar/docs/examples/8.phps deleted file mode 100644 index ada622ce799..00000000000 --- a/data/module/Calendar/docs/examples/8.phps +++ /dev/null @@ -1,70 +0,0 @@ -") ) { - die('PHP 5 has problems with PEAR::SOAP Client (8.0RC3) - - remove @ before include below to see why'); -} - -if (!@include('SOAP'.DIRECTORY_SEPARATOR.'Client.php')) { - die('You must have PEAR::SOAP installed'); -} - -// Just to save manaul modification... -$basePath = explode('/', $_SERVER['SCRIPT_NAME']); -array_pop($basePath); -$basePath = implode('/', $basePath); -$url = 'http://'.$_SERVER['SERVER_NAME'].$basePath.'/7.php?wsdl'; - -if (!isset($_GET['y'])) $_GET['y'] = date('Y'); -if (!isset($_GET['m'])) $_GET['m'] = date('n'); - -$wsdl = new SOAP_WSDL ($url); - -echo ( '
'.$wsdl->generateProxyCode().'
' ); - -$calendarClient = $wsdl->getProxy(); - -$month = $calendarClient->getMonth((int)$_GET['y'],(int)$_GET['m']); - -if ( PEAR::isError($month) ) { - die ( $month->toString() ); -} -?> - - - - Calendar over the Wire - - -

Calendar Over the Wire (featuring PEAR::SOAP)

- - - - - -days as $day ) { - - if ( $day->isFirst === 1 ) - echo ( "\n" ); - if ( $day->isEmpty === 1 ) { - echo ( "" ); - } else { - echo ( "" ); - } - if ( $day->isLast === 1 ) - echo ( "\n" ); -} -?> - -
monthname );?>
MTWTFSS
".$day->day."
-

Enter Year and Month to View:

-
-Year:   -Month:   - -
- - \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/9.php b/data/module/Calendar/docs/examples/9.php deleted file mode 100644 index 9db100ade55..00000000000 --- a/data/module/Calendar/docs/examples/9.php +++ /dev/null @@ -1,16 +0,0 @@ -getTimeStamp())); -?> diff --git a/data/module/Calendar/docs/examples/9.phps b/data/module/Calendar/docs/examples/9.phps deleted file mode 100644 index 01cfa7e8c63..00000000000 --- a/data/module/Calendar/docs/examples/9.phps +++ /dev/null @@ -1,16 +0,0 @@ -getTimeStamp())); -?> \ No newline at end of file diff --git a/data/module/Calendar/docs/examples/index.html b/data/module/Calendar/docs/examples/index.html deleted file mode 100644 index ace67856a55..00000000000 --- a/data/module/Calendar/docs/examples/index.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - PEAR::Calendar Examples - - - - -

PEAR::Calendar Examples

-

$Id: index.html,v 1.6 2004/08/17 09:10:53 hfuecks Exp $

-
    -
  • 1.php [src] - shows basic usage, passing all the way down from Calendar_Year to Calendar_Second - more of a quick test it's working
  • -
  • 2.php [src] - shows how to build a tabular month using Calendar_Month_Weeks, Calendar_Week, Calendar_Day as well as selecting some dates.
  • -
  • 3.php [src] - shows how to build a tabular month using Calendar_Month_Weekdays and Calendar_Day, as well as selecting some dates (this method is faster).
  • -
  • 4.php [src] - shows how to use PEAR::Calendar for validation.
  • -
  • 5.php [src] - shows PEAR::Calendar in use to help generate a form.
  • -
  • 6.php [src] - a month and day "planner" calendar, which can be rendered both as HTML and WML.
  • -
  • 7.php [src] - a simple SOAP Calendar Server, using PEAR::SOAP and PEAR::Calendar
  • -
  • 8.php [src] - a WSDL SOAP client for the SOAP Calendar Server
  • -
  • 9.php [src] - quick example of i18n with setlocale (not working on SF)
  • -
  • 10.php [src] - an example of extending Calendar_Decorator to modify output
  • -
  • 11.php [src] - attaching a "payload" (e.g. results of a DB query) to a calendar using Calendar_Decorator to allow the payload to be available inside the main loop.
  • -
  • 12.php [src] - a complete year with months.
  • -
  • 13.php [src] - same as 1.php but using Calendar_Engine_PearDate, (see PEAR::Date).
  • -
  • 14.php [src] - same as 3.php but using Calendar_Engine_PearDate
  • -
  • 15.php [src] - paging through weeks
  • -
  • 16.php [src] - example of Calendar_Decorator_Uri. Note you should prefer Calendar_Util_Uri (see below) in most cases, for performance
  • -
  • 17.php [src] - example of Calendar_Decorator_Textual. Note you should prefer Calendar_Util_Textual (see below) in most cases, for performance
  • -
  • 18.php [src] - example of Calendar_Decorator_Wrapper.
  • -
  • 19.php [src] - example of Calendar_Decorator_Weekday.
  • -
  • 20.php [src] - shows how to attach a "payload" spanning multiple days, with more than one entry per day
  • -
  • 21.php [src] - same as 12.php but using Calendar_Month_Weeks instead of Calendar_Month_Weekdays to allow the week in the year or week in the month to be displayed.
  • -
  • 22.php [src] - demonstrates use of Calendar_Util_Uri.
  • -
  • 23.php [src] - demonstrates use of Calendar_Util_Textual.
  • -
  • 24.php [src] - Calendar_Decorator_Weekday combined with Calendar_Decorator_Wrapper to decorate days in the month.
  • -
- - \ No newline at end of file diff --git a/data/module/Calendar/tests/README b/data/module/Calendar/tests/README deleted file mode 100644 index ecc755b129d..00000000000 --- a/data/module/Calendar/tests/README +++ /dev/null @@ -1,7 +0,0 @@ -These tests require Simple Test: http://www.lastcraft.com/simple_test.php - -Ideally they would use PEAR::PHPUnit but the current version has bugs and -lacks alot of the functionality (e.g. Mock Objects) which Simple Test -provides. - -Modifying the simple_include.php script for your simple test install dir \ No newline at end of file diff --git a/data/module/Calendar/tests/all_tests.php b/data/module/Calendar/tests/all_tests.php deleted file mode 100644 index 3630a361ee9..00000000000 --- a/data/module/Calendar/tests/all_tests.php +++ /dev/null @@ -1,34 +0,0 @@ -GroupTest('All PEAR::Calendar Tests'); - $this->AddTestCase(new CalendarTests()); - $this->AddTestCase(new CalendarTabularTests()); - $this->AddTestCase(new ValidatorTests()); - $this->AddTestCase(new CalendarEngineTests()); - $this->AddTestCase(new TableHelperTests()); - $this->AddTestCase(new DecoratorTests()); - $this->AddTestCase(new UtilTests()); - } -} - -$test = &new AllTests(); -$test->run(new HtmlReporter()); -?> diff --git a/data/module/Calendar/tests/calendar_engine_tests.php b/data/module/Calendar/tests/calendar_engine_tests.php deleted file mode 100644 index 95e90f18e37..00000000000 --- a/data/module/Calendar/tests/calendar_engine_tests.php +++ /dev/null @@ -1,20 +0,0 @@ -GroupTest('Calendar Engine Tests'); - $this->addTestFile('peardate_engine_test.php'); - $this->addTestFile('unixts_engine_test.php'); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new CalendarEngineTests(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/calendar_include.php b/data/module/Calendar/tests/calendar_include.php deleted file mode 100644 index 285c3c00baf..00000000000 --- a/data/module/Calendar/tests/calendar_include.php +++ /dev/null @@ -1,28 +0,0 @@ - diff --git a/data/module/Calendar/tests/calendar_tabular_tests.php b/data/module/Calendar/tests/calendar_tabular_tests.php deleted file mode 100644 index 850e9d12f72..00000000000 --- a/data/module/Calendar/tests/calendar_tabular_tests.php +++ /dev/null @@ -1,22 +0,0 @@ -GroupTest('Calendar Tabular Tests'); - $this->addTestFile('month_weekdays_test.php'); - $this->addTestFile('month_weeks_test.php'); - $this->addTestFile('week_test.php'); - //$this->addTestFile('week_firstday_0_test.php'); //switch with the above - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new CalendarTabularTests(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/calendar_test.php b/data/module/Calendar/tests/calendar_test.php deleted file mode 100644 index e220f7deda7..00000000000 --- a/data/module/Calendar/tests/calendar_test.php +++ /dev/null @@ -1,115 +0,0 @@ -UnitTestCase($name); - } - function setUp() { - $this->cal = new Calendar(2003,10,25,13,32,43); - } - function tearDown() { - unset($this->cal); - } - function testPrevYear () { - $this->assertEqual(2002,$this->cal->prevYear()); - } - function testPrevYear_Array () { - $this->assertEqual( - array( - 'year' => 2002, - 'month' => 1, - 'day' => 1, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevYear('array')); - } - function testThisYear () { - $this->assertEqual(2003,$this->cal->thisYear()); - } - function testNextYear () { - $this->assertEqual(2004,$this->cal->nextYear()); - } - function testPrevMonth () { - $this->assertEqual(9,$this->cal->prevMonth()); - } - function testPrevMonth_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 9, - 'day' => 1, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevMonth('array')); - } - function testThisMonth () { - $this->assertEqual(10,$this->cal->thisMonth()); - } - function testNextMonth () { - $this->assertEqual(11,$this->cal->nextMonth()); - } - function testPrevDay () { - $this->assertEqual(24,$this->cal->prevDay()); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 10, - 'day' => 24, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } - function testThisDay () { - $this->assertEqual(25,$this->cal->thisDay()); - } - function testNextDay () { - $this->assertEqual(26,$this->cal->nextDay()); - } - function testPrevHour () { - $this->assertEqual(12,$this->cal->prevHour()); - } - function testThisHour () { - $this->assertEqual(13,$this->cal->thisHour()); - } - function testNextHour () { - $this->assertEqual(14,$this->cal->nextHour()); - } - function testPrevMinute () { - $this->assertEqual(31,$this->cal->prevMinute()); - } - function testThisMinute () { - $this->assertEqual(32,$this->cal->thisMinute()); - } - function testNextMinute () { - $this->assertEqual(33,$this->cal->nextMinute()); - } - function testPrevSecond () { - $this->assertEqual(42,$this->cal->prevSecond()); - } - function testThisSecond () { - $this->assertEqual(43,$this->cal->thisSecond()); - } - function testNextSecond () { - $this->assertEqual(44,$this->cal->nextSecond()); - } - function testSetTimeStamp() { - $stamp = mktime(13,32,43,10,25,2003); - $this->cal->setTimeStamp($stamp); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } - function testGetTimeStamp() { - $stamp = mktime(13,32,43,10,25,2003); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } -} -?> diff --git a/data/module/Calendar/tests/calendar_tests.php b/data/module/Calendar/tests/calendar_tests.php deleted file mode 100644 index 44516103ffe..00000000000 --- a/data/module/Calendar/tests/calendar_tests.php +++ /dev/null @@ -1,25 +0,0 @@ -GroupTest('Calendar Tests'); - $this->addTestFile('calendar_test.php'); - $this->addTestFile('year_test.php'); - $this->addTestFile('month_test.php'); - $this->addTestFile('day_test.php'); - $this->addTestFile('hour_test.php'); - $this->addTestFile('minute_test.php'); - $this->addTestFile('second_test.php'); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new CalendarTests(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/day_test.php b/data/module/Calendar/tests/day_test.php deleted file mode 100644 index 729c41d8dc6..00000000000 --- a/data/module/Calendar/tests/day_test.php +++ /dev/null @@ -1,107 +0,0 @@ -UnitTestCase('Test of Day'); - } - function setUp() { - $this->cal = new Calendar_Day(2003,10,25); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 10, - 'day' => 24, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } - function testPrevHour () { - $this->assertEqual(23,$this->cal->prevHour()); - } - function testThisHour () { - $this->assertEqual(0,$this->cal->thisHour()); - } - function testNextHour () { - $this->assertEqual(1,$this->cal->nextHour()); - } - function testPrevMinute () { - $this->assertEqual(59,$this->cal->prevMinute()); - } - function testThisMinute () { - $this->assertEqual(0,$this->cal->thisMinute()); - } - function testNextMinute () { - $this->assertEqual(1,$this->cal->nextMinute()); - } - function testPrevSecond () { - $this->assertEqual(59,$this->cal->prevSecond()); - } - function testThisSecond () { - $this->assertEqual(0,$this->cal->thisSecond()); - } - function testNextSecond () { - $this->assertEqual(1,$this->cal->nextSecond()); - } - function testGetTimeStamp() { - $stamp = mktime(0,0,0,10,25,2003); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } -} - -class TestOfDayBuild extends TestOfDay { - function TestOfDayBuild() { - $this->UnitTestCase('Test of Day::build()'); - } - function testSize() { - $this->cal->build(); - $this->assertEqual(24,$this->cal->size()); - } - function testFetch() { - $this->cal->build(); - $i=0; - while ( $Child = $this->cal->fetch() ) { - $i++; - } - $this->assertEqual(24,$i); - } - function testFetchAll() { - $this->cal->build(); - $children = array(); - $i = 0; - while ( $Child = $this->cal->fetch() ) { - $children[$i]=$Child; - $i++; - } - $this->assertEqual($children,$this->cal->fetchAll()); - } - function testSelection() { - require_once(CALENDAR_ROOT . 'Hour.php'); - $selection = array(new Calendar_Hour(2003,10,25,13)); - $this->cal->build($selection); - $i = 0; - while ( $Child = $this->cal->fetch() ) { - if ( $i == 13 ) - break; - $i++; - } - $this->assertTrue($Child->isSelected()); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfDay(); - $test->run(new HtmlReporter()); - $test = &new TestOfDayBuild(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/decorator_test.php b/data/module/Calendar/tests/decorator_test.php deleted file mode 100644 index c2cbe26936d..00000000000 --- a/data/module/Calendar/tests/decorator_test.php +++ /dev/null @@ -1,268 +0,0 @@ -UnitTestCase('Test of Calendar_Decorator'); - } - function setUp() { - $this->mockengine = new Mock_Calendar_Engine($this); - $this->mockcal = new Mock_Calendar_Second($this); - $this->mockcal->setReturnValue('prevYear',2002); - $this->mockcal->setReturnValue('thisYear',2003); - $this->mockcal->setReturnValue('nextYear',2004); - $this->mockcal->setReturnValue('prevMonth',9); - $this->mockcal->setReturnValue('thisMonth',10); - $this->mockcal->setReturnValue('nextMonth',11); - $this->mockcal->setReturnValue('prevDay',14); - $this->mockcal->setReturnValue('thisDay',15); - $this->mockcal->setReturnValue('nextDay',16); - $this->mockcal->setReturnValue('prevHour',12); - $this->mockcal->setReturnValue('thisHour',13); - $this->mockcal->setReturnValue('nextHour',14); - $this->mockcal->setReturnValue('prevMinute',29); - $this->mockcal->setReturnValue('thisMinute',30); - $this->mockcal->setReturnValue('nextMinute',31); - $this->mockcal->setReturnValue('prevSecond',44); - $this->mockcal->setReturnValue('thisSecond',45); - $this->mockcal->setReturnValue('nextSecond',46); - $this->mockcal->setReturnValue('getEngine',$this->mockengine); - $this->mockcal->setReturnValue('getTimestamp',12345); - - } - function tearDown() { - unset ( $this->engine ); - unset ( $this->mockcal ); - } - function testPrevYear() { - $this->mockcal->expectOnce('prevYear',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(2002,$Decorator->prevYear()); - } - function testThisYear() { - $this->mockcal->expectOnce('thisYear',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(2003,$Decorator->thisYear()); - } - function testNextYear() { - $this->mockcal->expectOnce('nextYear',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(2004,$Decorator->nextYear()); - } - function testPrevMonth() { - $this->mockcal->expectOnce('prevMonth',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(9,$Decorator->prevMonth()); - } - function testThisMonth() { - $this->mockcal->expectOnce('thisMonth',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(10,$Decorator->thisMonth()); - } - function testNextMonth() { - $this->mockcal->expectOnce('nextMonth',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(11,$Decorator->nextMonth()); - } - function testPrevWeek() { - $mockweek = & new Mock_Calendar_Week($this); - $mockweek->setReturnValue('prevWeek',1); - $mockweek->expectOnce('prevWeek',array('n_in_month')); - $Decorator =& new Calendar_Decorator($mockweek); - $this->assertEqual(1,$Decorator->prevWeek()); - } - function testThisWeek() { - $mockweek = & new Mock_Calendar_Week($this); - $mockweek->setReturnValue('thisWeek',2); - $mockweek->expectOnce('thisWeek',array('n_in_month')); - $Decorator =& new Calendar_Decorator($mockweek); - $this->assertEqual(2,$Decorator->thisWeek()); - } - function testNextWeek() { - $mockweek = & new Mock_Calendar_Week($this); - $mockweek->setReturnValue('nextWeek',3); - $mockweek->expectOnce('nextWeek',array('n_in_month')); - $Decorator =& new Calendar_Decorator($mockweek); - $this->assertEqual(3,$Decorator->nextWeek()); - } - function testPrevDay() { - $this->mockcal->expectOnce('prevDay',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(14,$Decorator->prevDay()); - } - function testThisDay() { - $this->mockcal->expectOnce('thisDay',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(15,$Decorator->thisDay()); - } - function testNextDay() { - $this->mockcal->expectOnce('nextDay',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(16,$Decorator->nextDay()); - } - function testPrevHour() { - $this->mockcal->expectOnce('prevHour',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(12,$Decorator->prevHour()); - } - function testThisHour() { - $this->mockcal->expectOnce('thisHour',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(13,$Decorator->thisHour()); - } - function testNextHour() { - $this->mockcal->expectOnce('nextHour',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(14,$Decorator->nextHour()); - } - function testPrevMinute() { - $this->mockcal->expectOnce('prevMinute',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(29,$Decorator->prevMinute()); - } - function testThisMinute() { - $this->mockcal->expectOnce('thisMinute',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(30,$Decorator->thisMinute()); - } - function testNextMinute() { - $this->mockcal->expectOnce('nextMinute',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(31,$Decorator->nextMinute()); - } - function testPrevSecond() { - $this->mockcal->expectOnce('prevSecond',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(44,$Decorator->prevSecond()); - } - function testThisSecond() { - $this->mockcal->expectOnce('thisSecond',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(45,$Decorator->thisSecond()); - } - function testNextSecond() { - $this->mockcal->expectOnce('nextSecond',array('int')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(46,$Decorator->nextSecond()); - } - function testGetEngine() { - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertIsA($Decorator->getEngine(),'Mock_Calendar_Engine'); - } - function testSetTimestamp() { - $this->mockcal->expectOnce('setTimestamp',array('12345')); - $Decorator =& new Calendar_Decorator($this->mockcal); - $Decorator->setTimestamp('12345'); - } - function testGetTimestamp() { - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual(12345,$Decorator->getTimestamp()); - } - function testSetSelected() { - $this->mockcal->expectOnce('setSelected',array(true)); - $Decorator =& new Calendar_Decorator($this->mockcal); - $Decorator->setSelected(); - } - function testIsSelected() { - $this->mockcal->setReturnValue('isSelected',true); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertTrue($Decorator->isSelected()); - } - function testAdjust() { - $this->mockcal->expectOnce('adjust',array()); - $Decorator =& new Calendar_Decorator($this->mockcal); - $Decorator->adjust(); - } - function testToArray() { - $this->mockcal->expectOnce('toArray',array(12345)); - $testArray = array('foo'=>'bar'); - $this->mockcal->setReturnValue('toArray',$testArray); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual($testArray,$Decorator->toArray(12345)); - } - function testReturnValue() { - $this->mockcal->expectOnce('returnValue',array('a','b','c','d')); - $this->mockcal->setReturnValue('returnValue','foo'); - $Decorator =& new Calendar_Decorator($this->mockcal); - $this->assertEqual('foo',$Decorator->returnValue('a','b','c','d')); - } - function testSetFirst() { - $mockday = & new Mock_Calendar_Day($this); - $mockday->expectOnce('setFirst',array(true)); - $Decorator =& new Calendar_Decorator($mockday); - $Decorator->setFirst(); - } - function testSetLast() { - $mockday = & new Mock_Calendar_Day($this); - $mockday->expectOnce('setLast',array(true)); - $Decorator =& new Calendar_Decorator($mockday); - $Decorator->setLast(); - } - function testIsFirst() { - $mockday = & new Mock_Calendar_Day($this); - $mockday->setReturnValue('isFirst',TRUE); - $Decorator =& new Calendar_Decorator($mockday); - $this->assertTrue($Decorator->isFirst()); - } - function testIsLast() { - $mockday = & new Mock_Calendar_Day($this); - $mockday->setReturnValue('isLast',TRUE); - $Decorator =& new Calendar_Decorator($mockday); - $this->assertTrue($Decorator->isLast()); - } - function testSetEmpty() { - $mockday = & new Mock_Calendar_Day($this); - $mockday->expectOnce('setEmpty',array(true)); - $Decorator =& new Calendar_Decorator($mockday); - $Decorator->setEmpty(); - } - function testIsEmpty() { - $mockday = & new Mock_Calendar_Day($this); - $mockday->setReturnValue('isEmpty',TRUE); - $Decorator =& new Calendar_Decorator($mockday); - $this->assertTrue($Decorator->isEmpty()); - } - function testBuild() { - $testArray=array('foo'=>'bar'); - $this->mockcal->expectOnce('build',array($testArray)); - $Decorator =& new Calendar_Decorator($this->mockcal); - $Decorator->build($testArray); - } - function testFetch() { - $this->mockcal->expectOnce('fetch',array()); - $Decorator =& new Calendar_Decorator($this->mockcal); - $Decorator->fetch(); - } - function testFetchAll() { - $this->mockcal->expectOnce('fetchAll',array()); - $Decorator =& new Calendar_Decorator($this->mockcal); - $Decorator->fetchAll(); - } - function testSize() { - $this->mockcal->expectOnce('size',array()); - $Decorator =& new Calendar_Decorator($this->mockcal); - $Decorator->size(); - } - function testIsValid() { - $this->mockcal->expectOnce('isValid',array()); - $Decorator =& new Calendar_Decorator($this->mockcal); - $Decorator->isValid(); - } - function testGetValidator() { - $this->mockcal->expectOnce('getValidator',array()); - $Decorator =& new Calendar_Decorator($this->mockcal); - $Decorator->getValidator(); - } -} -?> diff --git a/data/module/Calendar/tests/decorator_tests.php b/data/module/Calendar/tests/decorator_tests.php deleted file mode 100644 index 454f86ea891..00000000000 --- a/data/module/Calendar/tests/decorator_tests.php +++ /dev/null @@ -1,21 +0,0 @@ -GroupTest('Decorator Tests'); - $this->addTestFile('decorator_test.php'); - $this->addTestFile('decorator_textual_test.php'); - $this->addTestFile('decorator_uri_test.php'); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new DecoratorTests(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/decorator_textual_test.php b/data/module/Calendar/tests/decorator_textual_test.php deleted file mode 100644 index e5956de4b39..00000000000 --- a/data/module/Calendar/tests/decorator_textual_test.php +++ /dev/null @@ -1,174 +0,0 @@ -UnitTestCase('Test of Calendar_Decorator_Textual'); - } - function testMonthNamesLong() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $monthNames = array( - 1=>'January', - 2=>'February', - 3=>'March', - 4=>'April', - 5=>'May', - 6=>'June', - 7=>'July', - 8=>'August', - 9=>'September', - 10=>'October', - 11=>'November', - 12=>'December', - ); - $this->assertEqual($monthNames,$Textual->monthNames()); - } - function testMonthNamesShort() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $monthNames = array( - 1=>'Jan', - 2=>'Feb', - 3=>'Mar', - 4=>'Apr', - 5=>'May', - 6=>'Jun', - 7=>'Jul', - 8=>'Aug', - 9=>'Sep', - 10=>'Oct', - 11=>'Nov', - 12=>'Dec', - ); - $this->assertEqual($monthNames,$Textual->monthNames('short')); - } - function testMonthNamesTwo() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $monthNames = array( - 1=>'Ja', - 2=>'Fe', - 3=>'Ma', - 4=>'Ap', - 5=>'Ma', - 6=>'Ju', - 7=>'Ju', - 8=>'Au', - 9=>'Se', - 10=>'Oc', - 11=>'No', - 12=>'De', - ); - $this->assertEqual($monthNames,$Textual->monthNames('two')); - } - function testMonthNamesOne() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $monthNames = array( - 1=>'J', - 2=>'F', - 3=>'M', - 4=>'A', - 5=>'M', - 6=>'J', - 7=>'J', - 8=>'A', - 9=>'S', - 10=>'O', - 11=>'N', - 12=>'D', - ); - $this->assertEqual($monthNames,$Textual->monthNames('one')); - } - function testWeekdayNamesLong() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $weekdayNames = array( - 0=>'Sunday', - 1=>'Monday', - 2=>'Tuesday', - 3=>'Wednesday', - 4=>'Thursday', - 5=>'Friday', - 6=>'Saturday', - ); - $this->assertEqual($weekdayNames,$Textual->weekdayNames()); - } - function testWeekdayNamesShort() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $weekdayNames = array( - 0=>'Sun', - 1=>'Mon', - 2=>'Tue', - 3=>'Wed', - 4=>'Thu', - 5=>'Fri', - 6=>'Sat', - ); - $this->assertEqual($weekdayNames,$Textual->weekdayNames('short')); - } - function testWeekdayNamesTwo() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $weekdayNames = array( - 0=>'Su', - 1=>'Mo', - 2=>'Tu', - 3=>'We', - 4=>'Th', - 5=>'Fr', - 6=>'Sa', - ); - $this->assertEqual($weekdayNames,$Textual->weekdayNames('two')); - } - function testWeekdayNamesOne() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $weekdayNames = array( - 0=>'S', - 1=>'M', - 2=>'T', - 3=>'W', - 4=>'T', - 5=>'F', - 6=>'S', - ); - $this->assertEqual($weekdayNames,$Textual->weekdayNames('one')); - } - function testPrevMonthNameShort() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $this->assertEqual('Sep',$Textual->prevMonthName('short')); - } - function testThisMonthNameShort() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $this->assertEqual('Oct',$Textual->thisMonthName('short')); - } - function testNextMonthNameShort() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $this->assertEqual('Nov',$Textual->nextMonthName('short')); - } - function testThisDayNameShort() { - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $this->assertEqual('Wed',$Textual->thisDayName('short')); - } - function testOrderedWeekdaysShort() { - $weekdayNames = array( - 0=>'Sun', - 1=>'Mon', - 2=>'Tue', - 3=>'Wed', - 4=>'Thu', - 5=>'Fri', - 6=>'Sat', - ); - $Textual = new Calendar_Decorator_Textual($this->mockcal); - $this->assertEqual($weekdayNames,$Textual->orderedWeekdays('short')); - } - -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfDecoratorTextual(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/decorator_uri_test.php b/data/module/Calendar/tests/decorator_uri_test.php deleted file mode 100644 index 231143e395e..00000000000 --- a/data/module/Calendar/tests/decorator_uri_test.php +++ /dev/null @@ -1,37 +0,0 @@ -UnitTestCase('Test of Calendar_Decorator_Uri'); - } - function testFragments() { - $Uri = new Calendar_Decorator_Uri($this->mockcal); - $Uri->setFragments('year','month','day','hour','minute','second'); - $this->assertEqual('year=&month=&day=&hour=&minute=&second=',$Uri->this('second')); - } - function testScalarFragments() { - $Uri = new Calendar_Decorator_Uri($this->mockcal); - $Uri->setFragments('year','month','day','hour','minute','second'); - $Uri->setScalar(); - $this->assertEqual('&&&&&',$Uri->this('second')); - } - function testSetSeperator() { - $Uri = new Calendar_Decorator_Uri($this->mockcal); - $Uri->setFragments('year','month','day','hour','minute','second'); - $Uri->setSeparator('/'); - $this->assertEqual('year=/month=/day=/hour=/minute=/second=',$Uri->this('second')); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfDecoratorUri(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/helper_test.php b/data/module/Calendar/tests/helper_test.php deleted file mode 100644 index 22362f29974..00000000000 --- a/data/module/Calendar/tests/helper_test.php +++ /dev/null @@ -1,83 +0,0 @@ -UnitTestCase('Test of Calendar_Table_Helper'); - } - function setUp() { - $this->mockengine = new Mock_Calendar_Engine($this); - $this->mockengine->setReturnValue('getMinYears',1970); - $this->mockengine->setReturnValue('getMaxYears',2037); - $this->mockengine->setReturnValue('getMonthsInYear',12); - $this->mockengine->setReturnValue('getDaysInMonth',31); - $this->mockengine->setReturnValue('getHoursInDay',24); - $this->mockengine->setReturnValue('getMinutesInHour',60); - $this->mockengine->setReturnValue('getSecondsInMinute',60); - $this->mockengine->setReturnValue('getWeekDays',array(0,1,2,3,4,5,6)); - $this->mockengine->setReturnValue('getDaysInWeek',7); - $this->mockengine->setReturnValue('getFirstDayOfWeek',1); - $this->mockengine->setReturnValue('getFirstDayInMonth',3); - $this->mockcal = new Mock_Calendar_Second($this); - $this->mockcal->setReturnValue('thisYear',2003); - $this->mockcal->setReturnValue('thisMonth',10); - $this->mockcal->setReturnValue('thisDay',15); - $this->mockcal->setReturnValue('thisHour',13); - $this->mockcal->setReturnValue('thisMinute',30); - $this->mockcal->setReturnValue('thisSecond',45); - $this->mockcal->setReturnValue('getEngine',$this->mockengine); - } - function testGetFirstDay() { - for ( $i = 0; $i <= 7; $i++ ) { - $Helper = & new Calendar_Table_Helper($this->mockcal,$i); - $this->assertEqual($Helper->getFirstDay(),$i); - } - } - function testGetDaysOfWeekMonday() { - $Helper = & new Calendar_Table_Helper($this->mockcal); - $this->assertEqual($Helper->getDaysOfWeek(),array(1,2,3,4,5,6,0)); - } - function testGetDaysOfWeekSunday() { - $Helper = & new Calendar_Table_Helper($this->mockcal,0); - $this->assertEqual($Helper->getDaysOfWeek(),array(0,1,2,3,4,5,6)); - } - function testGetDaysOfWeekThursday() { - $Helper = & new Calendar_Table_Helper($this->mockcal,4); - $this->assertEqual($Helper->getDaysOfWeek(),array(4,5,6,0,1,2,3)); - } - function testGetNumWeeks() { - $Helper = & new Calendar_Table_Helper($this->mockcal); - $this->assertEqual($Helper->getNumWeeks(),5); - } - function testGetNumTableDaysInMonth() { - $Helper = & new Calendar_Table_Helper($this->mockcal); - $this->assertEqual($Helper->getNumTableDaysInMonth(),35); - } - function testGetEmptyDaysBefore() { - $Helper = & new Calendar_Table_Helper($this->mockcal); - $this->assertEqual($Helper->getEmptyDaysBefore(),2); - } - function testGetEmptyDaysAfter() { - $Helper = & new Calendar_Table_Helper($this->mockcal); - $this->assertEqual($Helper->getEmptyDaysAfter(),33); - } - function testGetEmptyDaysAfterOffset() { - $Helper = & new Calendar_Table_Helper($this->mockcal); - $this->assertEqual($Helper->getEmptyDaysAfterOffset(),5); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfTableHelper(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/hour_test.php b/data/module/Calendar/tests/hour_test.php deleted file mode 100644 index 78f76ce33b3..00000000000 --- a/data/module/Calendar/tests/hour_test.php +++ /dev/null @@ -1,98 +0,0 @@ -UnitTestCase('Test of Hour'); - } - function setUp() { - $this->cal = new Calendar_Hour(2003,10,25,13); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 10, - 'day' => 24, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } - function testPrevMinute () { - $this->assertEqual(59,$this->cal->prevMinute()); - } - function testThisMinute () { - $this->assertEqual(0,$this->cal->thisMinute()); - } - function testNextMinute () { - $this->assertEqual(1,$this->cal->nextMinute()); - } - function testPrevSecond () { - $this->assertEqual(59,$this->cal->prevSecond()); - } - function testThisSecond () { - $this->assertEqual(0,$this->cal->thisSecond()); - } - function testNextSecond () { - $this->assertEqual(1,$this->cal->nextSecond()); - } - function testGetTimeStamp() { - $stamp = mktime(13,0,0,10,25,2003); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } -} - -class TestOfHourBuild extends TestOfHour { - function TestOfHourBuild() { - $this->UnitTestCase('Test of Hour::build()'); - } - function testSize() { - $this->cal->build(); - $this->assertEqual(60,$this->cal->size()); - } - function testFetch() { - $this->cal->build(); - $i=0; - while ( $Child = $this->cal->fetch() ) { - $i++; - } - $this->assertEqual(60,$i); - } - function testFetchAll() { - $this->cal->build(); - $children = array(); - $i = 0; - while ( $Child = $this->cal->fetch() ) { - $children[$i]=$Child; - $i++; - } - $this->assertEqual($children,$this->cal->fetchAll()); - } - function testSelection() { - require_once(CALENDAR_ROOT . 'Minute.php'); - $selection = array(new Calendar_Minute(2003,10,25,13,32)); - $this->cal->build($selection); - $i = 0; - while ( $Child = $this->cal->fetch() ) { - if ( $i == 32 ) - break; - $i++; - } - $this->assertTrue($Child->isSelected()); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfHour(); - $test->run(new HtmlReporter()); - $test = &new TestOfHourBuild(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/minute_test.php b/data/module/Calendar/tests/minute_test.php deleted file mode 100644 index d7710bc6b18..00000000000 --- a/data/module/Calendar/tests/minute_test.php +++ /dev/null @@ -1,99 +0,0 @@ -UnitTestCase('Test of Minute'); - } - function setUp() { - $this->cal = new Calendar_Minute(2003,10,25,13,32); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 10, - 'day' => 24, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } - function testPrevSecond () { - $this->assertEqual(59,$this->cal->prevSecond()); - } - function testThisSecond () { - $this->assertEqual(0,$this->cal->thisSecond()); - } - function testThisSecond_Timestamp () { - $this->assertEqual($this->cal->cE->dateToStamp( - 2003, 10, 25, 13, 32, 0), - $this->cal->thisSecond('timestamp')); - } - function testNextSecond () { - $this->assertEqual(1,$this->cal->nextSecond()); - } - function testNextSecond_Timestamp () { - $this->assertEqual($this->cal->cE->dateToStamp( - 2003, 10, 25, 13, 32, 1), - $this->cal->nextSecond('timestamp')); - } - function testGetTimeStamp() { - $stamp = mktime(13,32,0,10,25,2003); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } -} - -class TestOfMinuteBuild extends TestOfMinute { - function TestOfMinuteBuild() { - $this->UnitTestCase('Test of Minute::build()'); - } - function testSize() { - $this->cal->build(); - $this->assertEqual(60,$this->cal->size()); - } - function testFetch() { - $this->cal->build(); - $i=0; - while ( $Child = $this->cal->fetch() ) { - $i++; - } - $this->assertEqual(60,$i); - } - function testFetchAll() { - $this->cal->build(); - $children = array(); - $i = 0; - while ( $Child = $this->cal->fetch() ) { - $children[$i]=$Child; - $i++; - } - $this->assertEqual($children,$this->cal->fetchAll()); - } - function testSelection() { - require_once(CALENDAR_ROOT . 'Second.php'); - $selection = array(new Calendar_Second(2003,10,25,13,32,43)); - $this->cal->build($selection); - $i = 0; - while ( $Child = $this->cal->fetch() ) { - if ( $i == 43 ) - break; - $i++; - } - $this->assertTrue($Child->isSelected()); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfMinute(); - $test->run(new HtmlReporter()); - $test = &new TestOfMinuteBuild(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/month_test.php b/data/module/Calendar/tests/month_test.php deleted file mode 100644 index 9b6960aa4c5..00000000000 --- a/data/module/Calendar/tests/month_test.php +++ /dev/null @@ -1,119 +0,0 @@ -UnitTestCase('Test of Month'); - } - function setUp() { - $this->cal = new Calendar_Month(2003,10); - } - function testPrevMonth_Object() { - $this->assertEqual(new Calendar_Month(2003, 9), $this->cal->prevMonth('object')); - } - function testPrevDay () { - $this->assertEqual(30,$this->cal->prevDay()); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 9, - 'day' => 30, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } - function testThisDay () { - $this->assertEqual(1,$this->cal->thisDay()); - } - function testNextDay () { - $this->assertEqual(2,$this->cal->nextDay()); - } - function testPrevHour () { - $this->assertEqual(23,$this->cal->prevHour()); - } - function testThisHour () { - $this->assertEqual(0,$this->cal->thisHour()); - } - function testNextHour () { - $this->assertEqual(1,$this->cal->nextHour()); - } - function testPrevMinute () { - $this->assertEqual(59,$this->cal->prevMinute()); - } - function testThisMinute () { - $this->assertEqual(0,$this->cal->thisMinute()); - } - function testNextMinute () { - $this->assertEqual(1,$this->cal->nextMinute()); - } - function testPrevSecond () { - $this->assertEqual(59,$this->cal->prevSecond()); - } - function testThisSecond () { - $this->assertEqual(0,$this->cal->thisSecond()); - } - function testNextSecond () { - $this->assertEqual(1,$this->cal->nextSecond()); - } - function testGetTimeStamp() { - $stamp = mktime(0,0,0,10,1,2003); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } -} - -class TestOfMonthBuild extends TestOfMonth { - function TestOfMonthBuild() { - $this->UnitTestCase('Test of Month::build()'); - } - function testSize() { - $this->cal->build(); - $this->assertEqual(31,$this->cal->size()); - } - function testFetch() { - $this->cal->build(); - $i=0; - while ( $Child = $this->cal->fetch() ) { - $i++; - } - $this->assertEqual(31,$i); - } - function testFetchAll() { - $this->cal->build(); - $children = array(); - $i = 1; - while ( $Child = $this->cal->fetch() ) { - $children[$i]=$Child; - $i++; - } - $this->assertEqual($children,$this->cal->fetchAll()); - } - function testSelection() { - require_once(CALENDAR_ROOT . 'Day.php'); - $selection = array(new Calendar_Day(2003,10,25)); - $this->cal->build($selection); - $i = 1; - while ( $Child = $this->cal->fetch() ) { - if ( $i == 25 ) - break; - $i++; - } - $this->assertTrue($Child->isSelected()); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfMonth(); - $test->run(new HtmlReporter()); - $test = &new TestOfMonthBuild(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/month_weekdays_test.php b/data/module/Calendar/tests/month_weekdays_test.php deleted file mode 100644 index 9cf814387a4..00000000000 --- a/data/module/Calendar/tests/month_weekdays_test.php +++ /dev/null @@ -1,130 +0,0 @@ -UnitTestCase('Test of Month Weekdays'); - } - function setUp() { - $this->cal = new Calendar_Month_Weekdays(2003,10); - } - function testPrevDay () { - $this->assertEqual(30,$this->cal->prevDay()); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 9, - 'day' => 30, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } - function testThisDay () { - $this->assertEqual(1,$this->cal->thisDay()); - } - function testNextDay () { - $this->assertEqual(2,$this->cal->nextDay()); - } - function testPrevHour () { - $this->assertEqual(23,$this->cal->prevHour()); - } - function testThisHour () { - $this->assertEqual(0,$this->cal->thisHour()); - } - function testNextHour () { - $this->assertEqual(1,$this->cal->nextHour()); - } - function testPrevMinute () { - $this->assertEqual(59,$this->cal->prevMinute()); - } - function testThisMinute () { - $this->assertEqual(0,$this->cal->thisMinute()); - } - function testNextMinute () { - $this->assertEqual(1,$this->cal->nextMinute()); - } - function testPrevSecond () { - $this->assertEqual(59,$this->cal->prevSecond()); - } - function testThisSecond () { - $this->assertEqual(0,$this->cal->thisSecond()); - } - function testNextSecond () { - $this->assertEqual(1,$this->cal->nextSecond()); - } - function testGetTimeStamp() { - $stamp = mktime(0,0,0,10,1,2003); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } -} - -class TestOfMonthWeekdaysBuild extends TestOfMonthWeekdays { - function TestOfMonthWeekdaysBuild() { - $this->UnitTestCase('Test of Month_Weekdays::build()'); - } - function testSize() { - $this->cal->build(); - $this->assertEqual(35,$this->cal->size()); - } - function testFetch() { - $this->cal->build(); - $i=0; - while ( $Child = $this->cal->fetch() ) { - $i++; - } - $this->assertEqual(35,$i); - } - function testFetchAll() { - $this->cal->build(); - $children = array(); - $i = 1; - while ( $Child = $this->cal->fetch() ) { - $children[$i]=$Child; - $i++; - } - $this->assertEqual($children,$this->cal->fetchAll()); - } - function testSelection() { - require_once(CALENDAR_ROOT . 'Day.php'); - $selection = array(new Calendar_Day(2003,10,25)); - $this->cal->build($selection); - $i = 1; - while ( $Child = $this->cal->fetch() ) { - if ( $i == 27 ) - break; - $i++; - } - $this->assertTrue($Child->isSelected()); - } - function testEmptyCount() { - $this->cal->build(); - $empty = 0; - while ( $Child = $this->cal->fetch() ) { - if ( $Child->isEmpty() ) - $empty++; - } - $this->assertEqual(4,$empty); - } - function testEmptyDaysBefore_AfterAdjust() { - $this->cal = new Calendar_Month_Weekdays(2004,0); - $this->cal->build(); - $this->assertEqual(0,$this->cal->tableHelper->getEmptyDaysBefore()); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfMonthWeekdays(); - $test->run(new HtmlReporter()); - $test = &new TestOfMonthWeekdaysBuild(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/month_weeks_test.php b/data/module/Calendar/tests/month_weeks_test.php deleted file mode 100644 index c2e490cc099..00000000000 --- a/data/module/Calendar/tests/month_weeks_test.php +++ /dev/null @@ -1,125 +0,0 @@ -UnitTestCase('Test of Month Weeks'); - } - function setUp() { - $this->cal = new Calendar_Month_Weeks(2003,10); - } - function testPrevDay () { - $this->assertEqual(30,$this->cal->prevDay()); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 9, - 'day' => 30, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } - function testThisDay () { - $this->assertEqual(1,$this->cal->thisDay()); - } - function testNextDay () { - $this->assertEqual(2,$this->cal->nextDay()); - } - function testPrevHour () { - $this->assertEqual(23,$this->cal->prevHour()); - } - function testThisHour () { - $this->assertEqual(0,$this->cal->thisHour()); - } - function testNextHour () { - $this->assertEqual(1,$this->cal->nextHour()); - } - function testPrevMinute () { - $this->assertEqual(59,$this->cal->prevMinute()); - } - function testThisMinute () { - $this->assertEqual(0,$this->cal->thisMinute()); - } - function testNextMinute () { - $this->assertEqual(1,$this->cal->nextMinute()); - } - function testPrevSecond () { - $this->assertEqual(59,$this->cal->prevSecond()); - } - function testThisSecond () { - $this->assertEqual(0,$this->cal->thisSecond()); - } - function testNextSecond () { - $this->assertEqual(1,$this->cal->nextSecond()); - } - function testGetTimeStamp() { - $stamp = mktime(0,0,0,10,1,2003); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } -} - -class TestOfMonthWeeksBuild extends TestOfMonthWeeks { - function TestOfMonthWeeksBuild() { - $this->UnitTestCase('Test of Month_Weeks::build()'); - } - function testSize() { - $this->cal->build(); - $this->assertEqual(5,$this->cal->size()); - } - - function testFetch() { - $this->cal->build(); - $i=0; - while ( $Child = $this->cal->fetch() ) { - $i++; - } - $this->assertEqual(5,$i); - } -/* Recusive dependency issue with SimpleTest - function testFetchAll() { - $this->cal->build(); - $children = array(); - $i = 1; - while ( $Child = $this->cal->fetch() ) { - $children[$i]=$Child; - $i++; - } - $this->assertEqual($children,$this->cal->fetchAll()); - } -*/ - function testSelection() { - require_once(CALENDAR_ROOT . 'Week.php'); - $selection = array(new Calendar_Week(2003, 10, 12)); - $this->cal->build($selection); - $i = 1; - while ($Child = $this->cal->fetch()) { - if ($i == 2) { - break; //12-10-2003 is the 2nd day of the week - } - $i++; - } - $this->assertTrue($Child->isSelected()); - } - function testEmptyDaysBefore_AfterAdjust() { - $this->cal = new Calendar_Month_Weeks(2004,0); - $this->cal->build(); - $this->assertEqual(0,$this->cal->tableHelper->getEmptyDaysBefore()); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfMonthWeeks(); - $test->run(new HtmlReporter()); - $test = &new TestOfMonthWeeksBuild(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/peardate_engine_test.php b/data/module/Calendar/tests/peardate_engine_test.php deleted file mode 100644 index 5dfdec29b6e..00000000000 --- a/data/module/Calendar/tests/peardate_engine_test.php +++ /dev/null @@ -1,124 +0,0 @@ -UnitTestCase('Test of Calendar_Engine_PearDate'); - } - function setUp() { - $this->engine = new Calendar_Engine_PearDate(); - } - function testGetSecondsInMinute() { - $this->assertEqual($this->engine->getSecondsInMinute(),60); - } - function testGetMinutesInHour() { - $this->assertEqual($this->engine->getMinutesInHour(),60); - } - function testGetHoursInDay() { - $this->assertEqual($this->engine->getHoursInDay(),24); - } - function testGetFirstDayOfWeek() { - $this->assertEqual($this->engine->getFirstDayOfWeek(),1); - } - function testGetWeekDays() { - $this->assertEqual($this->engine->getWeekDays(),array(0,1,2,3,4,5,6)); - } - function testGetDaysInWeek() { - $this->assertEqual($this->engine->getDaysInWeek(),7); - } - function testGetWeekNInYear() { - $this->assertEqual($this->engine->getWeekNInYear(2003, 11, 3), 45); - } - function testGetWeekNInMonth() { - $this->assertEqual($this->engine->getWeekNInMonth(2003, 11, 3), 2); - } - function testGetWeeksInMonth0() { - $this->assertEqual($this->engine->getWeeksInMonth(2003, 11, 0), 6); //week starts on sunday - } - function testGetWeeksInMonth1() { - $this->assertEqual($this->engine->getWeeksInMonth(2003, 11, 1), 5); //week starts on monday - } - function testGetWeeksInMonth2() { - $this->assertEqual($this->engine->getWeeksInMonth(2003, 2, 6), 4); //week starts on saturday - } - function testGetWeeksInMonth3() { - // Unusual cases that can cause fails (shows up with example 21.php) - $this->assertEqual($this->engine->getWeeksInMonth(2004,2,1),5); - $this->assertEqual($this->engine->getWeeksInMonth(2004,8,1),6); - } - function testGetDayOfWeek() { - $this->assertEqual($this->engine->getDayOfWeek(2003, 11, 18), 2); - } - function testGetFirstDayInMonth() { - $this->assertEqual($this->engine->getFirstDayInMonth(2003,10),3); - } - function testGetDaysInMonth() { - $this->assertEqual($this->engine->getDaysInMonth(2003,10),31); - } - function testGetMinYears() { - $this->assertEqual($this->engine->getMinYears(),0); - } - function testGetMaxYears() { - $this->assertEqual($this->engine->getMaxYears(),9999); - } - function testDateToStamp() { - $stamp = '2003-10-15 13:30:45'; - $this->assertEqual($this->engine->dateToStamp(2003,10,15,13,30,45),$stamp); - } - function testStampToSecond() { - $stamp = '2003-10-15 13:30:45'; - $this->assertEqual($this->engine->stampToSecond($stamp),45); - } - function testStampToMinute() { - $stamp = '2003-10-15 13:30:45'; - $this->assertEqual($this->engine->stampToMinute($stamp),30); - } - function testStampToHour() { - $stamp = '2003-10-15 13:30:45'; - $this->assertEqual($this->engine->stampToHour($stamp),13); - } - function testStampToDay() { - $stamp = '2003-10-15 13:30:45'; - $this->assertEqual($this->engine->stampToDay($stamp),15); - } - function testStampToMonth() { - $stamp = '2003-10-15 13:30:45'; - $this->assertEqual($this->engine->stampToMonth($stamp),10); - } - function testStampToYear() { - $stamp = '2003-10-15 13:30:45'; - $this->assertEqual($this->engine->stampToYear($stamp),2003); - } - function testAdjustDate() { - $stamp = '2004-01-01 13:30:45'; - $y = $this->engine->stampToYear($stamp); - $m = $this->engine->stampToMonth($stamp); - $d = $this->engine->stampToDay($stamp); - - //the first day of the month should be thursday - $this->assertEqual($this->engine->getDayOfWeek($y, $m, $d), 4); - - $m--; // 2004-00-01 => 2003-12-01 - $this->engine->adjustDate($y, $m, $d, $dummy, $dummy, $dummy); - - $this->assertEqual($y, 2003); - $this->assertEqual($m, 12); - $this->assertEqual($d, 1); - - // get last day and check if it's wednesday - $d = $this->engine->getDaysInMonth($y, $m); - - $this->assertEqual($this->engine->getDayOfWeek($y, $m, $d), 3); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfPearDateEngine(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/second_test.php b/data/module/Calendar/tests/second_test.php deleted file mode 100644 index b9cd58c3068..00000000000 --- a/data/module/Calendar/tests/second_test.php +++ /dev/null @@ -1,34 +0,0 @@ -UnitTestCase('Test of Second'); - } - function setUp() { - $this->cal = new Calendar_Second(2003,10,25,13,32,43); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 10, - 'day' => 24, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfSecond(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/simple_include.php b/data/module/Calendar/tests/simple_include.php deleted file mode 100644 index 56003af2ba9..00000000000 --- a/data/module/Calendar/tests/simple_include.php +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/data/module/Calendar/tests/table_helper_tests.php b/data/module/Calendar/tests/table_helper_tests.php deleted file mode 100644 index 904c7270bd0..00000000000 --- a/data/module/Calendar/tests/table_helper_tests.php +++ /dev/null @@ -1,19 +0,0 @@ -GroupTest('Table Helper Tests'); - $this->addTestFile('helper_test.php'); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TableHelperTests(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/unixts_engine_test.php b/data/module/Calendar/tests/unixts_engine_test.php deleted file mode 100644 index 6c8127f27e4..00000000000 --- a/data/module/Calendar/tests/unixts_engine_test.php +++ /dev/null @@ -1,104 +0,0 @@ -UnitTestCase('Test of Calendar_Engine_UnixTs'); - } - function setUp() { - $this->engine = new Calendar_Engine_UnixTs(); - } - function testGetSecondsInMinute() { - $this->assertEqual($this->engine->getSecondsInMinute(),60); - } - function testGetMinutesInHour() { - $this->assertEqual($this->engine->getMinutesInHour(),60); - } - function testGetHoursInDay() { - $this->assertEqual($this->engine->getHoursInDay(),24); - } - function testGetFirstDayOfWeek() { - $this->assertEqual($this->engine->getFirstDayOfWeek(),1); - } - function testGetWeekDays() { - $this->assertEqual($this->engine->getWeekDays(),array(0,1,2,3,4,5,6)); - } - function testGetDaysInWeek() { - $this->assertEqual($this->engine->getDaysInWeek(),7); - } - function testGetWeekNInYear() { - $this->assertEqual($this->engine->getWeekNInYear(2003, 11, 3), 45); - } - function testGetWeekNInMonth() { - $this->assertEqual($this->engine->getWeekNInMonth(2003, 11, 3), 2); - } - function testGetWeeksInMonth0() { - $this->assertEqual($this->engine->getWeeksInMonth(2003, 11, 0), 6); //week starts on sunday - } - function testGetWeeksInMonth1() { - $this->assertEqual($this->engine->getWeeksInMonth(2003, 11, 1), 5); //week starts on monday - } - function testGetWeeksInMonth2() { - $this->assertEqual($this->engine->getWeeksInMonth(2003, 2, 6), 4); //week starts on saturday - } - function testGetWeeksInMonth3() { - // Unusual cases that can cause fails (shows up with example 21.php) - $this->assertEqual($this->engine->getWeeksInMonth(2004,2,1),5); - $this->assertEqual($this->engine->getWeeksInMonth(2004,8,1),6); - } - function testGetDayOfWeek() { - $this->assertEqual($this->engine->getDayOfWeek(2003, 11, 18), 2); - } - function testGetFirstDayInMonth() { - $this->assertEqual($this->engine->getFirstDayInMonth(2003,10),3); - } - function testGetDaysInMonth() { - $this->assertEqual($this->engine->getDaysInMonth(2003,10),31); - } - function testGetMinYears() { - $test = strpos(PHP_OS, 'WIN') >= 0 ? 1970 : 1902; - $this->assertEqual($this->engine->getMinYears(),$test); - } - function testGetMaxYears() { - $this->assertEqual($this->engine->getMaxYears(),2037); - } - function testDateToStamp() { - $stamp = mktime(0,0,0,10,15,2003); - $this->assertEqual($this->engine->dateToStamp(2003,10,15,0,0,0),$stamp); - } - function testStampToSecond() { - $stamp = mktime(13,30,45,10,15,2003); - $this->assertEqual($this->engine->stampToSecond($stamp),45); - } - function testStampToMinute() { - $stamp = mktime(13,30,45,10,15,2003); - $this->assertEqual($this->engine->stampToMinute($stamp),30); - } - function testStampToHour() { - $stamp = mktime(13,30,45,10,15,2003); - $this->assertEqual($this->engine->stampToHour($stamp),13); - } - function testStampToDay() { - $stamp = mktime(13,30,45,10,15,2003); - $this->assertEqual($this->engine->stampToDay($stamp),15); - } - function testStampToMonth() { - $stamp = mktime(13,30,45,10,15,2003); - $this->assertEqual($this->engine->stampToMonth($stamp),10); - } - function testStampToYear() { - $stamp = mktime(13,30,45,10,15,2003); - $this->assertEqual($this->engine->stampToYear($stamp),2003); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfUnixTsEngine(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/util_tests.php b/data/module/Calendar/tests/util_tests.php deleted file mode 100644 index 2c64d16ef42..00000000000 --- a/data/module/Calendar/tests/util_tests.php +++ /dev/null @@ -1,20 +0,0 @@ -GroupTest('Util Tests'); - $this->addTestFile('util_uri_test.php'); - $this->addTestFile('util_textual_test.php'); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new UtilTests(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/util_textual_test.php b/data/module/Calendar/tests/util_textual_test.php deleted file mode 100644 index 4f6c60bce8b..00000000000 --- a/data/module/Calendar/tests/util_textual_test.php +++ /dev/null @@ -1,191 +0,0 @@ -UnitTestCase('Test of Calendar_Util_Textual'); - } - function setUp() { - $this->mockengine = new Mock_Calendar_Engine($this); - $this->mockcal = new Mock_Calendar_Second($this); - $this->mockcal->setReturnValue('prevYear',2002); - $this->mockcal->setReturnValue('thisYear',2003); - $this->mockcal->setReturnValue('nextYear',2004); - $this->mockcal->setReturnValue('prevMonth',9); - $this->mockcal->setReturnValue('thisMonth',10); - $this->mockcal->setReturnValue('nextMonth',11); - $this->mockcal->setReturnValue('prevDay',14); - $this->mockcal->setReturnValue('thisDay',15); - $this->mockcal->setReturnValue('nextDay',16); - $this->mockcal->setReturnValue('prevHour',12); - $this->mockcal->setReturnValue('thisHour',13); - $this->mockcal->setReturnValue('nextHour',14); - $this->mockcal->setReturnValue('prevMinute',29); - $this->mockcal->setReturnValue('thisMinute',30); - $this->mockcal->setReturnValue('nextMinute',31); - $this->mockcal->setReturnValue('prevSecond',44); - $this->mockcal->setReturnValue('thisSecond',45); - $this->mockcal->setReturnValue('nextSecond',46); - $this->mockcal->setReturnValue('getEngine',$this->mockengine); - $this->mockcal->setReturnValue('getTimestamp',12345); - } - function tearDown() { - unset ( $this->engine ); - unset ( $this->mockcal ); - } - function testMonthNamesLong() { - $monthNames = array( - 1=>'January', - 2=>'February', - 3=>'March', - 4=>'April', - 5=>'May', - 6=>'June', - 7=>'July', - 8=>'August', - 9=>'September', - 10=>'October', - 11=>'November', - 12=>'December', - ); - $this->assertEqual($monthNames,Calendar_Util_Textual::monthNames()); - } - function testMonthNamesShort() { - $monthNames = array( - 1=>'Jan', - 2=>'Feb', - 3=>'Mar', - 4=>'Apr', - 5=>'May', - 6=>'Jun', - 7=>'Jul', - 8=>'Aug', - 9=>'Sep', - 10=>'Oct', - 11=>'Nov', - 12=>'Dec', - ); - $this->assertEqual($monthNames,Calendar_Util_Textual::monthNames('short')); - } - function testMonthNamesTwo() { - $monthNames = array( - 1=>'Ja', - 2=>'Fe', - 3=>'Ma', - 4=>'Ap', - 5=>'Ma', - 6=>'Ju', - 7=>'Ju', - 8=>'Au', - 9=>'Se', - 10=>'Oc', - 11=>'No', - 12=>'De', - ); - $this->assertEqual($monthNames,Calendar_Util_Textual::monthNames('two')); - } - function testMonthNamesOne() { - $monthNames = array( - 1=>'J', - 2=>'F', - 3=>'M', - 4=>'A', - 5=>'M', - 6=>'J', - 7=>'J', - 8=>'A', - 9=>'S', - 10=>'O', - 11=>'N', - 12=>'D', - ); - $this->assertEqual($monthNames,Calendar_Util_Textual::monthNames('one')); - } - function testWeekdayNamesLong() { - $weekdayNames = array( - 0=>'Sunday', - 1=>'Monday', - 2=>'Tuesday', - 3=>'Wednesday', - 4=>'Thursday', - 5=>'Friday', - 6=>'Saturday', - ); - $this->assertEqual($weekdayNames,Calendar_Util_Textual::weekdayNames()); - } - function testWeekdayNamesShort() { - $weekdayNames = array( - 0=>'Sun', - 1=>'Mon', - 2=>'Tue', - 3=>'Wed', - 4=>'Thu', - 5=>'Fri', - 6=>'Sat', - ); - $this->assertEqual($weekdayNames,Calendar_Util_Textual::weekdayNames('short')); - } - function testWeekdayNamesTwo() { - $weekdayNames = array( - 0=>'Su', - 1=>'Mo', - 2=>'Tu', - 3=>'We', - 4=>'Th', - 5=>'Fr', - 6=>'Sa', - ); - $this->assertEqual($weekdayNames,Calendar_Util_Textual::weekdayNames('two')); - } - function testWeekdayNamesOne() { - $weekdayNames = array( - 0=>'S', - 1=>'M', - 2=>'T', - 3=>'W', - 4=>'T', - 5=>'F', - 6=>'S', - ); - $this->assertEqual($weekdayNames,Calendar_Util_Textual::weekdayNames('one')); - } - function testPrevMonthNameShort() { - $this->assertEqual('Sep',Calendar_Util_Textual::prevMonthName($this->mockcal,'short')); - } - function testThisMonthNameShort() { - $this->assertEqual('Oct',Calendar_Util_Textual::thisMonthName($this->mockcal,'short')); - } - function testNextMonthNameShort() { - $this->assertEqual('Nov',Calendar_Util_Textual::nextMonthName($this->mockcal,'short')); - } - function testThisDayNameShort() { - $this->assertEqual('Wed',Calendar_Util_Textual::thisDayName($this->mockcal,'short')); - } - function testOrderedWeekdaysShort() { - $weekdayNames = array( - 0=>'Sun', - 1=>'Mon', - 2=>'Tue', - 3=>'Wed', - 4=>'Thu', - 5=>'Fri', - 6=>'Sat', - ); - $this->assertEqual($weekdayNames,Calendar_Util_Textual::orderedWeekdays($this->mockcal,'short')); - } - -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfUtilTextual(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/util_uri_test.php b/data/module/Calendar/tests/util_uri_test.php deleted file mode 100644 index 12a6f365a29..00000000000 --- a/data/module/Calendar/tests/util_uri_test.php +++ /dev/null @@ -1,54 +0,0 @@ -UnitTestCase('Test of Calendar_Util_Uri'); - } - - function setUp() { - $this->MockCal = & new Mock_Calendar_Day($this); - $this->MockCal->setReturnValue('getEngine',new Mock_Calendar_Engine($this)); - } - - function testFragments() { - $Uri = new Calendar_Util_Uri('y','m','d','h','m','s'); - $Uri->setFragments('year','month','day','hour','minute','second'); - $this->assertEqual( - 'year=&month=&day=&hour=&minute=&second=', - $Uri->this($this->MockCal, 'second') - ); - } - function testScalarFragments() { - $Uri = new Calendar_Util_Uri('year','month','day','hour','minute','second'); - $Uri->scalar = true; - $this->assertEqual( - '&&&&&', - $Uri->this($this->MockCal, 'second') - ); - } - function testSetSeperator() { - $Uri = new Calendar_Util_Uri('year','month','day','hour','minute','second'); - $Uri->separator = '/'; - $this->assertEqual( - 'year=/month=/day=/hour=/minute=/second=', - $Uri->this($this->MockCal, 'second') - ); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfUtilUri(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/validator_error_test.php b/data/module/Calendar/tests/validator_error_test.php deleted file mode 100644 index 865aea5654d..00000000000 --- a/data/module/Calendar/tests/validator_error_test.php +++ /dev/null @@ -1,34 +0,0 @@ -UnitTestCase('Test of Validation Error'); - } - function setUp() { - $this->vError = new Calendar_Validation_Error('foo',20,'bar'); - } - function testGetUnit() { - $this->assertEqual($this->vError->getUnit(),'foo'); - } - function testGetValue() { - $this->assertEqual($this->vError->getValue(),20); - } - function testGetMessage() { - $this->assertEqual($this->vError->getMessage(),'bar'); - } - function testToString() { - $this->assertEqual($this->vError->toString(),'foo = 20 [bar]'); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfValidationError(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/validator_tests.php b/data/module/Calendar/tests/validator_tests.php deleted file mode 100644 index 4cdc56de5f6..00000000000 --- a/data/module/Calendar/tests/validator_tests.php +++ /dev/null @@ -1,20 +0,0 @@ -GroupTest('Validator Tests'); - $this->addTestFile('validator_unit_test.php'); - $this->addTestFile('validator_error_test.php'); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new ValidatorTests(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/validator_unit_test.php b/data/module/Calendar/tests/validator_unit_test.php deleted file mode 100644 index 9cc67c33dce..00000000000 --- a/data/module/Calendar/tests/validator_unit_test.php +++ /dev/null @@ -1,210 +0,0 @@ -UnitTestCase('Test of Validator'); - } - function setUp() { - $this->mockengine = new Mock_Calendar_Engine($this); - $this->mockengine->setReturnValue('getMinYears',1970); - $this->mockengine->setReturnValue('getMaxYears',2037); - $this->mockengine->setReturnValue('getMonthsInYear',12); - $this->mockengine->setReturnValue('getDaysInMonth',30); - $this->mockengine->setReturnValue('getHoursInDay',24); - $this->mockengine->setReturnValue('getMinutesInHour',60); - $this->mockengine->setReturnValue('getSecondsInMinute',60); - $this->mockcal = new Mock_Calendar_Second($this); - $this->mockcal->setReturnValue('getEngine',$this->mockengine); - } - function tearDown() { - unset ($this->mockengine); - unset ($this->mocksecond); - } - function testIsValidYear() { - $this->mockcal->setReturnValue('thisYear',2000); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertTrue($Validator->isValidYear()); - } - function testIsValidYearTooSmall() { - $this->mockcal->setReturnValue('thisYear',1969); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidYear()); - } - function testIsValidYearTooLarge() { - $this->mockcal->setReturnValue('thisYear',2038); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidYear()); - } - function testIsValidMonth() { - $this->mockcal->setReturnValue('thisMonth',10); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertTrue($Validator->isValidMonth()); - } - function testIsValidMonthTooSmall() { - $this->mockcal->setReturnValue('thisMonth',0); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidMonth()); - } - function testIsValidMonthTooLarge() { - $this->mockcal->setReturnValue('thisMonth',13); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidMonth()); - } - function testIsValidDay() { - $this->mockcal->setReturnValue('thisDay',10); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertTrue($Validator->isValidDay()); - } - function testIsValidDayTooSmall() { - $this->mockcal->setReturnValue('thisDay',0); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidDay()); - } - function testIsValidDayTooLarge() { - $this->mockcal->setReturnValue('thisDay',31); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidDay()); - } - function testIsValidHour() { - $this->mockcal->setReturnValue('thisHour',10); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertTrue($Validator->isValidHour()); - } - function testIsValidHourTooSmall() { - $this->mockcal->setReturnValue('thisHour',-1); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidHour()); - } - function testIsValidHourTooLarge() { - $this->mockcal->setReturnValue('thisHour',24); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidHour()); - } - function testIsValidMinute() { - $this->mockcal->setReturnValue('thisMinute',30); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertTrue($Validator->isValidMinute()); - } - function testIsValidMinuteTooSmall() { - $this->mockcal->setReturnValue('thisMinute',-1); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidMinute()); - } - function testIsValidMinuteTooLarge() { - $this->mockcal->setReturnValue('thisMinute',60); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidMinute()); - } - function testIsValidSecond() { - $this->mockcal->setReturnValue('thisSecond',30); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertTrue($Validator->isValidSecond()); - } - function testIsValidSecondTooSmall() { - $this->mockcal->setReturnValue('thisSecond',-1); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidSecond()); - } - function testIsValidSecondTooLarge() { - $this->mockcal->setReturnValue('thisSecond',60); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValidSecond()); - } - function testIsValid() { - $this->mockcal->setReturnValue('thisYear',2000); - $this->mockcal->setReturnValue('thisMonth',5); - $this->mockcal->setReturnValue('thisDay',15); - $this->mockcal->setReturnValue('thisHour',13); - $this->mockcal->setReturnValue('thisMinute',30); - $this->mockcal->setReturnValue('thisSecond',40); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertTrue($Validator->isValid()); - } - function testIsValidAllWrong() { - $this->mockcal->setReturnValue('thisYear',2038); - $this->mockcal->setReturnValue('thisMonth',13); - $this->mockcal->setReturnValue('thisDay',31); - $this->mockcal->day = 31; - $this->mockcal->setReturnValue('thisHour',24); - $this->mockcal->setReturnValue('thisMinute',60); - $this->mockcal->setReturnValue('thisSecond',60); - $Validator = & new Calendar_Validator($this->mockcal); - $this->assertFalse($Validator->isValid()); - $i = 0; - while ( $Validator->fetch() ) { - $i++; - } - $this->assertEqual($i,6); - } -} - -class TestOfValidatorLive extends UnitTestCase { - function TestOfValidatorLive() { - $this->UnitTestCase('Test of Validator Live'); - } - function testYear() { - $Unit = new Calendar_Year(2038); - $Validator = & $Unit->getValidator(); - $this->assertFalse($Validator->isValidYear()); - } - function testMonth() { - $Unit = new Calendar_Month(2000,13); - $Validator = & $Unit->getValidator(); - $this->assertFalse($Validator->isValidMonth()); - } -/* - function testWeek() { - $Unit = new Calendar_Week(2000,12,7); - $Validator = & $Unit->getValidator(); - $this->assertFalse($Validator->isValidWeek()); - } -*/ - function testDay() { - $Unit = new Calendar_Day(2000,12,32); - $Validator = & $Unit->getValidator(); - $this->assertFalse($Validator->isValidDay()); - } - function testHour() { - $Unit = new Calendar_Hour(2000,12,20,24); - $Validator = & $Unit->getValidator(); - $this->assertFalse($Validator->isValidHour()); - } - function testMinute() { - $Unit = new Calendar_Minute(2000,12,20,23,60); - $Validator = & $Unit->getValidator(); - $this->assertFalse($Validator->isValidMinute()); - } - function testSecond() { - $Unit = new Calendar_Second(2000,12,20,23,59,60); - $Validator = & $Unit->getValidator(); - $this->assertFalse($Validator->isValidSecond()); - } - function testAllBad() { - $Unit = new Calendar_Second(2000,13,32,24,60,60); - $this->assertFalse($Unit->isValid()); - $Validator = & $Unit->getValidator(); - $i = 0; - while ( $Validator->fetch() ) { - $i++; - } - $this->assertEqual($i,5); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfValidator(); - $test->run(new HtmlReporter()); - $test = &new TestOfValidatorLive(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/week_firstday_0_test.php b/data/module/Calendar/tests/week_firstday_0_test.php deleted file mode 100644 index 06733e09e21..00000000000 --- a/data/module/Calendar/tests/week_firstday_0_test.php +++ /dev/null @@ -1,241 +0,0 @@ -UnitTestCase('Test of Week - Week Starting on Sunday'); - } - function setUp() { - $this->cal = Calendar_Factory::create('Week', 2003, 10, 9); - //print_r($this->cal); - } - function testPrevDay () { - $this->assertEqual(8, $this->cal->prevDay()); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 10, - 'day' => 8, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } - function testThisDay () { - $this->assertEqual(9, $this->cal->thisDay()); - } - function testNextDay () { - $this->assertEqual(10, $this->cal->nextDay()); - } - function testPrevHour () { - $this->assertEqual(23, $this->cal->prevHour()); - } - function testThisHour () { - $this->assertEqual(0, $this->cal->thisHour()); - } - function testNextHour () { - $this->assertEqual(1, $this->cal->nextHour()); - } - function testPrevMinute () { - $this->assertEqual(59, $this->cal->prevMinute()); - } - function testThisMinute () { - $this->assertEqual(0, $this->cal->thisMinute()); - } - function testNextMinute () { - $this->assertEqual(1, $this->cal->nextMinute()); - } - function testPrevSecond () { - $this->assertEqual(59, $this->cal->prevSecond()); - } - function testThisSecond () { - $this->assertEqual(0, $this->cal->thisSecond()); - } - function testNextSecond () { - $this->assertEqual(1, $this->cal->nextSecond()); - } - function testGetTimeStamp() { - $stamp = mktime(0,0,0,10,9,2003); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } - function testNewTimeStamp() { - $stamp = mktime(0,0,0,7,28,2004); - $this->cal->setTimestamp($stamp); - $this->assertEqual('29 2004', date('W Y', $this->cal->prevWeek(true))); - $this->assertEqual('30 2004', date('W Y', $this->cal->thisWeek(true))); - $this->assertEqual('31 2004', date('W Y', $this->cal->nextWeek(true))); - } - function testPrevWeekInMonth() { - $this->assertEqual(1, $this->cal->prevWeek()); - $stamp = mktime(0,0,0,2,3,2005); - $this->cal->setTimestamp($stamp); - $this->assertEqual(0, $this->cal->prevWeek()); - } - function testThisWeekInMonth() { - $this->assertEqual(2, $this->cal->thisWeek()); - $stamp = mktime(0,0,0,2,3,2005); - $this->cal->setTimestamp($stamp); - $this->assertEqual(1, $this->cal->thisWeek()); - $stamp = mktime(0,0,0,1,1,2005); - $this->cal->setTimestamp($stamp); - $this->assertEqual(1, $this->cal->thisWeek()); - $stamp = mktime(0,0,0,1,3,2005); - $this->cal->setTimestamp($stamp); - $this->assertEqual(2, $this->cal->thisWeek()); - } - function testNextWeekInMonth() { - $this->assertEqual(3, $this->cal->nextWeek()); - $stamp = mktime(0,0,0,2,3,2005); - $this->cal->setTimestamp($stamp); - $this->assertEqual(2, $this->cal->nextWeek()); - } - function testPrevWeekInYear() { - $this->assertEqual(date('W', $this->cal->prevWeek('timestamp')), $this->cal->prevWeek('n_in_year')); - $stamp = mktime(0,0,0,1,1,2004); - $this->cal->setTimestamp($stamp); - $this->assertEqual(date('W', $this->cal->nextWeek('timestamp')), $this->cal->nextWeek('n_in_year')); - } - function testThisWeekInYear() { - $this->assertEqual(date('W', $this->cal->thisWeek('timestamp')), $this->cal->thisWeek('n_in_year')); - $stamp = mktime(0,0,0,1,1,2004); - $this->cal->setTimestamp($stamp); - $this->assertEqual(date('W', $this->cal->thisWeek('timestamp')), $this->cal->thisWeek('n_in_year')); - } - function testFirstWeekInYear() { - $stamp = mktime(0,0,0,1,4,2004); - $this->cal->setTimestamp($stamp); - $this->assertEqual(1, $this->cal->thisWeek('n_in_year')); - } - function testNextWeekInYear() { - $this->assertEqual(date('W', $this->cal->nextWeek('timestamp')), $this->cal->nextWeek('n_in_year')); - } - function testPrevWeekArray() { - $testArray = array( - 'year'=>2003, - 'month'=>9, - 'day'=>28, - 'hour'=>0, - 'minute'=>0, - 'second'=>0 - ); - $this->assertEqual($testArray, $this->cal->prevWeek('array')); - } - function testThisWeekArray() { - $testArray = array( - 'year'=>2003, - 'month'=>10, - 'day'=>5, - 'hour'=>0, - 'minute'=>0, - 'second'=>0 - ); - $this->assertEqual($testArray, $this->cal->thisWeek('array')); - } - function testNextWeekArray() { - $testArray = array( - 'year'=>2003, - 'month'=>10, - 'day'=>12, - 'hour'=>0, - 'minute'=>0, - 'second'=>0 - ); - $this->assertEqual($testArray, $this->cal->nextWeek('array')); - } - function testPrevWeekObject() { - $testWeek = Calendar_Factory::create('Week', 2003,9,28); - $Week = $this->cal->prevWeek('object'); - $this->assertEqual($testWeek->getTimeStamp(),$Week->getTimeStamp()); - } - function testThisWeekObject() { - $testWeek = Calendar_Factory::create('Week', 2003,10,5); - $Week = $this->cal->thisWeek('object'); - $this->assertEqual($testWeek->getTimeStamp(),$Week->getTimeStamp()); - } - function testNextWeekObject() { - $testWeek = Calendar_Factory::create('Week', 2003,10,12); - $Week = $this->cal->nextWeek('object'); - $this->assertEqual($testWeek->getTimeStamp(),$Week->getTimeStamp()); - } -} - -class TestOfWeek_firstday_0_Build extends TestOfWeek_firstday_0 { - function TestOfWeek_firstday_0_Build() { - $this->UnitTestCase('Test of Week::build() - FirstDay = Sunday'); - } - function testSize() { - $this->cal->build(); - $this->assertEqual(7, $this->cal->size()); - } - - function testFetch() { - $this->cal->build(); - $i=0; - while ($Child = $this->cal->fetch()) { - $i++; - } - $this->assertEqual(7, $i); - } - function testFetchAll() { - $this->cal->build(); - $children = array(); - $i = 1; - while ( $Child = $this->cal->fetch() ) { - $children[$i]=$Child; - $i++; - } - $this->assertEqual($children,$this->cal->fetchAll()); - } - - function testSelection() { - require_once(CALENDAR_ROOT . 'Day.php'); - $selection = array(Calendar_Factory::create('Day', 2003, 10, 6)); - $this->cal->build($selection); - $i = 1; - while ($Child = $this->cal->fetch()) { - if ($i == 2) { - break; //06-10-2003 is the 2nd day of the week - } - $i++; - } - $this->assertTrue($Child->isSelected()); - } - function testSelectionCornerCase() { - require_once(CALENDAR_ROOT . 'Day.php'); - $selectedDays = array( - Calendar_Factory::create('Day', 2003, 12, 28), - Calendar_Factory::create('Day', 2003, 12, 29), - Calendar_Factory::create('Day', 2003, 12, 30), - Calendar_Factory::create('Day', 2003, 12, 31), - Calendar_Factory::create('Day', 2004, 01, 01), - Calendar_Factory::create('Day', 2004, 01, 02), - Calendar_Factory::create('Day', 2004, 01, 03) - ); - $this->cal = Calendar_Factory::create('Week', 2003, 12, 31, 0); - $this->cal->build($selectedDays); - while ($Day = $this->cal->fetch()) { - $this->assertTrue($Day->isSelected()); - } - $this->cal = Calendar_Factory::create('Week', 2004, 1, 1, 0); - $this->cal->build($selectedDays); - while ($Day = $this->cal->fetch()) { - $this->assertTrue($Day->isSelected()); - } - } -} -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfWeek_firstday_0(); - $test->run(new HtmlReporter()); - $test = &new TestOfWeek_firstday_0_Build(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/week_test.php b/data/module/Calendar/tests/week_test.php deleted file mode 100644 index d28f5eb9d21..00000000000 --- a/data/module/Calendar/tests/week_test.php +++ /dev/null @@ -1,241 +0,0 @@ -UnitTestCase('Test of Week'); - } - function setUp() { - $this->cal = Calendar_Factory::create('Week', 2003, 10, 9); - //print_r($this->cal); - } - function testPrevDay () { - $this->assertEqual(8, $this->cal->prevDay()); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2003, - 'month' => 10, - 'day' => 8, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } - function testThisDay () { - $this->assertEqual(9, $this->cal->thisDay()); - } - function testNextDay () { - $this->assertEqual(10, $this->cal->nextDay()); - } - function testPrevHour () { - $this->assertEqual(23, $this->cal->prevHour()); - } - function testThisHour () { - $this->assertEqual(0, $this->cal->thisHour()); - } - function testNextHour () { - $this->assertEqual(1, $this->cal->nextHour()); - } - function testPrevMinute () { - $this->assertEqual(59, $this->cal->prevMinute()); - } - function testThisMinute () { - $this->assertEqual(0, $this->cal->thisMinute()); - } - function testNextMinute () { - $this->assertEqual(1, $this->cal->nextMinute()); - } - function testPrevSecond () { - $this->assertEqual(59, $this->cal->prevSecond()); - } - function testThisSecond () { - $this->assertEqual(0, $this->cal->thisSecond()); - } - function testNextSecond () { - $this->assertEqual(1, $this->cal->nextSecond()); - } - function testGetTimeStamp() { - $stamp = mktime(0,0,0,10,9,2003); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } - function testNewTimeStamp() { - $stamp = mktime(0,0,0,7,28,2004); - $this->cal->setTimestamp($stamp); - $this->assertEqual('30 2004', date('W Y', $this->cal->prevWeek(true))); - $this->assertEqual('31 2004', date('W Y', $this->cal->thisWeek(true))); - $this->assertEqual('32 2004', date('W Y', $this->cal->nextWeek(true))); - } - function testPrevWeekInMonth() { - $this->assertEqual(1, $this->cal->prevWeek()); - $stamp = mktime(0,0,0,2,3,2005); - $this->cal->setTimestamp($stamp); - $this->assertEqual(0, $this->cal->prevWeek()); - } - function testThisWeekInMonth() { - $this->assertEqual(2, $this->cal->thisWeek()); - $stamp = mktime(0,0,0,2,3,2005); - $this->cal->setTimestamp($stamp); - $this->assertEqual(1, $this->cal->thisWeek()); - $stamp = mktime(0,0,0,1,1,2005); - $this->cal->setTimestamp($stamp); - $this->assertEqual(1, $this->cal->thisWeek()); - $stamp = mktime(0,0,0,1,3,2005); - $this->cal->setTimestamp($stamp); - $this->assertEqual(2, $this->cal->thisWeek()); - } - function testNextWeekInMonth() { - $this->assertEqual(3, $this->cal->nextWeek()); - $stamp = mktime(0,0,0,2,3,2005); - $this->cal->setTimestamp($stamp); - $this->assertEqual(2, $this->cal->nextWeek()); - } - function testPrevWeekInYear() { - $this->assertEqual(date('W', $this->cal->prevWeek('timestamp')), $this->cal->prevWeek('n_in_year')); - $stamp = mktime(0,0,0,1,1,2004); - $this->cal->setTimestamp($stamp); - $this->assertEqual(date('W', $this->cal->nextWeek('timestamp')), $this->cal->nextWeek('n_in_year')); - } - function testThisWeekInYear() { - $this->assertEqual(date('W', $this->cal->thisWeek('timestamp')), $this->cal->thisWeek('n_in_year')); - $stamp = mktime(0,0,0,1,1,2004); - $this->cal->setTimestamp($stamp); - $this->assertEqual(date('W', $this->cal->thisWeek('timestamp')), $this->cal->thisWeek('n_in_year')); - } - function testFirstWeekInYear() { - $stamp = mktime(0,0,0,1,4,2004); - $this->cal->setTimestamp($stamp); - $this->assertEqual(1, $this->cal->thisWeek('n_in_year')); - } - function testNextWeekInYear() { - $this->assertEqual(date('W', $this->cal->nextWeek('timestamp')), $this->cal->nextWeek('n_in_year')); - } - function testPrevWeekArray() { - $testArray = array( - 'year'=>2003, - 'month'=>9, - 'day'=>29, - 'hour'=>0, - 'minute'=>0, - 'second'=>0 - ); - $this->assertEqual($testArray, $this->cal->prevWeek('array')); - } - function testThisWeekArray() { - $testArray = array( - 'year'=>2003, - 'month'=>10, - 'day'=>6, - 'hour'=>0, - 'minute'=>0, - 'second'=>0 - ); - $this->assertEqual($testArray, $this->cal->thisWeek('array')); - } - function testNextWeekArray() { - $testArray = array( - 'year'=>2003, - 'month'=>10, - 'day'=>13, - 'hour'=>0, - 'minute'=>0, - 'second'=>0 - ); - $this->assertEqual($testArray, $this->cal->nextWeek('array')); - } - function testPrevWeekObject() { - $testWeek = Calendar_Factory::create('Week', 2003, 9, 29); //week starts on monday - $Week = $this->cal->prevWeek('object'); - $this->assertEqual($testWeek->getTimeStamp(), $Week->getTimeStamp()); - } - function testThisWeekObject() { - $testWeek = Calendar_Factory::create('Week', 2003, 10, 6); //week starts on monday - $Week = $this->cal->thisWeek('object'); - $this->assertEqual($testWeek->getTimeStamp(), $Week->getTimeStamp()); - } - function testNextWeekObject() { - $testWeek = Calendar_Factory::create('Week', 2003, 10, 13); //week starts on monday - $Week = $this->cal->nextWeek('object'); - $this->assertEqual($testWeek->getTimeStamp(), $Week->getTimeStamp()); - } -} - -class TestOfWeekBuild extends TestOfWeek { - function TestOfWeekBuild() { - $this->UnitTestCase('Test of Week::build()'); - } - function testSize() { - $this->cal->build(); - $this->assertEqual(7, $this->cal->size()); - } - - function testFetch() { - $this->cal->build(); - $i=0; - while ($Child = $this->cal->fetch()) { - $i++; - } - $this->assertEqual(7, $i); - } - function testFetchAll() { - $this->cal->build(); - $children = array(); - $i = 1; - while ( $Child = $this->cal->fetch() ) { - $children[$i]=$Child; - $i++; - } - $this->assertEqual($children,$this->cal->fetchAll()); - } - - function testSelection() { - require_once(CALENDAR_ROOT . 'Day.php'); - $selection = array(Calendar_Factory::create('Day', 2003, 10, 7)); - $this->cal->build($selection); - $i = 1; - while ($Child = $this->cal->fetch()) { - if ($i == 2) { - break; //07-10-2003 is the 2nd day of the week (starting on monday) - } - $i++; - } - $this->assertTrue($Child->isSelected()); - } - function testSelectionCornerCase() { - require_once(CALENDAR_ROOT . 'Day.php'); - $selectedDays = array( - Calendar_Factory::create('Day', 2003, 12, 29), - Calendar_Factory::create('Day', 2003, 12, 30), - Calendar_Factory::create('Day', 2003, 12, 31), - Calendar_Factory::create('Day', 2004, 01, 01), - Calendar_Factory::create('Day', 2004, 01, 02), - Calendar_Factory::create('Day', 2004, 01, 03), - Calendar_Factory::create('Day', 2004, 01, 04) - ); - $this->cal = Calendar_Factory::create('Week', 2003, 12, 31, 0); - $this->cal->build($selectedDays); - while ($Day = $this->cal->fetch()) { - $this->assertTrue($Day->isSelected()); - } - $this->cal = Calendar_Factory::create('Week', 2004, 1, 1, 0); - $this->cal->build($selectedDays); - while ($Day = $this->cal->fetch()) { - $this->assertTrue($Day->isSelected()); - } - } -} -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfWeek(); - $test->run(new HtmlReporter()); - $test = &new TestOfWeekBuild(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Calendar/tests/year_test.php b/data/module/Calendar/tests/year_test.php deleted file mode 100644 index 9288916fbd4..00000000000 --- a/data/module/Calendar/tests/year_test.php +++ /dev/null @@ -1,142 +0,0 @@ -UnitTestCase('Test of Year'); - } - function setUp() { - $this->cal = new Calendar_Year(2003); - } - function testPrevYear_Object() { - $this->assertEqual(new Calendar_Year(2002), $this->cal->prevYear('object')); - } - function testThisYear_Object() { - $this->assertEqual(new Calendar_Year(2003), $this->cal->thisYear('object')); - } - function testPrevMonth () { - $this->assertEqual(12,$this->cal->prevMonth()); - } - function testPrevMonth_Array () { - $this->assertEqual( - array( - 'year' => 2002, - 'month' => 12, - 'day' => 1, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevMonth('array')); - } - function testThisMonth () { - $this->assertEqual(1,$this->cal->thisMonth()); - } - function testNextMonth () { - $this->assertEqual(2,$this->cal->nextMonth()); - } - function testPrevDay () { - $this->assertEqual(31,$this->cal->prevDay()); - } - function testPrevDay_Array () { - $this->assertEqual( - array( - 'year' => 2002, - 'month' => 12, - 'day' => 31, - 'hour' => 0, - 'minute' => 0, - 'second' => 0), - $this->cal->prevDay('array')); - } - function testThisDay () { - $this->assertEqual(1,$this->cal->thisDay()); - } - function testNextDay () { - $this->assertEqual(2,$this->cal->nextDay()); - } - function testPrevHour () { - $this->assertEqual(23,$this->cal->prevHour()); - } - function testThisHour () { - $this->assertEqual(0,$this->cal->thisHour()); - } - function testNextHour () { - $this->assertEqual(1,$this->cal->nextHour()); - } - function testPrevMinute () { - $this->assertEqual(59,$this->cal->prevMinute()); - } - function testThisMinute () { - $this->assertEqual(0,$this->cal->thisMinute()); - } - function testNextMinute () { - $this->assertEqual(1,$this->cal->nextMinute()); - } - function testPrevSecond () { - $this->assertEqual(59,$this->cal->prevSecond()); - } - function testThisSecond () { - $this->assertEqual(0,$this->cal->thisSecond()); - } - function testNextSecond () { - $this->assertEqual(1,$this->cal->nextSecond()); - } - function testGetTimeStamp() { - $stamp = mktime(0,0,0,1,1,2003); - $this->assertEqual($stamp,$this->cal->getTimeStamp()); - } -} - -class TestOfYearBuild extends TestOfYear { - function TestOfYearBuild() { - $this->UnitTestCase('Test of Year::build()'); - } - function testSize() { - $this->cal->build(); - $this->assertEqual(12,$this->cal->size()); - } - function testFetch() { - $this->cal->build(); - $i=0; - while ( $Child = $this->cal->fetch() ) { - $i++; - } - $this->assertEqual(12,$i); - } - function testFetchAll() { - $this->cal->build(); - $children = array(); - $i = 1; - while ( $Child = $this->cal->fetch() ) { - $children[$i]=$Child; - $i++; - } - $this->assertEqual($children,$this->cal->fetchAll()); - } - function testSelection() { - require_once(CALENDAR_ROOT . 'Month.php'); - $selection = array(new Calendar_Month(2003,10)); - $this->cal->build($selection); - $i = 1; - while ( $Child = $this->cal->fetch() ) { - if ( $i == 10 ) - break; - $i++; - } - $this->assertTrue($Child->isSelected()); - } -} - -if (!defined('TEST_RUNNING')) { - define('TEST_RUNNING', true); - $test = &new TestOfYear(); - $test->run(new HtmlReporter()); - $test = &new TestOfYearBuild(); - $test->run(new HtmlReporter()); -} -?> diff --git a/data/module/Compat/Compat.php b/data/module/Compat/Compat.php deleted file mode 100644 index fdc29b6c7c4..00000000000 --- a/data/module/Compat/Compat.php +++ /dev/null @@ -1,133 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Compat.php,v 1.19 2005/05/10 12:05:36 aidan Exp $ - - -/** - * Provides missing functionality in the form of constants and functions - * for older versions of PHP - * - * Optionally, you may simply include the file. - * e.g. require_once 'PHP/Compat/Function/scandir.php'; - * - * @category PHP - * @package PHP_Compat - * @version $Revision: 1.19 $ - * @author Aidan Lister - * @static - */ -class PHP_Compat -{ - /** - * Load a function, or array of functions - * - * @param string|array $function The function or functions to load - * @return bool|array TRUE if loaded, FALSE if not - */ - function loadFunction($function) - { - // Recursiveness - if (is_array($function)) { - $res = array(); - foreach ($function as $singlefunc) { - $res[$singlefunc] = PHP_Compat::loadFunction($singlefunc); - } - - return $res; - } - - // Load function - if (!function_exists($function)) { - $file = sprintf('PHP/Compat/Function/%s.php', $function); - if ((@include_once $file) !== false) { - return true; - } - } - - return false; - } - - - /** - * Load a constant, or array of constants - * - * @param string|array $constant The constant or constants to load - * @return bool|array TRUE if loaded, FALSE if not - */ - function loadConstant($constant) - { - // Recursiveness - if (is_array($constant)) { - $res = array(); - foreach ($constant as $singleconst) { - $res[$singleconst] = PHP_Compat::loadConstant($singleconst); - } - - return $res; - } - - // Load constant - $file = sprintf('PHP/Compat/Constant/%s.php', $constant); - if ((@include_once $file) !== false) { - return true; - } - - return false; - } - - - /** - * Load components for a PHP version - * - * @param string $version PHP Version to load - * @return array An associative array of component names loaded - */ - function loadVersion($version = null) - { - // Include list of components - require 'PHP/Compat/Components.php'; - - // Include version_compare to work with older versions - PHP_Compat::loadFunction('version_compare'); - - // Init - $phpversion = phpversion(); - $methods = array( - 'function' => 'loadFunction', - 'constant' => 'loadConstant'); - $res = array(); - - // Iterate each component - foreach ($components as $type => $slice) { - foreach ($slice as $component => $compversion) { - if (($version === null && - 1 === version_compare($compversion, $phpversion)) || // C > PHP - (0 === version_compare($compversion, $version) || // C = S - 1 === version_compare($compversion, $phpversion))) { // C > PHP - - $res[$type][$component] = - call_user_func(array('PHP_Compat', $methods[$type]), $component); - } - } - } - - return $res; - } -} - -?> diff --git a/data/module/Compat/Compat/Components.php b/data/module/Compat/Compat/Components.php deleted file mode 100644 index 86352e38769..00000000000 --- a/data/module/Compat/Compat/Components.php +++ /dev/null @@ -1,108 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Components.php,v 1.10 2005/12/05 14:49:56 aidan Exp $ - - -// Functions -$components['function']['array_change_key_case'] = '4.2.0'; -$components['function']['array_chunk'] = '4.2.0'; -$components['function']['array_combine'] = '5.0.0'; -$components['function']['array_diff_assoc'] = '4.3.0'; -$components['function']['array_diff_key'] = '5.0.2'; -$components['function']['array_diff_uassoc'] = '5.0.0'; -$components['function']['array_diff_ukey'] = '5.0.2'; -$components['function']['array_intersect_assoc'] = '5.0.0'; -$components['function']['array_intersect_key'] = '5.0.2'; -$components['function']['array_intersect_uassoc'] = '5.0.0'; -$components['function']['array_intersect_ukey'] = '5.0.2'; -$components['function']['array_key_exists'] = '4.1.0'; -$components['function']['array_product'] = '5.1.0'; -$components['function']['array_search'] = '4.0.5'; -$components['function']['array_udiff'] = '5.0.0'; -$components['function']['array_udiff_assoc'] = '5.0.0'; -$components['function']['array_udiff_uassoc'] = '5.0.0'; -$components['function']['array_uintersect'] = '5.0.0'; -$components['function']['array_uintersect_assoc'] = '5.0.0'; -$components['function']['array_uintersect_uassoc'] = '5.0.0'; -$components['function']['array_walk_recursive'] = '5.0.0'; -$components['function']['bcinvert'] = '5.2.0'; -$components['function']['bcpowmod'] = '5.0.0'; -$components['function']['call_user_func_array'] = '4.0.4'; -$components['function']['clone'] = '5.0.0'; -$components['function']['constant'] = '4.0.4'; -$components['function']['convert_uudecode'] = '5.0.0'; -$components['function']['convert_uuencode'] = '5.0.0'; -$components['function']['debug_print_backtrace'] = '5.0.0'; -$components['function']['file_get_contents'] = '4.3.0'; -$components['function']['file_put_contents'] = '5.0.0'; -$components['function']['floatval'] = '4.2.0'; -$components['function']['fprintf'] = '5.0.0'; -$components['function']['fputcsv'] = '5.0.0'; -$components['function']['get_headers'] = '5.0.0'; -$components['function']['get_include_path'] = '4.3.0'; -$components['function']['html_entity_decode'] = '4.3.0'; -$components['function']['htmlspecialchars_decode'] = '5.1.0'; -$components['function']['http_build_query'] = '5.0.0'; -$components['function']['ibase_timefmt'] = '5.0.0'; -$components['function']['idate'] = '5.1.0'; -$components['function']['image_type_to_mime_type'] = '4.3.0'; -$components['function']['inet_ntop'] = '5.1.0'; -$components['function']['inet_pton'] = '5.1.0'; -$components['function']['ini_get_all'] = '4.2.0'; -$components['function']['is_a'] = '4.2.0'; -$components['function']['is_scalar'] = '4.0.5'; -$components['function']['md5_file'] = '4.2.0'; -$components['function']['mhash'] = '4.0.0'; -$components['function']['mime_content_type'] = '4.3.0'; -$components['function']['ob_clean'] = '4.2.0'; -$components['function']['ob_flush'] = '4.2.0'; -$components['function']['ob_get_clean'] = '4.3.0'; -$components['function']['ob_get_flush'] = '4.3.0'; -$components['function']['php_strip_whitespace'] = '5.0.0'; -$components['function']['property_exists'] = '5.1.0'; -$components['function']['pg_affected_rows'] = '4.2.0'; -$components['function']['pg_escape_bytea'] = '4.2.0'; -$components['function']['pg_unescape_bytea'] = '4.2.0'; -$components['function']['restore_include_path'] = '4.3.0'; -$components['function']['scandir'] = '5.0.0'; -$components['function']['set_include_path'] = '4.3.0'; -$components['function']['str_ireplace'] = '5.0.0'; -$components['function']['str_rot13'] = '4.2.0'; -$components['function']['str_shuffle'] = '4.3.0'; -$components['function']['str_split'] = '5.0.0'; -$components['function']['str_word_count'] = '4.3.0'; -$components['function']['stripos'] = '5.0.0'; -$components['function']['strpbrk'] = '5.0.0'; -$components['function']['strripos'] = '5.0.0'; -$components['function']['substr_compare'] = '5.0.0'; -$components['function']['time_sleep_until'] = '5.1.0'; -$components['function']['var_export'] = '4.2.0'; -$components['function']['version_compare'] = '4.1.0'; -$components['function']['vprintf'] = '4.1.0'; -$components['function']['vsprintf'] = '4.1.0'; - -// Constants -$components['constant']['DIRECTORY_SEPARATOR'] = '4.0.6'; -$components['constant']['E_STRICT'] = '5.0.0'; -$components['constant']['FILE'] = '4.3.0'; -$components['constant']['PATH_SEPARATOR'] = '4.3.0'; -$components['constant']['PHP_EOL'] = '5.0.1'; -$components['constant']['STD'] = '4.3.0'; -$components['constant']['T'] = '5.0.0'; -$components['constant']['UPLOAD_ERR'] = '4.3.0'; -?> diff --git a/data/module/Compat/Compat/Constant/DIRECTORY_SEPARATOR.php b/data/module/Compat/Compat/Constant/DIRECTORY_SEPARATOR.php deleted file mode 100644 index 27123086dde..00000000000 --- a/data/module/Compat/Compat/Constant/DIRECTORY_SEPARATOR.php +++ /dev/null @@ -1,37 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: DIRECTORY_SEPARATOR.php,v 1.1 2004/11/28 03:55:28 aidan Exp $ - - -/** - * Replace constant DIRECTORY_SEPARATOR - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/reserved.constants.standard - * @author Aidan Lister - * @version $Revision: 1.1 $ - * @since PHP 4.0.6 - */ -if (!defined('DIRECTORY_SEPARATOR')) { - define('DIRECTORY_SEPARATOR', - strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : '/' - ); -} - -?> diff --git a/data/module/Compat/Compat/Constant/E_STRICT.php b/data/module/Compat/Compat/Constant/E_STRICT.php deleted file mode 100644 index bb4471fdf33..00000000000 --- a/data/module/Compat/Compat/Constant/E_STRICT.php +++ /dev/null @@ -1,35 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: E_STRICT.php,v 1.11 2004/08/19 10:09:52 aidan Exp $ - - -/** - * Replace constant E_STRICT - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ref.errorfunc - * @author Aidan Lister - * @version $Revision: 1.11 $ - * @since PHP 5 - */ -if (!defined('E_STRICT')) { - define('E_STRICT', 2048); -} - -?> diff --git a/data/module/Compat/Compat/Constant/FILE.php b/data/module/Compat/Compat/Constant/FILE.php deleted file mode 100644 index 5ee689d7182..00000000000 --- a/data/module/Compat/Compat/Constant/FILE.php +++ /dev/null @@ -1,51 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: FILE.php,v 1.8 2004/08/19 10:09:52 aidan Exp $ - - -/** - * Replace filesystem constants - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ref.filesystem - * @author Aidan Lister - * @version $Revision: 1.8 $ - * @since PHP 5 - */ -if (!defined('FILE_USE_INCLUDE_PATH')) { - define('FILE_USE_INCLUDE_PATH', 1); -} - -if (!defined('FILE_IGNORE_NEW_LINES')) { - define('FILE_IGNORE_NEW_LINES', 2); -} - -if (!defined('FILE_SKIP_EMPTY_LINES')) { - define('FILE_SKIP_EMPTY_LINES', 4); -} - -if (!defined('FILE_APPEND')) { - define('FILE_APPEND', 8); -} - -if (!defined('FILE_NO_DEFAULT_CONTEXT')) { - define('FILE_NO_DEFAULT_CONTEXT', 16); -} - -?> diff --git a/data/module/Compat/Compat/Constant/PATH_SEPARATOR.php b/data/module/Compat/Compat/Constant/PATH_SEPARATOR.php deleted file mode 100644 index c870409b40d..00000000000 --- a/data/module/Compat/Compat/Constant/PATH_SEPARATOR.php +++ /dev/null @@ -1,37 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: PATH_SEPARATOR.php,v 1.13 2004/11/14 16:10:18 aidan Exp $ - - -/** - * Replace constant PATH_SEPARATOR - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ref.dir - * @author Aidan Lister - * @version $Revision: 1.13 $ - * @since PHP 4.3.0 - */ -if (!defined('PATH_SEPARATOR')) { - define('PATH_SEPARATOR', - strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? ';' : ':' - ); -} - -?> diff --git a/data/module/Compat/Compat/Constant/PHP_EOL.php b/data/module/Compat/Compat/Constant/PHP_EOL.php deleted file mode 100644 index 832f8e9f337..00000000000 --- a/data/module/Compat/Compat/Constant/PHP_EOL.php +++ /dev/null @@ -1,49 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: PHP_EOL.php,v 1.2 2004/10/10 13:58:09 aidan Exp $ - - -/** - * Replace PHP_EOL constant - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/reserved.constants.core - * @author Aidan Lister - * @version $Revision: 1.2 $ - * @since PHP 5.0.2 - */ -if (!defined('PHP_EOL')) { - switch (strtoupper(substr(PHP_OS, 0, 3))) { - // Windows - case 'WIN': - define('PHP_EOL', "\r\n"); - break; - - // Mac - case 'DAR': - define('PHP_EOL', "\r"); - break; - - // Unix - default: - define('PHP_EOL', "\n"); - } -} - -?> diff --git a/data/module/Compat/Compat/Constant/STD.php b/data/module/Compat/Compat/Constant/STD.php deleted file mode 100644 index 6073709dbce..00000000000 --- a/data/module/Compat/Compat/Constant/STD.php +++ /dev/null @@ -1,43 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: STD.php,v 1.9 2004/08/19 10:09:52 aidan Exp $ - - -/** - * Replace commandline constants - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/features.commandline - * @author Aidan Lister - * @version $Revision: 1.9 $ - * @since PHP 4.3.0 - */ -if (!defined('STDIN')) { - define('STDIN', fopen('php://stdin', 'r')); -} - -if (!defined('STDOUT')) { - define('STDOUT', fopen('php://stdout', 'w')); -} - -if (!defined('STDERR')) { - define('STDERR', fopen('php://stderr', 'w')); -} - -?> diff --git a/data/module/Compat/Compat/Constant/T.php b/data/module/Compat/Compat/Constant/T.php deleted file mode 100644 index f0ee53fc8c5..00000000000 --- a/data/module/Compat/Compat/Constant/T.php +++ /dev/null @@ -1,72 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: T.php,v 1.4 2004/11/14 16:43:40 aidan Exp $ - - -/** - * Replace tokenizer constants - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ref.tokenizer - * @author Aidan Lister - * @version $Revision: 1.4 $ - * @since PHP 5 - */ -if (!defined('T_ML_COMMENT')) { - define('T_ML_COMMENT', T_COMMENT); -} -if (!defined('T_DOC_COMMENT')) { - define('T_DOC_COMMENT', T_ML_COMMENT); -} - -if (!defined('T_OLD_FUNCTION')) { - define('T_OLD_FUNCTION', -1); -} -if (!defined('T_ABSTRACT')) { - define('T_ABSTRACT', -1); -} -if (!defined('T_CATCH')) { - define('T_CATCH', -1); -} -if (!defined('T_FINAL')) { - define('T_FINAL', -1); -} -if (!defined('T_INSTANCEOF')) { - define('T_INSTANCEOF', -1); -} -if (!defined('T_PRIVATE')) { - define('T_PRIVATE', -1); -} -if (!defined('T_PROTECTED')) { - define('T_PROTECTED', -1); -} -if (!defined('T_PUBLIC')) { - define('T_PUBLIC', -1); -} -if (!defined('T_THROW')) { - define('T_THROW', -1); -} -if (!defined('T_TRY')) { - define('T_TRY', -1); -} -if (!defined('T_CLONE')) { - define('T_CLONE', -1); -} - -?> diff --git a/data/module/Compat/Compat/Constant/UPLOAD_ERR.php b/data/module/Compat/Compat/Constant/UPLOAD_ERR.php deleted file mode 100644 index 568f23baa83..00000000000 --- a/data/module/Compat/Compat/Constant/UPLOAD_ERR.php +++ /dev/null @@ -1,51 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: UPLOAD_ERR.php,v 1.1 2004/10/12 08:41:11 aidan Exp $ - - -/** - * Replace upload error constants - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/features.file-upload.errors - * @author Aidan Lister - * @version $Revision: 1.1 $ - * @since PHP 4.3.0 - */ -if (!defined('UPLOAD_ERR_OK')) { - define('UPLOAD_ERR_OK', 0); -} - -if (!defined('UPLOAD_ERR_INI_SIZE')) { - define('UPLOAD_ERR_INI_SIZE', 1); -} - -if (!defined('UPLOAD_ERR_FORM_SIZE')) { - define('UPLOAD_ERR_FORM_SIZE', 2); -} - -if (!defined('UPLOAD_ERR_PARTIAL')) { - define('UPLOAD_ERR_PARTIAL', 3); -} - -if (!defined('UPLOAD_ERR_NO_FILE')) { - define('UPLOAD_ERR_NO_FILE', 4); -} - -?> diff --git a/data/module/Compat/Compat/Function/_sha256.php b/data/module/Compat/Compat/Function/_sha256.php deleted file mode 100644 index a19d0c51bb0..00000000000 --- a/data/module/Compat/Compat/Function/_sha256.php +++ /dev/null @@ -1,156 +0,0 @@ -, Arpad Ray - * @link http://php.net/function.hash - * @author revulo - * @require PHP 4.0.0 - */ -function php_compat_sha256($str, $raw_output = false) -{ - $h0 = (int)0x6a09e667; - $h1 = (int)0xbb67ae85; - $h2 = (int)0x3c6ef372; - $h3 = (int)0xa54ff53a; - $h4 = (int)0x510e527f; - $h5 = (int)0x9b05688c; - $h6 = (int)0x1f83d9ab; - $h7 = (int)0x5be0cd19; - - $k = array( - (int)0x428a2f98, (int)0x71374491, (int)0xb5c0fbcf, (int)0xe9b5dba5, - (int)0x3956c25b, (int)0x59f111f1, (int)0x923f82a4, (int)0xab1c5ed5, - (int)0xd807aa98, (int)0x12835b01, (int)0x243185be, (int)0x550c7dc3, - (int)0x72be5d74, (int)0x80deb1fe, (int)0x9bdc06a7, (int)0xc19bf174, - (int)0xe49b69c1, (int)0xefbe4786, (int)0x0fc19dc6, (int)0x240ca1cc, - (int)0x2de92c6f, (int)0x4a7484aa, (int)0x5cb0a9dc, (int)0x76f988da, - (int)0x983e5152, (int)0xa831c66d, (int)0xb00327c8, (int)0xbf597fc7, - (int)0xc6e00bf3, (int)0xd5a79147, (int)0x06ca6351, (int)0x14292967, - (int)0x27b70a85, (int)0x2e1b2138, (int)0x4d2c6dfc, (int)0x53380d13, - (int)0x650a7354, (int)0x766a0abb, (int)0x81c2c92e, (int)0x92722c85, - (int)0xa2bfe8a1, (int)0xa81a664b, (int)0xc24b8b70, (int)0xc76c51a3, - (int)0xd192e819, (int)0xd6990624, (int)0xf40e3585, (int)0x106aa070, - (int)0x19a4c116, (int)0x1e376c08, (int)0x2748774c, (int)0x34b0bcb5, - (int)0x391c0cb3, (int)0x4ed8aa4a, (int)0x5b9cca4f, (int)0x682e6ff3, - (int)0x748f82ee, (int)0x78a5636f, (int)0x84c87814, (int)0x8cc70208, - (int)0x90befffa, (int)0xa4506ceb, (int)0xbef9a3f7, (int)0xc67178f2 - ); - - $len = strlen($str); - - $str .= "\x80"; - $str .= str_repeat("\0", 63 - ($len + 8) % 64); - $str .= pack('N2', $len >> 29, $len << 3); - - for ($i = 0; $i < strlen($str); $i += 64) { - - $w = array(); - for ($j = 0; $j < 16; ++$j) { - $index = $i + $j * 4; - $w[$j] = ord($str[$index]) << 24 - | ord($str[$index + 1]) << 16 - | ord($str[$index + 2]) << 8 - | ord($str[$index + 3]); - } - for ($j = 16; $j < 64; ++$j) { - $s0 = php_compat_sha256_rotr_helper($w[$j - 15], 7) - ^ php_compat_sha256_rotr_helper($w[$j - 15], 18) - ^ php_compat_sha256_shr_helper ($w[$j - 15], 3); - - $s1 = php_compat_sha256_rotr_helper($w[$j - 2], 17) - ^ php_compat_sha256_rotr_helper($w[$j - 2], 19) - ^ php_compat_sha256_shr_helper ($w[$j - 2], 10); - - $w[$j] = php_compat_sha256_add32_helper( - php_compat_sha256_add32_helper( - php_compat_sha256_add32_helper($w[$j - 16], $s0), $w[$j - 7]), $s1); - } - - $a = $h0; - $b = $h1; - $c = $h2; - $d = $h3; - $e = $h4; - $f = $h5; - $g = $h6; - $h = $h7; - - for ($j = 0; $j < 64; ++$j) { - $s1 = php_compat_sha256_rotr_helper($e, 6) - ^ php_compat_sha256_rotr_helper($e, 11) - ^ php_compat_sha256_rotr_helper($e, 25); - - $ch = ($e & $f) ^ (~$e & $g); - - $s0 = php_compat_sha256_rotr_helper($a, 2) - ^ php_compat_sha256_rotr_helper($a, 13) - ^ php_compat_sha256_rotr_helper($a, 22); - - $maj = ($a & $b) ^ ($a & $c) ^ ($b & $c); - - $t1 = php_compat_sha256_add32_helper( - php_compat_sha256_add32_helper( - php_compat_sha256_add32_helper( - php_compat_sha256_add32_helper($h, $s1), $ch), $k[$j]), $w[$j]); - - $t2 = php_compat_sha256_add32_helper($s0, $maj); - - $h = $g; - $g = $f; - $f = $e; - $e = php_compat_sha256_add32_helper($d, $t1); - $d = $c; - $c = $b; - $b = $a; - $a = php_compat_sha256_add32_helper($t1, $t2); - } - - $h0 = php_compat_sha256_add32_helper($h0, $a); - $h1 = php_compat_sha256_add32_helper($h1, $b); - $h2 = php_compat_sha256_add32_helper($h2, $c); - $h3 = php_compat_sha256_add32_helper($h3, $d); - $h4 = php_compat_sha256_add32_helper($h4, $e); - $h5 = php_compat_sha256_add32_helper($h5, $f); - $h6 = php_compat_sha256_add32_helper($h6, $g); - $h7 = php_compat_sha256_add32_helper($h7, $h); - } - - $h0 &= (int)0xffffffff; - $h1 &= (int)0xffffffff; - $h2 &= (int)0xffffffff; - $h3 &= (int)0xffffffff; - $h4 &= (int)0xffffffff; - $h5 &= (int)0xffffffff; - $h6 &= (int)0xffffffff; - $h7 &= (int)0xffffffff; - - $hash = sprintf('%08x%08x%08x%08x%08x%08x%08x%08x', $h0, $h1, $h2, $h3, $h4, $h5, $h6, $h7); - - if ($raw_output) { - return pack('H*', $hash); - } else { - return $hash; - } -} - -function php_compat_sha256_add32_helper($x, $y) -{ - $lsw = ($x & 0xffff) + ($y & 0xffff); - $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16); - return ($msw << 16) | ($lsw & 0xffff); -} - -function php_compat_sha256_shr_helper($x, $n) -{ - return ($x >> $n) & (0x7fffffff >> ($n - 1)); -} - -function php_compat_sha256_rotr_helper($x, $n) -{ - return ($x << (32 - $n)) | ($x >> $n) & (0x7fffffff >> ($n - 1)); -} diff --git a/data/module/Compat/Compat/Function/array_change_key_case.php b/data/module/Compat/Compat/Function/array_change_key_case.php deleted file mode 100644 index fb635b40682..00000000000 --- a/data/module/Compat/Compat/Function/array_change_key_case.php +++ /dev/null @@ -1,64 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: array_change_key_case.php,v 1.11 2005/12/07 21:08:57 aidan Exp $ - - -if (!defined('CASE_LOWER')) { - define('CASE_LOWER', 0); -} - -if (!defined('CASE_UPPER')) { - define('CASE_UPPER', 1); -} - - -/** - * Replace array_change_key_case() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_change_key_case - * @author Stephan Schmidt - * @author Aidan Lister - * @version $Revision: 1.11 $ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('array_change_key_case')) { - function array_change_key_case($input, $case = CASE_LOWER) - { - if (!is_array($input)) { - user_error('array_change_key_case(): The argument should be an array', - E_USER_WARNING); - return false; - } - - $output = array (); - $keys = array_keys($input); - $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper'; - - foreach ($keys as $key) { - $output[$casefunc($key)] = $input[$key]; - } - - return $output; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_chunk.php b/data/module/Compat/Compat/Function/array_chunk.php deleted file mode 100644 index 34de55a1f0d..00000000000 --- a/data/module/Compat/Compat/Function/array_chunk.php +++ /dev/null @@ -1,72 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_chunk.php,v 1.14 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_combine() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_chunk - * @author Aidan Lister - * @author Thiemo Mttig (http://maettig.com) - * @version $Revision: 1.14 $ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('array_chunk')) { - function array_chunk($input, $size, $preserve_keys = false) - { - if (!is_array($input)) { - user_error('array_chunk() expects parameter 1 to be array, ' . - gettype($input) . ' given', E_USER_WARNING); - return; - } - - if (!is_numeric($size)) { - user_error('array_chunk() expects parameter 2 to be long, ' . - gettype($size) . ' given', E_USER_WARNING); - return; - } - - $size = (int)$size; - if ($size <= 0) { - user_error('array_chunk() Size parameter expected to be greater than 0', - E_USER_WARNING); - return; - } - - $chunks = array(); - $i = 0; - - if ($preserve_keys !== false) { - foreach ($input as $key => $value) { - $chunks[(int)($i++ / $size)][$key] = $value; - } - } else { - foreach ($input as $value) { - $chunks[(int)($i++ / $size)][] = $value; - } - } - - return $chunks; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_combine.php b/data/module/Compat/Compat/Function/array_combine.php deleted file mode 100644 index 26f19dc945b..00000000000 --- a/data/module/Compat/Compat/Function/array_combine.php +++ /dev/null @@ -1,71 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_combine.php,v 1.21 2005/01/28 02:27:52 aidan Exp $ - - -/** - * Replace array_combine() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_combine - * @author Aidan Lister - * @version $Revision: 1.21 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('array_combine')) { - function array_combine($keys, $values) - { - if (!is_array($keys)) { - user_error('array_combine() expects parameter 1 to be array, ' . - gettype($keys) . ' given', E_USER_WARNING); - return; - } - - if (!is_array($values)) { - user_error('array_combine() expects parameter 2 to be array, ' . - gettype($values) . ' given', E_USER_WARNING); - return; - } - - $key_count = count($keys); - $value_count = count($values); - if ($key_count !== $value_count) { - user_error('array_combine() Both parameters should have equal number of elements', E_USER_WARNING); - return false; - } - - if ($key_count === 0 || $value_count === 0) { - user_error('array_combine() Both parameters should have number of elements at least 0', E_USER_WARNING); - return false; - } - - $keys = array_values($keys); - $values = array_values($values); - - $combined = array(); - for ($i = 0; $i < $key_count; $i++) { - $combined[$keys[$i]] = $values[$i]; - } - - return $combined; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_diff_assoc.php b/data/module/Compat/Compat/Function/array_diff_assoc.php deleted file mode 100644 index d687ed13c7c..00000000000 --- a/data/module/Compat/Compat/Function/array_diff_assoc.php +++ /dev/null @@ -1,76 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_diff_assoc.php,v 1.12 2005/12/07 21:08:57 aidan Exp $ - - -/** - * Replace array_diff_assoc() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_diff_assoc - * @author Aidan Lister - * @version $Revision: 1.12 $ - * @since PHP 4.3.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('array_diff_assoc')) { - function array_diff_assoc() - { - // Check we have enough arguments - $args = func_get_args(); - $count = count($args); - if (count($args) < 2) { - user_error('Wrong parameter count for array_diff_assoc()', E_USER_WARNING); - return; - } - - // Check arrays - for ($i = 0; $i < $count; $i++) { - if (!is_array($args[$i])) { - user_error('array_diff_assoc() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Get the comparison array - $array_comp = array_shift($args); - --$count; - - // Traverse values of the first array - foreach ($array_comp as $key => $value) { - // Loop through the other arrays - for ($i = 0; $i < $count; $i++) { - // Loop through this arrays key/value pairs and compare - foreach ($args[$i] as $comp_key => $comp_value) { - if ((string)$key === (string)$comp_key && - (string)$value === (string)$comp_value) - { - - unset($array_comp[$key]); - } - } - } - } - - return $array_comp; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_diff_key.php b/data/module/Compat/Compat/Function/array_diff_key.php deleted file mode 100644 index 0b083cda90b..00000000000 --- a/data/module/Compat/Compat/Function/array_diff_key.php +++ /dev/null @@ -1,66 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_diff_key.php,v 1.4 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_diff_key() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_diff_key - * @author Tom Buskens - * @version $Revision: 1.4 $ - * @since PHP 5.0.2 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('array_diff_key')) { - function array_diff_key() - { - $args = func_get_args(); - if (count($args) < 2) { - user_error('Wrong parameter count for array_diff_key()', E_USER_WARNING); - return; - } - - // Check arrays - $array_count = count($args); - for ($i = 0; $i !== $array_count; $i++) { - if (!is_array($args[$i])) { - user_error('array_diff_key() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - $result = $args[0]; - foreach ($args[0] as $key1 => $value1) { - for ($i = 1; $i !== $array_count; $i++) { - foreach ($args[$i] as $key2 => $value2) { - if ((string) $key1 === (string) $key2) { - unset($result[$key2]); - break 2; - } - } - } - } - return $result; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_diff_uassoc.php b/data/module/Compat/Compat/Function/array_diff_uassoc.php deleted file mode 100644 index 4eeb4a4eeb9..00000000000 --- a/data/module/Compat/Compat/Function/array_diff_uassoc.php +++ /dev/null @@ -1,83 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_diff_uassoc.php,v 1.2 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_diff_uassoc() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_diff_uassoc - * @version $Revision: 1.2 $ - * @since PHP 5.0.0 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_diff_uassoc')) { - function array_diff_uassoc() - { - // Sanity check - $args = func_get_args(); - if (count($args) < 3) { - user_error('Wrong parameter count for array_diff_uassoc()', E_USER_WARNING); - return; - } - - // Get compare function - $compare_func = array_pop($args); - if (!is_callable($compare_func)) { - if (is_array($compare_func)) { - $compare_func = $compare_func[0] . '::' . $compare_func[1]; - } - user_error('array_diff_uassoc() Not a valid callback ' . - $compare_func, E_USER_WARNING); - return; - } - - // Check arrays - $array_count = count($args); - for ($i = 0; $i !== $array_count; $i++) { - if (!is_array($args[$i])) { - user_error('array_diff_uassoc() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Compare entries - $result = array(); - foreach ($args[0] as $k => $v) { - for ($i = 1; $i < $array_count; $i++) { - foreach ($args[$i] as $kk => $vv) { - if ($v == $vv) { - $compare = call_user_func_array($compare_func, array($k, $kk)); - if ($compare == 0) { - continue 3; - } - } - } - } - - $result[$k] = $v; - } - - return $result; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_diff_ukey.php b/data/module/Compat/Compat/Function/array_diff_ukey.php deleted file mode 100644 index 9f7ae079d7e..00000000000 --- a/data/module/Compat/Compat/Function/array_diff_ukey.php +++ /dev/null @@ -1,79 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_diff_ukey.php,v 1.4 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_diff_ukey() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_diff_ukey - * @author Tom Buskens - * @version $Revision: 1.4 $ - * @since PHP 5.0.2 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_diff_ukey')) { - function array_diff_ukey() - { - $args = func_get_args(); - if (count($args) < 3) { - user_error('Wrong parameter count for array_diff_ukey()', E_USER_WARNING); - return; - } - - // Get compare function - $compare_func = array_pop($args); - if (!is_callable($compare_func)) { - if (is_array($compare_func)) { - $compare_func = $compare_func[0].'::'.$compare_func[1]; - } - user_error('array_diff_ukey() Not a valid callback ' . - $compare_func, E_USER_WARNING); - return; - } - - // Check arrays - $array_count = count($args); - for ($i = 0; $i !== $array_count; $i++) { - if (!is_array($args[$i])) { - user_error('array_diff_ukey() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Compare entries - $result = $args[0]; - foreach ($args[0] as $key1 => $value1) { - for ($i = 1; $i !== $array_count; $i++) { - foreach ($args[$i] as $key2 => $value2) { - if (!(call_user_func($compare_func, (string) $key1, (string) $key2))) { - unset($result[$key1]); - break 2; - } - } - } - } - - return $result; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_intersect_assoc.php b/data/module/Compat/Compat/Function/array_intersect_assoc.php deleted file mode 100644 index e8bef196e94..00000000000 --- a/data/module/Compat/Compat/Function/array_intersect_assoc.php +++ /dev/null @@ -1,69 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_intersect_assoc.php,v 1.4 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_intersect_assoc() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_intersect_assoc - * @author Aidan Lister - * @version $Revision: 1.4 $ - * @since PHP 4.3.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('array_intersect_assoc')) { - function array_intersect_assoc() - { - // Sanity check - $args = func_get_args(); - if (count($args) < 2) { - user_error('wrong parameter count for array_intersect_assoc()', E_USER_WARNING); - return; - } - - // Check arrays - $array_count = count($args); - for ($i = 0; $i !== $array_count; $i++) { - if (!is_array($args[$i])) { - user_error('array_intersect_assoc() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Compare entries - $intersect = array(); - foreach ($args[0] as $key => $value) { - $intersect[$key] = $value; - - for ($i = 1; $i < $array_count; $i++) { - if (!isset($args[$i][$key]) || $args[$i][$key] != $value) { - unset($intersect[$key]); - break; - } - } - } - - return $intersect; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_intersect_key.php b/data/module/Compat/Compat/Function/array_intersect_key.php deleted file mode 100644 index 78adc1a28fa..00000000000 --- a/data/module/Compat/Compat/Function/array_intersect_key.php +++ /dev/null @@ -1,67 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_intersect_key.php,v 1.4 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_intersect_key() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_intersect_key - * @author Tom Buskens - * @version $Revision: 1.4 $ - * @since PHP 5.0.2 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('array_intersect_key')) { - function array_intersect_key() - { - $args = func_get_args(); - if (count($args) < 2) { - user_error('Wrong parameter count for array_intersect_key()', E_USER_WARNING); - return; - } - - // Check arrays - $array_count = count($args); - for ($i = 0; $i !== $array_count; $i++) { - if (!is_array($args[$i])) { - user_error('array_intersect_key() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Compare entries - $result = array(); - foreach ($args[0] as $key1 => $value1) { - for ($i = 1; $i !== $array_count; $i++) { - foreach ($args[$i] as $key2 => $value2) { - if ((string) $key1 === (string) $key2) { - $result[$key1] = $value1; - } - } - } - } - - return $result; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_intersect_uassoc.php b/data/module/Compat/Compat/Function/array_intersect_uassoc.php deleted file mode 100644 index 7ed4d3dd5ac..00000000000 --- a/data/module/Compat/Compat/Function/array_intersect_uassoc.php +++ /dev/null @@ -1,90 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_intersect_uassoc.php,v 1.5 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_intersect_assoc() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_intersect_uassoc - * @author Aidan Lister - * @version $Revision: 1.5 $ - * @since PHP 5 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_intersect_uassoc')) { - function array_intersect_uassoc() - { - // Sanity check - $args = func_get_args(); - if (count($args) < 3) { - user_error('Wrong parameter count for array_intersect_ukey()', E_USER_WARNING); - return; - } - - // Get compare function - $compare_func = array_pop($args); - if (!is_callable($compare_func)) { - if (is_array($compare_func)) { - $compare_func = $compare_func[0] . '::' . $compare_func[1]; - } - user_error('array_intersect_uassoc() Not a valid callback ' . - $compare_func, E_USER_WARNING); - return; - } - - // Check arrays - $array_count = count($args); - for ($i = 0; $i !== $array_count; $i++) { - if (!is_array($args[$i])) { - user_error('array_intersect_uassoc() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Compare entries - $result = array(); - foreach ($args[0] as $k => $v) { - for ($i = 0; $i < $array_count; $i++) { - $match = false; - foreach ($args[$i] as $kk => $vv) { - $compare = call_user_func_array($compare_func, array($k, $kk)); - if ($compare === 0 && $v == $vv) { - $match = true; - continue 2; - } - } - - if ($match === false) { - continue 2; - } - } - - if ($match === true) { - $result[$k] = $v; - } - } - - return $result; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_intersect_ukey.php b/data/module/Compat/Compat/Function/array_intersect_ukey.php deleted file mode 100644 index bea171f6023..00000000000 --- a/data/module/Compat/Compat/Function/array_intersect_ukey.php +++ /dev/null @@ -1,79 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_intersect_ukey.php,v 1.4 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_intersect_ukey() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_intersect_ukey - * @author Tom Buskens - * @version $Revision: 1.4 $ - * @since PHP 5.0.2 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_intersect_ukey')) { - function array_intersect_ukey() - { - $args = func_get_args(); - if (count($args) < 3) { - user_error('Wrong parameter count for array_intersect_ukey()', E_USER_WARNING); - return; - } - - // Get compare function - $compare_func = array_pop($args); - if (!is_callable($compare_func)) { - if (is_array($compare_func)) { - $compare_func = $compare_func[0].'::'.$compare_func[1]; - } - user_error('array_diff_ukey() Not a valid callback ' . - $compare_func, E_USER_WARNING); - return; - } - - // Check arrays - $array_count = count($args); - for ($i = 0; $i !== $array_count; $i++) { - if (!is_array($args[$i])) { - user_error('array_intersect_ukey() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Compare entries - $result = array(); - foreach ($args[0] as $key1 => $value1) { - for ($i = 1; $i !== $array_count; $i++) { - foreach ($args[$i] as $key2 => $value2) { - if (!(call_user_func($compare_func, (string) $key1, (string) $key2))) { - $result[$key1] = $value1; - break 2; - } - } - } - } - - return $result; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_key_exists.php b/data/module/Compat/Compat/Function/array_key_exists.php deleted file mode 100644 index d2e09b53bb2..00000000000 --- a/data/module/Compat/Compat/Function/array_key_exists.php +++ /dev/null @@ -1,55 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_key_exists.php,v 1.7 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_key_exists() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_key_exists - * @author Aidan Lister - * @version $Revision: 1.7 $ - * @since PHP 4.1.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('array_key_exists')) { - function array_key_exists($key, $search) - { - if (!is_scalar($key)) { - user_error('array_key_exists() The first argument should be either a string or an integer', - E_USER_WARNING); - return false; - } - - if (is_object($search)) { - $search = get_object_vars($search); - } - - if (!is_array($search)) { - user_error('array_key_exists() The second argument should be either an array or an object', - E_USER_WARNING); - return false; - } - - return in_array($key, array_keys($search)); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_product.php b/data/module/Compat/Compat/Function/array_product.php deleted file mode 100644 index 8adeed3f5ef..00000000000 --- a/data/module/Compat/Compat/Function/array_product.php +++ /dev/null @@ -1,53 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_product.php,v 1.1 2005/12/05 14:49:08 aidan Exp $ - - -/** - * Replace array_product() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/time_sleep_until - * @author Arpad Ray - * @version $Revision: 1.1 $ - * @since PHP 5.1.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('array_product')) { - function array_product($array) - { - if (!is_array($array)) { - trigger_error('The argument should be an array', E_USER_WARNING); - return; - } - - if (empty($array)) { - return 0; - } - - $r = 1; - foreach ($array as $v) { - $r *= $v; - } - - return $r; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_search.php b/data/module/Compat/Compat/Function/array_search.php deleted file mode 100644 index 5b0aa721f0b..00000000000 --- a/data/module/Compat/Compat/Function/array_search.php +++ /dev/null @@ -1,51 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_search.php,v 1.6 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_search() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_search - * @author Aidan Lister - * @author Thiemo Mttig (http://maettig.com/) - * @version $Revision: 1.6 $ - * @since PHP 4.0.5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('array_search')) { - function array_search($needle, $haystack, $strict = false) - { - if (!is_array($haystack)) { - user_error('array_search() Wrong datatype for second argument', E_USER_WARNING); - return false; - } - - foreach ($haystack as $key => $value) { - if ($strict ? $value === $needle : $value == $needle) { - return $key; - } - } - - return false; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_udiff.php b/data/module/Compat/Compat/Function/array_udiff.php deleted file mode 100644 index 27c0f83026b..00000000000 --- a/data/module/Compat/Compat/Function/array_udiff.php +++ /dev/null @@ -1,83 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: array_udiff.php,v 1.10 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_udiff() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_udiff - * @author Stephan Schmidt - * @author Aidan Lister - * @version $Revision: 1.10 $ - * @since PHP 5 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_udiff')) { - function array_udiff() - { - $args = func_get_args(); - - if (count($args) < 3) { - user_error('Wrong parameter count for array_udiff()', E_USER_WARNING); - return; - } - - // Get compare function - $compare_func = array_pop($args); - if (!is_callable($compare_func)) { - if (is_array($compare_func)) { - $compare_func = $compare_func[0] . '::' . $compare_func[1]; - } - user_error('array_udiff() Not a valid callback ' . - $compare_func, E_USER_WARNING); - return; - } - - // Check arrays - $cnt = count($args); - for ($i = 0; $i < $cnt; $i++) { - if (!is_array($args[$i])) { - user_error('array_udiff() Argument #' . - ($i + 1). ' is not an array', E_USER_WARNING); - return; - } - } - - $diff = array (); - // Traverse values of the first array - foreach ($args[0] as $key => $value) { - // Check all arrays - for ($i = 1; $i < $cnt; $i++) { - foreach ($args[$i] as $cmp_value) { - $result = call_user_func($compare_func, $value, $cmp_value); - if ($result === 0) { - continue 3; - } - } - } - $diff[$key] = $value; - } - return $diff; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_udiff_assoc.php b/data/module/Compat/Compat/Function/array_udiff_assoc.php deleted file mode 100644 index b3b7495edef..00000000000 --- a/data/module/Compat/Compat/Function/array_udiff_assoc.php +++ /dev/null @@ -1,85 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: array_udiff_assoc.php,v 1.14 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_udiff_assoc() - * - * @category PHP - * @package PHP_Compat - * @author Stephan Schmidt - * @author Aidan Lister - * @version $Revision: 1.14 $ - * @link http://php.net/function.array-udiff-assoc - * @since PHP 5 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_udiff_assoc')) { - function array_udiff_assoc() - { - $args = func_get_args(); - if (count($args) < 3) { - user_error('Wrong parameter count for array_udiff_assoc()', E_USER_WARNING); - return; - } - - // Get compare function - $compare_func = array_pop($args); - if (!is_callable($compare_func)) { - if (is_array($compare_func)) { - $compare_func = $compare_func[0] . '::' . $compare_func[1]; - } - user_error('array_udiff_assoc() Not a valid callback ' . - $compare_func, E_USER_WARNING); - return; - } - - // Check arrays - $count = count($args); - for ($i = 0; $i < $count; $i++) { - if (!is_array($args[$i])) { - user_error('array_udiff_assoc() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - $diff = array (); - // Traverse values of the first array - foreach ($args[0] as $key => $value) { - // Check all arrays - for ($i = 1; $i < $count; $i++) { - if (!array_key_exists($key, $args[$i])) { - continue; - } - $result = call_user_func($compare_func, $value, $args[$i][$key]); - if ($result === 0) { - continue 2; - } - } - - $diff[$key] = $value; - } - - return $diff; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_udiff_uassoc.php b/data/module/Compat/Compat/Function/array_udiff_uassoc.php deleted file mode 100644 index 74e0c71ecfc..00000000000 --- a/data/module/Compat/Compat/Function/array_udiff_uassoc.php +++ /dev/null @@ -1,82 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_udiff_uassoc.php,v 1.8 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_udiff_uassoc() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_udiff_uassoc - * @author Aidan Lister - * @version $Revision: 1.8 $ - * @since PHP 5 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_udiff_uassoc')) { - function array_udiff_uassoc() - { - $args = func_get_args(); - if (count($args) < 3) { - user_error('Wrong parameter count for array_udiff_uassoc()', E_USER_WARNING); - return; - } - - // Get compare function - $compare_func = array_pop($args); - if (!is_callable($compare_func)) { - if (is_array($compare_func)) { - $compare_func = $compare_func[0] . '::' . $compare_func[1]; - } - user_error('array_udiff_uassoc() Not a valid callback ' . $compare_func, E_USER_WARNING); - return; - } - - // Check arrays - $count = count($args); - for ($i = 0; $i < $count; $i++) { - if (!is_array($args[$i])) { - user_error('array_udiff_uassoc() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Traverse values of the first array - $diff = array (); - foreach ($args[0] as $key => $value) { - // Check all arrays - for ($i = 1; $i < $count; $i++) { - if (!array_key_exists($key, $args[$i])) { - continue; - } - $result = call_user_func($compare_func, $value, $args[$i][$key]); - if ($result === 0) { - continue 2; - } - } - - $diff[$key] = $value; - } - - return $diff; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_uintersect.php b/data/module/Compat/Compat/Function/array_uintersect.php deleted file mode 100644 index d232449b82e..00000000000 --- a/data/module/Compat/Compat/Function/array_uintersect.php +++ /dev/null @@ -1,82 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: array_uintersect.php,v 1.9 2005/05/10 12:05:48 aidan Exp $ - - -/** - * Replace array_uintersect() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_uintersect - * @author Tom Buskens - * @author Aidan Lister - * @version $Revision: 1.9 $ - * @since PHP 5 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_uintersect')) { - function array_uintersect() - { - $args = func_get_args(); - if (count($args) < 3) { - user_error('wrong parameter count for array_uintersect()', - E_USER_WARNING); - return; - } - - // Get compare function - $user_func = array_pop($args); - if (!is_callable($user_func)) { - if (is_array($user_func)) { - $user_func = $user_func[0] . '::' . $user_func[1]; - } - user_error('array_uintersect() Not a valid callback ' . - $user_func, E_USER_WARNING); - return; - } - - // Check arrays - $array_count = count($args); - for ($i = 0; $i < $array_count; $i++) { - if (!is_array($args[$i])) { - user_error('array_uintersect() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Compare entries - $output = array(); - foreach ($args[0] as $key => $item) { - for ($i = 1; $i !== $array_count; $i++) { - $array = $args[$i]; - foreach($array as $key0 => $item0) { - if (!call_user_func($user_func, $item, $item0)) { - $output[$key] = $item; - } - } - } - } - - return $output; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_uintersect_assoc.php b/data/module/Compat/Compat/Function/array_uintersect_assoc.php deleted file mode 100644 index 83d50964bb6..00000000000 --- a/data/module/Compat/Compat/Function/array_uintersect_assoc.php +++ /dev/null @@ -1,81 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: array_uintersect_assoc.php,v 1.9 2005/05/10 07:50:08 aidan Exp $ - - -/** - * Replace array_uintersect_assoc() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_uintersect_assoc - * @author Tom Buskens - * @author Aidan Lister - * @version $Revision: 1.9 $ - * @since PHP 5 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_uintersect_assoc')) { - function array_uintersect_assoc() - { - $args = func_get_args(); - if (count($args) < 3) { - user_error('wrong parameter count for array_uintersect_assoc()', E_USER_WARNING); - return; - } - - // Get compare function - $user_func = array_pop($args); - if (!is_callable($user_func)) { - if (is_array($user_func)) { - $user_func = $user_func[0] . '::' . $user_func[1]; - } - user_error('array_uintersect_assoc() Not a valid callback ' . - $user_func, E_USER_WARNING); - return; - } - - // Check arrays - $array_count = count($args); - for ($i = 0; $i < $array_count; $i++) { - if (!is_array($args[$i])) { - user_error('array_uintersect_assoc() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Compare entries - $output = array(); - foreach ($args[0] as $key => $item) { - for ($i = 1; $i !== $array_count; $i++) { - if (array_key_exists($key, $args[$i])) { - $compare = call_user_func($user_func, $item, $args[$i][$key]); - if ($compare === 0) { - $output[$key] = $item; - } - } - } - } - - return $output; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_uintersect_uassoc.php b/data/module/Compat/Compat/Function/array_uintersect_uassoc.php deleted file mode 100644 index f73267f8a92..00000000000 --- a/data/module/Compat/Compat/Function/array_uintersect_uassoc.php +++ /dev/null @@ -1,97 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: array_uintersect_uassoc.php,v 1.12 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_uintersect_uassoc() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_uintersect_uassoc - * @author Aidan Lister - * @version $Revision: 1.12 $ - * @since PHP 5 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_uintersect_uassoc')) { - function array_uintersect_uassoc() - { - $args = func_get_args(); - if (count($args) < 4) { - user_error('Wrong parameter count for array_uintersect_uassoc()', - E_USER_WARNING); - return; - } - - // Get key_compare_func - $key_compare_func = array_pop($args); - if (!is_callable($key_compare_func)) { - if (is_array($key_compare_func)) { - $key_compare_func = $key_compare_func[0] . '::' . $key_compare_func[1]; - } - user_error('array_uintersect_uassoc() Not a valid callback ' . - $key_compare_func, E_USER_WARNING); - return; - } - - // Get data_compare_func - $data_compare_func = array_pop($args); - if (!is_callable($data_compare_func)) { - if (is_array($data_compare_func)) { - $data_compare_func = $data_compare_func[0] . '::' . $data_compare_func[1]; - } - user_error('array_uintersect_uassoc() Not a valid callback ' - . $data_compare_func, E_USER_WARNING); - return; - } - - // Check arrays - $count = count($args); - for ($i = 0; $i !== $count; $i++) { - if (!is_array($args[$i])) { - user_error('array_uintersect_uassoc() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Traverse values of the first array - $intersect = array (); - foreach ($args[0] as $key => $value) { - // Check against each array - for ($i = 1; $i < $count; $i++) { - // Traverse each element in current array - foreach ($args[$i] as $ckey => $cvalue) { - // Compare key and value - if (call_user_func($key_compare_func, $key, $ckey) === 0 && - call_user_func($data_compare_func, $value, $cvalue) === 0) - { - - $intersect[$key] = $value; - continue; - } - } - } - } - - return $intersect; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/array_walk_recursive.php b/data/module/Compat/Compat/Function/array_walk_recursive.php deleted file mode 100644 index 612df8457e6..00000000000 --- a/data/module/Compat/Compat/Function/array_walk_recursive.php +++ /dev/null @@ -1,68 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: array_walk_recursive.php,v 1.7 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace array_walk_recursive() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_walk_recursive - * @author Tom Buskens - * @author Aidan Lister - * @version $Revision: 1.7 $ - * @since PHP 5 - * @require PHP 4.0.6 (is_callable) - */ -if (!function_exists('array_walk_recursive')) { - function array_walk_recursive(&$input, $funcname) - { - if (!is_callable($funcname)) { - if (is_array($funcname)) { - $funcname = $funcname[0] . '::' . $funcname[1]; - } - user_error('array_walk_recursive() Not a valid callback ' . $user_func, - E_USER_WARNING); - return; - } - - if (!is_array($input)) { - user_error('array_walk_recursive() The argument should be an array', - E_USER_WARNING); - return; - } - - $args = func_get_args(); - - foreach ($input as $key => $item) { - if (is_array($item)) { - array_walk_recursive($item, $funcname, $args); - $input[$key] = $item; - } else { - $args[0] = &$item; - $args[1] = &$key; - call_user_func_array($funcname, $args); - $input[$key] = $item; - } - } - } -} - -?> diff --git a/data/module/Compat/Compat/Function/bcinvert.php b/data/module/Compat/Compat/Function/bcinvert.php deleted file mode 100644 index 4e965b0700d..00000000000 --- a/data/module/Compat/Compat/Function/bcinvert.php +++ /dev/null @@ -1,76 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: bcinvert.php,v 1.2 2005/11/22 20:24:45 aidan Exp $ - - -/** - * Replace bcinvert() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.bcinvert - * @author Sara Golemon - * @version $Revision: 1.2 $ - * @since PHP 5.2.0 - * @require PHP 4.0.4 (call_user_func_array) - */ -if (!function_exists('bcinvert')) { - function bcinvert($a, $n) - { - // Sanity check - if (!is_scalar($a)) { - user_error('bcinvert() expects parameter 1 to be string, ' . - gettype($a) . ' given', E_USER_WARNING); - return false; - } - - if (!is_scalar($n)) { - user_error('bcinvert() expects parameter 2 to be string, ' . - gettype($n) . ' given', E_USER_WARNING); - return false; - } - - $u1 = $v2 = '1'; - $u2 = $v1 = '0'; - $u3 = $n; - $v3 = $a; - - while (bccomp($v3, '0')) { - $q0 = bcdiv($u3, $v3); - $t1 = bcsub($u1, bcmul($q0, $v1)); - $t2 = bcsub($u2, bcmul($q0, $v2)); - $t3 = bcsub($u3, bcmul($q0, $v3)); - - $u1 = $v1; - $u2 = $v2; - $u3 = $v3; - - $v1 = $t1; - $v2 = $t2; - $v3 = $t3; - } - - if (bccomp($u2, '0') < 0) { - return bcadd($u2, $n); - } else { - return bcmod($u2, $n); - } - } -} - -?> diff --git a/data/module/Compat/Compat/Function/bcpowmod.php b/data/module/Compat/Compat/Function/bcpowmod.php deleted file mode 100644 index 3b4aa010a4e..00000000000 --- a/data/module/Compat/Compat/Function/bcpowmod.php +++ /dev/null @@ -1,75 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: bcpowmod.php,v 1.2 2005/11/22 20:24:45 aidan Exp $ - - -/** - * Replace bcpowmod() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.bcpowmod - * @author Sara Golemon - * @version $Revision: 1.2 $ - * @since PHP 5.0.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('bcpowmod')) { - function bcpowmod($x, $y, $modulus, $scale) - { - // Sanity check - if (!is_scalar($x)) { - user_error('bcpowmod() expects parameter 1 to be string, ' . - gettype($x) . ' given', E_USER_WARNING); - return false; - } - - if (!is_scalar($y)) { - user_error('bcpowmod() expects parameter 2 to be string, ' . - gettype($y) . ' given', E_USER_WARNING); - return false; - } - - if (!is_scalar($modulus)) { - user_error('bcpowmod() expects parameter 3 to be string, ' . - gettype($modulus) . ' given', E_USER_WARNING); - return false; - } - - if (!is_scalar($scale)) { - user_error('bcpowmod() expects parameter 4 to be integer, ' . - gettype($scale) . ' given', E_USER_WARNING); - return false; - } - - $t = '1'; - while (bccomp($y, '0')) { - if (bccomp(bcmod($y, '2'), '0')) { - $t = bcmod(bcmul($t, $x), $modulus); - $y = bcsub($y, '1'); - } - - $x = bcmod(bcmul($x, $x), $modulus); - $y = bcdiv($y, '2'); - } - - return $t; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/call_user_func_array.php b/data/module/Compat/Compat/Function/call_user_func_array.php deleted file mode 100644 index 06f9eaa8db8..00000000000 --- a/data/module/Compat/Compat/Function/call_user_func_array.php +++ /dev/null @@ -1,75 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: call_user_func_array.php,v 1.13 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace call_user_func_array() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.call_user_func_array - * @author Aidan Lister - * @version $Revision: 1.13 $ - * @since PHP 4.0.4 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('call_user_func_array')) { - function call_user_func_array($function, $param_arr) - { - $param_arr = array_values((array) $param_arr); - - // Sanity check - if (!is_callable($function)) { - if (is_array($function) && count($function) > 2) { - $function = $function[0] . '::' . $function[1]; - } - $error = sprintf('call_user_func_array() First argument is expected ' . - 'to be a valid callback, \'%s\' was given', $function); - user_error($error, E_USER_WARNING); - return; - } - - // Build argument string - $arg_string = ''; - $comma = ''; - for ($i = 0, $x = count($param_arr); $i < $x; $i++) { - $arg_string .= $comma . "\$param_arr[$i]"; - $comma = ', '; - } - - // Determine method of calling function - if (is_array($function)) { - $object =& $function[0]; - $method = $function[1]; - - // Static vs method call - if (is_string($function[0])) { - eval("\$retval = $object::\$method($arg_string);"); - } else { - eval("\$retval = \$object->\$method($arg_string);"); - } - } else { - eval("\$retval = \$function($arg_string);"); - } - - return $retval; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/clone.php b/data/module/Compat/Compat/Function/clone.php deleted file mode 100644 index bf4115a056d..00000000000 --- a/data/module/Compat/Compat/Function/clone.php +++ /dev/null @@ -1,56 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: clone.php,v 1.3 2005/05/01 10:40:59 aidan Exp $ - - -/** - * Replace clone() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/language.oop5.cloning - * @author Aidan Lister - * @version $Revision: 1.3 $ - * @since PHP 5.0.0 - * @require PHP 4.0.0 (user_error) - */ -if (version_compare(phpversion(), '5.0') === -1) { - // Needs to be wrapped in eval as clone is a keyword in PHP5 - eval(' - function clone($object) - { - // Sanity check - if (!is_object($object)) { - user_error(\'clone() __clone method called on non-object\', E_USER_WARNING); - return; - } - - // Use serialize/unserialize trick to deep copy the object - $object = unserialize(serialize($object)); - - // If there is a __clone method call it on the "new" class - if (method_exists($object, \'__clone\')) { - $object->__clone(); - } - - return $object; - } - '); -} - -?> diff --git a/data/module/Compat/Compat/Function/constant.php b/data/module/Compat/Compat/Function/constant.php deleted file mode 100644 index 10ff7a04bf9..00000000000 --- a/data/module/Compat/Compat/Function/constant.php +++ /dev/null @@ -1,47 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: constant.php,v 1.7 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace constant() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.constant - * @author Aidan Lister - * @version $Revision: 1.7 $ - * @since PHP 4.0.4 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('constant')) { - function constant($constant) - { - if (!defined($constant)) { - $error = sprintf('constant() Couldn\'t find constant %s', $constant); - user_error($error, E_USER_WARNING); - return false; - } - - eval("\$value=$constant;"); - - return $value; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/convert_uudecode.php b/data/module/Compat/Compat/Function/convert_uudecode.php deleted file mode 100644 index ed07d5fe136..00000000000 --- a/data/module/Compat/Compat/Function/convert_uudecode.php +++ /dev/null @@ -1,79 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: convert_uudecode.php,v 1.8 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace convert_uudecode() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.convert_uudecode - * @author Michael Wallner - * @author Aidan Lister - * @version $Revision: 1.8 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('convert_uudecode')) { - function convert_uudecode($string) - { - // Sanity check - if (!is_scalar($string)) { - user_error('convert_uuencode() expects parameter 1 to be string, ' . - gettype($string) . ' given', E_USER_WARNING); - return false; - } - - if (strlen($string) < 8) { - user_error('convert_uuencode() The given parameter is not a valid uuencoded string', E_USER_WARNING); - return false; - } - - $decoded = ''; - foreach (explode("\n", $string) as $line) { - - $c = count($bytes = unpack('c*', substr(trim($line), 1))); - - while ($c % 4) { - $bytes[++$c] = 0; - } - - foreach (array_chunk($bytes, 4) as $b) { - $b0 = $b[0] == 0x60 ? 0 : $b[0] - 0x20; - $b1 = $b[1] == 0x60 ? 0 : $b[1] - 0x20; - $b2 = $b[2] == 0x60 ? 0 : $b[2] - 0x20; - $b3 = $b[3] == 0x60 ? 0 : $b[3] - 0x20; - - $b0 <<= 2; - $b0 |= ($b1 >> 4) & 0x03; - $b1 <<= 4; - $b1 |= ($b2 >> 2) & 0x0F; - $b2 <<= 6; - $b2 |= $b3 & 0x3F; - - $decoded .= pack('c*', $b0, $b1, $b2); - } - } - - return rtrim($decoded, "\0"); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/convert_uuencode.php b/data/module/Compat/Compat/Function/convert_uuencode.php deleted file mode 100644 index 56d6403965a..00000000000 --- a/data/module/Compat/Compat/Function/convert_uuencode.php +++ /dev/null @@ -1,79 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: convert_uuencode.php,v 1.7 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace convert_uuencode() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.convert_uuencode - * @author Michael Wallner - * @author Aidan Lister - * @version $Revision: 1.7 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('convert_uuencode')) { - function convert_uuencode($string) - { - // Sanity check - if (!is_scalar($string)) { - user_error('convert_uuencode() expects parameter 1 to be string, ' . - gettype($string) . ' given', E_USER_WARNING); - return false; - } - - $u = 0; - $encoded = ''; - - while ($c = count($bytes = unpack('c*', substr($string, $u, 45)))) { - $u += 45; - $encoded .= pack('c', $c + 0x20); - - while ($c % 3) { - $bytes[++$c] = 0; - } - - foreach (array_chunk($bytes, 3) as $b) { - $b0 = ($b[0] & 0xFC) >> 2; - $b1 = (($b[0] & 0x03) << 4) + (($b[1] & 0xF0) >> 4); - $b2 = (($b[1] & 0x0F) << 2) + (($b[2] & 0xC0) >> 6); - $b3 = $b[2] & 0x3F; - - $b0 = $b0 ? $b0 + 0x20 : 0x60; - $b1 = $b1 ? $b1 + 0x20 : 0x60; - $b2 = $b2 ? $b2 + 0x20 : 0x60; - $b3 = $b3 ? $b3 + 0x20 : 0x60; - - $encoded .= pack('c*', $b0, $b1, $b2, $b3); - } - - $encoded .= "\n"; - } - - // Add termination characters - $encoded .= "\x60\n"; - - return $encoded; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/debug_print_backtrace.php b/data/module/Compat/Compat/Function/debug_print_backtrace.php deleted file mode 100644 index d6b5589382b..00000000000 --- a/data/module/Compat/Compat/Function/debug_print_backtrace.php +++ /dev/null @@ -1,67 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: debug_print_backtrace.php,v 1.3 2005/08/17 02:58:09 aidan Exp $ - - -/** - * Replace debug_print_backtrace() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.debug_print_backtrace - * @author Laurent Laville - * @author Aidan Lister - * @version $Revision: 1.3 $ - * @since PHP 5 - * @require PHP 4.3.0 (debug_backtrace) - */ -if (!function_exists('debug_print_backtrace')) { - function debug_print_backtrace() - { - // Get backtrace - $backtrace = debug_backtrace(); - - // Unset call to debug_print_backtrace - array_shift($backtrace); - - // Iterate backtrace - $calls = array(); - foreach ($backtrace as $i => $call) { - $location = $call['file'] . ':' . $call['line']; - $function = (isset($call['class'])) ? - $call['class'] . '.' . $call['function'] : - $call['function']; - - $params = ''; - if (isset($call['args'])) { - $params = implode(', ', $call['args']); - } - - $calls[] = sprintf('#%d %s(%s) called at [%s]', - $i, - $function, - $params, - $location); - } - - echo implode("\n", $calls); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/file_get_contents.php b/data/module/Compat/Compat/Function/file_get_contents.php deleted file mode 100644 index d4dcf11f609..00000000000 --- a/data/module/Compat/Compat/Function/file_get_contents.php +++ /dev/null @@ -1,57 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: file_get_contents.php,v 1.21 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace file_get_contents() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.file_get_contents - * @author Aidan Lister - * @version $Revision: 1.21 $ - * @internal resource_context is not supported - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('file_get_contents')) { - function file_get_contents($filename, $incpath = false, $resource_context = null) - { - if (false === $fh = fopen($filename, 'rb', $incpath)) { - user_error('file_get_contents() failed to open stream: No such file or directory', - E_USER_WARNING); - return false; - } - - clearstatcache(); - if ($fsize = @filesize($filename)) { - $data = fread($fh, $fsize); - } else { - $data = ''; - while (!feof($fh)) { - $data .= fread($fh, 8192); - } - } - - fclose($fh); - return $data; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/file_put_contents.php b/data/module/Compat/Compat/Function/file_put_contents.php deleted file mode 100644 index af10e2e2532..00000000000 --- a/data/module/Compat/Compat/Function/file_put_contents.php +++ /dev/null @@ -1,116 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: file_put_contents.php,v 1.25 2005/12/05 09:25:15 aidan Exp $ - - -if (!defined('FILE_USE_INCLUDE_PATH')) { - define('FILE_USE_INCLUDE_PATH', 1); -} - -if (!defined('LOCK_EX')) { - define('LOCK_EX', 2); -} - -if (!defined('FILE_APPEND')) { - define('FILE_APPEND', 8); -} - - -/** - * Replace file_put_contents() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.file_put_contents - * @author Aidan Lister - * @version $Revision: 1.25 $ - * @internal resource_context is not supported - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('file_put_contents')) { - function file_put_contents($filename, $content, $flags = null, $resource_context = null) - { - // If $content is an array, convert it to a string - if (is_array($content)) { - $content = implode('', $content); - } - - // If we don't have a string, throw an error - if (!is_scalar($content)) { - user_error('file_put_contents() The 2nd parameter should be either a string or an array', - E_USER_WARNING); - return false; - } - - // Get the length of data to write - $length = strlen($content); - - // Check what mode we are using - $mode = ($flags & FILE_APPEND) ? - 'a' : - 'wb'; - - // Check if we're using the include path - $use_inc_path = ($flags & FILE_USE_INCLUDE_PATH) ? - true : - false; - - // Open the file for writing - if (($fh = @fopen($filename, $mode, $use_inc_path)) === false) { - user_error('file_put_contents() failed to open stream: Permission denied', - E_USER_WARNING); - return false; - } - - // Attempt to get an exclusive lock - $use_lock = ($flags & LOCK_EX) ? true : false ; - if ($use_lock === true) { - if (!flock($fh, LOCK_EX)) { - return false; - } - } - - // Write to the file - $bytes = 0; - if (($bytes = @fwrite($fh, $content)) === false) { - $errormsg = sprintf('file_put_contents() Failed to write %d bytes to %s', - $length, - $filename); - user_error($errormsg, E_USER_WARNING); - return false; - } - - // Close the handle - @fclose($fh); - - // Check all the data was written - if ($bytes != $length) { - $errormsg = sprintf('file_put_contents() Only %d of %d bytes written, possibly out of free disk space.', - $bytes, - $length); - user_error($errormsg, E_USER_WARNING); - return false; - } - - // Return length - return $bytes; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/floatval.php b/data/module/Compat/Compat/Function/floatval.php deleted file mode 100644 index cadafc4e8f0..00000000000 --- a/data/module/Compat/Compat/Function/floatval.php +++ /dev/null @@ -1,39 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: floatval.php,v 1.2 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace floatval() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.floatval - * @author Aidan Lister - * @version $Revision: 1.2 $ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (user_error) (Type Casting) - */ -if (!function_exists('floatval')) { - function floatval($var) - { - return (float) $var; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/fprintf.php b/data/module/Compat/Compat/Function/fprintf.php deleted file mode 100644 index 025cebc1567..00000000000 --- a/data/module/Compat/Compat/Function/fprintf.php +++ /dev/null @@ -1,54 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: fprintf.php,v 1.13 2005/05/28 17:25:25 aidan Exp $ - - -/** - * Replace fprintf() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.fprintf - * @author Aidan Lister - * @version $Revision: 1.13 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('fprintf')) { - function fprintf() { - $args = func_get_args(); - - if (count($args) < 2) { - user_error('Wrong parameter count for fprintf()', E_USER_WARNING); - return; - } - - $resource_handle = array_shift($args); - $format = array_shift($args); - - if (!is_resource($resource_handle)) { - user_error('fprintf() supplied argument is not a valid stream resource', - E_USER_WARNING); - return false; - } - - return fwrite($resource_handle, vsprintf($format, $args)); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/fputcsv.php b/data/module/Compat/Compat/Function/fputcsv.php deleted file mode 100644 index 25bde7afce6..00000000000 --- a/data/module/Compat/Compat/Function/fputcsv.php +++ /dev/null @@ -1,64 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: fputcsv.php,v 1.2 2005/11/22 08:28:16 aidan Exp $ - - -/** - * Replace fprintf() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.fprintf - * @author Twebb - * @author Aidan Lister - * @version $Revision: 1.2 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('fputcsv')) { - function fputcsv($handle, $fields, $delimiter = ',', $enclosure = '"') - { - // Sanity Check - if (!is_resource($handle)) { - user_error('fputcsv() expects parameter 1 to be resource, ' . - gettype($handle) . ' given', E_USER_WARNING); - return false; - } - - - $str = ''; - foreach ($fields as $cell) { - $cell = str_replace($enclosure, $enclosure . $enclosure, $cell); - - if (strchr($cell, $delimiter) !== false || - strchr($cell, $enclosure) !== false || - strchr($cell, "\n") !== false) { - - $str .= $enclosure . $cell . $enclosure . $delimiter; - } else { - $str .= $cell . $delimiter; - } - } - - fputs($handle, substr($str, 0, -1) . "\n"); - - return strlen($str); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/get_headers.php b/data/module/Compat/Compat/Function/get_headers.php deleted file mode 100644 index a9cfba2d9f4..00000000000 --- a/data/module/Compat/Compat/Function/get_headers.php +++ /dev/null @@ -1,77 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: get_headers.php,v 1.1 2005/05/10 07:50:53 aidan Exp $ - - -/** - * Replace get_headers() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.get_headers - * @author Aeontech - * @author Cpurruc - * @author Aidan Lister - * @version $Revision: 1.1 $ - * @since PHP 5.0.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('get_headers')) { - function get_headers($url, $format = 0) - { - // Init - $urlinfo = parse_url($url); - $port = isset($urlinfo['port']) ? $urlinfo['port'] : 80; - - // Connect - $fp = fsockopen($urlinfo['host'], $port, $errno, $errstr, 30); - if ($fp === false) { - return false; - } - - // Send request - $head = 'HEAD ' . $urlinfo['path'] . - (isset($urlinfo['query']) ? '?' . $urlinfo['query'] : '') . - ' HTTP/1.0' . "\r\n" . - 'Host: ' . $urlinfo['host'] . "\r\n\r\n"; - fputs($fp, $head); - - // Read - while (!feof($fp)) { - if ($header = trim(fgets($fp, 1024))) { - list($key) = explode(':', $header); - - if ($format === 1) { - // First element is the HTTP header type, such as HTTP 200 OK - // It doesn't have a separate name, so check for it - if ($key == $header) { - $headers[] = $header; - } else { - $headers[$key] = substr($header, strlen($key)+2); - } - } else { - $headers[] = $header; - } - } - } - - return $headers; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/get_include_path.php b/data/module/Compat/Compat/Function/get_include_path.php deleted file mode 100644 index 47ad8a5ba9b..00000000000 --- a/data/module/Compat/Compat/Function/get_include_path.php +++ /dev/null @@ -1,39 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: get_include_path.php,v 1.4 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace get_include_path() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.get_include_path - * @author Stephan Schmidt - * @version $Revision: 1.4 $ - * @since PHP 4.3.0 - * @require PHP 4.0.0 - */ -if (!function_exists('get_include_path')) { - function get_include_path() - { - return ini_get('include_path'); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/hash.php b/data/module/Compat/Compat/Function/hash.php deleted file mode 100644 index 686969a3643..00000000000 --- a/data/module/Compat/Compat/Function/hash.php +++ /dev/null @@ -1,56 +0,0 @@ -, Arpad Ray - * @link http://php.net/function.hash - * @author revulo - * @since PHP 5.1.2 - * @require PHP 4.0.0 (user_error) - */ -function php_compat_hash($algo, $data, $raw_output = false) -{ - $algo = strtolower($algo); - switch ($algo) { - case 'md5': - $hash = md5($data); - break; - - case 'sha1': - if (!function_exists('sha1')) { - require dirname(__FILE__) . '/sha1.php'; - } - $hash = sha1($data); - break; - - case 'sha256': - if (!function_exists('php_compat_sha256')) { - require dirname(__FILE__) . '/_sha256.php'; - } - $hash = php_compat_sha256($data); - break; - - default: - user_error('hash(): Unknown hashing algorithm: ' . $algo, E_USER_WARNING); - return false; - } - - if ($raw_output) { - return pack('H*', $hash); - } else { - return $hash; - } -} - - -// Define -if (!function_exists('hash')) { - function hash($algo, $data, $raw_output = false) - { - return php_compat_hash($algo, $data, $raw_output); - } -} diff --git a/data/module/Compat/Compat/Function/hash_algos.php b/data/module/Compat/Compat/Function/hash_algos.php deleted file mode 100644 index 40d9f795275..00000000000 --- a/data/module/Compat/Compat/Function/hash_algos.php +++ /dev/null @@ -1,27 +0,0 @@ -, Arpad Ray - * @link http://php.net/function.hash_algos - * @author revulo - * @since PHP 5.1.2 - * @require PHP 4.0.0 - */ -function php_compat_hash_algos() -{ - return array('md5', 'sha1', 'sha256'); -} - - -// Define -if (!function_exists('hash_algos')) { - function hash_algos() - { - return php_compat_hash_algos(); - } -} diff --git a/data/module/Compat/Compat/Function/hash_hmac.php b/data/module/Compat/Compat/Function/hash_hmac.php deleted file mode 100644 index a02c0fd181b..00000000000 --- a/data/module/Compat/Compat/Function/hash_hmac.php +++ /dev/null @@ -1,44 +0,0 @@ -, Arpad Ray - * @link http://php.net/function.hash_hmac - * @author revulo - * @since PHP 5.1.2 - * @require PHP 4.0.1 (str_pad) - */ -function php_compat_hash_hmac($algo, $data, $key, $raw_output = false) -{ - // Block size (byte) for MD5, SHA-1 and SHA-256. - $blocksize = 64; - - $ipad = str_repeat("\x36", $blocksize); - $opad = str_repeat("\x5c", $blocksize); - - if (strlen($key) > $blocksize) { - $key = hash($algo, $key, true); - } else { - $key = str_pad($key, $blocksize, "\x00"); - } - - $ipad ^= $key; - $opad ^= $key; - - return hash($algo, $opad . hash($algo, $ipad . $data, true), $raw_output); -} - - -// Define -if (!function_exists('hash_hmac')) { - function hash_hmac($algo, $data, $key, $raw_output = false) - { - return php_compat_hash_hmac($algo, $data, $key, $raw_output); - } -} diff --git a/data/module/Compat/Compat/Function/html_entity_decode.php b/data/module/Compat/Compat/Function/html_entity_decode.php deleted file mode 100644 index 1e0c60ae15a..00000000000 --- a/data/module/Compat/Compat/Function/html_entity_decode.php +++ /dev/null @@ -1,73 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: html_entity_decode.php,v 1.8 2005/12/07 21:08:57 aidan Exp $ - - -if (!defined('ENT_NOQUOTES')) { - define('ENT_NOQUOTES', 0); -} - -if (!defined('ENT_COMPAT')) { - define('ENT_COMPAT', 2); -} - -if (!defined('ENT_QUOTES')) { - define('ENT_QUOTES', 3); -} - - -/** - * Replace html_entity_decode() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.html_entity_decode - * @author David Irvine - * @author Aidan Lister - * @version $Revision: 1.8 $ - * @since PHP 4.3.0 - * @internal Setting the charset will not do anything - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('html_entity_decode')) { - function html_entity_decode($string, $quote_style = ENT_COMPAT, $charset = null) - { - if (!is_int($quote_style)) { - user_error('html_entity_decode() expects parameter 2 to be long, ' . - gettype($quote_style) . ' given', E_USER_WARNING); - return; - } - - $trans_tbl = get_html_translation_table(HTML_ENTITIES); - $trans_tbl = array_flip($trans_tbl); - - // Add single quote to translation table; - $trans_tbl['''] = '\''; - - // Not translating double quotes - if ($quote_style & ENT_NOQUOTES) { - // Remove double quote from translation table - unset($trans_tbl['"']); - } - - return strtr($string, $trans_tbl); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/htmlspecialchars_decode.php b/data/module/Compat/Compat/Function/htmlspecialchars_decode.php deleted file mode 100644 index 57279109fa2..00000000000 --- a/data/module/Compat/Compat/Function/htmlspecialchars_decode.php +++ /dev/null @@ -1,67 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: htmlspecialchars_decode.php,v 1.3 2005/06/18 14:02:09 aidan Exp $ - - -/** - * Replace function htmlspecialchars_decode() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.htmlspecialchars_decode - * @author Aidan Lister - * @version $Revision: 1.3 $ - * @since PHP 5.1.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('htmlspecialchars_decode')) { - function htmlspecialchars_decode($string, $quote_style = null) - { - // Sanity check - if (!is_scalar($string)) { - user_error('htmlspecialchars_decode() expects parameter 1 to be string, ' . - gettype($string) . ' given', E_USER_WARNING); - return; - } - - if (!is_int($quote_style) && $quote_style !== null) { - user_error('htmlspecialchars_decode() expects parameter 2 to be integer, ' . - gettype($quote_style) . ' given', E_USER_WARNING); - return; - } - - // Init - $from = array('&', '<', '>'); - $to = array('&', '<', '>'); - - // The function does not behave as documented - // This matches the actual behaviour of the function - if ($quote_style & ENT_COMPAT || $quote_style & ENT_QUOTES) { - $from[] = '"'; - $to[] = '"'; - - $from[] = '''; - $to[] = "'"; - } - - return str_replace($from, $to, $string); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/http_build_query.php b/data/module/Compat/Compat/Function/http_build_query.php deleted file mode 100644 index 0385affff98..00000000000 --- a/data/module/Compat/Compat/Function/http_build_query.php +++ /dev/null @@ -1,100 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: http_build_query.php,v 1.16 2005/05/31 08:54:57 aidan Exp $ - - -/** - * Replace function http_build_query() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.http-build-query - * @author Stephan Schmidt - * @author Aidan Lister - * @version $Revision: 1.16 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('http_build_query')) { - function http_build_query($formdata, $numeric_prefix = null) - { - // If $formdata is an object, convert it to an array - if (is_object($formdata)) { - $formdata = get_object_vars($formdata); - } - - // Check we have an array to work with - if (!is_array($formdata)) { - user_error('http_build_query() Parameter 1 expected to be Array or Object. Incorrect value given.', - E_USER_WARNING); - return false; - } - - // If the array is empty, return null - if (empty($formdata)) { - return; - } - - // Argument seperator - $separator = ini_get('arg_separator.output'); - - // Start building the query - $tmp = array (); - foreach ($formdata as $key => $val) { - if (is_integer($key) && $numeric_prefix != null) { - $key = $numeric_prefix . $key; - } - - if (is_scalar($val)) { - array_push($tmp, urlencode($key).'='.urlencode($val)); - continue; - } - - // If the value is an array, recursively parse it - if (is_array($val)) { - array_push($tmp, __http_build_query($val, urlencode($key))); - continue; - } - } - - return implode($separator, $tmp); - } - - // Helper function - function __http_build_query ($array, $name) - { - $tmp = array (); - foreach ($array as $key => $value) { - if (is_array($value)) { - array_push($tmp, __http_build_query($value, sprintf('%s[%s]', $name, $key))); - } elseif (is_scalar($value)) { - array_push($tmp, sprintf('%s[%s]=%s', $name, urlencode($key), urlencode($value))); - } elseif (is_object($value)) { - array_push($tmp, __http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key))); - } - } - - // Argument seperator - $separator = ini_get('arg_separator.output'); - - return implode($separator, $tmp); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/ibase_timefmt.php b/data/module/Compat/Compat/Function/ibase_timefmt.php deleted file mode 100644 index ddaa4c3a8a8..00000000000 --- a/data/module/Compat/Compat/Function/ibase_timefmt.php +++ /dev/null @@ -1,56 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: ibase_timefmt.php,v 1.1 2005/05/10 07:51:07 aidan Exp $ - - -/** - * Replace function ibase_timefmt() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.ibase_timefmt - * @author Aidan Lister - * @version $Revision: 1.1 $ - * @since PHP 5.0.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('ibase_timefmt')) { - function ibase_timefmt($format, $columntype = IBASE_TIMESTAMP) - { - switch ($columntype) { - case IBASE_TIMESTAMP: - ini_set('ibase.dateformat', $format); - break; - - case IBASE_DATE: - ini_set('ibase.dateformat', $format); - break; - - case IBASE_TIME: - ini_set('ibase.timeformat', $format); - break; - - default: - return false; - } - - return true; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/idate.php b/data/module/Compat/Compat/Function/idate.php deleted file mode 100644 index 5e6a245dec8..00000000000 --- a/data/module/Compat/Compat/Function/idate.php +++ /dev/null @@ -1,52 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: idate.php,v 1.2 2005/12/07 21:08:57 aidan Exp $ - - -/** - * Replace idate() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/idate - * @author Arpad Ray - * @version $Revision: 1.2 $ - * @since PHP 5.0.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('idate')) { - function idate($format, $timestamp = false) - { - if (strlen($format) !== 1) { - user_error('idate format is one char', E_USER_WARNING); - return false; - } - - if (strpos('BdhHiILmstUwWyYzZ', $format) === false) { - return 0; - } - - if ($timestamp === false) { - $timestamp = time(); - } - - return intval(date($format, $timestamp)); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/image_type_to_mime_type.php b/data/module/Compat/Compat/Function/image_type_to_mime_type.php deleted file mode 100644 index f20343855f5..00000000000 --- a/data/module/Compat/Compat/Function/image_type_to_mime_type.php +++ /dev/null @@ -1,147 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: image_type_to_mime_type.php,v 1.8 2005/01/26 04:55:13 aidan Exp $ - - -if (!defined('IMAGETYPE_GIF')) { - define('IMAGETYPE_GIF', 1); -} - -if (!defined('IMAGETYPE_JPEG')) { - define('IMAGETYPE_JPEG', 2); -} - -if (!defined('IMAGETYPE_PNG')) { - define('IMAGETYPE_PNG', 3); -} - -if (!defined('IMAGETYPE_SWF')) { - define('IMAGETYPE_SWF', 4); -} - -if (!defined('IMAGETYPE_PSD')) { - define('IMAGETYPE_PSD', 5); -} - -if (!defined('IMAGETYPE_BMP')) { - define('IMAGETYPE_BMP', 6); -} - -if (!defined('IMAGETYPE_TIFF_II')) { - define('IMAGETYPE_TIFF_II', 7); -} - -if (!defined('IMAGETYPE_TIFF_MM')) { - define('IMAGETYPE_TIFF_MM', 8); -} - -if (!defined('IMAGETYPE_JPC')) { - define('IMAGETYPE_JPC', 9); -} - -if (!defined('IMAGETYPE_JP2')) { - define('IMAGETYPE_JP2', 10); -} - -if (!defined('IMAGETYPE_JPX')) { - define('IMAGETYPE_JPX', 11); -} - -if (!defined('IMAGETYPE_JB2')) { - define('IMAGETYPE_JB2', 12); -} - -if (!defined('IMAGETYPE_SWC')) { - define('IMAGETYPE_SWC', 13); -} - -if (!defined('IMAGETYPE_IFF')) { - define('IMAGETYPE_IFF', 14); -} - -if (!defined('IMAGETYPE_WBMP')) { - define('IMAGETYPE_WBMP', 15); -} - -if (!defined('IMAGETYPE_XBM')) { - define('IMAGETYPE_XBM', 16); -} - - -/** - * Replace image_type_to_mime_type() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.image_type_to_mime_type - * @author Aidan Lister - * @version $Revision: 1.8 $ - * @since PHP 4.3.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('image_type_to_mime_type')) { - function image_type_to_mime_type($imagetype) - { - switch ($imagetype): - case IMAGETYPE_GIF: - return 'image/gif'; - break; - case IMAGETYPE_JPEG: - return 'image/jpeg'; - break; - case IMAGETYPE_PNG: - return 'image/png'; - break; - case IMAGETYPE_SWF: - case IMAGETYPE_SWC: - return 'application/x-shockwave-flash'; - break; - case IMAGETYPE_PSD: - return 'image/psd'; - break; - case IMAGETYPE_BMP: - return 'image/bmp'; - break; - case IMAGETYPE_TIFF_MM: - case IMAGETYPE_TIFF_II: - return 'image/tiff'; - break; - case IMAGETYPE_JP2: - return 'image/jp2'; - break; - case IMAGETYPE_IFF: - return 'image/iff'; - break; - case IMAGETYPE_WBMP: - return 'image/vnd.wap.wbmp'; - break; - case IMAGETYPE_XBM: - return 'image/xbm'; - break; - case IMAGETYPE_JPX: - case IMAGETYPE_JB2: - case IMAGETYPE_JPC: - default: - return 'application/octet-stream'; - break; - - endswitch; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/inet_ntop.php b/data/module/Compat/Compat/Function/inet_ntop.php deleted file mode 100644 index 3d19052031c..00000000000 --- a/data/module/Compat/Compat/Function/inet_ntop.php +++ /dev/null @@ -1,53 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: inet_ntop.php,v 1.3 2005/12/05 14:49:40 aidan Exp $ - - -/** - * Replace inet_ntop() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/inet_ntop - * @author Arpad Ray - * @version $Revision: 1.3 $ - * @since PHP 5.1.0 - * @require PHP 4.0.0 (long2ip) - */ -if (!function_exists('inet_ntop')) { - function inet_ntop($in_addr) - { - switch (strlen($in_addr)) { - case 4: - list(,$r) = unpack('N', $in_addr); - return long2ip($r); - - case 16: - $r = substr(chunk_split(bin2hex($in_addr), 4, ':'), 0, -1); - $r = preg_replace( - array('/(?::?\b0+\b:?){2,}/', '/\b0+([^0])/e'), - array('::', '(int)"$1"?"$1":"0$1"'), - $r); - return $r; - } - - return false; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/inet_pton.php b/data/module/Compat/Compat/Function/inet_pton.php deleted file mode 100644 index 46e4a656189..00000000000 --- a/data/module/Compat/Compat/Function/inet_pton.php +++ /dev/null @@ -1,60 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: inet_pton.php,v 1.2 2005/12/05 14:49:40 aidan Exp $ - - -/** - * Replace inet_pton() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/inet_pton - * @author Arpad Ray - * @version $Revision: 1.2 $ - * @since PHP 5.1.0 - * @require PHP 4.2.0 (array_fill) - */ -if (!function_exists('inet_pton')) { - function inet_pton($address) - { - $r = ip2long($address); - if ($r !== false && $r != -1) { - return pack('N', $r); - } - - $delim_count = substr_count($address, ':'); - if ($delim_count < 1 || $delim_count > 7) { - return false; - } - - $r = explode(':', $address); - $rcount = count($r); - if (($doub = array_search('', $r, 1)) !== false) { - $length = (!$doub || $doub == $rcount - 1 ? 2 : 1); - array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0)); - } - - $r = array_map('hexdec', $r); - array_unshift($r, 'n*'); - $r = call_user_func_array('pack', $r); - - return $r; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/ini_get_all.php b/data/module/Compat/Compat/Function/ini_get_all.php deleted file mode 100644 index 7bfd04eba53..00000000000 --- a/data/module/Compat/Compat/Function/ini_get_all.php +++ /dev/null @@ -1,85 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: ini_get_all.php,v 1.3 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace ini_get_all() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.ini_get_all - * @author Aidan Lister - * @version $Revision: 1.3 $ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('ini_get_all')) { - function ini_get_all($extension = null) - { - // Sanity check - if (!is_scalar($extension)) { - user_error('ini_get_all() expects parameter 1 to be string, ' . - gettype($extension) . ' given', E_USER_WARNING); - return false; - } - - // Get the location of php.ini - ob_start(); - phpinfo(INFO_GENERAL); - $info = ob_get_contents(); - ob_clean(); - $info = explode("\n", $info); - $line = array_values(preg_grep('#php.ini#', $info)); - list (, $value) = explode('', $line[0]); - $inifile = trim(strip_tags($value)); - - // Parse - if ($extension !== null) { - $ini_all = parse_ini_file($inifile, true); - - // Lowercase extension keys - foreach ($ini_all as $key => $value) { - $ini_arr[strtolower($key)] = $value; - } - - $ini = $ini_arr[$extension]; - } else { - $ini = parse_ini_file($inifile); - } - - // Order - $ini_lc = array_map('strtolower', array_keys($ini)); - array_multisort($ini_lc, SORT_ASC, SORT_STRING, $ini); - - // Format - $info = array(); - foreach ($ini as $key => $value) { - $info[$key] = array( - 'global_value' => $value, - 'local_value' => ini_get($key), - // No way to know this - 'access' => -1 - ); - } - - return $info; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/is_a.php b/data/module/Compat/Compat/Function/is_a.php deleted file mode 100644 index 2a431d6f089..00000000000 --- a/data/module/Compat/Compat/Function/is_a.php +++ /dev/null @@ -1,47 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: is_a.php,v 1.16 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace function is_a() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.is_a - * @author Aidan Lister - * @version $Revision: 1.16 $ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (user_error) (is_subclass_of) - */ -if (!function_exists('is_a')) { - function is_a($object, $class) - { - if (!is_object($object)) { - return false; - } - - if (get_class($object) == strtolower($class)) { - return true; - } else { - return is_subclass_of($object, $class); - } - } -} - -?> diff --git a/data/module/Compat/Compat/Function/md5_file.php b/data/module/Compat/Compat/Function/md5_file.php deleted file mode 100644 index ee0eff20f03..00000000000 --- a/data/module/Compat/Compat/Function/md5_file.php +++ /dev/null @@ -1,82 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: md5_file.php,v 1.3 2005/11/22 08:29:19 aidan Exp $ - - -/** - * Replace md5_file() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/md5_file - * @author Aidan Lister - * @version $Revision: 1.3 $ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('md5_file')) { - function md5_file($filename, $raw_output = false) - { - // Sanity check - if (!is_scalar($filename)) { - user_error('md5_file() expects parameter 1 to be string, ' . - gettype($filename) . ' given', E_USER_WARNING); - return; - } - - if (!is_scalar($raw_output)) { - user_error('md5_file() expects parameter 2 to be bool, ' . - gettype($raw_output) . ' given', E_USER_WARNING); - return; - } - - if (!file_exists($filename)) { - user_error('md5_file() Unable to open file', E_USER_WARNING); - return false; - } - - // Read the file - if (false === $fh = fopen($filename, 'rb')) { - user_error('md5_file() failed to open stream: No such file or directory', - E_USER_WARNING); - return false; - } - - clearstatcache(); - if ($fsize = @filesize($filename)) { - $data = fread($fh, $fsize); - } else { - $data = ''; - while (!feof($fh)) { - $data .= fread($fh, 8192); - } - } - - fclose($fh); - - // Return - $data = md5($data); - if ($raw_output === true) { - $data = pack('H*', $data); - } - - return $data; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/mhash.php b/data/module/Compat/Compat/Function/mhash.php deleted file mode 100644 index 128c68ee121..00000000000 --- a/data/module/Compat/Compat/Function/mhash.php +++ /dev/null @@ -1,115 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: mhash.php,v 1.1 2005/05/10 07:56:44 aidan Exp $ - - -if (!defined('MHASH_CRC32')) { - define('MHASH_CRC32', 0); -} - -if (!defined('MHASH_MD5')) { - define('MHASH_MD5', 1); -} - -if (!defined('MHASH_SHA1')) { - define('MHASH_SHA1', 2); -} - -if (!defined('MHASH_HAVAL256')) { - define('MHASH_HAVAL256', 3); -} - -if (!defined('MHASH_RIPEMD160')) { - define('MHASH_RIPEMD160', 5); -} - -if (!defined('MHASH_TIGER')) { - define('MHASH_TIGER', 7); -} - -if (!defined('MHASH_GOST')) { - define('MHASH_GOST', 8); -} - -if (!defined('MHASH_CRC32B')) { - define('MHASH_CRC32B', 9); -} - -if (!defined('MHASH_HAVAL192')) { - define('MHASH_HAVAL192', 11); -} - -if (!defined('MHASH_HAVAL160')) { - define('MHASH_HAVAL160', 12); -} - -if (!defined('MHASH_HAVAL128')) { - define('MHASH_HAVAL128', 13); -} - -if (!defined('MHASH_TIGER128')) { - define('MHASH_TIGER128', 14); -} - -if (!defined('MHASH_TIGER160')) { - define('MHASH_TIGER160', 15); -} - -if (!defined('MHASH_MD4')) { - define('MHASH_MD4', 16); -} - -if (!defined('MHASH_SHA256')) { - define('MHASH_SHA256', 17); -} - -if (!defined('MHASH_ADLER32')) { - define('MHASH_ADLER32', 18); -} - - -/** - * Replace mhash() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.mhash - * @author Aidan Lister - * @version $Revision: 1.1 $ - * @since PHP 4.1.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('mhash')) { - function mhash($hashtype, $data, $key = '') - { - switch ($hashtype) { - case MHASH_MD5: - $key = str_pad((strlen($key) > 64 ? pack("H*", md5($key)) : $key), 64, chr(0x00)); - $k_opad = $key ^ (str_pad('', 64, chr(0x5c))); - $k_ipad = $key ^ (str_pad('', 64, chr(0x36))); - return pack("H*", md5($k_opad . pack("H*", md5($k_ipad . $data)))); - - default: - return false; - - break; - } - } -} - -?> diff --git a/data/module/Compat/Compat/Function/mime_content_type.php b/data/module/Compat/Compat/Function/mime_content_type.php deleted file mode 100644 index 625d24a435c..00000000000 --- a/data/module/Compat/Compat/Function/mime_content_type.php +++ /dev/null @@ -1,63 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: mime_content_type.php,v 1.3 2005/12/07 21:08:57 aidan Exp $ - - -/** -* Replace mime_content_type() -* -* You will need the `file` command installed and present in your $PATH. If -* `file` is not available, the type 'application/octet-stream' is returned -* for all files. -* -* @category PHP -* @package PHP_Compat -* @link http://php.net/function.mime_content_type -* @version $Revision: 1.3 $ -* @author Ian Eure -* @since PHP 4.3.0 -* @require PHP 4.0.3 (escapeshellarg) -*/ -if (!function_exists('mime_content_type')) { - function mime_content_type($filename) - { - // Sanity check - if (!file_exists($filename)) { - return false; - } - - $filename = escapeshellarg($filename); - $out = `file -iL $filename 2>/dev/null`; - if (empty($out)) { - return 'application/octet-stream'; - } - - // Strip off filename - $t = substr($out, strpos($out, ':') + 2); - - if (strpos($t, ';') !== false) { - // Strip MIME parameters - $t = substr($t, 0, strpos($t, ';')); - } - - // Strip any remaining whitespace - return trim($t); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/ob_clean.php b/data/module/Compat/Compat/Function/ob_clean.php deleted file mode 100644 index 554d03fe42d..00000000000 --- a/data/module/Compat/Compat/Function/ob_clean.php +++ /dev/null @@ -1,46 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: ob_clean.php,v 1.6 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace ob_clean() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.ob_clean - * @author Aidan Lister - * @author Thiemo Mttig (http://maettig.com/) - * @version $Revision: 1.6 $ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('ob_clean')) { - function ob_clean() - { - if (@ob_end_clean()) { - return ob_start(); - } - - user_error("ob_clean() failed to delete buffer. No buffer to delete.", E_USER_NOTICE); - - return false; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/ob_flush.php b/data/module/Compat/Compat/Function/ob_flush.php deleted file mode 100644 index eea99198001..00000000000 --- a/data/module/Compat/Compat/Function/ob_flush.php +++ /dev/null @@ -1,46 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: ob_flush.php,v 1.6 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace ob_flush() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.ob_flush - * @author Aidan Lister - * @author Thiemo Mttig (http://maettig.com/) - * @version $Revision: 1.6 $ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('ob_flush')) { - function ob_flush() - { - if (@ob_end_flush()) { - return ob_start(); - } - - user_error("ob_flush() Failed to flush buffer. No buffer to flush.", E_USER_NOTICE); - - return false; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/ob_get_clean.php b/data/module/Compat/Compat/Function/ob_get_clean.php deleted file mode 100644 index 32d66edb487..00000000000 --- a/data/module/Compat/Compat/Function/ob_get_clean.php +++ /dev/null @@ -1,46 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: ob_get_clean.php,v 1.6 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace ob_get_clean() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.ob_get_clean - * @author Aidan Lister - * @author Thiemo Mttig (http://maettig.com/) - * @version $Revision: 1.6 $ - * @since PHP 4.3.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('ob_get_clean')) { - function ob_get_clean() - { - $contents = ob_get_contents(); - - if ($contents !== false) { - ob_end_clean(); - } - - return $contents; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/ob_get_flush.php b/data/module/Compat/Compat/Function/ob_get_flush.php deleted file mode 100644 index da3e8c5fa94..00000000000 --- a/data/module/Compat/Compat/Function/ob_get_flush.php +++ /dev/null @@ -1,46 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: ob_get_flush.php,v 1.6 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace ob_get_flush() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.ob_get_flush - * @author Aidan Lister - * @author Thiemo Mttig (http://maettig.com/) - * @version $Revision: 1.6 $ - * @since PHP 4.3.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('ob_get_flush')) { - function ob_get_flush() - { - $contents = ob_get_contents(); - - if ($contents !== false) { - ob_end_flush(); - } - - return $contents; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/pg_affected_rows.php b/data/module/Compat/Compat/Function/pg_affected_rows.php deleted file mode 100644 index 09df5c244a8..00000000000 --- a/data/module/Compat/Compat/Function/pg_affected_rows.php +++ /dev/null @@ -1,40 +0,0 @@ - | -// | Mocha (http://us4.php.net/pg_escape_bytea) | -// +----------------------------------------------------------------------+ -// -// $Id: pg_affected_rows.php,v 1.1 2005/05/10 07:56:51 aidan Exp $ - - -/** - * Replace pg_affected_rows() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.pg_affectd_rows - * @author Ian Eure - * @version $Revision@ - * @since PHP 4.2.0 - * @require PHP 4.0.0 - */ -if (!function_exists('pg_affected_rows')) { - function pg_affected_rows($resource) - { - return pg_cmdtuples($resource); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/pg_escape_bytea.php b/data/module/Compat/Compat/Function/pg_escape_bytea.php deleted file mode 100644 index d8e824998bd..00000000000 --- a/data/module/Compat/Compat/Function/pg_escape_bytea.php +++ /dev/null @@ -1,43 +0,0 @@ - | -// | Mocha (http://us4.php.net/pg_escape_bytea) | -// +----------------------------------------------------------------------+ -// -// $Id: pg_escape_bytea.php,v 1.1 2005/05/10 07:56:51 aidan Exp $ - - -/** - * Replace pg_escape_bytea() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.pg_escape_bytea - * @author Ian Eure - * @version $Revision@ - * @since PHP 4.2.0 - * @require PHP 4.0.0 - */ -if (!function_exists('pg_escape_bytea')) { - function pg_escape_bytea($data) - { - return str_replace( - array(chr(92), chr(0), chr(39)), - array('\\\134', '\\\000', '\\\047'), - $data); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/pg_unescape_bytea.php b/data/module/Compat/Compat/Function/pg_unescape_bytea.php deleted file mode 100644 index 5dc9d0440af..00000000000 --- a/data/module/Compat/Compat/Function/pg_unescape_bytea.php +++ /dev/null @@ -1,43 +0,0 @@ - | -// | Tobias | -// +----------------------------------------------------------------------+ -// -// $Id: pg_unescape_bytea.php,v 1.2 2005/12/07 21:08:57 aidan Exp $ - - -/** - * Replace pg_unescape_bytea() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.pg_unescape_bytea - * @author Ian Eure - * @version $Revision@ - * @since PHP 4.2.0 - * @require PHP 4.0.0 - */ -if (!function_exists('pg_unescape_bytea')) { - function pg_unescape_bytea(&$data) - { - return str_replace( - array('$', '"'), - array('\\$', '\\"'), - $data); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/php_strip_whitespace.php b/data/module/Compat/Compat/Function/php_strip_whitespace.php deleted file mode 100644 index ca66121898c..00000000000 --- a/data/module/Compat/Compat/Function/php_strip_whitespace.php +++ /dev/null @@ -1,86 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: php_strip_whitespace.php,v 1.10 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace php_strip_whitespace() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.php_strip_whitespace - * @author Aidan Lister - * @version $Revision: 1.10 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) + Tokenizer extension - */ -if (!function_exists('php_strip_whitespace')) { - function php_strip_whitespace($file) - { - // Sanity check - if (!is_scalar($file)) { - user_error('php_strip_whitespace() expects parameter 1 to be string, ' . - gettype($file) . ' given', E_USER_WARNING); - return; - } - - // Load file / tokens - $source = implode('', file($file)); - $tokens = token_get_all($source); - - // Init - $source = ''; - $was_ws = false; - - // Process - foreach ($tokens as $token) { - if (is_string($token)) { - // Single character tokens - $source .= $token; - } else { - list($id, $text) = $token; - - switch ($id) { - // Skip all comments - case T_COMMENT: - case T_ML_COMMENT: - case T_DOC_COMMENT: - break; - - // Remove whitespace - case T_WHITESPACE: - // We don't want more than one whitespace in a row replaced - if ($was_ws !== true) { - $source .= ' '; - } - $was_ws = true; - break; - - default: - $was_ws = false; - $source .= $text; - break; - } - } - } - - return $source; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/restore_include_path.php b/data/module/Compat/Compat/Function/restore_include_path.php deleted file mode 100644 index 9bfc3ae7026..00000000000 --- a/data/module/Compat/Compat/Function/restore_include_path.php +++ /dev/null @@ -1,38 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: restore_include_path.php,v 1.4 2005/12/07 21:08:57 aidan Exp $ - - -/** - * Replace restore_include_path() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.restore_include_path - * @author Stephan Schmidt - * @version $Revision: 1.4 $ - * @since PHP 4.3.0 - */ -if (!function_exists('restore_include_path')) { - function restore_include_path() - { - return ini_restore('include_path'); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/scandir.php b/data/module/Compat/Compat/Function/scandir.php deleted file mode 100644 index 3147552c48d..00000000000 --- a/data/module/Compat/Compat/Function/scandir.php +++ /dev/null @@ -1,69 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: scandir.php,v 1.18 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace scandir() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.scandir - * @author Aidan Lister - * @version $Revision: 1.18 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('scandir')) { - function scandir($directory, $sorting_order = 0) - { - if (!is_string($directory)) { - user_error('scandir() expects parameter 1 to be string, ' . - gettype($directory) . ' given', E_USER_WARNING); - return; - } - - if (!is_int($sorting_order) && !is_bool($sorting_order)) { - user_error('scandir() expects parameter 2 to be long, ' . - gettype($sorting_order) . ' given', E_USER_WARNING); - return; - } - - if (!is_dir($directory) || (false === $fh = @opendir($directory))) { - user_error('scandir() failed to open dir: Invalid argument', E_USER_WARNING); - return false; - } - - $files = array (); - while (false !== ($filename = readdir($fh))) { - $files[] = $filename; - } - - closedir($fh); - - if ($sorting_order == 1) { - rsort($files); - } else { - sort($files); - } - - return $files; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/set_include_path.php b/data/module/Compat/Compat/Function/set_include_path.php deleted file mode 100644 index a520faaa384..00000000000 --- a/data/module/Compat/Compat/Function/set_include_path.php +++ /dev/null @@ -1,38 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: set_include_path.php,v 1.4 2005/12/07 21:08:57 aidan Exp $ - - -/** - * Replace set_include_path() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.set_include_path - * @author Stephan Schmidt - * @version $Revision: 1.4 $ - * @since PHP 4.3.0 - */ -if (!function_exists('set_include_path')) { - function set_include_path($new_include_path) - { - return ini_set('include_path', $new_include_path); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/sha1.php b/data/module/Compat/Compat/Function/sha1.php deleted file mode 100644 index a04a8b352af..00000000000 --- a/data/module/Compat/Compat/Function/sha1.php +++ /dev/null @@ -1,117 +0,0 @@ -, Arpad Ray - * @link http://php.net/function.sha1 - * @author revulo - * @since PHP 4.3.0 - * @require PHP 4.0.0 - */ -function php_compat_sha1($str, $raw_output = false) -{ - $h0 = (int)0x67452301; - $h1 = (int)0xefcdab89; - $h2 = (int)0x98badcfe; - $h3 = (int)0x10325476; - $h4 = (int)0xc3d2e1f0; - - $len = strlen($str); - - $str .= "\x80"; - $str .= str_repeat("\0", 63 - ($len + 8) % 64); - $str .= pack('N2', $len >> 29, $len << 3); - - for ($i = 0; $i < strlen($str); $i += 64) { - - $w = array(); - for ($j = 0; $j < 16; ++$j) { - $index = $i + $j * 4; - $w[$j] = ord($str[$index]) << 24 - | ord($str[$index + 1]) << 16 - | ord($str[$index + 2]) << 8 - | ord($str[$index + 3]); - } - for ($j = 16; $j < 80; ++$j) { - $w[$j] = php_compat_sha1_rotl_helper($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); - } - - $a = $h0; - $b = $h1; - $c = $h2; - $d = $h3; - $e = $h4; - - for ($j = 0; $j < 80; ++$j) { - if ($j < 20) { - $f = ($b & $c) | (~$b & $d); - $k = (int)0x5a827999; - } else if ($j < 40) { - $f = $b ^ $c ^ $d; - $k = (int)0x6ed9eba1; - } else if ($j < 60) { - $f = ($b & $c) | ($b & $d) | ($c & $d); - $k = (int)0x8f1bbcdc; - } else { - $f = $b ^ $c ^ $d; - $k = (int)0xca62c1d6; - } - - $t = php_compat_sha1_add32_helper( - php_compat_sha1_add32_helper( - php_compat_sha1_add32_helper( - php_compat_sha1_add32_helper( - php_compat_sha1_rotl_helper($a, 5), $f), $e), $k), $w[$j]); - - $e = $d; - $d = $c; - $c = php_compat_sha1_rotl_helper($b, 30); - $b = $a; - $a = $t; - } - - $h0 = php_compat_sha1_add32_helper($h0, $a); - $h1 = php_compat_sha1_add32_helper($h1, $b); - $h2 = php_compat_sha1_add32_helper($h2, $c); - $h3 = php_compat_sha1_add32_helper($h3, $d); - $h4 = php_compat_sha1_add32_helper($h4, $e); - } - - $h0 &= (int)0xffffffff; - $h1 &= (int)0xffffffff; - $h2 &= (int)0xffffffff; - $h3 &= (int)0xffffffff; - $h4 &= (int)0xffffffff; - - $hash = sprintf('%08x%08x%08x%08x%08x', $h0, $h1, $h2, $h3, $h4); - - if ($raw_output) { - return pack('H*', $hash); - } else { - return $hash; - } -} - -function php_compat_sha1_add32_helper($x, $y) -{ - $lsw = ($x & 0xffff) + ($y & 0xffff); - $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16); - return ($msw << 16) | ($lsw & 0xffff); -} - -function php_compat_sha1_rotl_helper($x, $n) -{ - return ($x << $n) | ($x >> (32 - $n)) & (0x7fffffff >> (31 - $n)); -} - -// Define -if (!function_exists('sha1')) { - function sha1($str, $raw_output = false) - { - return php_compat_sha1($str, $raw_output); - } -} diff --git a/data/module/Compat/Compat/Function/sha256.php b/data/module/Compat/Compat/Function/sha256.php deleted file mode 100644 index a19d0c51bb0..00000000000 --- a/data/module/Compat/Compat/Function/sha256.php +++ /dev/null @@ -1,156 +0,0 @@ -, Arpad Ray - * @link http://php.net/function.hash - * @author revulo - * @require PHP 4.0.0 - */ -function php_compat_sha256($str, $raw_output = false) -{ - $h0 = (int)0x6a09e667; - $h1 = (int)0xbb67ae85; - $h2 = (int)0x3c6ef372; - $h3 = (int)0xa54ff53a; - $h4 = (int)0x510e527f; - $h5 = (int)0x9b05688c; - $h6 = (int)0x1f83d9ab; - $h7 = (int)0x5be0cd19; - - $k = array( - (int)0x428a2f98, (int)0x71374491, (int)0xb5c0fbcf, (int)0xe9b5dba5, - (int)0x3956c25b, (int)0x59f111f1, (int)0x923f82a4, (int)0xab1c5ed5, - (int)0xd807aa98, (int)0x12835b01, (int)0x243185be, (int)0x550c7dc3, - (int)0x72be5d74, (int)0x80deb1fe, (int)0x9bdc06a7, (int)0xc19bf174, - (int)0xe49b69c1, (int)0xefbe4786, (int)0x0fc19dc6, (int)0x240ca1cc, - (int)0x2de92c6f, (int)0x4a7484aa, (int)0x5cb0a9dc, (int)0x76f988da, - (int)0x983e5152, (int)0xa831c66d, (int)0xb00327c8, (int)0xbf597fc7, - (int)0xc6e00bf3, (int)0xd5a79147, (int)0x06ca6351, (int)0x14292967, - (int)0x27b70a85, (int)0x2e1b2138, (int)0x4d2c6dfc, (int)0x53380d13, - (int)0x650a7354, (int)0x766a0abb, (int)0x81c2c92e, (int)0x92722c85, - (int)0xa2bfe8a1, (int)0xa81a664b, (int)0xc24b8b70, (int)0xc76c51a3, - (int)0xd192e819, (int)0xd6990624, (int)0xf40e3585, (int)0x106aa070, - (int)0x19a4c116, (int)0x1e376c08, (int)0x2748774c, (int)0x34b0bcb5, - (int)0x391c0cb3, (int)0x4ed8aa4a, (int)0x5b9cca4f, (int)0x682e6ff3, - (int)0x748f82ee, (int)0x78a5636f, (int)0x84c87814, (int)0x8cc70208, - (int)0x90befffa, (int)0xa4506ceb, (int)0xbef9a3f7, (int)0xc67178f2 - ); - - $len = strlen($str); - - $str .= "\x80"; - $str .= str_repeat("\0", 63 - ($len + 8) % 64); - $str .= pack('N2', $len >> 29, $len << 3); - - for ($i = 0; $i < strlen($str); $i += 64) { - - $w = array(); - for ($j = 0; $j < 16; ++$j) { - $index = $i + $j * 4; - $w[$j] = ord($str[$index]) << 24 - | ord($str[$index + 1]) << 16 - | ord($str[$index + 2]) << 8 - | ord($str[$index + 3]); - } - for ($j = 16; $j < 64; ++$j) { - $s0 = php_compat_sha256_rotr_helper($w[$j - 15], 7) - ^ php_compat_sha256_rotr_helper($w[$j - 15], 18) - ^ php_compat_sha256_shr_helper ($w[$j - 15], 3); - - $s1 = php_compat_sha256_rotr_helper($w[$j - 2], 17) - ^ php_compat_sha256_rotr_helper($w[$j - 2], 19) - ^ php_compat_sha256_shr_helper ($w[$j - 2], 10); - - $w[$j] = php_compat_sha256_add32_helper( - php_compat_sha256_add32_helper( - php_compat_sha256_add32_helper($w[$j - 16], $s0), $w[$j - 7]), $s1); - } - - $a = $h0; - $b = $h1; - $c = $h2; - $d = $h3; - $e = $h4; - $f = $h5; - $g = $h6; - $h = $h7; - - for ($j = 0; $j < 64; ++$j) { - $s1 = php_compat_sha256_rotr_helper($e, 6) - ^ php_compat_sha256_rotr_helper($e, 11) - ^ php_compat_sha256_rotr_helper($e, 25); - - $ch = ($e & $f) ^ (~$e & $g); - - $s0 = php_compat_sha256_rotr_helper($a, 2) - ^ php_compat_sha256_rotr_helper($a, 13) - ^ php_compat_sha256_rotr_helper($a, 22); - - $maj = ($a & $b) ^ ($a & $c) ^ ($b & $c); - - $t1 = php_compat_sha256_add32_helper( - php_compat_sha256_add32_helper( - php_compat_sha256_add32_helper( - php_compat_sha256_add32_helper($h, $s1), $ch), $k[$j]), $w[$j]); - - $t2 = php_compat_sha256_add32_helper($s0, $maj); - - $h = $g; - $g = $f; - $f = $e; - $e = php_compat_sha256_add32_helper($d, $t1); - $d = $c; - $c = $b; - $b = $a; - $a = php_compat_sha256_add32_helper($t1, $t2); - } - - $h0 = php_compat_sha256_add32_helper($h0, $a); - $h1 = php_compat_sha256_add32_helper($h1, $b); - $h2 = php_compat_sha256_add32_helper($h2, $c); - $h3 = php_compat_sha256_add32_helper($h3, $d); - $h4 = php_compat_sha256_add32_helper($h4, $e); - $h5 = php_compat_sha256_add32_helper($h5, $f); - $h6 = php_compat_sha256_add32_helper($h6, $g); - $h7 = php_compat_sha256_add32_helper($h7, $h); - } - - $h0 &= (int)0xffffffff; - $h1 &= (int)0xffffffff; - $h2 &= (int)0xffffffff; - $h3 &= (int)0xffffffff; - $h4 &= (int)0xffffffff; - $h5 &= (int)0xffffffff; - $h6 &= (int)0xffffffff; - $h7 &= (int)0xffffffff; - - $hash = sprintf('%08x%08x%08x%08x%08x%08x%08x%08x', $h0, $h1, $h2, $h3, $h4, $h5, $h6, $h7); - - if ($raw_output) { - return pack('H*', $hash); - } else { - return $hash; - } -} - -function php_compat_sha256_add32_helper($x, $y) -{ - $lsw = ($x & 0xffff) + ($y & 0xffff); - $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16); - return ($msw << 16) | ($lsw & 0xffff); -} - -function php_compat_sha256_shr_helper($x, $n) -{ - return ($x >> $n) & (0x7fffffff >> ($n - 1)); -} - -function php_compat_sha256_rotr_helper($x, $n) -{ - return ($x << (32 - $n)) | ($x >> $n) & (0x7fffffff >> ($n - 1)); -} diff --git a/data/module/Compat/Compat/Function/str_ireplace.php b/data/module/Compat/Compat/Function/str_ireplace.php deleted file mode 100644 index aa3cf4aa8f0..00000000000 --- a/data/module/Compat/Compat/Function/str_ireplace.php +++ /dev/null @@ -1,113 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: str_ireplace.php,v 1.18 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace str_ireplace() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.str_ireplace - * @author Aidan Lister - * @version $Revision: 1.18 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - * @note count not by returned by reference, to enable - * change '$count = null' to '&$count' - */ -if (!function_exists('str_ireplace')) { - function str_ireplace($search, $replace, $subject, $count = null) - { - // Sanity check - if (is_string($search) && is_array($replace)) { - user_error('Array to string conversion', E_USER_NOTICE); - $replace = (string) $replace; - } - - // If search isn't an array, make it one - if (!is_array($search)) { - $search = array ($search); - } - $search = array_values($search); - - // If replace isn't an array, make it one, and pad it to the length of search - if (!is_array($replace)) { - $replace_string = $replace; - - $replace = array (); - for ($i = 0, $c = count($search); $i < $c; $i++) { - $replace[$i] = $replace_string; - } - } - $replace = array_values($replace); - - // Check the replace array is padded to the correct length - $length_replace = count($replace); - $length_search = count($search); - if ($length_replace < $length_search) { - for ($i = $length_replace; $i < $length_search; $i++) { - $replace[$i] = ''; - } - } - - // If subject is not an array, make it one - $was_array = false; - if (!is_array($subject)) { - $was_array = true; - $subject = array ($subject); - } - - // Loop through each subject - $count = 0; - foreach ($subject as $subject_key => $subject_value) { - // Loop through each search - foreach ($search as $search_key => $search_value) { - // Split the array into segments, in between each part is our search - $segments = explode(strtolower($search_value), strtolower($subject_value)); - - // The number of replacements done is the number of segments minus the first - $count += count($segments) - 1; - $pos = 0; - - // Loop through each segment - foreach ($segments as $segment_key => $segment_value) { - // Replace the lowercase segments with the upper case versions - $segments[$segment_key] = substr($subject_value, $pos, strlen($segment_value)); - // Increase the position relative to the initial string - $pos += strlen($segment_value) + strlen($search_value); - } - - // Put our original string back together - $subject_value = implode($replace[$search_key], $segments); - } - - $result[$subject_key] = $subject_value; - } - - // Check if subject was initially a string and return it as a string - if ($was_array === true) { - return $result[0]; - } - - // Otherwise, just return the array - return $result; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/str_rot13.php b/data/module/Compat/Compat/Function/str_rot13.php deleted file mode 100644 index 25bebc25496..00000000000 --- a/data/module/Compat/Compat/Function/str_rot13.php +++ /dev/null @@ -1,43 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: str_rot13.php,v 1.4 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace str_rot13() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.str_rot13 - * @author Alan Morey - * @author Aidan Lister - * @version $Revision: 1.4 $ - * @since PHP 4.0.0 - */ -if (!function_exists('str_rot13')) { - function str_rot13($str) - { - $from = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $to = 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'; - - return strtr($str, $from, $to); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/str_shuffle.php b/data/module/Compat/Compat/Function/str_shuffle.php deleted file mode 100644 index 0ab3ece24d6..00000000000 --- a/data/module/Compat/Compat/Function/str_shuffle.php +++ /dev/null @@ -1,52 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: str_shuffle.php,v 1.6 2005/08/14 03:24:16 aidan Exp $ - - -/** - * Replace str_shuffle() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.str_shuffle - * @author Aidan Lister - * @version $Revision: 1.6 $ - * @since PHP 4.3.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('str_shuffle')) { - function str_shuffle($str) - { - // Init - $str = (string) $str; - - // Seed - list($usec, $sec) = explode(' ', microtime()); - $seed = (float) $sec + ((float) $usec * 100000); - mt_srand($seed); - - // Shuffle - for ($new = '', $len = strlen($str); $len > 0; $str{$p} = $str{$len}) { - $new .= $str{$p = mt_rand(0, --$len)}; - } - - return $new; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/str_split.php b/data/module/Compat/Compat/Function/str_split.php deleted file mode 100644 index 10d74550460..00000000000 --- a/data/module/Compat/Compat/Function/str_split.php +++ /dev/null @@ -1,71 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: str_split.php,v 1.15 2005/06/18 12:15:32 aidan Exp $ - - -/** - * Replace str_split() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.str_split - * @author Aidan Lister - * @version $Revision: 1.15 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('str_split')) { - function str_split($string, $split_length = 1) - { - if (!is_scalar($split_length)) { - user_error('str_split() expects parameter 2 to be long, ' . - gettype($split_length) . ' given', E_USER_WARNING); - return false; - } - - $split_length = (int) $split_length; - if ($split_length < 1) { - user_error('str_split() The length of each segment must be greater than zero', E_USER_WARNING); - return false; - } - - // Select split method - if ($split_length < 65536) { - // Faster, but only works for less than 2^16 - preg_match_all('/.{1,' . $split_length . '}/s', $string, $matches); - return $matches[0]; - } else { - // Required due to preg limitations - $arr = array(); - $idx = 0; - $pos = 0; - $len = strlen($string); - - while ($len > 0) { - $blk = ($len < $split_length) ? $len : $split_length; - $arr[$idx++] = substr($string, $pos, $blk); - $pos += $blk; - $len -= $blk; - } - - return $arr; - } - } -} - -?> diff --git a/data/module/Compat/Compat/Function/str_word_count.php b/data/module/Compat/Compat/Function/str_word_count.php deleted file mode 100644 index 623afa837f1..00000000000 --- a/data/module/Compat/Compat/Function/str_word_count.php +++ /dev/null @@ -1,68 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: str_word_count.php,v 1.9 2005/02/28 11:45:28 aidan Exp $ - - -/** - * Replace str_word_count() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.str_word_count - * @author Aidan Lister - * @version $Revision: 1.9 $ - * @since PHP 4.3.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('str_word_count')) { - function str_word_count($string, $format = null) - { - if ($format !== 1 && $format !== 2 && $format !== null) { - user_error('str_word_count() The specified format parameter, "' . $format . '" is invalid', - E_USER_WARNING); - return false; - } - - $word_string = preg_replace('/[0-9]+/', '', $string); - $word_array = preg_split('/[^A-Za-z0-9_\']+/', $word_string, -1, PREG_SPLIT_NO_EMPTY); - - switch ($format) { - case null: - $result = count($word_array); - break; - - case 1: - $result = $word_array; - break; - - case 2: - $lastmatch = 0; - $word_assoc = array(); - foreach ($word_array as $word) { - $word_assoc[$lastmatch = strpos($string, $word, $lastmatch)] = $word; - $lastmatch += strlen($word); - } - $result = $word_assoc; - break; - } - - return $result; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/stripos.php b/data/module/Compat/Compat/Function/stripos.php deleted file mode 100644 index efac325eede..00000000000 --- a/data/module/Compat/Compat/Function/stripos.php +++ /dev/null @@ -1,73 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: stripos.php,v 1.13 2005/05/30 20:33:03 aidan Exp $ - - -/** - * Replace stripos() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.stripos - * @author Aidan Lister - * @version $Revision: 1.13 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('stripos')) { - function stripos($haystack, $needle, $offset = null) - { - if (!is_scalar($haystack)) { - user_error('stripos() expects parameter 1 to be string, ' . - gettype($haystack) . ' given', E_USER_WARNING); - return false; - } - - if (!is_scalar($needle)) { - user_error('stripos() needle is not a string or an integer.', E_USER_WARNING); - return false; - } - - if (!is_int($offset) && !is_bool($offset) && !is_null($offset)) { - user_error('stripos() expects parameter 3 to be long, ' . - gettype($offset) . ' given', E_USER_WARNING); - return false; - } - - // Manipulate the string if there is an offset - $fix = 0; - if (!is_null($offset)) { - if ($offset > 0) { - $haystack = substr($haystack, $offset, strlen($haystack) - $offset); - $fix = $offset; - } - } - - $segments = explode(strtolower($needle), strtolower($haystack), 2); - - // Check there was a match - if (count($segments) === 1) { - return false; - } - - $position = strlen($segments[0]) + $fix; - return $position; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/strpbrk.php b/data/module/Compat/Compat/Function/strpbrk.php deleted file mode 100644 index 4c6a1158e8a..00000000000 --- a/data/module/Compat/Compat/Function/strpbrk.php +++ /dev/null @@ -1,63 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: strpbrk.php,v 1.4 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace strpbrk() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.strpbrk - * @author Stephan Schmidt - * @version $Revision: 1.4 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('strpbrk')) { - function strpbrk($haystack, $char_list) - { - if (!is_scalar($haystack)) { - user_error('strpbrk() expects parameter 1 to be string, ' . - gettype($haystack) . ' given', E_USER_WARNING); - return false; - } - - if (!is_scalar($char_list)) { - user_error('strpbrk() expects parameter 2 to be scalar, ' . - gettype($needle) . ' given', E_USER_WARNING); - return false; - } - - $haystack = (string) $haystack; - $char_list = (string) $char_list; - - $len = strlen($haystack); - for ($i = 0; $i < $len; $i++) { - $char = substr($haystack, $i, 1); - if (strpos($char_list, $char) === false) { - continue; - } - return substr($haystack, $i); - } - - return false; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/strripos.php b/data/module/Compat/Compat/Function/strripos.php deleted file mode 100644 index c178a9af5bf..00000000000 --- a/data/module/Compat/Compat/Function/strripos.php +++ /dev/null @@ -1,79 +0,0 @@ - | -// | Stephan Schmidt | -// +----------------------------------------------------------------------+ -// -// $Id: strripos.php,v 1.24 2005/08/10 10:19:59 aidan Exp $ - - -/** - * Replace strripos() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.strripos - * @author Aidan Lister - * @version $Revision: 1.24 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('strripos')) { - function strripos($haystack, $needle, $offset = null) - { - // Sanity check - if (!is_scalar($haystack)) { - user_error('strripos() expects parameter 1 to be scalar, ' . - gettype($haystack) . ' given', E_USER_WARNING); - return false; - } - - if (!is_scalar($needle)) { - user_error('strripos() expects parameter 2 to be scalar, ' . - gettype($needle) . ' given', E_USER_WARNING); - return false; - } - - if (!is_int($offset) && !is_bool($offset) && !is_null($offset)) { - user_error('strripos() expects parameter 3 to be long, ' . - gettype($offset) . ' given', E_USER_WARNING); - return false; - } - - // Initialise variables - $needle = strtolower($needle); - $haystack = strtolower($haystack); - $needle_fc = $needle{0}; - $needle_len = strlen($needle); - $haystack_len = strlen($haystack); - $offset = (int) $offset; - $leftlimit = ($offset >= 0) ? $offset : 0; - $p = ($offset >= 0) ? - $haystack_len : - $haystack_len + $offset + 1; - - // Reverse iterate haystack - while (--$p >= $leftlimit) { - if ($needle_fc === $haystack{$p} && - substr($haystack, $p, $needle_len) === $needle) { - return $p; - } - } - - return false; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/substr_compare.php b/data/module/Compat/Compat/Function/substr_compare.php deleted file mode 100644 index edfa4ccb9d7..00000000000 --- a/data/module/Compat/Compat/Function/substr_compare.php +++ /dev/null @@ -1,74 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: substr_compare.php,v 1.5 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace substr_compare() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.substr_compare - * @author Tom Buskens - * @author Aidan Lister - * @version $Revision: 1.5 $ - * @since PHP 5 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('substr_compare')) { - function substr_compare($main_str, $str, $offset, $length = null, $case_insensitive = false) - { - if (!is_string($main_str)) { - user_error('substr_compare() expects parameter 1 to be string, ' . - gettype($main_str) . ' given', E_USER_WARNING); - return; - } - - if (!is_string($str)) { - user_error('substr_compare() expects parameter 2 to be string, ' . - gettype($str) . ' given', E_USER_WARNING); - return; - } - - if (!is_int($offset)) { - user_error('substr_compare() expects parameter 3 to be long, ' . - gettype($offset) . ' given', E_USER_WARNING); - return; - } - - if (is_null($length)) { - $length = strlen($main_str) - $offset; - } elseif ($offset >= strlen($main_str)) { - user_error('substr_compare() The start position cannot exceed initial string length', - E_USER_WARNING); - return false; - } - - $main_str = substr($main_str, $offset, $length); - $str = substr($str, 0, strlen($main_str)); - - if ($case_insensitive === false) { - return strcmp($main_str, $str); - } else { - return strcasecmp($main_str, $str); - } - } -} - -?> diff --git a/data/module/Compat/Compat/Function/time_sleep_until.php b/data/module/Compat/Compat/Function/time_sleep_until.php deleted file mode 100644 index d015dc3eb1e..00000000000 --- a/data/module/Compat/Compat/Function/time_sleep_until.php +++ /dev/null @@ -1,48 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: time_sleep_until.php,v 1.2 2005/12/07 21:08:57 aidan Exp $ - - -/** - * Replace time_sleep_until() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/time_sleep_until - * @author Arpad Ray - * @version $Revision: 1.2 $ - * @since PHP 5.1.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('time_sleep_until')) { - function time_sleep_until($timestamp) - { - list($usec, $sec) = explode(' ', microtime()); - $now = $sec + $usec; - if ($timestamp <= $now) { - user_error('Specified timestamp is in the past', E_USER_WARNING); - return false; - } - - $diff = $timestamp - $now; - usleep($diff * 1000000); - return true; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/var_export.php b/data/module/Compat/Compat/Function/var_export.php deleted file mode 100644 index b15fe82288e..00000000000 --- a/data/module/Compat/Compat/Function/var_export.php +++ /dev/null @@ -1,136 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: var_export.php,v 1.15 2005/12/05 14:24:27 aidan Exp $ - - -/** - * Replace var_export() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.var_export - * @author Aidan Lister - * @version $Revision: 1.15 $ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (user_error) - */ -if (!function_exists('var_export')) { - function var_export($var, $return = false, $level = 0) - { - // Init - $indent = ' '; - $doublearrow = ' => '; - $lineend = ",\n"; - $stringdelim = '\''; - $newline = "\n"; - $find = array(null, '\\', '\''); - $replace = array('NULL', '\\\\', '\\\''); - $out = ''; - - // Indent - $level++; - for ($i = 1, $previndent = ''; $i < $level; $i++) { - $previndent .= $indent; - } - - // Handle each type - switch (gettype($var)) { - // Array - case 'array': - $out = 'array (' . $newline; - foreach ($var as $key => $value) { - // Key - if (is_string($key)) { - // Make key safe - for ($i = 0, $c = count($find); $i < $c; $i++) { - $var = str_replace($find[$i], $replace[$i], $var); - } - $key = $stringdelim . $key . $stringdelim; - } - - // Value - if (is_array($value)) { - $export = var_export($value, true, $level); - $value = $newline . $previndent . $indent . $export; - } else { - $value = var_export($value, true, $level); - } - - // Piece line together - $out .= $previndent . $indent . $key . $doublearrow . $value . $lineend; - } - - // End string - $out .= $previndent . ')'; - break; - - // String - case 'string': - // Make the string safe - for ($i = 0, $c = count($find); $i < $c; $i++) { - $var = str_replace($find[$i], $replace[$i], $var); - } - $out = $stringdelim . $var . $stringdelim; - break; - - // Number - case 'integer': - case 'double': - $out = (string) $var; - break; - - // Boolean - case 'boolean': - $out = $var ? 'true' : 'false'; - break; - - // NULLs - case 'NULL': - case 'resource': - $out = 'NULL'; - break; - - // Objects - case 'object': - // Start the object export - $out = $newline . $previndent . 'class ' . get_class($var) . ' {' . $newline; - - // Export the object vars - foreach (get_object_vars($var) as $key => $val) { - $out .= $previndent . ' var $' . $key . ' = '; - if (is_array($val)) { - $export = var_export($val, true, $level); - $out .= $newline . $previndent . $indent . $export . ';' . $newline; - } else { - $out .= var_export($val, true, $level) . ';' . $newline; - } - } - $out .= $previndent . '}'; - break; - } - - // Method of output - if ($return === true) { - return $out; - } else { - echo $out; - } - } -} - -?> diff --git a/data/module/Compat/Compat/Function/version_compare.php b/data/module/Compat/Compat/Function/version_compare.php deleted file mode 100644 index ea6b12f505d..00000000000 --- a/data/module/Compat/Compat/Function/version_compare.php +++ /dev/null @@ -1,182 +0,0 @@ - | -// | Aidan Lister | -// +----------------------------------------------------------------------+ -// -// $Id: version_compare.php,v 1.13 2005/08/01 12:21:14 aidan Exp $ - - -/** - * Replace version_compare() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.version_compare - * @author Philippe Jausions - * @author Aidan Lister - * @version $Revision: 1.13 $ - * @since PHP 4.1.0 - * @require PHP 4.0.5 (user_error) - */ -if (!function_exists('version_compare')) { - function version_compare($version1, $version2, $operator = '<') - { - // Check input - if (!is_scalar($version1)) { - user_error('version_compare() expects parameter 1 to be string, ' . - gettype($version1) . ' given', E_USER_WARNING); - return; - } - - if (!is_scalar($version2)) { - user_error('version_compare() expects parameter 2 to be string, ' . - gettype($version2) . ' given', E_USER_WARNING); - return; - } - - if (!is_scalar($operator)) { - user_error('version_compare() expects parameter 3 to be string, ' . - gettype($operator) . ' given', E_USER_WARNING); - return; - } - - // Standardise versions - $v1 = explode('.', - str_replace('..', '.', - preg_replace('/([^0-9\.]+)/', '.$1.', - str_replace(array('-', '_', '+'), '.', - trim($version1))))); - - $v2 = explode('.', - str_replace('..', '.', - preg_replace('/([^0-9\.]+)/', '.$1.', - str_replace(array('-', '_', '+'), '.', - trim($version2))))); - - // Replace empty entries at the start of the array - while (empty($v1[0]) && array_shift($v1)) {} - while (empty($v2[0]) && array_shift($v2)) {} - - // Release state order - // '#' stands for any number - $versions = array( - 'dev' => 0, - 'alpha' => 1, - 'a' => 1, - 'beta' => 2, - 'b' => 2, - 'RC' => 3, - '#' => 4, - 'p' => 5, - 'pl' => 5); - - // Loop through each segment in the version string - $compare = 0; - for ($i = 0, $x = min(count($v1), count($v2)); $i < $x; $i++) { - if ($v1[$i] == $v2[$i]) { - continue; - } - $i1 = $v1[$i]; - $i2 = $v2[$i]; - if (is_numeric($i1) && is_numeric($i2)) { - $compare = ($i1 < $i2) ? -1 : 1; - break; - } - - // We use the position of '#' in the versions list - // for numbers... (so take care of # in original string) - if ($i1 == '#') { - $i1 = ''; - } elseif (is_numeric($i1)) { - $i1 = '#'; - } - - if ($i2 == '#') { - $i2 = ''; - } elseif (is_numeric($i2)) { - $i2 = '#'; - } - - if (isset($versions[$i1]) && isset($versions[$i2])) { - $compare = ($versions[$i1] < $versions[$i2]) ? -1 : 1; - } elseif (isset($versions[$i1])) { - $compare = 1; - } elseif (isset($versions[$i2])) { - $compare = -1; - } else { - $compare = 0; - } - - break; - } - - // If previous loop didn't find anything, compare the "extra" segments - if ($compare == 0) { - if (count($v2) > count($v1)) { - if (isset($versions[$v2[$i]])) { - $compare = ($versions[$v2[$i]] < 4) ? 1 : -1; - } else { - $compare = -1; - } - } elseif (count($v2) < count($v1)) { - if (isset($versions[$v1[$i]])) { - $compare = ($versions[$v1[$i]] < 4) ? -1 : 1; - } else { - $compare = 1; - } - } - } - - // Compare the versions - if (func_num_args() > 2) { - switch ($operator) { - case '>': - case 'gt': - return (bool) ($compare > 0); - break; - case '>=': - case 'ge': - return (bool) ($compare >= 0); - break; - case '<=': - case 'le': - return (bool) ($compare <= 0); - break; - case '==': - case '=': - case 'eq': - return (bool) ($compare == 0); - break; - case '<>': - case '!=': - case 'ne': - return (bool) ($compare != 0); - break; - case '': - case '<': - case 'lt': - return (bool) ($compare < 0); - break; - default: - return; - } - } - - return $compare; - } -} - -?> diff --git a/data/module/Compat/Compat/Function/vprintf.php b/data/module/Compat/Compat/Function/vprintf.php deleted file mode 100644 index 6a600a0afc3..00000000000 --- a/data/module/Compat/Compat/Function/vprintf.php +++ /dev/null @@ -1,45 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: vprintf.php,v 1.14 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace vprintf() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.vprintf - * @author Aidan Lister - * @version $Revision: 1.14 $ - * @since PHP 4.1.0 - * @require PHP 4.0.4 (call_user_func_array) - */ -if (!function_exists('vprintf')) { - function vprintf ($format, $args) - { - if (count($args) < 2) { - user_error('vprintf() Too few arguments', E_USER_WARNING); - return; - } - - array_unshift($args, $format); - return call_user_func_array('printf', $args); - } -} - -?> diff --git a/data/module/Compat/Compat/Function/vsprintf.php b/data/module/Compat/Compat/Function/vsprintf.php deleted file mode 100644 index 84ec73aca4a..00000000000 --- a/data/module/Compat/Compat/Function/vsprintf.php +++ /dev/null @@ -1,45 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: vsprintf.php,v 1.10 2005/01/26 04:55:13 aidan Exp $ - - -/** - * Replace vsprintf() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.vsprintf - * @author Aidan Lister - * @version $Revision: 1.10 $ - * @since PHP 4.1.0 - * @require PHP 4.0.4 (call_user_func_array) - */ -if (!function_exists('vsprintf')) { - function vsprintf ($format, $args) - { - if (count($args) < 2) { - user_error('vsprintf() Too few arguments', E_USER_WARNING); - return; - } - - array_unshift($args, $format); - return call_user_func_array('sprintf', $args); - } -} - -?> diff --git a/data/module/Compat/tests/constant/directory_separator.phpt b/data/module/Compat/tests/constant/directory_separator.phpt deleted file mode 100644 index 412e0ca8c10..00000000000 --- a/data/module/Compat/tests/constant/directory_separator.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Constant -- DIRECTORY_SEPARATOR ---SKIPIF-- - ---FILE-- - ---EXPECT-- -true \ No newline at end of file diff --git a/data/module/Compat/tests/constant/e_strict.phpt b/data/module/Compat/tests/constant/e_strict.phpt deleted file mode 100644 index 5faffcd42c4..00000000000 --- a/data/module/Compat/tests/constant/e_strict.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Constant -- E_STRICT ---SKIPIF-- - ---FILE-- - ---EXPECT-- -2048 \ No newline at end of file diff --git a/data/module/Compat/tests/constant/file.phpt b/data/module/Compat/tests/constant/file.phpt deleted file mode 100644 index f7d6de9d260..00000000000 --- a/data/module/Compat/tests/constant/file.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Constant -- File System Constants ---SKIPIF-- - ---FILE-- - ---EXPECT-- -1 -2 -4 -8 -16 \ No newline at end of file diff --git a/data/module/Compat/tests/constant/path_separator.phpt b/data/module/Compat/tests/constant/path_separator.phpt deleted file mode 100644 index cd5b7c08085..00000000000 --- a/data/module/Compat/tests/constant/path_separator.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Constant -- PATH_SEPARATOR ---SKIPIF-- - ---FILE-- - ---EXPECT-- -true \ No newline at end of file diff --git a/data/module/Compat/tests/constant/php_eol.phpt b/data/module/Compat/tests/constant/php_eol.phpt deleted file mode 100644 index 57fee360642..00000000000 --- a/data/module/Compat/tests/constant/php_eol.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Constant -- PHP_EOL ---SKIPIF-- - ---FILE-- - ---EXPECT-- -true \ No newline at end of file diff --git a/data/module/Compat/tests/constant/std.phpt b/data/module/Compat/tests/constant/std.phpt deleted file mode 100644 index 0826bb92207..00000000000 --- a/data/module/Compat/tests/constant/std.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Constant -- CLI Constants ---SKIPIF-- - ---FILE-- - ---EXPECT-- -true -true -true \ No newline at end of file diff --git a/data/module/Compat/tests/constant/t.phpt b/data/module/Compat/tests/constant/t.phpt deleted file mode 100644 index 6fb65355a34..00000000000 --- a/data/module/Compat/tests/constant/t.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -Constant -- Tokenizer constants ---FILE-- - ---EXPECT-- -true -true -true -true -true -true -true -true -true -true -true -true -true -true \ No newline at end of file diff --git a/data/module/Compat/tests/constant/upload_err.phpt b/data/module/Compat/tests/constant/upload_err.phpt deleted file mode 100644 index 6bddce8a6f7..00000000000 --- a/data/module/Compat/tests/constant/upload_err.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Constant -- Upload error constants ---FILE-- - ---EXPECT-- -0 -1 -2 -3 -4 \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_change_key_case.phpt b/data/module/Compat/tests/function/array_change_key_case.phpt deleted file mode 100644 index 5d36af6394d..00000000000 --- a/data/module/Compat/tests/function/array_change_key_case.phpt +++ /dev/null @@ -1,100 +0,0 @@ ---TEST-- -Function -- array_change_key_case ---SKIPIF-- - ---FILE-- - 1, 'SecOnd' => 4); -print_r(array_change_key_case($in)); -print_r(array_change_key_case($in, CASE_LOWER)); -print_r(array_change_key_case($in, CASE_UPPER)); -$in = array('FIRST' => 1, 'SECOND' => 4); -print_r(array_change_key_case($in)); -print_r(array_change_key_case($in, CASE_LOWER)); -print_r(array_change_key_case($in, CASE_UPPER)); -$in = array('first' => 1, 'second' => 4); -print_r(array_change_key_case($in)); -print_r(array_change_key_case($in, CASE_LOWER)); -print_r(array_change_key_case($in, CASE_UPPER)); -$in = array('foo', 'bar'); -print_r(array_change_key_case($in)); -print_r(array_change_key_case($in, CASE_LOWER)); -print_r(array_change_key_case($in, CASE_UPPER)); -$in = array(); -print_r(array_change_key_case($in)); -print_r(array_change_key_case($in, CASE_LOWER)); -print_r(array_change_key_case($in, CASE_UPPER)); -?> ---EXPECT-- -Array -( - [first] => 1 - [second] => 4 -) -Array -( - [first] => 1 - [second] => 4 -) -Array -( - [FIRST] => 1 - [SECOND] => 4 -) -Array -( - [first] => 1 - [second] => 4 -) -Array -( - [first] => 1 - [second] => 4 -) -Array -( - [FIRST] => 1 - [SECOND] => 4 -) -Array -( - [first] => 1 - [second] => 4 -) -Array -( - [first] => 1 - [second] => 4 -) -Array -( - [FIRST] => 1 - [SECOND] => 4 -) -Array -( - [0] => foo - [1] => bar -) -Array -( - [0] => foo - [1] => bar -) -Array -( - [0] => foo - [1] => bar -) -Array -( -) -Array -( -) -Array -( -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_chunk.phpt b/data/module/Compat/tests/function/array_chunk.phpt deleted file mode 100644 index f7fdd20e6ea..00000000000 --- a/data/module/Compat/tests/function/array_chunk.phpt +++ /dev/null @@ -1,174 +0,0 @@ ---TEST-- -Function -- array_chunk ---SKIPIF-- - ---FILE-- - 'a', 3 => 'b', 4 => 'c', 5 => 'd', 6 => 'e'); -print_r(array_chunk($input_array, 2)); -print_r(array_chunk($input_array, 2, true)); -print_r(array_chunk($input_array, 3)); -print_r(array_chunk($input_array, 3, true)); -print_r(array_chunk($input_array, 4)); -print_r(array_chunk($input_array, 4, true)); -print_r(array_chunk($input_array, 5)); -print_r(array_chunk($input_array, 5, true)); -print_r(array_chunk($input_array, 6)); -print_r(array_chunk($input_array, 6, true)); -?> ---EXPECT-- -Array -( - [0] => Array - ( - [0] => a - [1] => b - ) - - [1] => Array - ( - [0] => c - [1] => d - ) - - [2] => Array - ( - [0] => e - ) - -) -Array -( - [0] => Array - ( - [2] => a - [3] => b - ) - - [1] => Array - ( - [4] => c - [5] => d - ) - - [2] => Array - ( - [6] => e - ) - -) -Array -( - [0] => Array - ( - [0] => a - [1] => b - [2] => c - ) - - [1] => Array - ( - [0] => d - [1] => e - ) - -) -Array -( - [0] => Array - ( - [2] => a - [3] => b - [4] => c - ) - - [1] => Array - ( - [5] => d - [6] => e - ) - -) -Array -( - [0] => Array - ( - [0] => a - [1] => b - [2] => c - [3] => d - ) - - [1] => Array - ( - [0] => e - ) - -) -Array -( - [0] => Array - ( - [2] => a - [3] => b - [4] => c - [5] => d - ) - - [1] => Array - ( - [6] => e - ) - -) -Array -( - [0] => Array - ( - [0] => a - [1] => b - [2] => c - [3] => d - [4] => e - ) - -) -Array -( - [0] => Array - ( - [2] => a - [3] => b - [4] => c - [5] => d - [6] => e - ) - -) -Array -( - [0] => Array - ( - [0] => a - [1] => b - [2] => c - [3] => d - [4] => e - ) - -) -Array -( - [0] => Array - ( - [2] => a - [3] => b - [4] => c - [5] => d - [6] => e - ) - -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_combine.phpt b/data/module/Compat/tests/function/array_combine.phpt deleted file mode 100644 index 87fb897392b..00000000000 --- a/data/module/Compat/tests/function/array_combine.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Function -- array_combine ---SKIPIF-- - ---FILE-- - ---EXPECT-- -Array -( - [green] => avocado - [red] => apple - [yellow] => banana -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_diff_assoc.phpt b/data/module/Compat/tests/function/array_diff_assoc.phpt deleted file mode 100644 index 85b9c0eb4c9..00000000000 --- a/data/module/Compat/tests/function/array_diff_assoc.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Function -- array_diff_assoc ---SKIPIF-- - ---FILE-- - "green", "b" => "brown", "c" => "blue", "red"); -$array2 = array("a" => "green", "yellow", "red"); -$result = array_diff_assoc($array1, $array2); -print_r($result); -?> ---EXPECT-- -Array -( - [b] => brown - [c] => blue - [0] => red -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_diff_key.phpt b/data/module/Compat/tests/function/array_diff_key.phpt deleted file mode 100644 index cf8eae39bed..00000000000 --- a/data/module/Compat/tests/function/array_diff_key.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Function -- array_diff_key ---SKIPIF-- - ---FILE-- - 1, 'red' => 2, 'green' => 3, 'purple' => 4); -$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); - -print_r(array_diff_key($array1, $array2)); - -?> ---EXPECT-- -Array -( - [red] => 2 - [purple] => 4 -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_diff_uassoc.phpt b/data/module/Compat/tests/function/array_diff_uassoc.phpt deleted file mode 100644 index 55768f2ba23..00000000000 --- a/data/module/Compat/tests/function/array_diff_uassoc.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -Function -- array_diff_uassoc ---SKIPIF-- - ---FILE-- - $b) ? 1 : -1; -} - -$array1 = array('a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red'); -$array2 = array('a' => 'green', 'yellow', 'red'); -$result = array_diff_uassoc($array1, $array2, 'key_compare_func'); -print_r($result); - -?> ---EXPECT-- -Array -( - [b] => brown - [c] => blue - [0] => red -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_diff_ukey.phpt b/data/module/Compat/tests/function/array_diff_ukey.phpt deleted file mode 100644 index 8abcbbfc760..00000000000 --- a/data/module/Compat/tests/function/array_diff_ukey.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Function -- array_diff_ukey ---SKIPIF-- - ---FILE-- - $key2) { - return 1; - } else { - return -1; - } -} - -$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); -$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); - -print_r(array_diff_ukey($array1, $array2, 'key_compare_func')); - -?> ---EXPECT-- -Array -( - [red] => 2 - [purple] => 4 -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_intersect_assoc.phpt b/data/module/Compat/tests/function/array_intersect_assoc.phpt deleted file mode 100644 index 87f5fa8bc23..00000000000 --- a/data/module/Compat/tests/function/array_intersect_assoc.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- array_intersect_assoc ---SKIPIF-- - ---FILE-- - "green", "b" => "brown", "c" => "blue", "red"); -$array2 = array("a" => "green", "yellow", "red"); -$result = array_intersect_assoc($array1, $array2); -print_r($result); - -?> ---EXPECT-- -Array -( - [a] => green -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_intersect_key.phpt b/data/module/Compat/tests/function/array_intersect_key.phpt deleted file mode 100644 index f19371bd5be..00000000000 --- a/data/module/Compat/tests/function/array_intersect_key.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Function -- array_intersect_key ---SKIPIF-- - ---FILE-- - 1, 'red' => 2, 'green' => 3, 'purple' => 4); -$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); - -print_r(array_intersect_key($array1, $array2)); - -?> ---EXPECT-- -Array -( - [blue] => 1 - [green] => 3 -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_intersect_uassoc.phpt b/data/module/Compat/tests/function/array_intersect_uassoc.phpt deleted file mode 100644 index 07c41e4e530..00000000000 --- a/data/module/Compat/tests/function/array_intersect_uassoc.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- array_intersect_uassoc ---SKIPIF-- - ---FILE-- - "green", "b" => "brown", "c" => "blue", "red"); -$array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red"); - -print_r(array_intersect_uassoc($array1, $array2, "strcasecmp")); - -?> ---EXPECT-- -Array -( - [b] => brown -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_intersect_ukey.phpt b/data/module/Compat/tests/function/array_intersect_ukey.phpt deleted file mode 100644 index 2658f4ec3d1..00000000000 --- a/data/module/Compat/tests/function/array_intersect_ukey.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Function -- array_intersect_ukey ---SKIPIF-- - ---FILE-- - $key2) { - return 1; - } else { - return -1; - } -} - -$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); -$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); - -print_r(array_intersect_ukey($array1, $array2, 'key_compare_func')); - -?> ---EXPECT-- -Array -( - [blue] => 1 - [green] => 3 -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_key_exists.phpt b/data/module/Compat/tests/function/array_key_exists.phpt deleted file mode 100644 index a5da114cd5c..00000000000 --- a/data/module/Compat/tests/function/array_key_exists.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -Function -- array_key_exists ---SKIPIF-- - ---FILE-- - 1, "second" => 4); -if (array_key_exists("first", $search_array)) { - echo "The 'first' element is in the array"; -} -?> ---EXPECT-- -The 'first' element is in the array \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_product.phpt b/data/module/Compat/tests/function/array_product.phpt deleted file mode 100644 index cbf1133d83c..00000000000 --- a/data/module/Compat/tests/function/array_product.phpt +++ /dev/null @@ -1,55 +0,0 @@ ---TEST-- -Function -- array_product ---SKIPIF-- - ---FILE-- - ---EXPECT-- -testing: (foo) - result: (Warning) NULL - - -testing: () - result: int(0) - - -testing: (0) - result: int(0) - - -testing: (3) - result: int(3) - - -testing: (3 * 3) - result: int(9) - - -testing: (0.5 * 2 * 3) - result: float(3) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_search.phpt b/data/module/Compat/tests/function/array_search.phpt deleted file mode 100644 index 989c44c7f87..00000000000 --- a/data/module/Compat/tests/function/array_search.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Function -- array_search ---SKIPIF-- - ---FILE-- - 'blue', 1 => 'red', 2 => 'green', 3 => 'red'); - -var_dump(array_search('green', $array)); -var_dump(array_search('red', $array)); -?> ---EXPECT-- -int(2) -int(1) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_udiff.phpt b/data/module/Compat/tests/function/array_udiff.phpt deleted file mode 100644 index 1f4530bcb7c..00000000000 --- a/data/module/Compat/tests/function/array_udiff.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -Function -- array_udiff ---SKIPIF-- - ---FILE-- -priv_member = $val; - } - - function comp_func_cr($a, $b) - { - if ($a->priv_member === $b->priv_member) return 0; - return ($a->priv_member > $b->priv_member)? 1:-1; - } -} - -$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); -$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); - -$result = array_udiff($a, $b, array("cr", "comp_func_cr")); -echo serialize($result); -?> ---EXPECT-- -a:2:{s:3:"0.5";O:2:"cr":1:{s:11:"priv_member";i:12;}i:0;O:2:"cr":1:{s:11:"priv_member";i:23;}} \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_udiff_assoc.phpt b/data/module/Compat/tests/function/array_udiff_assoc.phpt deleted file mode 100644 index dcb1ebc4150..00000000000 --- a/data/module/Compat/tests/function/array_udiff_assoc.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -Function -- array_udiff_assoc ---SKIPIF-- - ---FILE-- -priv_member = $val; - } - - function comp_func_cr($a, $b) - { - if ($a->priv_member === $b->priv_member) return 0; - return ($a->priv_member > $b->priv_member)? 1:-1; - } -} - -$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); -$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); - -$result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr")); -echo serialize($result); -?> ---EXPECT-- -a:3:{s:3:"0.1";O:2:"cr":1:{s:11:"priv_member";i:9;}s:3:"0.5";O:2:"cr":1:{s:11:"priv_member";i:12;}i:0;O:2:"cr":1:{s:11:"priv_member";i:23;}} \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_udiff_uassoc.phpt b/data/module/Compat/tests/function/array_udiff_uassoc.phpt deleted file mode 100644 index 6fb446fc682..00000000000 --- a/data/module/Compat/tests/function/array_udiff_uassoc.phpt +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -Function -- array_udiff_uassoc ---SKIPIF-- - ---FILE-- -val = $val; - } - - function comp_func_cr($a, $b) - { - if ($a->val === $b->val) return 0; - return ($a->val > $b->val) ? 1 : -1; - } - - function comp_func_key($a, $b) - { - if ($a === $b) return 0; - return ($a > $b) ? 1 : -1; - } -} - -$a = array('0.1' => new cr(9), '0.5' => new cr(12), 0 => new cr(23), 1 => new cr(4), 2 => new cr(-15)); -$b = array('0.2' => new cr(9), '0.5' => new cr(22), 0 => new cr(3), 1 => new cr(4), 2 => new cr(-15)); - -$result = array_udiff_uassoc($a, $b, array('cr', 'comp_func_cr'), array('cr', 'comp_func_key')); -print_r($result); -?> ---EXPECT-- -Array -( - [0.1] => cr Object - ( - [val] => 9 - ) - - [0.5] => cr Object - ( - [val] => 12 - ) - - [0] => cr Object - ( - [val] => 23 - ) - -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_uintersect.phpt b/data/module/Compat/tests/function/array_uintersect.phpt deleted file mode 100644 index 0a3c4e6c726..00000000000 --- a/data/module/Compat/tests/function/array_uintersect.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Function -- array_uintersect ---SKIPIF-- - ---FILE-- - 'green', 'b' => 'brown', 'c' => 'blue', 'red'); -$array2 = array('a' => 'GREEN', 'B' => 'brown', 'yellow', 'red'); - -print_r(array_uintersect($array1, $array2, 'strcasecmp')); -?> ---EXPECT-- -Array -( - [a] => green - [b] => brown - [0] => red -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_uintersect_assoc.phpt b/data/module/Compat/tests/function/array_uintersect_assoc.phpt deleted file mode 100644 index 54486d3e2d8..00000000000 --- a/data/module/Compat/tests/function/array_uintersect_assoc.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -Function -- array_uintersect_assoc ---SKIPIF-- - ---FILE-- - 'green', 'b' => 'brown', 'c' => 'blue', 'red'); -$array2 = array('a' => 'GREEN', 'B' => 'brown', 'yellow', 'red'); - -print_r(array_uintersect_assoc($array1, $array2, 'strcasecmp')); -?> ---EXPECT-- -Array -( - [a] => green -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_uintersect_uassoc.phpt b/data/module/Compat/tests/function/array_uintersect_uassoc.phpt deleted file mode 100644 index 34873770095..00000000000 --- a/data/module/Compat/tests/function/array_uintersect_uassoc.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- array_uintersect_uassoc ---SKIPIF-- - ---FILE-- - 'green', 'b' => 'brown', 'c' => 'blue', 'red'); -$array2 = array('a' => 'GREEN', 'B' => 'brown', 'yellow', 'red'); - -print_r(array_uintersect_uassoc($array1, $array2, 'strcasecmp', 'strcasecmp')); -?> ---EXPECT-- -Array -( - [a] => green - [b] => brown -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/array_walk_recursive.phpt b/data/module/Compat/tests/function/array_walk_recursive.phpt deleted file mode 100644 index 0e8f514134c..00000000000 --- a/data/module/Compat/tests/function/array_walk_recursive.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Function -- array_walk_recursive ---SKIPIF-- - ---FILE-- - 'apple', 'b' => 'banana'); -$fruits = array('sweet' => $sweet, 'sour' => 'lemon'); - -function test_print($item, $key) -{ - echo "$key holds $item\n"; -} - -array_walk_recursive($fruits, 'test_print'); -?> ---EXPECT-- -a holds apple -b holds banana -sour holds lemon \ No newline at end of file diff --git a/data/module/Compat/tests/function/bcinvert.phpt b/data/module/Compat/tests/function/bcinvert.phpt deleted file mode 100644 index 57a907570cc..00000000000 --- a/data/module/Compat/tests/function/bcinvert.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- bcinvert ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/bcpowmod.phpt b/data/module/Compat/tests/function/bcpowmod.phpt deleted file mode 100644 index bbc0f47f4e2..00000000000 --- a/data/module/Compat/tests/function/bcpowmod.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- bcpowmod ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/call_user_func_array.phpt b/data/module/Compat/tests/function/call_user_func_array.phpt deleted file mode 100644 index a53f6616aa2..00000000000 --- a/data/module/Compat/tests/function/call_user_func_array.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- call_user_func_array ---SKIPIF-- - ---FILE-- - ---EXPECT-- -foo -bar -meta \ No newline at end of file diff --git a/data/module/Compat/tests/function/clone.phpt b/data/module/Compat/tests/function/clone.phpt deleted file mode 100644 index e358905d37e..00000000000 --- a/data/module/Compat/tests/function/clone.phpt +++ /dev/null @@ -1,69 +0,0 @@ ---TEST-- -Function -- clone ---SKIPIF-- - ---FILE-- -foo = 'bar'; - } -} - -class testclass3 -{ - var $bar; -} - -class testclass4 -{ - var $foo; - function __clone() - { - $this->foo = clone($this->foo); - } -} - -// Test 1: Initial value -$aa = new testclass; -echo $aa->foo, "\n"; // foo - -// Test 2: Not referenced -$bb = clone($aa); -$bb->foo = 'baz'; -echo $aa->foo, "\n"; // foo - -// Test 3: __clone method -$cc = new testclass2; -echo $cc->foo, "\n"; // foo -$dd = clone($cc); -echo $dd->foo, "\n"; // bar - -// Test 4: Bug #3649 -$a = new testclass3; -$a->foo =& new testclass4; -$a->foo->bar = 'hello'; -$aclone = clone($a); -$aclone->b->bar = 'goodbye'; -echo $a->foo->bar, "\n"; - -?> ---EXPECT-- -foo -foo -foo -bar -hello \ No newline at end of file diff --git a/data/module/Compat/tests/function/constant.phpt b/data/module/Compat/tests/function/constant.phpt deleted file mode 100644 index 03b40e73357..00000000000 --- a/data/module/Compat/tests/function/constant.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Function -- constant ---SKIPIF-- - ---FILE-- - ---EXPECT-- -foo \ No newline at end of file diff --git a/data/module/Compat/tests/function/convert_uudecode.phpt b/data/module/Compat/tests/function/convert_uudecode.phpt deleted file mode 100644 index 30197f652c2..00000000000 --- a/data/module/Compat/tests/function/convert_uudecode.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Function -- convert_uudecode ---SKIPIF-- - ---FILE-- - ---EXPECT-- -This is a simple test \ No newline at end of file diff --git a/data/module/Compat/tests/function/convert_uuencode.phpt b/data/module/Compat/tests/function/convert_uuencode.phpt deleted file mode 100644 index 1d19e82ecc7..00000000000 --- a/data/module/Compat/tests/function/convert_uuencode.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Function -- convert_uuencode ---SKIPIF-- - ---FILE-- - $i; $i++) { - $string .= str_repeat(chr($i), 10); -} -echo md5(convert_uuencode($string)); - -?> ---EXPECT-- -d7974131c8970783f70851c83fe17767 -19acf7157a8345307ea5e5ea6878abb4 \ No newline at end of file diff --git a/data/module/Compat/tests/function/debug_print_backtrace.phpt b/data/module/Compat/tests/function/debug_print_backtrace.phpt deleted file mode 100644 index d938d0132d3..00000000000 --- a/data/module/Compat/tests/function/debug_print_backtrace.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- debug_print_backtrace ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/file_get_contents.phpt b/data/module/Compat/tests/function/file_get_contents.phpt deleted file mode 100644 index e4726b2b055..00000000000 --- a/data/module/Compat/tests/function/file_get_contents.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- file_get_contents ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test test \ No newline at end of file diff --git a/data/module/Compat/tests/function/file_put_contents.phpt b/data/module/Compat/tests/function/file_put_contents.phpt deleted file mode 100644 index 80ba1111e05..00000000000 --- a/data/module/Compat/tests/function/file_put_contents.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Function -- file_put_contents ---SKIPIF-- - ---FILE-- - ---EXPECT-- -4 -abcd -6 -foobar -6 -8 -foobartesttest -8 -testtest \ No newline at end of file diff --git a/data/module/Compat/tests/function/floatval.phpt b/data/module/Compat/tests/function/floatval.phpt deleted file mode 100644 index 31a7f897817..00000000000 --- a/data/module/Compat/tests/function/floatval.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Function -- floatval ---SKIPIF-- - ---FILE-- - ---EXPECT-- -float(12312.123) \ No newline at end of file diff --git a/data/module/Compat/tests/function/fprintf.phpt b/data/module/Compat/tests/function/fprintf.phpt deleted file mode 100644 index 0c0f17e794a..00000000000 --- a/data/module/Compat/tests/function/fprintf.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- fprintf ---SKIPIF-- - ---FILE-- - ---EXPECT-- -The dog went to the park for 2 days \ No newline at end of file diff --git a/data/module/Compat/tests/function/fputcsv.phpt b/data/module/Compat/tests/function/fputcsv.phpt deleted file mode 100644 index bede70b8839..00000000000 --- a/data/module/Compat/tests/function/fputcsv.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- fputcsv ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/get_headers.phpt b/data/module/Compat/tests/function/get_headers.phpt deleted file mode 100644 index c33c64ec11e..00000000000 --- a/data/module/Compat/tests/function/get_headers.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- get_headers ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/get_include_path.phpt b/data/module/Compat/tests/function/get_include_path.phpt deleted file mode 100644 index 08e3b627c10..00000000000 --- a/data/module/Compat/tests/function/get_include_path.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Function -- get_include_path ---SKIPIF-- - ---FILE-- - ---EXPECT-- -true \ No newline at end of file diff --git a/data/module/Compat/tests/function/hash.phpt b/data/module/Compat/tests/function/hash.phpt deleted file mode 100644 index ac7afb1aa58..00000000000 --- a/data/module/Compat/tests/function/hash.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Function -- hash ---FILE-- - ---EXPECT-- -md5: bf33deeefaf5a9413160935be950cc07 -sha1: f0dc0e88cc1008e46762f40a1b4a4c0b6baedfa0 -sha256: a78149615dd1ef8aeb22a8254c36edd87713f2e79a052a89ff32ed94e827d47b -md5(raw): bf33deeefaf5a9413160935be950cc07 -sha256(raw): a78149615dd1ef8aeb22a8254c36edd87713f2e79a052a89ff32ed94e827d47b diff --git a/data/module/Compat/tests/function/hash_algos.phpt b/data/module/Compat/tests/function/hash_algos.phpt deleted file mode 100644 index 26c1cbbf62c..00000000000 --- a/data/module/Compat/tests/function/hash_algos.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Function -- hash_algos ---FILE-- - ---EXPECT-- -array(3) { - [0]=> - string(3) "md5" - [1]=> - string(4) "sha1" - [2]=> - string(6) "sha256" -} diff --git a/data/module/Compat/tests/function/hash_hmac.phpt b/data/module/Compat/tests/function/hash_hmac.phpt deleted file mode 100644 index df42aaaf5b7..00000000000 --- a/data/module/Compat/tests/function/hash_hmac.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Function -- hash_hmac ---FILE-- - ---EXPECT-- -md5: 2a632783e2812cf23de100d7d6a463ae -sha1: 5bfdb62b97e2c987405463e9f7c193139c0e1fd0 -sha256: 49bde3496b9510a17d0edd8a4b0ac70148e32a1d51e881ec76faa96534125838 -md5(raw): 2a632783e2812cf23de100d7d6a463ae -sha256(raw): 49bde3496b9510a17d0edd8a4b0ac70148e32a1d51e881ec76faa96534125838 diff --git a/data/module/Compat/tests/function/html_entity_decode.phpt b/data/module/Compat/tests/function/html_entity_decode.phpt deleted file mode 100644 index e29bb225a96..00000000000 --- a/data/module/Compat/tests/function/html_entity_decode.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- html_entity_decode ---SKIPIF-- - ---FILE-- - ---EXPECT-- -I'll "walk" the dog now -I'll "walk" the dog now -I'll "walk" the dog now -I'll "walk" the dog now \ No newline at end of file diff --git a/data/module/Compat/tests/function/htmlspecialchars_decode.phpt b/data/module/Compat/tests/function/htmlspecialchars_decode.phpt deleted file mode 100644 index 946ddb69d5f..00000000000 --- a/data/module/Compat/tests/function/htmlspecialchars_decode.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Function -- htmlspecialchars_decode ---SKIPIF-- - ---FILE-- - ---EXPECT-- -Text & " ' < > End Text -Text & " ' < > End Text -Text & " ' < > End Text -Text & " ' < > End Text -Text & " ' < > End Text \ No newline at end of file diff --git a/data/module/Compat/tests/function/http_build_query.phpt b/data/module/Compat/tests/function/http_build_query.phpt deleted file mode 100644 index 524bd881644..00000000000 --- a/data/module/Compat/tests/function/http_build_query.phpt +++ /dev/null @@ -1,70 +0,0 @@ ---TEST-- -Function -- http_build_query ---SKIPIF-- - ---INI-- -arg_separator.output=QQQ ---FILE-- -'bar', - 'baz'=>'boom', - 'cow'=>'milk', - 'php'=>'hypertext processor'); - -echo http_build_query($data), "\n"; - - -// With an object -class myClass { - var $foo; - var $baz; - - function myClass() - { - $this->foo = 'bar'; - $this->baz = 'boom'; - } -} - -$data = new myClass(); -echo http_build_query($data), "\n"; - - -// With numerically indexed elements -$data = array('foo', 'bar', 'baz', 'boom', 'cow' => 'milk', 'php' =>'hypertext processor'); -echo http_build_query($data), "\n"; -echo http_build_query($data, 'myvar_'), "\n"; - - -// With a complex array -$data = array('user' => array( - 'name' => 'Bob Smith', - 'age' => 47, - 'sex' => 'M', - 'dob' => '5/12/1956'), - 'pastimes' => array( - 'golf', - 'opera', - 'poker', - 'rap'), - 'children' => array( - 'bobby' => array( - 'age' => 12, - 'sex' => 'M'), - 'sally' => array( - 'age' => 8, - 'sex'=>'F')), - 'CEO'); - -echo http_build_query($data, 'flags_'); -?> ---EXPECT-- -foo=barQQQbaz=boomQQQcow=milkQQQphp=hypertext+processor -foo=barQQQbaz=boom -0=fooQQQ1=barQQQ2=bazQQQ3=boomQQQcow=milkQQQphp=hypertext+processor -myvar_0=fooQQQmyvar_1=barQQQmyvar_2=bazQQQmyvar_3=boomQQQcow=milkQQQphp=hypertext+processor -user[name]=Bob+SmithQQQuser[age]=47QQQuser[sex]=MQQQuser[dob]=5%2F12%2F1956QQQpastimes[0]=golfQQQpastimes[1]=operaQQQpastimes[2]=pokerQQQpastimes[3]=rapQQQchildren[bobby][age]=12QQQchildren[bobby][sex]=MQQQchildren[sally][age]=8QQQchildren[sally][sex]=FQQQflags_0=CEO \ No newline at end of file diff --git a/data/module/Compat/tests/function/ibase_timefmt.phpt b/data/module/Compat/tests/function/ibase_timefmt.phpt deleted file mode 100644 index da5e95e28e3..00000000000 --- a/data/module/Compat/tests/function/ibase_timefmt.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- ibase_timefmt ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/idate.phpt b/data/module/Compat/tests/function/idate.phpt deleted file mode 100644 index 5fde61e6e96..00000000000 --- a/data/module/Compat/tests/function/idate.phpt +++ /dev/null @@ -1,159 +0,0 @@ ---TEST-- -Function -- idate ---SKIPIF-- - ---FILE-- - 0\n"; - } - echo "\n\n"; -} - -restore_error_handler(); -?> ---EXPECT-- -testing: string(1) "B" - -result: > 0 - - -testing: string(1) "d" - -result: > 0 - - -testing: string(1) "h" - -result: > 0 - - -testing: string(1) "H" - -result: > 0 - - -testing: string(1) "i" - -result: > 0 - - -testing: string(1) "I" - -result: int(0) - - -testing: string(1) "L" - -result: int(0) - - -testing: string(1) "m" - -result: > 0 - - -testing: string(1) "s" - -result: > 0 - - -testing: string(1) "t" - -result: > 0 - - -testing: string(1) "U" - -result: > 0 - - -testing: string(1) "w" - -result: > 0 - - -testing: string(1) "W" - -result: > 0 - - -testing: string(1) "y" - -result: > 0 - - -testing: string(1) "Y" - -result: > 0 - - -testing: string(1) "z" - -result: > 0 - - -testing: string(1) "Z" - -result: int(0) - - -testing: string(3) "foo" - -result: (Warning) bool(false) - - -testing: string(0) "" - -result: (Warning) bool(false) - - -testing: string(1) "!" - -result: int(0) - - -testing: string(1) "\" - -result: int(0) \ No newline at end of file diff --git a/data/module/Compat/tests/function/image_type_to_mime_type.phpt b/data/module/Compat/tests/function/image_type_to_mime_type.phpt deleted file mode 100644 index 6659c5efa12..00000000000 --- a/data/module/Compat/tests/function/image_type_to_mime_type.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -Function -- image_type_to_mime_type ---SKIPIF-- - ---FILE-- - ---EXPECT-- -image/gif -image/jpeg -image/png -application/x-shockwave-flash -image/psd -image/bmp -image/tiff -image/tiff -application/octet-stream -image/jp2 -application/octet-stream -application/octet-stream -application/x-shockwave-flash -image/iff -image/vnd.wap.wbmp -image/xbm \ No newline at end of file diff --git a/data/module/Compat/tests/function/inet_ntop.phpt b/data/module/Compat/tests/function/inet_ntop.phpt deleted file mode 100644 index 95fc46e55af..00000000000 --- a/data/module/Compat/tests/function/inet_ntop.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -Function -- inet_ntop ---SKIPIF-- - ---FILE-- - '7f000001', - '192.232.131.222' => 'c0e883de', - '::1' => '00000000000000000000000000000001', - '2001:260:0:10::1' => '20010260000000100000000000000001', - 'fe80::200:4cff:fe43:172f' => 'fe8000000000000002004cfffe43172f' -); - -foreach ($adds as $k => $v) { - echo "\ntesting: $k\n "; - var_dump(inet_ntop(pack('H*', $v))); -} - -?> ---EXPECT-- -testing: 127.0.0.1 - string(9) "127.0.0.1" - -testing: 192.232.131.222 - string(15) "192.232.131.222" - -testing: ::1 - string(3) "::1" - -testing: 2001:260:0:10::1 - string(16) "2001:260:0:10::1" - -testing: fe80::200:4cff:fe43:172f - string(24) "fe80::200:4cff:fe43:172f" \ No newline at end of file diff --git a/data/module/Compat/tests/function/inet_pton.phpt b/data/module/Compat/tests/function/inet_pton.phpt deleted file mode 100644 index 05c6fa53adc..00000000000 --- a/data/module/Compat/tests/function/inet_pton.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -Function -- inet_pton ---SKIPIF-- - ---FILE-- - '7f000001', - '192.232.131.222' => 'c0e883de', - '::1' => '00000000000000000000000000000001', - '2001:260:0:10::1' => '20010260000000100000000000000001', - 'fe80::200:4cff:fe43:172f' => 'fe8000000000000002004cfffe43172f' -); - -foreach ($adds as $k => $v) { - echo "\ntesting: $k\n "; - echo bin2hex(inet_pton($k)), "\n"; -} - -?> ---EXPECT-- -testing: 127.0.0.1 - 7f000001 - -testing: 192.232.131.222 - c0e883de - -testing: ::1 - 00000000000000000000000000000001 - -testing: 2001:260:0:10::1 - 20010260000000100000000000000001 - -testing: fe80::200:4cff:fe43:172f - fe8000000000000002004cfffe43172f \ No newline at end of file diff --git a/data/module/Compat/tests/function/ini_get_all.phpt b/data/module/Compat/tests/function/ini_get_all.phpt deleted file mode 100644 index 3c4a796964b..00000000000 --- a/data/module/Compat/tests/function/ini_get_all.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- ini_get_all ---SKIPIF-- - ---FILE-- - ---EXPECT-- -true -true \ No newline at end of file diff --git a/data/module/Compat/tests/function/is_a.phpt b/data/module/Compat/tests/function/is_a.phpt deleted file mode 100644 index 972bbcb43a4..00000000000 --- a/data/module/Compat/tests/function/is_a.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Function -- is_a ---SKIPIF-- - ---FILE-- - ---EXPECT-- -true \ No newline at end of file diff --git a/data/module/Compat/tests/function/is_scalar.phpt b/data/module/Compat/tests/function/is_scalar.phpt deleted file mode 100644 index e31a9714fec..00000000000 --- a/data/module/Compat/tests/function/is_scalar.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- is_scalar ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/md5_file.phpt b/data/module/Compat/tests/function/md5_file.phpt deleted file mode 100644 index f30bc2973e0..00000000000 --- a/data/module/Compat/tests/function/md5_file.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- md5_file ---SKIPIF-- - ---FILE-- - ---EXPECT-- -762a55bb01c6133a956599e6a51c49b0 \ No newline at end of file diff --git a/data/module/Compat/tests/function/mhash.phpt b/data/module/Compat/tests/function/mhash.phpt deleted file mode 100644 index f81a59ea6eb..00000000000 --- a/data/module/Compat/tests/function/mhash.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- mhash ---SKIPIF-- - ---FILE-- - ---EXPECT-- -ae2e4b39f3b5ee2c8b585994294201ea -750c783e6ab0b503eaa86e310a5db738 \ No newline at end of file diff --git a/data/module/Compat/tests/function/mime_content_type.phpt b/data/module/Compat/tests/function/mime_content_type.phpt deleted file mode 100644 index 3f2674f00c4..00000000000 --- a/data/module/Compat/tests/function/mime_content_type.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- inet_pton ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/ob_clean.phpt b/data/module/Compat/tests/function/ob_clean.phpt deleted file mode 100644 index 23a32c1f938..00000000000 --- a/data/module/Compat/tests/function/ob_clean.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Function -- ob_clean ---SKIPIF-- - ---FILE-- - ---EXPECT-- -foo \ No newline at end of file diff --git a/data/module/Compat/tests/function/ob_flush.phpt b/data/module/Compat/tests/function/ob_flush.phpt deleted file mode 100644 index 1e98d615c25..00000000000 --- a/data/module/Compat/tests/function/ob_flush.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -Function -- ob_flush ---SKIPIF-- - ---FILE-- - ---EXPECT-- -foo \ No newline at end of file diff --git a/data/module/Compat/tests/function/ob_get_clean.phpt b/data/module/Compat/tests/function/ob_get_clean.phpt deleted file mode 100644 index e1ac66bd208..00000000000 --- a/data/module/Compat/tests/function/ob_get_clean.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -Function -- ob_get_clean ---SKIPIF-- - ---FILE-- - ---EXPECT-- -foo \ No newline at end of file diff --git a/data/module/Compat/tests/function/ob_get_flush.phpt b/data/module/Compat/tests/function/ob_get_flush.phpt deleted file mode 100644 index bc7c135b44b..00000000000 --- a/data/module/Compat/tests/function/ob_get_flush.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -Function -- ob_get_flush ---SKIPIF-- - ---FILE-- - ---EXPECT-- -foofoo \ No newline at end of file diff --git a/data/module/Compat/tests/function/pg_affected_rows.phpt b/data/module/Compat/tests/function/pg_affected_rows.phpt deleted file mode 100644 index e67285771ac..00000000000 --- a/data/module/Compat/tests/function/pg_affected_rows.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- pg_affected_rows ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/pg_escape_bytea.phpt b/data/module/Compat/tests/function/pg_escape_bytea.phpt deleted file mode 100644 index 72c0b11b494..00000000000 --- a/data/module/Compat/tests/function/pg_escape_bytea.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- pg_escape_bytea ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/pg_unescape_bytea.phpt b/data/module/Compat/tests/function/pg_unescape_bytea.phpt deleted file mode 100644 index eefed99ff86..00000000000 --- a/data/module/Compat/tests/function/pg_unescape_bytea.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Function -- pg_unescape_bytea ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test \ No newline at end of file diff --git a/data/module/Compat/tests/function/php_strip_whitespace.phpt b/data/module/Compat/tests/function/php_strip_whitespace.phpt deleted file mode 100644 index 619b89f12a6..00000000000 --- a/data/module/Compat/tests/function/php_strip_whitespace.phpt +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -Function -- php_strip_whitespace ---SKIPIF-- - ---FILE-- -'; - -// Create a temp file -$tmpfname = tempnam('/tmp', 'phpcompat'); -$fh = fopen($tmpfname, 'w'); -fwrite($fh, $string); - -// Test -echo php_strip_whitespace($tmpfname); - -// Close -fclose($fh); -?> ---EXPECT-- - \ No newline at end of file diff --git a/data/module/Compat/tests/function/restore_include_path.phpt b/data/module/Compat/tests/function/restore_include_path.phpt deleted file mode 100644 index 9ffc02e4230..00000000000 --- a/data/module/Compat/tests/function/restore_include_path.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Function -- restore_include_path ---SKIPIF-- - ---FILE-- - ---EXPECT-- -foo -true \ No newline at end of file diff --git a/data/module/Compat/tests/function/scandir.phpt b/data/module/Compat/tests/function/scandir.phpt deleted file mode 100644 index 85a529fe999..00000000000 --- a/data/module/Compat/tests/function/scandir.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -Function -- scandir ---SKIPIF-- - ---FILE-- - ---EXPECT-- -Array -( - [0] => . - [1] => .. - [2] => test1 - [3] => test2 -) -Array -( - [0] => test2 - [1] => test1 - [2] => .. - [3] => . -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/set_include_path.phpt b/data/module/Compat/tests/function/set_include_path.phpt deleted file mode 100644 index 8d963870e8f..00000000000 --- a/data/module/Compat/tests/function/set_include_path.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Function -- set_include_path ---SKIPIF-- - ---FILE-- - ---EXPECT-- -foo \ No newline at end of file diff --git a/data/module/Compat/tests/function/sha1.phpt b/data/module/Compat/tests/function/sha1.phpt deleted file mode 100644 index 3e6de2742bf..00000000000 --- a/data/module/Compat/tests/function/sha1.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -Function -- sha1 ---FILE-- - ---EXPECT-- -a9993e364706816aba3e25717850c26c9cd0d89d -84983e441c3bd26ebaae4aa1f95129e5e54670f1 -86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -e0c094e867ef46c350ef54a7f59dd60bed92ae83 -da39a3ee5e6b4b0d3255bfef95601890afd80709 diff --git a/data/module/Compat/tests/function/sha256.phpt b/data/module/Compat/tests/function/sha256.phpt deleted file mode 100644 index 9f679be2370..00000000000 --- a/data/module/Compat/tests/function/sha256.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- sha256 ---FILE-- - ---EXPECT-- -e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 -ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb -5e43c8704ac81f33d701c1ace046ba9f257062b4d17e78f3254cbf243177e4f2 -ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad -248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 diff --git a/data/module/Compat/tests/function/str_ireplace.phpt b/data/module/Compat/tests/function/str_ireplace.phpt deleted file mode 100644 index c04b90cabc1..00000000000 --- a/data/module/Compat/tests/function/str_ireplace.phpt +++ /dev/null @@ -1,113 +0,0 @@ ---TEST-- -Function -- str_ireplace ---SKIPIF-- - ---FILE-- - ---EXPECT-- -The dog jumped over the fence -Array -( - [0] => A Lady - [1] => The Lady - [2] => My Lady -) -Array -( - [0] => The dog jumped over the {object} -) -The dog jumped over the Array -The frog jumped over the frog and the frog... -The frog jumped over the gate -The frog jumped over the gate and the ... -The frog jumped over the gate and the {thing}... -Array -( - [0] => A frog - [1] => The gate - [2] => My beer -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/str_rot13.phpt b/data/module/Compat/tests/function/str_rot13.phpt deleted file mode 100644 index be6a3f71037..00000000000 --- a/data/module/Compat/tests/function/str_rot13.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Function -- str_rot13 ---SKIPIF-- - ---FILE-- - ---EXPECT-- -Gur dhvpx oebja sbk whzcrq bire gur ynml qbt. \ No newline at end of file diff --git a/data/module/Compat/tests/function/str_shuffle.phpt b/data/module/Compat/tests/function/str_shuffle.phpt deleted file mode 100644 index 46e434c2537..00000000000 --- a/data/module/Compat/tests/function/str_shuffle.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Function -- str_shuffle ---SKIPIF-- - ---FILE-- - ---EXPECT-- -true \ No newline at end of file diff --git a/data/module/Compat/tests/function/str_split.phpt b/data/module/Compat/tests/function/str_split.phpt deleted file mode 100644 index 41fe70fadbc..00000000000 --- a/data/module/Compat/tests/function/str_split.phpt +++ /dev/null @@ -1,59 +0,0 @@ ---TEST-- -Function -- str_split ---SKIPIF-- - ---FILE-- - ---EXPECT-- -Array -( - [0] => H - [1] => e - [2] => l - [3] => l - [4] => o - [5] => - [6] => F - [7] => r - [8] => i - [9] => e - [10] => n - [11] => d -) -Array -( - [0] => Hel - [1] => lo - [2] => Fri - [3] => end -) -Array -( - [0] => Hello Friend -) -Array -( - [0] => Hello Frien - [1] => d -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/str_word_count.phpt b/data/module/Compat/tests/function/str_word_count.phpt deleted file mode 100644 index 285c43c02ee..00000000000 --- a/data/module/Compat/tests/function/str_word_count.phpt +++ /dev/null @@ -1,57 +0,0 @@ ---TEST-- -Function -- str_word_count ---SKIPIF-- - ---FILE-- - ---EXPECT-- -int(12) -Array -( - [0] => Hello - [1] => friend - [2] => you're - [3] => sdf - [4] => looking - [5] => good - [6] => to - [7] => day - [8] => yes - [9] => sir - [10] => you - [11] => am -) -Array -( - [0] => Hello - [6] => friend - [14] => you're - [23] => sdf - [27] => looking - [48] => good - [53] => to - [56] => day - [61] => yes - [66] => sir - [71] => you - [75] => am -) -Array -( - [0] => hello - [6] => I - [8] => am - [11] => repeated - [20] => repeated -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/stripos.phpt b/data/module/Compat/tests/function/stripos.phpt deleted file mode 100644 index 4aa34a0b27d..00000000000 --- a/data/module/Compat/tests/function/stripos.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Function -- stripos ---SKIPIF-- - ---FILE-- - ---EXPECT-- -int(11) -int(11) -int(11) -int(41) -bool(false) \ No newline at end of file diff --git a/data/module/Compat/tests/function/strpbrk.phpt b/data/module/Compat/tests/function/strpbrk.phpt deleted file mode 100644 index 9590b750410..00000000000 --- a/data/module/Compat/tests/function/strpbrk.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -Function -- strpbrk ---SKIPIF-- - ---FILE-- - ---EXPECT-- -string(9) "not to be" \ No newline at end of file diff --git a/data/module/Compat/tests/function/strripos.phpt b/data/module/Compat/tests/function/strripos.phpt deleted file mode 100644 index 1376bdab93a..00000000000 --- a/data/module/Compat/tests/function/strripos.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -Function -- strripos ---SKIPIF-- - ---FILE-- - ---EXPECT-- -int(41) -int(41) -int(41) -bool(false) -int(41) -int(11) -int(11) -bool(false) -bool(false) -int(1) -int(3) -int(0) \ No newline at end of file diff --git a/data/module/Compat/tests/function/substr_compare.phpt b/data/module/Compat/tests/function/substr_compare.phpt deleted file mode 100644 index 7313b371437..00000000000 --- a/data/module/Compat/tests/function/substr_compare.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Function -- substr_compare ---SKIPIF-- - ---FILE-- - ---EXPECT-- -0 -0 -0 -1 --1 \ No newline at end of file diff --git a/data/module/Compat/tests/function/time_sleep_until.phpt b/data/module/Compat/tests/function/time_sleep_until.phpt deleted file mode 100644 index 565f65ae63a..00000000000 --- a/data/module/Compat/tests/function/time_sleep_until.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Function -- time_sleep_until ---SKIPIF-- - ---FILE-- - ---EXPECT-- -3:3 -(Warning) -1:0 \ No newline at end of file diff --git a/data/module/Compat/tests/function/var_export.phpt b/data/module/Compat/tests/function/var_export.phpt deleted file mode 100644 index 459ea357d66..00000000000 --- a/data/module/Compat/tests/function/var_export.phpt +++ /dev/null @@ -1,123 +0,0 @@ ---TEST-- -Function -- var_export ---SKIPIF-- - ---FILE-- - null, - 'O\'neil', - 'He said "bar" ...' => 'He said "bar" ...', - 'Yes \ No' =>'Yes \ No O\'neil', - 'foo' => null, - ); -var_export($a); -echo "\n\n"; - -// Classes -$var = new stdClass; -$var->foo = 'foo'; -$var->bar = 'bar'; -$var = array(array($var)); -var_export($var); - -?> ---EXPECT-- -true -false -NULL -NULL -array ( - 0 => 1, - 1 => - array ( - 0 => 2, - 1 => - array ( - 0 => 3, - 1 => 4, - ), - 2 => - array ( - 0 => 5, - 1 => - array ( - 0 => 6, - 1 => - array ( - 0 => 7, - ), - ), - ), - ), -) -array ( - 0 => 1, - 1 => 2, - 2 => - array ( - 0 => 'a', - 1 => 'b', - 2 => 'c', - ), -) - -array ( - 0 => 1, - 1 => 2, - 2 => - array ( - 0 => 'a', - 1 => 'b', - 2 => 'c', - ), -) - -array ( - '' => NULL, - 0 => 'O\'neil', - 'He said "bar" ...' => 'He said "bar" ...', - 'Yes \\ No' => 'Yes \\ No O\'neil', - 'foo' => NULL, -) - -array ( - 0 => - array ( - 0 => - class stdClass { - var $foo = 'foo'; - var $bar = 'bar'; - }, - ), -) \ No newline at end of file diff --git a/data/module/Compat/tests/function/version_compare.phpt b/data/module/Compat/tests/function/version_compare.phpt deleted file mode 100644 index 2af28faf162..00000000000 --- a/data/module/Compat/tests/function/version_compare.phpt +++ /dev/null @@ -1,615 +0,0 @@ ---TEST-- -Function -- version_compare ---SKIPIF-- - ---FILE-- -", - "ge", ">=", - "eq", "=", "==", - "ne", "<>", "!=" -); - -foreach ($special_forms as $f1) { - foreach ($special_forms as $f2) { - test("1.0$f1", "1.0$f2"); - } -} - -// Operators -print "testing operators\n"; -foreach ($special_forms as $f1) { - foreach ($special_forms as $f2) { - foreach ($operators as $op) { - $v1 = "1.0$f1"; - $v2 = "1.0$f2"; - $test = version_compare($v1, $v2, $op) ? "true" : "false"; - printf("%7s %2s %-7s : %s\n", $v1, $op, $v2, $test); - } - } -} - -function test($v1, $v2) { - $compare = version_compare($v1, $v2); - switch ($compare) { - case -1: - print "$v1 < $v2\n"; - break; - case 1: - print "$v1 > $v2\n"; - break; - case 0: - default: - print "$v1 = $v2\n"; - break; - } -} - -?> -testing basic -1 < 2 -10 > 2 -1.0 < 1.1 -1.2 > 1.0.1 -1.2.p3 > 1.2.4 -1.2.y = 1.2.z -testing compare -1.0-dev = 1.0-dev -1.0-dev < 1.0a1 -1.0-dev < 1.0b1 -1.0-dev < 1.0RC1 -1.0-dev < 1.0 -1.0-dev < 1.0pl1 -1.0a1 > 1.0-dev -1.0a1 = 1.0a1 -1.0a1 < 1.0b1 -1.0a1 < 1.0RC1 -1.0a1 < 1.0 -1.0a1 < 1.0pl1 -1.0b1 > 1.0-dev -1.0b1 > 1.0a1 -1.0b1 = 1.0b1 -1.0b1 < 1.0RC1 -1.0b1 < 1.0 -1.0b1 < 1.0pl1 -1.0RC1 > 1.0-dev -1.0RC1 > 1.0a1 -1.0RC1 > 1.0b1 -1.0RC1 = 1.0RC1 -1.0RC1 < 1.0 -1.0RC1 < 1.0pl1 -1.0 > 1.0-dev -1.0 > 1.0a1 -1.0 > 1.0b1 -1.0 > 1.0RC1 -1.0 = 1.0 -1.0 < 1.0pl1 -1.0pl1 > 1.0-dev -1.0pl1 > 1.0a1 -1.0pl1 > 1.0b1 -1.0pl1 > 1.0RC1 -1.0pl1 > 1.0 -1.0pl1 = 1.0pl1 -testing operators -1.0-dev lt 1.0-dev : false -1.0-dev < 1.0-dev : false -1.0-dev le 1.0-dev : true -1.0-dev <= 1.0-dev : true -1.0-dev gt 1.0-dev : false -1.0-dev > 1.0-dev : false -1.0-dev ge 1.0-dev : true -1.0-dev >= 1.0-dev : true -1.0-dev eq 1.0-dev : true -1.0-dev = 1.0-dev : true -1.0-dev == 1.0-dev : true -1.0-dev ne 1.0-dev : false -1.0-dev <> 1.0-dev : false -1.0-dev != 1.0-dev : false -1.0-dev lt 1.0a1 : true -1.0-dev < 1.0a1 : true -1.0-dev le 1.0a1 : true -1.0-dev <= 1.0a1 : true -1.0-dev gt 1.0a1 : false -1.0-dev > 1.0a1 : false -1.0-dev ge 1.0a1 : false -1.0-dev >= 1.0a1 : false -1.0-dev eq 1.0a1 : false -1.0-dev = 1.0a1 : false -1.0-dev == 1.0a1 : false -1.0-dev ne 1.0a1 : true -1.0-dev <> 1.0a1 : true -1.0-dev != 1.0a1 : true -1.0-dev lt 1.0b1 : true -1.0-dev < 1.0b1 : true -1.0-dev le 1.0b1 : true -1.0-dev <= 1.0b1 : true -1.0-dev gt 1.0b1 : false -1.0-dev > 1.0b1 : false -1.0-dev ge 1.0b1 : false -1.0-dev >= 1.0b1 : false -1.0-dev eq 1.0b1 : false -1.0-dev = 1.0b1 : false -1.0-dev == 1.0b1 : false -1.0-dev ne 1.0b1 : true -1.0-dev <> 1.0b1 : true -1.0-dev != 1.0b1 : true -1.0-dev lt 1.0RC1 : true -1.0-dev < 1.0RC1 : true -1.0-dev le 1.0RC1 : true -1.0-dev <= 1.0RC1 : true -1.0-dev gt 1.0RC1 : false -1.0-dev > 1.0RC1 : false -1.0-dev ge 1.0RC1 : false -1.0-dev >= 1.0RC1 : false -1.0-dev eq 1.0RC1 : false -1.0-dev = 1.0RC1 : false -1.0-dev == 1.0RC1 : false -1.0-dev ne 1.0RC1 : true -1.0-dev <> 1.0RC1 : true -1.0-dev != 1.0RC1 : true -1.0-dev lt 1.0 : true -1.0-dev < 1.0 : true -1.0-dev le 1.0 : true -1.0-dev <= 1.0 : true -1.0-dev gt 1.0 : false -1.0-dev > 1.0 : false -1.0-dev ge 1.0 : false -1.0-dev >= 1.0 : false -1.0-dev eq 1.0 : false -1.0-dev = 1.0 : false -1.0-dev == 1.0 : false -1.0-dev ne 1.0 : true -1.0-dev <> 1.0 : true -1.0-dev != 1.0 : true -1.0-dev lt 1.0pl1 : true -1.0-dev < 1.0pl1 : true -1.0-dev le 1.0pl1 : true -1.0-dev <= 1.0pl1 : true -1.0-dev gt 1.0pl1 : false -1.0-dev > 1.0pl1 : false -1.0-dev ge 1.0pl1 : false -1.0-dev >= 1.0pl1 : false -1.0-dev eq 1.0pl1 : false -1.0-dev = 1.0pl1 : false -1.0-dev == 1.0pl1 : false -1.0-dev ne 1.0pl1 : true -1.0-dev <> 1.0pl1 : true -1.0-dev != 1.0pl1 : true - 1.0a1 lt 1.0-dev : false - 1.0a1 < 1.0-dev : false - 1.0a1 le 1.0-dev : false - 1.0a1 <= 1.0-dev : false - 1.0a1 gt 1.0-dev : true - 1.0a1 > 1.0-dev : true - 1.0a1 ge 1.0-dev : true - 1.0a1 >= 1.0-dev : true - 1.0a1 eq 1.0-dev : false - 1.0a1 = 1.0-dev : false - 1.0a1 == 1.0-dev : false - 1.0a1 ne 1.0-dev : true - 1.0a1 <> 1.0-dev : true - 1.0a1 != 1.0-dev : true - 1.0a1 lt 1.0a1 : false - 1.0a1 < 1.0a1 : false - 1.0a1 le 1.0a1 : true - 1.0a1 <= 1.0a1 : true - 1.0a1 gt 1.0a1 : false - 1.0a1 > 1.0a1 : false - 1.0a1 ge 1.0a1 : true - 1.0a1 >= 1.0a1 : true - 1.0a1 eq 1.0a1 : true - 1.0a1 = 1.0a1 : true - 1.0a1 == 1.0a1 : true - 1.0a1 ne 1.0a1 : false - 1.0a1 <> 1.0a1 : false - 1.0a1 != 1.0a1 : false - 1.0a1 lt 1.0b1 : true - 1.0a1 < 1.0b1 : true - 1.0a1 le 1.0b1 : true - 1.0a1 <= 1.0b1 : true - 1.0a1 gt 1.0b1 : false - 1.0a1 > 1.0b1 : false - 1.0a1 ge 1.0b1 : false - 1.0a1 >= 1.0b1 : false - 1.0a1 eq 1.0b1 : false - 1.0a1 = 1.0b1 : false - 1.0a1 == 1.0b1 : false - 1.0a1 ne 1.0b1 : true - 1.0a1 <> 1.0b1 : true - 1.0a1 != 1.0b1 : true - 1.0a1 lt 1.0RC1 : true - 1.0a1 < 1.0RC1 : true - 1.0a1 le 1.0RC1 : true - 1.0a1 <= 1.0RC1 : true - 1.0a1 gt 1.0RC1 : false - 1.0a1 > 1.0RC1 : false - 1.0a1 ge 1.0RC1 : false - 1.0a1 >= 1.0RC1 : false - 1.0a1 eq 1.0RC1 : false - 1.0a1 = 1.0RC1 : false - 1.0a1 == 1.0RC1 : false - 1.0a1 ne 1.0RC1 : true - 1.0a1 <> 1.0RC1 : true - 1.0a1 != 1.0RC1 : true - 1.0a1 lt 1.0 : true - 1.0a1 < 1.0 : true - 1.0a1 le 1.0 : true - 1.0a1 <= 1.0 : true - 1.0a1 gt 1.0 : false - 1.0a1 > 1.0 : false - 1.0a1 ge 1.0 : false - 1.0a1 >= 1.0 : false - 1.0a1 eq 1.0 : false - 1.0a1 = 1.0 : false - 1.0a1 == 1.0 : false - 1.0a1 ne 1.0 : true - 1.0a1 <> 1.0 : true - 1.0a1 != 1.0 : true - 1.0a1 lt 1.0pl1 : true - 1.0a1 < 1.0pl1 : true - 1.0a1 le 1.0pl1 : true - 1.0a1 <= 1.0pl1 : true - 1.0a1 gt 1.0pl1 : false - 1.0a1 > 1.0pl1 : false - 1.0a1 ge 1.0pl1 : false - 1.0a1 >= 1.0pl1 : false - 1.0a1 eq 1.0pl1 : false - 1.0a1 = 1.0pl1 : false - 1.0a1 == 1.0pl1 : false - 1.0a1 ne 1.0pl1 : true - 1.0a1 <> 1.0pl1 : true - 1.0a1 != 1.0pl1 : true - 1.0b1 lt 1.0-dev : false - 1.0b1 < 1.0-dev : false - 1.0b1 le 1.0-dev : false - 1.0b1 <= 1.0-dev : false - 1.0b1 gt 1.0-dev : true - 1.0b1 > 1.0-dev : true - 1.0b1 ge 1.0-dev : true - 1.0b1 >= 1.0-dev : true - 1.0b1 eq 1.0-dev : false - 1.0b1 = 1.0-dev : false - 1.0b1 == 1.0-dev : false - 1.0b1 ne 1.0-dev : true - 1.0b1 <> 1.0-dev : true - 1.0b1 != 1.0-dev : true - 1.0b1 lt 1.0a1 : false - 1.0b1 < 1.0a1 : false - 1.0b1 le 1.0a1 : false - 1.0b1 <= 1.0a1 : false - 1.0b1 gt 1.0a1 : true - 1.0b1 > 1.0a1 : true - 1.0b1 ge 1.0a1 : true - 1.0b1 >= 1.0a1 : true - 1.0b1 eq 1.0a1 : false - 1.0b1 = 1.0a1 : false - 1.0b1 == 1.0a1 : false - 1.0b1 ne 1.0a1 : true - 1.0b1 <> 1.0a1 : true - 1.0b1 != 1.0a1 : true - 1.0b1 lt 1.0b1 : false - 1.0b1 < 1.0b1 : false - 1.0b1 le 1.0b1 : true - 1.0b1 <= 1.0b1 : true - 1.0b1 gt 1.0b1 : false - 1.0b1 > 1.0b1 : false - 1.0b1 ge 1.0b1 : true - 1.0b1 >= 1.0b1 : true - 1.0b1 eq 1.0b1 : true - 1.0b1 = 1.0b1 : true - 1.0b1 == 1.0b1 : true - 1.0b1 ne 1.0b1 : false - 1.0b1 <> 1.0b1 : false - 1.0b1 != 1.0b1 : false - 1.0b1 lt 1.0RC1 : true - 1.0b1 < 1.0RC1 : true - 1.0b1 le 1.0RC1 : true - 1.0b1 <= 1.0RC1 : true - 1.0b1 gt 1.0RC1 : false - 1.0b1 > 1.0RC1 : false - 1.0b1 ge 1.0RC1 : false - 1.0b1 >= 1.0RC1 : false - 1.0b1 eq 1.0RC1 : false - 1.0b1 = 1.0RC1 : false - 1.0b1 == 1.0RC1 : false - 1.0b1 ne 1.0RC1 : true - 1.0b1 <> 1.0RC1 : true - 1.0b1 != 1.0RC1 : true - 1.0b1 lt 1.0 : true - 1.0b1 < 1.0 : true - 1.0b1 le 1.0 : true - 1.0b1 <= 1.0 : true - 1.0b1 gt 1.0 : false - 1.0b1 > 1.0 : false - 1.0b1 ge 1.0 : false - 1.0b1 >= 1.0 : false - 1.0b1 eq 1.0 : false - 1.0b1 = 1.0 : false - 1.0b1 == 1.0 : false - 1.0b1 ne 1.0 : true - 1.0b1 <> 1.0 : true - 1.0b1 != 1.0 : true - 1.0b1 lt 1.0pl1 : true - 1.0b1 < 1.0pl1 : true - 1.0b1 le 1.0pl1 : true - 1.0b1 <= 1.0pl1 : true - 1.0b1 gt 1.0pl1 : false - 1.0b1 > 1.0pl1 : false - 1.0b1 ge 1.0pl1 : false - 1.0b1 >= 1.0pl1 : false - 1.0b1 eq 1.0pl1 : false - 1.0b1 = 1.0pl1 : false - 1.0b1 == 1.0pl1 : false - 1.0b1 ne 1.0pl1 : true - 1.0b1 <> 1.0pl1 : true - 1.0b1 != 1.0pl1 : true - 1.0RC1 lt 1.0-dev : false - 1.0RC1 < 1.0-dev : false - 1.0RC1 le 1.0-dev : false - 1.0RC1 <= 1.0-dev : false - 1.0RC1 gt 1.0-dev : true - 1.0RC1 > 1.0-dev : true - 1.0RC1 ge 1.0-dev : true - 1.0RC1 >= 1.0-dev : true - 1.0RC1 eq 1.0-dev : false - 1.0RC1 = 1.0-dev : false - 1.0RC1 == 1.0-dev : false - 1.0RC1 ne 1.0-dev : true - 1.0RC1 <> 1.0-dev : true - 1.0RC1 != 1.0-dev : true - 1.0RC1 lt 1.0a1 : false - 1.0RC1 < 1.0a1 : false - 1.0RC1 le 1.0a1 : false - 1.0RC1 <= 1.0a1 : false - 1.0RC1 gt 1.0a1 : true - 1.0RC1 > 1.0a1 : true - 1.0RC1 ge 1.0a1 : true - 1.0RC1 >= 1.0a1 : true - 1.0RC1 eq 1.0a1 : false - 1.0RC1 = 1.0a1 : false - 1.0RC1 == 1.0a1 : false - 1.0RC1 ne 1.0a1 : true - 1.0RC1 <> 1.0a1 : true - 1.0RC1 != 1.0a1 : true - 1.0RC1 lt 1.0b1 : false - 1.0RC1 < 1.0b1 : false - 1.0RC1 le 1.0b1 : false - 1.0RC1 <= 1.0b1 : false - 1.0RC1 gt 1.0b1 : true - 1.0RC1 > 1.0b1 : true - 1.0RC1 ge 1.0b1 : true - 1.0RC1 >= 1.0b1 : true - 1.0RC1 eq 1.0b1 : false - 1.0RC1 = 1.0b1 : false - 1.0RC1 == 1.0b1 : false - 1.0RC1 ne 1.0b1 : true - 1.0RC1 <> 1.0b1 : true - 1.0RC1 != 1.0b1 : true - 1.0RC1 lt 1.0RC1 : false - 1.0RC1 < 1.0RC1 : false - 1.0RC1 le 1.0RC1 : true - 1.0RC1 <= 1.0RC1 : true - 1.0RC1 gt 1.0RC1 : false - 1.0RC1 > 1.0RC1 : false - 1.0RC1 ge 1.0RC1 : true - 1.0RC1 >= 1.0RC1 : true - 1.0RC1 eq 1.0RC1 : true - 1.0RC1 = 1.0RC1 : true - 1.0RC1 == 1.0RC1 : true - 1.0RC1 ne 1.0RC1 : false - 1.0RC1 <> 1.0RC1 : false - 1.0RC1 != 1.0RC1 : false - 1.0RC1 lt 1.0 : true - 1.0RC1 < 1.0 : true - 1.0RC1 le 1.0 : true - 1.0RC1 <= 1.0 : true - 1.0RC1 gt 1.0 : false - 1.0RC1 > 1.0 : false - 1.0RC1 ge 1.0 : false - 1.0RC1 >= 1.0 : false - 1.0RC1 eq 1.0 : false - 1.0RC1 = 1.0 : false - 1.0RC1 == 1.0 : false - 1.0RC1 ne 1.0 : true - 1.0RC1 <> 1.0 : true - 1.0RC1 != 1.0 : true - 1.0RC1 lt 1.0pl1 : true - 1.0RC1 < 1.0pl1 : true - 1.0RC1 le 1.0pl1 : true - 1.0RC1 <= 1.0pl1 : true - 1.0RC1 gt 1.0pl1 : false - 1.0RC1 > 1.0pl1 : false - 1.0RC1 ge 1.0pl1 : false - 1.0RC1 >= 1.0pl1 : false - 1.0RC1 eq 1.0pl1 : false - 1.0RC1 = 1.0pl1 : false - 1.0RC1 == 1.0pl1 : false - 1.0RC1 ne 1.0pl1 : true - 1.0RC1 <> 1.0pl1 : true - 1.0RC1 != 1.0pl1 : true - 1.0 lt 1.0-dev : false - 1.0 < 1.0-dev : false - 1.0 le 1.0-dev : false - 1.0 <= 1.0-dev : false - 1.0 gt 1.0-dev : true - 1.0 > 1.0-dev : true - 1.0 ge 1.0-dev : true - 1.0 >= 1.0-dev : true - 1.0 eq 1.0-dev : false - 1.0 = 1.0-dev : false - 1.0 == 1.0-dev : false - 1.0 ne 1.0-dev : true - 1.0 <> 1.0-dev : true - 1.0 != 1.0-dev : true - 1.0 lt 1.0a1 : false - 1.0 < 1.0a1 : false - 1.0 le 1.0a1 : false - 1.0 <= 1.0a1 : false - 1.0 gt 1.0a1 : true - 1.0 > 1.0a1 : true - 1.0 ge 1.0a1 : true - 1.0 >= 1.0a1 : true - 1.0 eq 1.0a1 : false - 1.0 = 1.0a1 : false - 1.0 == 1.0a1 : false - 1.0 ne 1.0a1 : true - 1.0 <> 1.0a1 : true - 1.0 != 1.0a1 : true - 1.0 lt 1.0b1 : false - 1.0 < 1.0b1 : false - 1.0 le 1.0b1 : false - 1.0 <= 1.0b1 : false - 1.0 gt 1.0b1 : true - 1.0 > 1.0b1 : true - 1.0 ge 1.0b1 : true - 1.0 >= 1.0b1 : true - 1.0 eq 1.0b1 : false - 1.0 = 1.0b1 : false - 1.0 == 1.0b1 : false - 1.0 ne 1.0b1 : true - 1.0 <> 1.0b1 : true - 1.0 != 1.0b1 : true - 1.0 lt 1.0RC1 : false - 1.0 < 1.0RC1 : false - 1.0 le 1.0RC1 : false - 1.0 <= 1.0RC1 : false - 1.0 gt 1.0RC1 : true - 1.0 > 1.0RC1 : true - 1.0 ge 1.0RC1 : true - 1.0 >= 1.0RC1 : true - 1.0 eq 1.0RC1 : false - 1.0 = 1.0RC1 : false - 1.0 == 1.0RC1 : false - 1.0 ne 1.0RC1 : true - 1.0 <> 1.0RC1 : true - 1.0 != 1.0RC1 : true - 1.0 lt 1.0 : false - 1.0 < 1.0 : false - 1.0 le 1.0 : true - 1.0 <= 1.0 : true - 1.0 gt 1.0 : false - 1.0 > 1.0 : false - 1.0 ge 1.0 : true - 1.0 >= 1.0 : true - 1.0 eq 1.0 : true - 1.0 = 1.0 : true - 1.0 == 1.0 : true - 1.0 ne 1.0 : false - 1.0 <> 1.0 : false - 1.0 != 1.0 : false - 1.0 lt 1.0pl1 : true - 1.0 < 1.0pl1 : true - 1.0 le 1.0pl1 : true - 1.0 <= 1.0pl1 : true - 1.0 gt 1.0pl1 : false - 1.0 > 1.0pl1 : false - 1.0 ge 1.0pl1 : false - 1.0 >= 1.0pl1 : false - 1.0 eq 1.0pl1 : false - 1.0 = 1.0pl1 : false - 1.0 == 1.0pl1 : false - 1.0 ne 1.0pl1 : true - 1.0 <> 1.0pl1 : true - 1.0 != 1.0pl1 : true - 1.0pl1 lt 1.0-dev : false - 1.0pl1 < 1.0-dev : false - 1.0pl1 le 1.0-dev : false - 1.0pl1 <= 1.0-dev : false - 1.0pl1 gt 1.0-dev : true - 1.0pl1 > 1.0-dev : true - 1.0pl1 ge 1.0-dev : true - 1.0pl1 >= 1.0-dev : true - 1.0pl1 eq 1.0-dev : false - 1.0pl1 = 1.0-dev : false - 1.0pl1 == 1.0-dev : false - 1.0pl1 ne 1.0-dev : true - 1.0pl1 <> 1.0-dev : true - 1.0pl1 != 1.0-dev : true - 1.0pl1 lt 1.0a1 : false - 1.0pl1 < 1.0a1 : false - 1.0pl1 le 1.0a1 : false - 1.0pl1 <= 1.0a1 : false - 1.0pl1 gt 1.0a1 : true - 1.0pl1 > 1.0a1 : true - 1.0pl1 ge 1.0a1 : true - 1.0pl1 >= 1.0a1 : true - 1.0pl1 eq 1.0a1 : false - 1.0pl1 = 1.0a1 : false - 1.0pl1 == 1.0a1 : false - 1.0pl1 ne 1.0a1 : true - 1.0pl1 <> 1.0a1 : true - 1.0pl1 != 1.0a1 : true - 1.0pl1 lt 1.0b1 : false - 1.0pl1 < 1.0b1 : false - 1.0pl1 le 1.0b1 : false - 1.0pl1 <= 1.0b1 : false - 1.0pl1 gt 1.0b1 : true - 1.0pl1 > 1.0b1 : true - 1.0pl1 ge 1.0b1 : true - 1.0pl1 >= 1.0b1 : true - 1.0pl1 eq 1.0b1 : false - 1.0pl1 = 1.0b1 : false - 1.0pl1 == 1.0b1 : false - 1.0pl1 ne 1.0b1 : true - 1.0pl1 <> 1.0b1 : true - 1.0pl1 != 1.0b1 : true - 1.0pl1 lt 1.0RC1 : false - 1.0pl1 < 1.0RC1 : false - 1.0pl1 le 1.0RC1 : false - 1.0pl1 <= 1.0RC1 : false - 1.0pl1 gt 1.0RC1 : true - 1.0pl1 > 1.0RC1 : true - 1.0pl1 ge 1.0RC1 : true - 1.0pl1 >= 1.0RC1 : true - 1.0pl1 eq 1.0RC1 : false - 1.0pl1 = 1.0RC1 : false - 1.0pl1 == 1.0RC1 : false - 1.0pl1 ne 1.0RC1 : true - 1.0pl1 <> 1.0RC1 : true - 1.0pl1 != 1.0RC1 : true - 1.0pl1 lt 1.0 : false - 1.0pl1 < 1.0 : false - 1.0pl1 le 1.0 : false - 1.0pl1 <= 1.0 : false - 1.0pl1 gt 1.0 : true - 1.0pl1 > 1.0 : true - 1.0pl1 ge 1.0 : true - 1.0pl1 >= 1.0 : true - 1.0pl1 eq 1.0 : false - 1.0pl1 = 1.0 : false - 1.0pl1 == 1.0 : false - 1.0pl1 ne 1.0 : true - 1.0pl1 <> 1.0 : true - 1.0pl1 != 1.0 : true - 1.0pl1 lt 1.0pl1 : false - 1.0pl1 < 1.0pl1 : false - 1.0pl1 le 1.0pl1 : true - 1.0pl1 <= 1.0pl1 : true - 1.0pl1 gt 1.0pl1 : false - 1.0pl1 > 1.0pl1 : false - 1.0pl1 ge 1.0pl1 : true - 1.0pl1 >= 1.0pl1 : true - 1.0pl1 eq 1.0pl1 : true - 1.0pl1 = 1.0pl1 : true - 1.0pl1 == 1.0pl1 : true - 1.0pl1 ne 1.0pl1 : false - 1.0pl1 <> 1.0pl1 : false - 1.0pl1 != 1.0pl1 : false \ No newline at end of file diff --git a/data/module/Compat/tests/function/vprintf.phpt b/data/module/Compat/tests/function/vprintf.phpt deleted file mode 100644 index 3f4e4fae04e..00000000000 --- a/data/module/Compat/tests/function/vprintf.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -Function -- vprintf ---SKIPIF-- - ---FILE-- - ---EXPECT-- -There are 2 monkeys in the car \ No newline at end of file diff --git a/data/module/Compat/tests/function/vsprintf.phpt b/data/module/Compat/tests/function/vsprintf.phpt deleted file mode 100644 index 9876b7f07d3..00000000000 --- a/data/module/Compat/tests/function/vsprintf.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -Function -- vsprintf ---SKIPIF-- - ---FILE-- - ---EXPECT-- -There are 2 monkeys in the car \ No newline at end of file diff --git a/data/module/Compat/tests/loadconstant.phpt b/data/module/Compat/tests/loadconstant.phpt deleted file mode 100644 index ea9340643da..00000000000 --- a/data/module/Compat/tests/loadconstant.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -Method -- PHP_Compat::loadConstant ---FILE-- - $result) { - echo $comp . ': '; - echo ($result === false) ? 'false' : 'true', "\n"; -} - -?> ---EXPECT-- -false -an-invalid: false -also-invalid: false -more-invalid: false -E_STRICT: true \ No newline at end of file diff --git a/data/module/Compat/tests/loadfunction.phpt b/data/module/Compat/tests/loadfunction.phpt deleted file mode 100644 index f2d15a9e80e..00000000000 --- a/data/module/Compat/tests/loadfunction.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -Method -- PHP_Compat::loadFunction ---FILE-- - $result) { - echo $comp . ': '; - echo ($result === false) ? 'false' : 'true', "\n"; -} - -?> ---EXPECT-- -false -an-invalid: false -also-invalid: false -more-invalid: false \ No newline at end of file diff --git a/data/module/Compat/tests/loadversion.phpt b/data/module/Compat/tests/loadversion.phpt deleted file mode 100644 index 026e54d5a80..00000000000 --- a/data/module/Compat/tests/loadversion.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Method -- PHP_Compat::loadVersion ---FILE-- - ---EXPECT-- -bool(true) -bool(true) -bool(true) \ No newline at end of file diff --git a/data/module/HTTP/Request.php b/data/module/HTTP/Request.php deleted file mode 100644 index ef6109f22a6..00000000000 --- a/data/module/HTTP/Request.php +++ /dev/null @@ -1,1528 +0,0 @@ - - * @author Alexey Borzov - * @copyright 2002-2007 Richard Heyes - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTTP_Request/ - */ - -/** - * PEAR and PEAR_Error classes (for error handling) - */ -require_once 'PEAR.php'; -/** - * Socket class - */ -require_once 'Net/Socket.php'; -/** - * URL handling class - */ -require_once 'Net/URL.php'; - -/**#@+ - * Constants for HTTP request methods - */ -define('HTTP_REQUEST_METHOD_GET', 'GET', true); -define('HTTP_REQUEST_METHOD_HEAD', 'HEAD', true); -define('HTTP_REQUEST_METHOD_POST', 'POST', true); -define('HTTP_REQUEST_METHOD_PUT', 'PUT', true); -define('HTTP_REQUEST_METHOD_DELETE', 'DELETE', true); -define('HTTP_REQUEST_METHOD_OPTIONS', 'OPTIONS', true); -define('HTTP_REQUEST_METHOD_TRACE', 'TRACE', true); -/**#@-*/ - -/**#@+ - * Constants for HTTP request error codes - */ -define('HTTP_REQUEST_ERROR_FILE', 1); -define('HTTP_REQUEST_ERROR_URL', 2); -define('HTTP_REQUEST_ERROR_PROXY', 4); -define('HTTP_REQUEST_ERROR_REDIRECTS', 8); -define('HTTP_REQUEST_ERROR_RESPONSE', 16); -define('HTTP_REQUEST_ERROR_GZIP_METHOD', 32); -define('HTTP_REQUEST_ERROR_GZIP_READ', 64); -define('HTTP_REQUEST_ERROR_GZIP_DATA', 128); -define('HTTP_REQUEST_ERROR_GZIP_CRC', 256); -/**#@-*/ - -/**#@+ - * Constants for HTTP protocol versions - */ -define('HTTP_REQUEST_HTTP_VER_1_0', '1.0', true); -define('HTTP_REQUEST_HTTP_VER_1_1', '1.1', true); -/**#@-*/ - -if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - /** - * Whether string functions are overloaded by their mbstring equivalents - */ - define('HTTP_REQUEST_MBSTRING', true); -} else { - /** - * @ignore - */ - define('HTTP_REQUEST_MBSTRING', false); -} - -/** - * Class for performing HTTP requests - * - * Simple example (fetches yahoo.com and displays it): - * - * $a = &new HTTP_Request('http://www.yahoo.com/'); - * $a->sendRequest(); - * echo $a->getResponseBody(); - * - * - * @category HTTP - * @package HTTP_Request - * @author Richard Heyes - * @author Alexey Borzov - * @version Release: 1.4.4 - */ -class HTTP_Request -{ - /**#@+ - * @access private - */ - /** - * Instance of Net_URL - * @var Net_URL - */ - var $_url; - - /** - * Type of request - * @var string - */ - var $_method; - - /** - * HTTP Version - * @var string - */ - var $_http; - - /** - * Request headers - * @var array - */ - var $_requestHeaders; - - /** - * Basic Auth Username - * @var string - */ - var $_user; - - /** - * Basic Auth Password - * @var string - */ - var $_pass; - - /** - * Socket object - * @var Net_Socket - */ - var $_sock; - - /** - * Proxy server - * @var string - */ - var $_proxy_host; - - /** - * Proxy port - * @var integer - */ - var $_proxy_port; - - /** - * Proxy username - * @var string - */ - var $_proxy_user; - - /** - * Proxy password - * @var string - */ - var $_proxy_pass; - - /** - * Post data - * @var array - */ - var $_postData; - - /** - * Request body - * @var string - */ - var $_body; - - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - var $_bodyDisallowed = array('TRACE'); - - /** - * Methods having defined semantics for request body - * - * Content-Length header (indicating that the body follows, section 4.3 of - * RFC 2616) will be sent for these methods even if no body was added - * - * @var array - */ - var $_bodyRequired = array('POST', 'PUT'); - - /** - * Files to post - * @var array - */ - var $_postFiles = array(); - - /** - * Connection timeout. - * @var float - */ - var $_timeout; - - /** - * HTTP_Response object - * @var HTTP_Response - */ - var $_response; - - /** - * Whether to allow redirects - * @var boolean - */ - var $_allowRedirects; - - /** - * Maximum redirects allowed - * @var integer - */ - var $_maxRedirects; - - /** - * Current number of redirects - * @var integer - */ - var $_redirects; - - /** - * Whether to append brackets [] to array variables - * @var bool - */ - var $_useBrackets = true; - - /** - * Attached listeners - * @var array - */ - var $_listeners = array(); - - /** - * Whether to save response body in response object property - * @var bool - */ - var $_saveBody = true; - - /** - * Timeout for reading from socket (array(seconds, microseconds)) - * @var array - */ - var $_readTimeout = null; - - /** - * Options to pass to Net_Socket::connect. See stream_context_create - * @var array - */ - var $_socketOptions = null; - /**#@-*/ - - /** - * Constructor - * - * Sets up the object - * @param string The url to fetch/access - * @param array Associative array of parameters which can have the following keys: - *
    - *
  • method - Method to use, GET, POST etc (string)
  • - *
  • http - HTTP Version to use, 1.0 or 1.1 (string)
  • - *
  • user - Basic Auth username (string)
  • - *
  • pass - Basic Auth password (string)
  • - *
  • proxy_host - Proxy server host (string)
  • - *
  • proxy_port - Proxy server port (integer)
  • - *
  • proxy_user - Proxy auth username (string)
  • - *
  • proxy_pass - Proxy auth password (string)
  • - *
  • timeout - Connection timeout in seconds (float)
  • - *
  • allowRedirects - Whether to follow redirects or not (bool)
  • - *
  • maxRedirects - Max number of redirects to follow (integer)
  • - *
  • useBrackets - Whether to append [] to array variable names (bool)
  • - *
  • saveBody - Whether to save response body in response object property (bool)
  • - *
  • readTimeout - Timeout for reading / writing data over the socket (array (seconds, microseconds))
  • - *
  • socketOptions - Options to pass to Net_Socket object (array)
  • - *
- * @access public - */ - function HTTP_Request($url = '', $params = array()) - { - $this->_method = HTTP_REQUEST_METHOD_GET; - $this->_http = HTTP_REQUEST_HTTP_VER_1_1; - $this->_requestHeaders = array(); - $this->_postData = array(); - $this->_body = null; - - $this->_user = null; - $this->_pass = null; - - $this->_proxy_host = null; - $this->_proxy_port = null; - $this->_proxy_user = null; - $this->_proxy_pass = null; - - $this->_allowRedirects = false; - $this->_maxRedirects = 3; - $this->_redirects = 0; - - $this->_timeout = null; - $this->_response = null; - - foreach ($params as $key => $value) { - $this->{'_' . $key} = $value; - } - - if (!empty($url)) { - $this->setURL($url); - } - - // Default useragent - $this->addHeader('User-Agent', 'PEAR HTTP_Request class ( http://pear.php.net/ )'); - - // We don't do keep-alives by default - $this->addHeader('Connection', 'close'); - - // Basic authentication - if (!empty($this->_user)) { - $this->addHeader('Authorization', 'Basic ' . base64_encode($this->_user . ':' . $this->_pass)); - } - - // Proxy authentication (see bug #5913) - if (!empty($this->_proxy_user)) { - $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($this->_proxy_user . ':' . $this->_proxy_pass)); - } - - // Use gzip encoding if possible - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && extension_loaded('zlib')) { - $this->addHeader('Accept-Encoding', 'gzip'); - } - } - - /** - * Generates a Host header for HTTP/1.1 requests - * - * @access private - * @return string - */ - function _generateHostHeader() - { - if ($this->_url->port != 80 AND strcasecmp($this->_url->protocol, 'http') == 0) { - $host = $this->_url->host . ':' . $this->_url->port; - - } elseif ($this->_url->port != 443 AND strcasecmp($this->_url->protocol, 'https') == 0) { - $host = $this->_url->host . ':' . $this->_url->port; - - } elseif ($this->_url->port == 443 AND strcasecmp($this->_url->protocol, 'https') == 0 AND strpos($this->_url->url, ':443') !== false) { - $host = $this->_url->host . ':' . $this->_url->port; - - } else { - $host = $this->_url->host; - } - - return $host; - } - - /** - * Resets the object to its initial state (DEPRECATED). - * Takes the same parameters as the constructor. - * - * @param string $url The url to be requested - * @param array $params Associative array of parameters - * (see constructor for details) - * @access public - * @deprecated deprecated since 1.2, call the constructor if this is necessary - */ - function reset($url, $params = array()) - { - $this->HTTP_Request($url, $params); - } - - /** - * Sets the URL to be requested - * - * @param string The url to be requested - * @access public - */ - function setURL($url) - { - $this->_url = &new Net_URL($url, $this->_useBrackets); - - if (!empty($this->_url->user) || !empty($this->_url->pass)) { - $this->setBasicAuth($this->_url->user, $this->_url->pass); - } - - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http) { - $this->addHeader('Host', $this->_generateHostHeader()); - } - - // set '/' instead of empty path rather than check later (see bug #8662) - if (empty($this->_url->path)) { - $this->_url->path = '/'; - } - } - - /** - * Returns the current request URL - * - * @return string Current request URL - * @access public - */ - function getUrl() - { - return empty($this->_url)? '': $this->_url->getUrl(); - } - - /** - * Sets a proxy to be used - * - * @param string Proxy host - * @param int Proxy port - * @param string Proxy username - * @param string Proxy password - * @access public - */ - function setProxy($host, $port = 8080, $user = null, $pass = null) - { - $this->_proxy_host = $host; - $this->_proxy_port = $port; - $this->_proxy_user = $user; - $this->_proxy_pass = $pass; - - if (!empty($user)) { - $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); - } - } - - /** - * Sets basic authentication parameters - * - * @param string Username - * @param string Password - */ - function setBasicAuth($user, $pass) - { - $this->_user = $user; - $this->_pass = $pass; - - $this->addHeader('Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); - } - - /** - * Sets the method to be used, GET, POST etc. - * - * @param string Method to use. Use the defined constants for this - * @access public - */ - function setMethod($method) - { - $this->_method = $method; - } - - /** - * Sets the HTTP version to use, 1.0 or 1.1 - * - * @param string Version to use. Use the defined constants for this - * @access public - */ - function setHttpVer($http) - { - $this->_http = $http; - } - - /** - * Adds a request header - * - * @param string Header name - * @param string Header value - * @access public - */ - function addHeader($name, $value) - { - $this->_requestHeaders[strtolower($name)] = $value; - } - - /** - * Removes a request header - * - * @param string Header name to remove - * @access public - */ - function removeHeader($name) - { - if (isset($this->_requestHeaders[strtolower($name)])) { - unset($this->_requestHeaders[strtolower($name)]); - } - } - - /** - * Adds a querystring parameter - * - * @param string Querystring parameter name - * @param string Querystring parameter value - * @param bool Whether the value is already urlencoded or not, default = not - * @access public - */ - function addQueryString($name, $value, $preencoded = false) - { - $this->_url->addQueryString($name, $value, $preencoded); - } - - /** - * Sets the querystring to literally what you supply - * - * @param string The querystring data. Should be of the format foo=bar&x=y etc - * @param bool Whether data is already urlencoded or not, default = already encoded - * @access public - */ - function addRawQueryString($querystring, $preencoded = true) - { - $this->_url->addRawQueryString($querystring, $preencoded); - } - - /** - * Adds postdata items - * - * @param string Post data name - * @param string Post data value - * @param bool Whether data is already urlencoded or not, default = not - * @access public - */ - function addPostData($name, $value, $preencoded = false) - { - if ($preencoded) { - $this->_postData[$name] = $value; - } else { - $this->_postData[$name] = $this->_arrayMapRecursive('urlencode', $value); - } - } - - function addPostDataArray($array, $preencoded = false) - { - foreach($array as $key => $val){ - $this->addPostData($key, $val, $preencoded); - } - } - - /** - * Recursively applies the callback function to the value - * - * @param mixed Callback function - * @param mixed Value to process - * @access private - * @return mixed Processed value - */ - function _arrayMapRecursive($callback, $value) - { - if (!is_array($value)) { - return call_user_func($callback, $value); - } else { - $map = array(); - foreach ($value as $k => $v) { - $map[$k] = $this->_arrayMapRecursive($callback, $v); - } - return $map; - } - } - - /** - * Adds a file to form-based file upload - * - * Used to emulate file upload via a HTML form. The method also sets - * Content-Type of HTTP request to 'multipart/form-data'. - * - * If you just want to send the contents of a file as the body of HTTP - * request you should use setBody() method. - * - * @access public - * @param string name of file-upload field - * @param mixed file name(s) - * @param mixed content-type(s) of file(s) being uploaded - * @return bool true on success - * @throws PEAR_Error - */ - function addFile($inputName, $fileName, $contentType = 'application/octet-stream') - { - if (!is_array($fileName) && !is_readable($fileName)) { - return PEAR::raiseError("File '{$fileName}' is not readable", HTTP_REQUEST_ERROR_FILE); - } elseif (is_array($fileName)) { - foreach ($fileName as $name) { - if (!is_readable($name)) { - return PEAR::raiseError("File '{$name}' is not readable", HTTP_REQUEST_ERROR_FILE); - } - } - } - $this->addHeader('Content-Type', 'multipart/form-data'); - $this->_postFiles[$inputName] = array( - 'name' => $fileName, - 'type' => $contentType - ); - return true; - } - - /** - * Adds raw postdata (DEPRECATED) - * - * @param string The data - * @param bool Whether data is preencoded or not, default = already encoded - * @access public - * @deprecated deprecated since 1.3.0, method setBody() should be used instead - */ - function addRawPostData($postdata, $preencoded = true) - { - $this->_body = $preencoded ? $postdata : urlencode($postdata); - } - - /** - * Sets the request body (for POST, PUT and similar requests) - * - * @param string Request body - * @access public - */ - function setBody($body) - { - $this->_body = $body; - } - - /** - * Clears any postdata that has been added (DEPRECATED). - * - * Useful for multiple request scenarios. - * - * @access public - * @deprecated deprecated since 1.2 - */ - function clearPostData() - { - $this->_postData = null; - } - - /** - * Appends a cookie to "Cookie:" header - * - * @param string $name cookie name - * @param string $value cookie value - * @access public - */ - function addCookie($name, $value) - { - $cookies = isset($this->_requestHeaders['cookie']) ? $this->_requestHeaders['cookie']. '; ' : ''; - $this->addHeader('Cookie', $cookies . $name . '=' . $value); - } - - /** - * Clears any cookies that have been added (DEPRECATED). - * - * Useful for multiple request scenarios - * - * @access public - * @deprecated deprecated since 1.2 - */ - function clearCookies() - { - $this->removeHeader('Cookie'); - } - - /** - * Sends the request - * - * @access public - * @param bool Whether to store response body in Response object property, - * set this to false if downloading a LARGE file and using a Listener - * @return mixed PEAR error on error, true otherwise - */ - function sendRequest($saveBody = true) - { - if (!is_a($this->_url, 'Net_URL')) { - return PEAR::raiseError('No URL given', HTTP_REQUEST_ERROR_URL); - } - - $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host; - $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port; - - if (strcasecmp($this->_url->protocol, 'https') == 0) { - // Bug #14127, don't try connecting to HTTPS sites without OpenSSL - if (version_compare(PHP_VERSION, '4.3.0', '<') || !extension_loaded('openssl')) { - return PEAR::raiseError('Need PHP 4.3.0 or later with OpenSSL support for https:// requests', - HTTP_REQUEST_ERROR_URL); - } elseif (isset($this->_proxy_host)) { - return PEAR::raiseError('HTTPS proxies are not supported', HTTP_REQUEST_ERROR_PROXY); - } - $host = 'ssl://' . $host; - } - - // magic quotes may fuck up file uploads and chunked response processing - $magicQuotes = ini_get('magic_quotes_runtime'); - ini_set('magic_quotes_runtime', false); - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - // connection token to a proxy server... - if (isset($this->_proxy_host) && !empty($this->_requestHeaders['connection']) && - 'Keep-Alive' == $this->_requestHeaders['connection']) - { - $this->removeHeader('connection'); - } - - $keepAlive = (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && empty($this->_requestHeaders['connection'])) || - (!empty($this->_requestHeaders['connection']) && 'Keep-Alive' == $this->_requestHeaders['connection']); - $sockets = &PEAR::getStaticProperty('HTTP_Request', 'sockets'); - $sockKey = $host . ':' . $port; - unset($this->_sock); - - // There is a connected socket in the "static" property? - if ($keepAlive && !empty($sockets[$sockKey]) && - !empty($sockets[$sockKey]->fp)) - { - $this->_sock =& $sockets[$sockKey]; - $err = null; - } else { - $this->_notify('connect'); - $this->_sock =& new Net_Socket(); - $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions); - } - PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest()); - - if (!PEAR::isError($err)) { - if (!empty($this->_readTimeout)) { - $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]); - } - - $this->_notify('sentRequest'); - - // Read the response - $this->_response = &new HTTP_Response($this->_sock, $this->_listeners); - $err = $this->_response->process( - $this->_saveBody && $saveBody, - HTTP_REQUEST_METHOD_HEAD != $this->_method - ); - - if ($keepAlive) { - $keepAlive = (isset($this->_response->_headers['content-length']) - || (isset($this->_response->_headers['transfer-encoding']) - && strtolower($this->_response->_headers['transfer-encoding']) == 'chunked')); - if ($keepAlive) { - if (isset($this->_response->_headers['connection'])) { - $keepAlive = strtolower($this->_response->_headers['connection']) == 'keep-alive'; - } else { - $keepAlive = 'HTTP/'.HTTP_REQUEST_HTTP_VER_1_1 == $this->_response->_protocol; - } - } - } - } - - ini_set('magic_quotes_runtime', $magicQuotes); - - if (PEAR::isError($err)) { - return $err; - } - - if (!$keepAlive) { - $this->disconnect(); - // Store the connected socket in "static" property - } elseif (empty($sockets[$sockKey]) || empty($sockets[$sockKey]->fp)) { - $sockets[$sockKey] =& $this->_sock; - } - - // Check for redirection - if ( $this->_allowRedirects - AND $this->_redirects <= $this->_maxRedirects - AND $this->getResponseCode() > 300 - AND $this->getResponseCode() < 399 - AND !empty($this->_response->_headers['location'])) { - - - $redirect = $this->_response->_headers['location']; - - // Absolute URL - if (preg_match('/^https?:\/\//i', $redirect)) { - $this->_url = &new Net_URL($redirect); - $this->addHeader('Host', $this->_generateHostHeader()); - // Absolute path - } elseif ($redirect{0} == '/') { - $this->_url->path = $redirect; - - // Relative path - } elseif (substr($redirect, 0, 3) == '../' OR substr($redirect, 0, 2) == './') { - if (substr($this->_url->path, -1) == '/') { - $redirect = $this->_url->path . $redirect; - } else { - $redirect = dirname($this->_url->path) . '/' . $redirect; - } - $redirect = Net_URL::resolvePath($redirect); - $this->_url->path = $redirect; - - // Filename, no path - } else { - if (substr($this->_url->path, -1) == '/') { - $redirect = $this->_url->path . $redirect; - } else { - $redirect = dirname($this->_url->path) . '/' . $redirect; - } - $this->_url->path = $redirect; - } - - $this->_redirects++; - return $this->sendRequest($saveBody); - - // Too many redirects - } elseif ($this->_allowRedirects AND $this->_redirects > $this->_maxRedirects) { - return PEAR::raiseError('Too many redirects', HTTP_REQUEST_ERROR_REDIRECTS); - } - - return true; - } - - /** - * Disconnect the socket, if connected. Only useful if using Keep-Alive. - * - * @access public - */ - function disconnect() - { - if (!empty($this->_sock) && !empty($this->_sock->fp)) { - $this->_notify('disconnect'); - $this->_sock->disconnect(); - } - } - - /** - * Returns the response code - * - * @access public - * @return mixed Response code, false if not set - */ - function getResponseCode() - { - return isset($this->_response->_code) ? $this->_response->_code : false; - } - - /** - * Returns the response reason phrase - * - * @access public - * @return mixed Response reason phrase, false if not set - */ - function getResponseReason() - { - return isset($this->_response->_reason) ? $this->_response->_reason : false; - } - - /** - * Returns either the named header or all if no name given - * - * @access public - * @param string The header name to return, do not set to get all headers - * @return mixed either the value of $headername (false if header is not present) - * or an array of all headers - */ - function getResponseHeader($headername = null) - { - if (!isset($headername)) { - return isset($this->_response->_headers)? $this->_response->_headers: array(); - } else { - $headername = strtolower($headername); - return isset($this->_response->_headers[$headername]) ? $this->_response->_headers[$headername] : false; - } - } - - /** - * Returns the body of the response - * - * @access public - * @return mixed response body, false if not set - */ - function getResponseBody() - { - return isset($this->_response->_body) ? $this->_response->_body : false; - } - - /** - * Returns cookies set in response - * - * @access public - * @return mixed array of response cookies, false if none are present - */ - function getResponseCookies() - { - return isset($this->_response->_cookies) ? $this->_response->_cookies : false; - } - - /** - * Builds the request string - * - * @access private - * @return string The request string - */ - function _buildRequest() - { - $separator = ini_get('arg_separator.output'); - ini_set('arg_separator.output', '&'); - $querystring = ($querystring = $this->_url->getQueryString()) ? '?' . $querystring : ''; - ini_set('arg_separator.output', $separator); - - $host = isset($this->_proxy_host) ? $this->_url->protocol . '://' . $this->_url->host : ''; - $port = (isset($this->_proxy_host) AND $this->_url->port != 80) ? ':' . $this->_url->port : ''; - $path = $this->_url->path . $querystring; - $url = $host . $port . $path; - - if (!strlen($url)) { - $url = '/'; - } - - $request = $this->_method . ' ' . $url . ' HTTP/' . $this->_http . "\r\n"; - - if (in_array($this->_method, $this->_bodyDisallowed) || - (0 == strlen($this->_body) && (HTTP_REQUEST_METHOD_POST != $this->_method || - (empty($this->_postData) && empty($this->_postFiles))))) - { - $this->removeHeader('Content-Type'); - } else { - if (empty($this->_requestHeaders['content-type'])) { - // Add default content-type - $this->addHeader('Content-Type', 'application/x-www-form-urlencoded'); - } elseif ('multipart/form-data' == $this->_requestHeaders['content-type']) { - $boundary = 'HTTP_Request_' . md5(uniqid('request') . microtime()); - $this->addHeader('Content-Type', 'multipart/form-data; boundary=' . $boundary); - } - } - - // Request Headers - if (!empty($this->_requestHeaders)) { - foreach ($this->_requestHeaders as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $request .= $canonicalName . ': ' . $value . "\r\n"; - } - } - - // Method does not allow a body, simply add a final CRLF - if (in_array($this->_method, $this->_bodyDisallowed)) { - - $request .= "\r\n"; - - // Post data if it's an array - } elseif (HTTP_REQUEST_METHOD_POST == $this->_method && - (!empty($this->_postData) || !empty($this->_postFiles))) { - - // "normal" POST request - if (!isset($boundary)) { - $postdata = implode('&', array_map( - create_function('$a', 'return $a[0] . \'=\' . $a[1];'), - $this->_flattenArray('', $this->_postData) - )); - - // multipart request, probably with file uploads - } else { - $postdata = ''; - if (!empty($this->_postData)) { - $flatData = $this->_flattenArray('', $this->_postData); - foreach ($flatData as $item) { - $postdata .= '--' . $boundary . "\r\n"; - $postdata .= 'Content-Disposition: form-data; name="' . $item[0] . '"'; - $postdata .= "\r\n\r\n" . urldecode($item[1]) . "\r\n"; - } - } - foreach ($this->_postFiles as $name => $value) { - if (is_array($value['name'])) { - $varname = $name . ($this->_useBrackets? '[]': ''); - } else { - $varname = $name; - $value['name'] = array($value['name']); - } - foreach ($value['name'] as $key => $filename) { - $fp = fopen($filename, 'r'); - $basename = basename($filename); - $type = is_array($value['type'])? @$value['type'][$key]: $value['type']; - - $postdata .= '--' . $boundary . "\r\n"; - $postdata .= 'Content-Disposition: form-data; name="' . $varname . '"; filename="' . $basename . '"'; - $postdata .= "\r\nContent-Type: " . $type; - $postdata .= "\r\n\r\n" . fread($fp, filesize($filename)) . "\r\n"; - fclose($fp); - } - } - $postdata .= '--' . $boundary . "--\r\n"; - } - $request .= 'Content-Length: ' . - (HTTP_REQUEST_MBSTRING? mb_strlen($postdata, 'iso-8859-1'): strlen($postdata)) . - "\r\n\r\n"; - $request .= $postdata; - - // Explicitly set request body - } elseif (0 < strlen($this->_body)) { - - $request .= 'Content-Length: ' . - (HTTP_REQUEST_MBSTRING? mb_strlen($this->_body, 'iso-8859-1'): strlen($this->_body)) . - "\r\n\r\n"; - $request .= $this->_body; - - // No body: send a Content-Length header nonetheless (request #12900), - // but do that only for methods that require a body (bug #14740) - } else { - - if (in_array($this->_method, $this->_bodyRequired)) { - $request .= "Content-Length: 0\r\n"; - } - $request .= "\r\n"; - } - - return $request; - } - - /** - * Helper function to change the (probably multidimensional) associative array - * into the simple one. - * - * @param string name for item - * @param mixed item's values - * @return array array with the following items: array('item name', 'item value'); - * @access private - */ - function _flattenArray($name, $values) - { - if (!is_array($values)) { - return array(array($name, $values)); - } else { - $ret = array(); - foreach ($values as $k => $v) { - if (empty($name)) { - $newName = $k; - } elseif ($this->_useBrackets) { - $newName = $name . '[' . $k . ']'; - } else { - $newName = $name; - } - $ret = array_merge($ret, $this->_flattenArray($newName, $v)); - } - return $ret; - } - } - - - /** - * Adds a Listener to the list of listeners that are notified of - * the object's events - * - * Events sent by HTTP_Request object - * - 'connect': on connection to server - * - 'sentRequest': after the request was sent - * - 'disconnect': on disconnection from server - * - * Events sent by HTTP_Response object - * - 'gotHeaders': after receiving response headers (headers are passed in $data) - * - 'tick': on receiving a part of response body (the part is passed in $data) - * - 'gzTick': on receiving a gzip-encoded part of response body (ditto) - * - 'gotBody': after receiving the response body (passes the decoded body in $data if it was gzipped) - * - * @param HTTP_Request_Listener listener to attach - * @return boolean whether the listener was successfully attached - * @access public - */ - function attach(&$listener) - { - if (!is_a($listener, 'HTTP_Request_Listener')) { - return false; - } - $this->_listeners[$listener->getId()] =& $listener; - return true; - } - - - /** - * Removes a Listener from the list of listeners - * - * @param HTTP_Request_Listener listener to detach - * @return boolean whether the listener was successfully detached - * @access public - */ - function detach(&$listener) - { - if (!is_a($listener, 'HTTP_Request_Listener') || - !isset($this->_listeners[$listener->getId()])) { - return false; - } - unset($this->_listeners[$listener->getId()]); - return true; - } - - - /** - * Notifies all registered listeners of an event. - * - * @param string Event name - * @param mixed Additional data - * @access private - * @see HTTP_Request::attach() - */ - function _notify($event, $data = null) - { - foreach (array_keys($this->_listeners) as $id) { - $this->_listeners[$id]->update($this, $event, $data); - } - } -} - - -/** - * Response class to complement the Request class - * - * @category HTTP - * @package HTTP_Request - * @author Richard Heyes - * @author Alexey Borzov - * @version Release: 1.4.4 - */ -class HTTP_Response -{ - /** - * Socket object - * @var Net_Socket - */ - var $_sock; - - /** - * Protocol - * @var string - */ - var $_protocol; - - /** - * Return code - * @var string - */ - var $_code; - - /** - * Response reason phrase - * @var string - */ - var $_reason; - - /** - * Response headers - * @var array - */ - var $_headers; - - /** - * Cookies set in response - * @var array - */ - var $_cookies; - - /** - * Response body - * @var string - */ - var $_body = ''; - - /** - * Used by _readChunked(): remaining length of the current chunk - * @var string - */ - var $_chunkLength = 0; - - /** - * Attached listeners - * @var array - */ - var $_listeners = array(); - - /** - * Bytes left to read from message-body - * @var null|int - */ - var $_toRead; - - /** - * Constructor - * - * @param Net_Socket socket to read the response from - * @param array listeners attached to request - */ - function HTTP_Response(&$sock, &$listeners) - { - $this->_sock =& $sock; - $this->_listeners =& $listeners; - } - - - /** - * Processes a HTTP response - * - * This extracts response code, headers, cookies and decodes body if it - * was encoded in some way - * - * @access public - * @param bool Whether to store response body in object property, set - * this to false if downloading a LARGE file and using a Listener. - * This is assumed to be true if body is gzip-encoded. - * @param bool Whether the response can actually have a message-body. - * Will be set to false for HEAD requests. - * @throws PEAR_Error - * @return mixed true on success, PEAR_Error in case of malformed response - */ - function process($saveBody = true, $canHaveBody = true) - { - do { - $line = $this->_sock->readLine(); - if (!preg_match('!^(HTTP/\d\.\d) (\d{3})(?: (.+))?!', $line, $s)) { - return PEAR::raiseError('Malformed response', HTTP_REQUEST_ERROR_RESPONSE); - } else { - $this->_protocol = $s[1]; - $this->_code = intval($s[2]); - $this->_reason = empty($s[3])? null: $s[3]; - } - while ('' !== ($header = $this->_sock->readLine())) { - $this->_processHeader($header); - } - } while (100 == $this->_code); - - $this->_notify('gotHeaders', $this->_headers); - - // RFC 2616, section 4.4: - // 1. Any response message which "MUST NOT" include a message-body ... - // is always terminated by the first empty line after the header fields - // 3. ... If a message is received with both a - // Transfer-Encoding header field and a Content-Length header field, - // the latter MUST be ignored. - $canHaveBody = $canHaveBody && $this->_code >= 200 && - $this->_code != 204 && $this->_code != 304; - - // If response body is present, read it and decode - $chunked = isset($this->_headers['transfer-encoding']) && ('chunked' == $this->_headers['transfer-encoding']); - $gzipped = isset($this->_headers['content-encoding']) && ('gzip' == $this->_headers['content-encoding']); - $hasBody = false; - if ($canHaveBody && ($chunked || !isset($this->_headers['content-length']) || - 0 != $this->_headers['content-length'])) - { - if ($chunked || !isset($this->_headers['content-length'])) { - $this->_toRead = null; - } else { - $this->_toRead = $this->_headers['content-length']; - } - while (!$this->_sock->eof() && (is_null($this->_toRead) || 0 < $this->_toRead)) { - if ($chunked) { - $data = $this->_readChunked(); - } elseif (is_null($this->_toRead)) { - $data = $this->_sock->read(4096); - } else { - $data = $this->_sock->read(min(4096, $this->_toRead)); - $this->_toRead -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data); - } - if ('' == $data && (!$this->_chunkLength || $this->_sock->eof())) { - break; - } else { - $hasBody = true; - if ($saveBody || $gzipped) { - $this->_body .= $data; - } - $this->_notify($gzipped? 'gzTick': 'tick', $data); - } - } - } - - if ($hasBody) { - // Uncompress the body if needed - if ($gzipped) { - $body = $this->_decodeGzip($this->_body); - if (PEAR::isError($body)) { - return $body; - } - $this->_body = $body; - $this->_notify('gotBody', $this->_body); - } else { - $this->_notify('gotBody'); - } - } - return true; - } - - - /** - * Processes the response header - * - * @access private - * @param string HTTP header - */ - function _processHeader($header) - { - if (false === strpos($header, ':')) { - return; - } - list($headername, $headervalue) = explode(':', $header, 2); - $headername = strtolower($headername); - $headervalue = ltrim($headervalue); - - if ('set-cookie' != $headername) { - if (isset($this->_headers[$headername])) { - $this->_headers[$headername] .= ',' . $headervalue; - } else { - $this->_headers[$headername] = $headervalue; - } - } else { - $this->_parseCookie($headervalue); - } - } - - - /** - * Parse a Set-Cookie header to fill $_cookies array - * - * @access private - * @param string value of Set-Cookie header - */ - function _parseCookie($headervalue) - { - $cookie = array( - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false - ); - - // Only a name=value pair - if (!strpos($headervalue, ';')) { - $pos = strpos($headervalue, '='); - $cookie['name'] = trim(substr($headervalue, 0, $pos)); - $cookie['value'] = trim(substr($headervalue, $pos + 1)); - - // Some optional parameters are supplied - } else { - $elements = explode(';', $headervalue); - $pos = strpos($elements[0], '='); - $cookie['name'] = trim(substr($elements[0], 0, $pos)); - $cookie['value'] = trim(substr($elements[0], $pos + 1)); - - for ($i = 1; $i < count($elements); $i++) { - if (false === strpos($elements[$i], '=')) { - $elName = trim($elements[$i]); - $elValue = null; - } else { - list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - } - $elName = strtolower($elName); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName || 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->_cookies[] = $cookie; - } - - - /** - * Read a part of response body encoded with chunked Transfer-Encoding - * - * @access private - * @return string - */ - function _readChunked() - { - // at start of the next chunk? - if (0 == $this->_chunkLength) { - $line = $this->_sock->readLine(); - if (preg_match('/^([0-9a-f]+)/i', $line, $matches)) { - $this->_chunkLength = hexdec($matches[1]); - // Chunk with zero length indicates the end - if (0 == $this->_chunkLength) { - $this->_sock->readLine(); // make this an eof() - return ''; - } - } else { - return ''; - } - } - $data = $this->_sock->read($this->_chunkLength); - $this->_chunkLength -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data); - if (0 == $this->_chunkLength) { - $this->_sock->readLine(); // Trailing CRLF - } - return $data; - } - - - /** - * Notifies all registered listeners of an event. - * - * @param string Event name - * @param mixed Additional data - * @access private - * @see HTTP_Request::_notify() - */ - function _notify($event, $data = null) - { - foreach (array_keys($this->_listeners) as $id) { - $this->_listeners[$id]->update($this, $event, $data); - } - } - - - /** - * Decodes the message-body encoded by gzip - * - * The real decoding work is done by gzinflate() built-in function, this - * method only parses the header and checks data for compliance with - * RFC 1952 - * - * @access private - * @param string gzip-encoded data - * @return string decoded data - */ - function _decodeGzip($data) - { - if (HTTP_REQUEST_MBSTRING) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('iso-8859-1'); - } - $length = strlen($data); - // If it doesn't look like gzip-encoded data, don't bother - if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { - return $data; - } - $method = ord(substr($data, 2, 1)); - if (8 != $method) { - return PEAR::raiseError('_decodeGzip(): unknown compression method', HTTP_REQUEST_ERROR_GZIP_METHOD); - } - $flags = ord(substr($data, 3, 1)); - if ($flags & 224) { - return PEAR::raiseError('_decodeGzip(): reserved bits are set', HTTP_REQUEST_ERROR_GZIP_DATA); - } - - // header is 10 bytes minimum. may be longer, though. - $headerLength = 10; - // extra fields, need to skip 'em - if ($flags & 4) { - if ($length - $headerLength - 2 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $extraLength = unpack('v', substr($data, 10, 2)); - if ($length - $headerLength - 2 - $extraLength[1] < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $headerLength += $extraLength[1] + 2; - } - // file name, need to skip that - if ($flags & 8) { - if ($length - $headerLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $filenameLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $headerLength += $filenameLength + 1; - } - // comment, need to skip that also - if ($flags & 16) { - if ($length - $headerLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $commentLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $headerLength += $commentLength + 1; - } - // have a CRC for header. let's check - if ($flags & 1) { - if ($length - $headerLength - 2 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA); - } - $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); - $crcStored = unpack('v', substr($data, $headerLength, 2)); - if ($crcReal != $crcStored[1]) { - return PEAR::raiseError('_decodeGzip(): header CRC check failed', HTTP_REQUEST_ERROR_GZIP_CRC); - } - $headerLength += 2; - } - // unpacked data CRC and size at the end of encoded data - $tmp = unpack('V2', substr($data, -8)); - $dataCrc = $tmp[1]; - $dataSize = $tmp[2]; - - // finally, call the gzinflate() function - // don't pass $dataSize to gzinflate, see bugs #13135, #14370 - $unpacked = gzinflate(substr($data, $headerLength, -8)); - if (false === $unpacked) { - return PEAR::raiseError('_decodeGzip(): gzinflate() call failed', HTTP_REQUEST_ERROR_GZIP_READ); - } elseif ($dataSize != strlen($unpacked)) { - return PEAR::raiseError('_decodeGzip(): data size check failed', HTTP_REQUEST_ERROR_GZIP_READ); - } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { - return PEAR::raiseError('_decodeGzip(): data CRC check failed', HTTP_REQUEST_ERROR_GZIP_CRC); - } - if (HTTP_REQUEST_MBSTRING) { - mb_internal_encoding($oldEncoding); - } - return $unpacked; - } -} // End class HTTP_Response -?> diff --git a/data/module/HTTP/Request/Listener.php b/data/module/HTTP/Request/Listener.php deleted file mode 100644 index b4fe444b35d..00000000000 --- a/data/module/HTTP/Request/Listener.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright 2002-2007 Richard Heyes - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Listener.php,v 1.3 2007/05/18 10:33:31 avb Exp $ - * @link http://pear.php.net/package/HTTP_Request/ - */ - -/** - * Listener for HTTP_Request and HTTP_Response objects - * - * This class implements the Observer part of a Subject-Observer - * design pattern. - * - * @category HTTP - * @package HTTP_Request - * @author Alexey Borzov - * @version Release: 1.4.4 - */ -class HTTP_Request_Listener -{ - /** - * A listener's identifier - * @var string - */ - var $_id; - - /** - * Constructor, sets the object's identifier - * - * @access public - */ - function HTTP_Request_Listener() - { - $this->_id = md5(uniqid('http_request_', 1)); - } - - - /** - * Returns the listener's identifier - * - * @access public - * @return string - */ - function getId() - { - return $this->_id; - } - - - /** - * This method is called when Listener is notified of an event - * - * @access public - * @param object an object the listener is attached to - * @param string Event name - * @param mixed Additional data - * @abstract - */ - function update(&$subject, $event, $data = null) - { - echo "Notified of event: '$event'\n"; - if (null !== $data) { - echo "Additional data: "; - var_dump($data); - } - } -} -?> diff --git a/data/module/MDB2.php b/data/module/MDB2.php deleted file mode 100644 index 45c0802dfb6..00000000000 --- a/data/module/MDB2.php +++ /dev/null @@ -1,4607 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: MDB2.php 328183 2012-10-29 15:10:42Z danielc $ -// - -/** - * @package MDB2 - * @category Database - * @author Lukas Smith - */ - -require_once 'PEAR.php'; - -// {{{ Error constants - -/** - * The method mapErrorCode in each MDB2_dbtype implementation maps - * native error codes to one of these. - * - * If you add an error code here, make sure you also add a textual - * version of it in MDB2::errorMessage(). - */ - -define('MDB2_OK', true); -define('MDB2_ERROR', -1); -define('MDB2_ERROR_SYNTAX', -2); -define('MDB2_ERROR_CONSTRAINT', -3); -define('MDB2_ERROR_NOT_FOUND', -4); -define('MDB2_ERROR_ALREADY_EXISTS', -5); -define('MDB2_ERROR_UNSUPPORTED', -6); -define('MDB2_ERROR_MISMATCH', -7); -define('MDB2_ERROR_INVALID', -8); -define('MDB2_ERROR_NOT_CAPABLE', -9); -define('MDB2_ERROR_TRUNCATED', -10); -define('MDB2_ERROR_INVALID_NUMBER', -11); -define('MDB2_ERROR_INVALID_DATE', -12); -define('MDB2_ERROR_DIVZERO', -13); -define('MDB2_ERROR_NODBSELECTED', -14); -define('MDB2_ERROR_CANNOT_CREATE', -15); -define('MDB2_ERROR_CANNOT_DELETE', -16); -define('MDB2_ERROR_CANNOT_DROP', -17); -define('MDB2_ERROR_NOSUCHTABLE', -18); -define('MDB2_ERROR_NOSUCHFIELD', -19); -define('MDB2_ERROR_NEED_MORE_DATA', -20); -define('MDB2_ERROR_NOT_LOCKED', -21); -define('MDB2_ERROR_VALUE_COUNT_ON_ROW', -22); -define('MDB2_ERROR_INVALID_DSN', -23); -define('MDB2_ERROR_CONNECT_FAILED', -24); -define('MDB2_ERROR_EXTENSION_NOT_FOUND',-25); -define('MDB2_ERROR_NOSUCHDB', -26); -define('MDB2_ERROR_ACCESS_VIOLATION', -27); -define('MDB2_ERROR_CANNOT_REPLACE', -28); -define('MDB2_ERROR_CONSTRAINT_NOT_NULL',-29); -define('MDB2_ERROR_DEADLOCK', -30); -define('MDB2_ERROR_CANNOT_ALTER', -31); -define('MDB2_ERROR_MANAGER', -32); -define('MDB2_ERROR_MANAGER_PARSE', -33); -define('MDB2_ERROR_LOADMODULE', -34); -define('MDB2_ERROR_INSUFFICIENT_DATA', -35); -define('MDB2_ERROR_NO_PERMISSION', -36); -define('MDB2_ERROR_DISCONNECT_FAILED', -37); - -// }}} -// {{{ Verbose constants -/** - * These are just helper constants to more verbosely express parameters to prepare() - */ - -define('MDB2_PREPARE_MANIP', false); -define('MDB2_PREPARE_RESULT', null); - -// }}} -// {{{ Fetchmode constants - -/** - * This is a special constant that tells MDB2 the user hasn't specified - * any particular get mode, so the default should be used. - */ -define('MDB2_FETCHMODE_DEFAULT', 0); - -/** - * Column data indexed by numbers, ordered from 0 and up - */ -define('MDB2_FETCHMODE_ORDERED', 1); - -/** - * Column data indexed by column names - */ -define('MDB2_FETCHMODE_ASSOC', 2); - -/** - * Column data as object properties - */ -define('MDB2_FETCHMODE_OBJECT', 3); - -/** - * For multi-dimensional results: normally the first level of arrays - * is the row number, and the second level indexed by column number or name. - * MDB2_FETCHMODE_FLIPPED switches this order, so the first level of arrays - * is the column name, and the second level the row number. - */ -define('MDB2_FETCHMODE_FLIPPED', 4); - -// }}} -// {{{ Portability mode constants - -/** - * Portability: turn off all portability features. - * @see MDB2_Driver_Common::setOption() - */ -define('MDB2_PORTABILITY_NONE', 0); - -/** - * Portability: convert names of tables and fields to case defined in the - * "field_case" option when using the query*(), fetch*() and tableInfo() methods. - * @see MDB2_Driver_Common::setOption() - */ -define('MDB2_PORTABILITY_FIX_CASE', 1); - -/** - * Portability: right trim the data output by query*() and fetch*(). - * @see MDB2_Driver_Common::setOption() - */ -define('MDB2_PORTABILITY_RTRIM', 2); - -/** - * Portability: force reporting the number of rows deleted. - * @see MDB2_Driver_Common::setOption() - */ -define('MDB2_PORTABILITY_DELETE_COUNT', 4); - -/** - * Portability: not needed in MDB2 (just left here for compatibility to DB) - * @see MDB2_Driver_Common::setOption() - */ -define('MDB2_PORTABILITY_NUMROWS', 8); - -/** - * Portability: makes certain error messages in certain drivers compatible - * with those from other DBMS's. - * - * + mysql, mysqli: change unique/primary key constraints - * MDB2_ERROR_ALREADY_EXISTS -> MDB2_ERROR_CONSTRAINT - * - * + odbc(access): MS's ODBC driver reports 'no such field' as code - * 07001, which means 'too few parameters.' When this option is on - * that code gets mapped to MDB2_ERROR_NOSUCHFIELD. - * - * @see MDB2_Driver_Common::setOption() - */ -define('MDB2_PORTABILITY_ERRORS', 16); - -/** - * Portability: convert empty values to null strings in data output by - * query*() and fetch*(). - * @see MDB2_Driver_Common::setOption() - */ -define('MDB2_PORTABILITY_EMPTY_TO_NULL', 32); - -/** - * Portability: removes database/table qualifiers from associative indexes - * @see MDB2_Driver_Common::setOption() - */ -define('MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES', 64); - -/** - * Portability: turn on all portability features. - * @see MDB2_Driver_Common::setOption() - */ -define('MDB2_PORTABILITY_ALL', 127); - -// }}} -// {{{ Globals for class instance tracking - -/** - * These are global variables that are used to track the various class instances - */ - -$GLOBALS['_MDB2_databases'] = array(); -$GLOBALS['_MDB2_dsninfo_default'] = array( - 'phptype' => false, - 'dbsyntax' => false, - 'username' => false, - 'password' => false, - 'protocol' => false, - 'hostspec' => false, - 'port' => false, - 'socket' => false, - 'database' => false, - 'mode' => false, -); - -// }}} -// {{{ class MDB2 - -/** - * The main 'MDB2' class is simply a container class with some static - * methods for creating DB objects as well as some utility functions - * common to all parts of DB. - * - * The object model of MDB2 is as follows (indentation means inheritance): - * - * MDB2 The main MDB2 class. This is simply a utility class - * with some 'static' methods for creating MDB2 objects as - * well as common utility functions for other MDB2 classes. - * - * MDB2_Driver_Common The base for each MDB2 implementation. Provides default - * | implementations (in OO lingo virtual methods) for - * | the actual DB implementations as well as a bunch of - * | query utility functions. - * | - * +-MDB2_Driver_mysql The MDB2 implementation for MySQL. Inherits MDB2_Driver_Common. - * When calling MDB2::factory or MDB2::connect for MySQL - * connections, the object returned is an instance of this - * class. - * +-MDB2_Driver_pgsql The MDB2 implementation for PostGreSQL. Inherits MDB2_Driver_Common. - * When calling MDB2::factory or MDB2::connect for PostGreSQL - * connections, the object returned is an instance of this - * class. - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2 -{ - // {{{ function setOptions($db, $options) - - /** - * set option array in an exiting database object - * - * @param MDB2_Driver_Common MDB2 object - * @param array An associative array of option names and their values. - * - * @return mixed MDB2_OK or a PEAR Error object - * - * @access public - */ - static function setOptions($db, $options) - { - if (is_array($options)) { - foreach ($options as $option => $value) { - $test = $db->setOption($option, $value); - if (MDB2::isError($test)) { - return $test; - } - } - } - return MDB2_OK; - } - - // }}} - // {{{ function classExists($classname) - - /** - * Checks if a class exists without triggering __autoload - * - * @param string classname - * - * @return bool true success and false on error - * @static - * @access public - */ - static function classExists($classname) - { - return class_exists($classname, false); - } - - // }}} - // {{{ function loadClass($class_name, $debug) - - /** - * Loads a PEAR class. - * - * @param string classname to load - * @param bool if errors should be suppressed - * - * @return mixed true success or PEAR_Error on failure - * - * @access public - */ - static function loadClass($class_name, $debug) - { - if (!MDB2::classExists($class_name)) { - $file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php'; - if ($debug) { - $include = include_once($file_name); - } else { - $include = @include_once($file_name); - } - if (!$include) { - if (!MDB2::fileExists($file_name)) { - $msg = "unable to find package '$class_name' file '$file_name'"; - } else { - $msg = "unable to load class '$class_name' from file '$file_name'"; - } - $err = MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, $msg); - return $err; - } - if (!MDB2::classExists($class_name)) { - $msg = "unable to load class '$class_name' from file '$file_name'"; - $err = MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, $msg); - return $err; - } - } - return MDB2_OK; - } - - // }}} - // {{{ function factory($dsn, $options = false) - - /** - * Create a new MDB2 object for the specified database type - * - * @param mixed 'data source name', see the MDB2::parseDSN - * method for a description of the dsn format. - * Can also be specified as an array of the - * format returned by MDB2::parseDSN. - * @param array An associative array of option names and - * their values. - * - * @return mixed a newly created MDB2 object, or false on error - * - * @access public - */ - static function factory($dsn, $options = false) - { - $dsninfo = MDB2::parseDSN($dsn); - if (empty($dsninfo['phptype'])) { - $err = MDB2::raiseError(MDB2_ERROR_NOT_FOUND, - null, null, 'no RDBMS driver specified'); - return $err; - } - $class_name = 'MDB2_Driver_'.$dsninfo['phptype']; - - $debug = (!empty($options['debug'])); - $err = MDB2::loadClass($class_name, $debug); - if (MDB2::isError($err)) { - return $err; - } - - $db = new $class_name(); - $db->setDSN($dsninfo); - $err = MDB2::setOptions($db, $options); - if (MDB2::isError($err)) { - return $err; - } - - return $db; - } - - // }}} - // {{{ function connect($dsn, $options = false) - - /** - * Create a new MDB2_Driver_* connection object and connect to the specified - * database - * - * @param mixed $dsn 'data source name', see the MDB2::parseDSN - * method for a description of the dsn format. - * Can also be specified as an array of the - * format returned by MDB2::parseDSN. - * @param array $options An associative array of option names and - * their values. - * - * @return mixed a newly created MDB2 connection object, or a MDB2 - * error object on error - * - * @access public - * @see MDB2::parseDSN - */ - static function connect($dsn, $options = false) - { - $db = MDB2::factory($dsn, $options); - if (MDB2::isError($db)) { - return $db; - } - - $err = $db->connect(); - if (MDB2::isError($err)) { - $dsn = $db->getDSN('string', 'xxx'); - $db->disconnect(); - $err->addUserInfo($dsn); - return $err; - } - - return $db; - } - - // }}} - // {{{ function singleton($dsn = null, $options = false) - - /** - * Returns a MDB2 connection with the requested DSN. - * A new MDB2 connection object is only created if no object with the - * requested DSN exists yet. - * - * @param mixed 'data source name', see the MDB2::parseDSN - * method for a description of the dsn format. - * Can also be specified as an array of the - * format returned by MDB2::parseDSN. - * @param array An associative array of option names and - * their values. - * - * @return mixed a newly created MDB2 connection object, or a MDB2 - * error object on error - * - * @access public - * @see MDB2::parseDSN - */ - static function singleton($dsn = null, $options = false) - { - if ($dsn) { - $dsninfo = MDB2::parseDSN($dsn); - $dsninfo = array_merge($GLOBALS['_MDB2_dsninfo_default'], $dsninfo); - $keys = array_keys($GLOBALS['_MDB2_databases']); - for ($i=0, $j=count($keys); $i<$j; ++$i) { - if (isset($GLOBALS['_MDB2_databases'][$keys[$i]])) { - $tmp_dsn = $GLOBALS['_MDB2_databases'][$keys[$i]]->getDSN('array'); - if (count(array_diff_assoc($tmp_dsn, $dsninfo)) == 0) { - MDB2::setOptions($GLOBALS['_MDB2_databases'][$keys[$i]], $options); - return $GLOBALS['_MDB2_databases'][$keys[$i]]; - } - } - } - } elseif (is_array($GLOBALS['_MDB2_databases']) && reset($GLOBALS['_MDB2_databases'])) { - return $GLOBALS['_MDB2_databases'][key($GLOBALS['_MDB2_databases'])]; - } - $db = MDB2::factory($dsn, $options); - return $db; - } - - // }}} - // {{{ function areEquals() - - /** - * It looks like there's a memory leak in array_diff() in PHP 5.1.x, - * so use this method instead. - * @see http://pear.php.net/bugs/bug.php?id=11790 - * - * @param array $arr1 - * @param array $arr2 - * @return boolean - */ - static function areEquals($arr1, $arr2) - { - if (count($arr1) != count($arr2)) { - return false; - } - foreach (array_keys($arr1) as $k) { - if (!array_key_exists($k, $arr2) || $arr1[$k] != $arr2[$k]) { - return false; - } - } - return true; - } - - // }}} - // {{{ function loadFile($file) - - /** - * load a file (like 'Date') - * - * @param string $file name of the file in the MDB2 directory (without '.php') - * - * @return string name of the file that was included - * - * @access public - */ - static function loadFile($file) - { - $file_name = 'MDB2'.DIRECTORY_SEPARATOR.$file.'.php'; - if (!MDB2::fileExists($file_name)) { - return MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'unable to find: '.$file_name); - } - if (!include_once($file_name)) { - return MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'unable to load driver class: '.$file_name); - } - return $file_name; - } - - // }}} - // {{{ function apiVersion() - - /** - * Return the MDB2 API version - * - * @return string the MDB2 API version number - * - * @access public - */ - static function apiVersion() - { - return '2.5.0b5'; - } - - // }}} - // {{{ function &raiseError($code = null, $mode = null, $options = null, $userinfo = null) - - /** - * This method is used to communicate an error and invoke error - * callbacks etc. Basically a wrapper for PEAR::raiseError - * without the message string. - * - * @param mixed int error code - * - * @param int error mode, see PEAR_Error docs - * - * @param mixed If error mode is PEAR_ERROR_TRIGGER, this is the - * error level (E_USER_NOTICE etc). If error mode is - * PEAR_ERROR_CALLBACK, this is the callback function, - * either as a function name, or as an array of an - * object and method name. For other error modes this - * parameter is ignored. - * - * @param string Extra debug information. Defaults to the last - * query and native error code. - * - * @return PEAR_Error instance of a PEAR Error object - * - * @access private - * @see PEAR_Error - */ - public static function &raiseError($code = null, - $mode = null, - $options = null, - $userinfo = null, - $dummy1 = null, - $dummy2 = null, - $dummy3 = false) - { - $pear = new PEAR; - $err =& $pear->raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true); - return $err; - } - - // }}} - // {{{ function isError($data, $code = null) - - /** - * Tell whether a value is a MDB2 error. - * - * @param mixed the value to test - * @param int if is an error object, return true - * only if $code is a string and - * $db->getMessage() == $code or - * $code is an integer and $db->getCode() == $code - * - * @return bool true if parameter is an error - * - * @access public - */ - static function isError($data, $code = null) - { - if ($data instanceof MDB2_Error) { - if (null === $code) { - return true; - } - if (is_string($code)) { - return $data->getMessage() === $code; - } - return in_array($data->getCode(), (array)$code); - } - return false; - } - - // }}} - // {{{ function isConnection($value) - - /** - * Tell whether a value is a MDB2 connection - * - * @param mixed value to test - * - * @return bool whether $value is a MDB2 connection - * @access public - */ - static function isConnection($value) - { - return ($value instanceof MDB2_Driver_Common); - } - - // }}} - // {{{ function isResult($value) - - /** - * Tell whether a value is a MDB2 result - * - * @param mixed $value value to test - * - * @return bool whether $value is a MDB2 result - * - * @access public - */ - static function isResult($value) - { - return ($value instanceof MDB2_Result); - } - - // }}} - // {{{ function isResultCommon($value) - - /** - * Tell whether a value is a MDB2 result implementing the common interface - * - * @param mixed $value value to test - * - * @return bool whether $value is a MDB2 result implementing the common interface - * - * @access public - */ - static function isResultCommon($value) - { - return ($value instanceof MDB2_Result_Common); - } - - // }}} - // {{{ function isStatement($value) - - /** - * Tell whether a value is a MDB2 statement interface - * - * @param mixed value to test - * - * @return bool whether $value is a MDB2 statement interface - * - * @access public - */ - static function isStatement($value) - { - return ($value instanceof MDB2_Statement_Common); - } - - // }}} - // {{{ function errorMessage($value = null) - - /** - * Return a textual error message for a MDB2 error code - * - * @param int|array integer error code, - null to get the current error code-message map, - or an array with a new error code-message map - * - * @return string error message, or false if the error code was - * not recognized - * - * @access public - */ - static function errorMessage($value = null) - { - static $errorMessages; - - if (is_array($value)) { - $errorMessages = $value; - return MDB2_OK; - } - - if (!isset($errorMessages)) { - $errorMessages = array( - MDB2_OK => 'no error', - MDB2_ERROR => 'unknown error', - MDB2_ERROR_ALREADY_EXISTS => 'already exists', - MDB2_ERROR_CANNOT_CREATE => 'can not create', - MDB2_ERROR_CANNOT_ALTER => 'can not alter', - MDB2_ERROR_CANNOT_REPLACE => 'can not replace', - MDB2_ERROR_CANNOT_DELETE => 'can not delete', - MDB2_ERROR_CANNOT_DROP => 'can not drop', - MDB2_ERROR_CONSTRAINT => 'constraint violation', - MDB2_ERROR_CONSTRAINT_NOT_NULL=> 'null value violates not-null constraint', - MDB2_ERROR_DIVZERO => 'division by zero', - MDB2_ERROR_INVALID => 'invalid', - MDB2_ERROR_INVALID_DATE => 'invalid date or time', - MDB2_ERROR_INVALID_NUMBER => 'invalid number', - MDB2_ERROR_MISMATCH => 'mismatch', - MDB2_ERROR_NODBSELECTED => 'no database selected', - MDB2_ERROR_NOSUCHFIELD => 'no such field', - MDB2_ERROR_NOSUCHTABLE => 'no such table', - MDB2_ERROR_NOT_CAPABLE => 'MDB2 backend not capable', - MDB2_ERROR_NOT_FOUND => 'not found', - MDB2_ERROR_NOT_LOCKED => 'not locked', - MDB2_ERROR_SYNTAX => 'syntax error', - MDB2_ERROR_UNSUPPORTED => 'not supported', - MDB2_ERROR_VALUE_COUNT_ON_ROW => 'value count on row', - MDB2_ERROR_INVALID_DSN => 'invalid DSN', - MDB2_ERROR_CONNECT_FAILED => 'connect failed', - MDB2_ERROR_NEED_MORE_DATA => 'insufficient data supplied', - MDB2_ERROR_EXTENSION_NOT_FOUND=> 'extension not found', - MDB2_ERROR_NOSUCHDB => 'no such database', - MDB2_ERROR_ACCESS_VIOLATION => 'insufficient permissions', - MDB2_ERROR_LOADMODULE => 'error while including on demand module', - MDB2_ERROR_TRUNCATED => 'truncated', - MDB2_ERROR_DEADLOCK => 'deadlock detected', - MDB2_ERROR_NO_PERMISSION => 'no permission', - MDB2_ERROR_DISCONNECT_FAILED => 'disconnect failed', - ); - } - - if (null === $value) { - return $errorMessages; - } - - if (MDB2::isError($value)) { - $value = $value->getCode(); - } - - return isset($errorMessages[$value]) ? - $errorMessages[$value] : $errorMessages[MDB2_ERROR]; - } - - // }}} - // {{{ function parseDSN($dsn) - - /** - * Parse a data source name. - * - * Additional keys can be added by appending a URI query string to the - * end of the DSN. - * - * The format of the supplied DSN is in its fullest form: - * - * phptype(dbsyntax)://username:password@protocol+hostspec/database?option=8&another=true - * - * - * Most variations are allowed: - * - * phptype://username:password@protocol+hostspec:110//usr/db_file.db?mode=0644 - * phptype://username:password@hostspec/database_name - * phptype://username:password@hostspec - * phptype://username@hostspec - * phptype://hostspec/database - * phptype://hostspec - * phptype(dbsyntax) - * phptype - * - * - * @param string Data Source Name to be parsed - * - * @return array an associative array with the following keys: - * + phptype: Database backend used in PHP (mysql, odbc etc.) - * + dbsyntax: Database used with regards to SQL syntax etc. - * + protocol: Communication protocol to use (tcp, unix etc.) - * + hostspec: Host specification (hostname[:port]) - * + database: Database to use on the DBMS server - * + username: User name for login - * + password: Password for login - * - * @access public - * @author Tomas V.V.Cox - */ - static function parseDSN($dsn) - { - $parsed = $GLOBALS['_MDB2_dsninfo_default']; - - if (is_array($dsn)) { - $dsn = array_merge($parsed, $dsn); - if (!$dsn['dbsyntax']) { - $dsn['dbsyntax'] = $dsn['phptype']; - } - return $dsn; - } - - // Find phptype and dbsyntax - if (($pos = strpos($dsn, '://')) !== false) { - $str = substr($dsn, 0, $pos); - $dsn = substr($dsn, $pos + 3); - } else { - $str = $dsn; - $dsn = null; - } - - // Get phptype and dbsyntax - // $str => phptype(dbsyntax) - if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { - $parsed['phptype'] = $arr[1]; - $parsed['dbsyntax'] = !$arr[2] ? $arr[1] : $arr[2]; - } else { - $parsed['phptype'] = $str; - $parsed['dbsyntax'] = $str; - } - - if (!count($dsn)) { - return $parsed; - } - - // Get (if found): username and password - // $dsn => username:password@protocol+hostspec/database - if (($at = strrpos($dsn,'@')) !== false) { - $str = substr($dsn, 0, $at); - $dsn = substr($dsn, $at + 1); - if (($pos = strpos($str, ':')) !== false) { - $parsed['username'] = rawurldecode(substr($str, 0, $pos)); - $parsed['password'] = rawurldecode(substr($str, $pos + 1)); - } else { - $parsed['username'] = rawurldecode($str); - } - } - - // Find protocol and hostspec - - // $dsn => proto(proto_opts)/database - if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { - $proto = $match[1]; - $proto_opts = $match[2] ? $match[2] : false; - $dsn = $match[3]; - - // $dsn => protocol+hostspec/database (old format) - } else { - if (strpos($dsn, '+') !== false) { - list($proto, $dsn) = explode('+', $dsn, 2); - } - if ( strpos($dsn, '//') === 0 - && strpos($dsn, '/', 2) !== false - && $parsed['phptype'] == 'oci8' - ) { - //oracle's "Easy Connect" syntax: - //"username/password@[//]host[:port][/service_name]" - //e.g. "scott/tiger@//mymachine:1521/oracle" - $proto_opts = $dsn; - $pos = strrpos($proto_opts, '/'); - $dsn = substr($proto_opts, $pos + 1); - $proto_opts = substr($proto_opts, 0, $pos); - } elseif (strpos($dsn, '/') !== false) { - list($proto_opts, $dsn) = explode('/', $dsn, 2); - } else { - $proto_opts = $dsn; - $dsn = null; - } - } - - // process the different protocol options - $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp'; - $proto_opts = rawurldecode($proto_opts); - if (strpos($proto_opts, ':') !== false) { - list($proto_opts, $parsed['port']) = explode(':', $proto_opts); - } - if ($parsed['protocol'] == 'tcp') { - $parsed['hostspec'] = $proto_opts; - } elseif ($parsed['protocol'] == 'unix') { - $parsed['socket'] = $proto_opts; - } - - // Get dabase if any - // $dsn => database - if ($dsn) { - // /database - if (($pos = strpos($dsn, '?')) === false) { - $parsed['database'] = rawurldecode($dsn); - // /database?param1=value1¶m2=value2 - } else { - $parsed['database'] = rawurldecode(substr($dsn, 0, $pos)); - $dsn = substr($dsn, $pos + 1); - if (strpos($dsn, '&') !== false) { - $opts = explode('&', $dsn); - } else { // database?param1=value1 - $opts = array($dsn); - } - foreach ($opts as $opt) { - list($key, $value) = explode('=', $opt); - if (!array_key_exists($key, $parsed) || false === $parsed[$key]) { - // don't allow params overwrite - $parsed[$key] = rawurldecode($value); - } - } - } - } - - return $parsed; - } - - // }}} - // {{{ function fileExists($file) - - /** - * Checks if a file exists in the include path - * - * @param string filename - * - * @return bool true success and false on error - * - * @access public - */ - static function fileExists($file) - { - // safe_mode does notwork with is_readable() - if (!@ini_get('safe_mode')) { - $dirs = explode(PATH_SEPARATOR, ini_get('include_path')); - foreach ($dirs as $dir) { - if (is_readable($dir . DIRECTORY_SEPARATOR . $file)) { - return true; - } - } - } else { - $fp = @fopen($file, 'r', true); - if (is_resource($fp)) { - @fclose($fp); - return true; - } - } - return false; - } - // }}} -} - -// }}} -// {{{ class MDB2_Error extends PEAR_Error - -/** - * MDB2_Error implements a class for reporting portable database error - * messages. - * - * @package MDB2 - * @category Database - * @author Stig Bakken - */ -class MDB2_Error extends PEAR_Error -{ - // {{{ constructor: function MDB2_Error($code = MDB2_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null) - - /** - * MDB2_Error constructor. - * - * @param mixed MDB2 error code, or string with error message. - * @param int what 'error mode' to operate in - * @param int what error level to use for $mode & PEAR_ERROR_TRIGGER - * @param mixed additional debug info, such as the last query - */ - function __construct($code = MDB2_ERROR, $mode = PEAR_ERROR_RETURN, - $level = E_USER_NOTICE, $debuginfo = null, $dummy = null) - { - if (null === $code) { - $code = MDB2_ERROR; - } - $this->PEAR_Error('MDB2 Error: '.MDB2::errorMessage($code), $code, - $mode, $level, $debuginfo); - } - - // }}} -} - -// }}} -// {{{ class MDB2_Driver_Common extends PEAR - -/** - * MDB2_Driver_Common: Base class that is extended by each MDB2 driver - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Common -{ - // {{{ Variables (Properties) - - /** - * @var MDB2_Driver_Datatype_Common - */ - public $datatype; - - /** - * @var MDB2_Extended - */ - public $extended; - - /** - * @var MDB2_Driver_Function_Common - */ - public $function; - - /** - * @var MDB2_Driver_Manager_Common - */ - public $manager; - - /** - * @var MDB2_Driver_Native_Commonn - */ - public $native; - - /** - * @var MDB2_Driver_Reverse_Common - */ - public $reverse; - - /** - * index of the MDB2 object within the $GLOBALS['_MDB2_databases'] array - * @var int - * @access public - */ - public $db_index = 0; - - /** - * DSN used for the next query - * @var array - * @access protected - */ - public $dsn = array(); - - /** - * DSN that was used to create the current connection - * @var array - * @access protected - */ - public $connected_dsn = array(); - - /** - * connection resource - * @var mixed - * @access protected - */ - public $connection = 0; - - /** - * if the current opened connection is a persistent connection - * @var bool - * @access protected - */ - public $opened_persistent; - - /** - * the name of the database for the next query - * @var string - * @access public - */ - public $database_name = ''; - - /** - * the name of the database currently selected - * @var string - * @access protected - */ - public $connected_database_name = ''; - - /** - * server version information - * @var string - * @access protected - */ - public $connected_server_info = ''; - - /** - * list of all supported features of the given driver - * @var array - * @access public - */ - public $supported = array( - 'sequences' => false, - 'indexes' => false, - 'affected_rows' => false, - 'summary_functions' => false, - 'order_by_text' => false, - 'transactions' => false, - 'savepoints' => false, - 'current_id' => false, - 'limit_queries' => false, - 'LOBs' => false, - 'replace' => false, - 'sub_selects' => false, - 'triggers' => false, - 'auto_increment' => false, - 'primary_key' => false, - 'result_introspection' => false, - 'prepared_statements' => false, - 'identifier_quoting' => false, - 'pattern_escaping' => false, - 'new_link' => false, - ); - - /** - * Array of supported options that can be passed to the MDB2 instance. - * - * The options can be set during object creation, using - * MDB2::connect(), MDB2::factory() or MDB2::singleton(). The options can - * also be set after the object is created, using MDB2::setOptions() or - * MDB2_Driver_Common::setOption(). - * The list of available option includes: - *
    - *
  • $options['ssl'] -> boolean: determines if ssl should be used for connections
  • - *
  • $options['field_case'] -> CASE_LOWER|CASE_UPPER: determines what case to force on field/table names
  • - *
  • $options['disable_query'] -> boolean: determines if queries should be executed
  • - *
  • $options['result_class'] -> string: class used for result sets
  • - *
  • $options['buffered_result_class'] -> string: class used for buffered result sets
  • - *
  • $options['result_wrap_class'] -> string: class used to wrap result sets into
  • - *
  • $options['result_buffering'] -> boolean should results be buffered or not?
  • - *
  • $options['fetch_class'] -> string: class to use when fetch mode object is used
  • - *
  • $options['persistent'] -> boolean: persistent connection?
  • - *
  • $options['debug'] -> integer: numeric debug level
  • - *
  • $options['debug_handler'] -> string: function/method that captures debug messages
  • - *
  • $options['debug_expanded_output'] -> bool: BC option to determine if more context information should be send to the debug handler
  • - *
  • $options['default_text_field_length'] -> integer: default text field length to use
  • - *
  • $options['lob_buffer_length'] -> integer: LOB buffer length
  • - *
  • $options['log_line_break'] -> string: line-break format
  • - *
  • $options['idxname_format'] -> string: pattern for index name
  • - *
  • $options['seqname_format'] -> string: pattern for sequence name
  • - *
  • $options['savepoint_format'] -> string: pattern for auto generated savepoint names
  • - *
  • $options['statement_format'] -> string: pattern for prepared statement names
  • - *
  • $options['seqcol_name'] -> string: sequence column name
  • - *
  • $options['quote_identifier'] -> boolean: if identifier quoting should be done when check_option is used
  • - *
  • $options['use_transactions'] -> boolean: if transaction use should be enabled
  • - *
  • $options['decimal_places'] -> integer: number of decimal places to handle
  • - *
  • $options['portability'] -> integer: portability constant
  • - *
  • $options['modules'] -> array: short to long module name mapping for __call()
  • - *
  • $options['emulate_prepared'] -> boolean: force prepared statements to be emulated
  • - *
  • $options['datatype_map'] -> array: map user defined datatypes to other primitive datatypes
  • - *
  • $options['datatype_map_callback'] -> array: callback function/method that should be called
  • - *
  • $options['bindname_format'] -> string: regular expression pattern for named parameters
  • - *
  • $options['multi_query'] -> boolean: determines if queries returning multiple result sets should be executed
  • - *
  • $options['max_identifiers_length'] -> integer: max identifier length
  • - *
  • $options['default_fk_action_onupdate'] -> string: default FOREIGN KEY ON UPDATE action ['RESTRICT'|'NO ACTION'|'SET DEFAULT'|'SET NULL'|'CASCADE']
  • - *
  • $options['default_fk_action_ondelete'] -> string: default FOREIGN KEY ON DELETE action ['RESTRICT'|'NO ACTION'|'SET DEFAULT'|'SET NULL'|'CASCADE']
  • - *
- * - * @var array - * @access public - * @see MDB2::connect() - * @see MDB2::factory() - * @see MDB2::singleton() - * @see MDB2_Driver_Common::setOption() - */ - public $options = array( - 'ssl' => false, - 'field_case' => CASE_LOWER, - 'disable_query' => false, - 'result_class' => 'MDB2_Result_%s', - 'buffered_result_class' => 'MDB2_BufferedResult_%s', - 'result_wrap_class' => false, - 'result_buffering' => true, - 'fetch_class' => 'stdClass', - 'persistent' => false, - 'debug' => 0, - 'debug_handler' => 'MDB2_defaultDebugOutput', - 'debug_expanded_output' => false, - 'default_text_field_length' => 4096, - 'lob_buffer_length' => 8192, - 'log_line_break' => "\n", - 'idxname_format' => '%s_idx', - 'seqname_format' => '%s_seq', - 'savepoint_format' => 'MDB2_SAVEPOINT_%s', - 'statement_format' => 'MDB2_STATEMENT_%1$s_%2$s', - 'seqcol_name' => 'sequence', - 'quote_identifier' => false, - 'use_transactions' => true, - 'decimal_places' => 2, - 'portability' => MDB2_PORTABILITY_ALL, - 'modules' => array( - 'ex' => 'Extended', - 'dt' => 'Datatype', - 'mg' => 'Manager', - 'rv' => 'Reverse', - 'na' => 'Native', - 'fc' => 'Function', - ), - 'emulate_prepared' => false, - 'datatype_map' => array(), - 'datatype_map_callback' => array(), - 'nativetype_map_callback' => array(), - 'lob_allow_url_include' => false, - 'bindname_format' => '(?:\d+)|(?:[a-zA-Z][a-zA-Z0-9_]*)', - 'max_identifiers_length' => 30, - 'default_fk_action_onupdate' => 'RESTRICT', - 'default_fk_action_ondelete' => 'RESTRICT', - ); - - /** - * string array - * @var string - * @access public - */ - public $string_quoting = array( - 'start' => "'", - 'end' => "'", - 'escape' => false, - 'escape_pattern' => false, - ); - - /** - * identifier quoting - * @var array - * @access public - */ - public $identifier_quoting = array( - 'start' => '"', - 'end' => '"', - 'escape' => '"', - ); - - /** - * sql comments - * @var array - * @access protected - */ - public $sql_comments = array( - array('start' => '--', 'end' => "\n", 'escape' => false), - array('start' => '/*', 'end' => '*/', 'escape' => false), - ); - - /** - * comparision wildcards - * @var array - * @access protected - */ - protected $wildcards = array('%', '_'); - - /** - * column alias keyword - * @var string - * @access protected - */ - public $as_keyword = ' AS '; - - /** - * warnings - * @var array - * @access protected - */ - public $warnings = array(); - - /** - * string with the debugging information - * @var string - * @access public - */ - public $debug_output = ''; - - /** - * determine if there is an open transaction - * @var bool - * @access protected - */ - public $in_transaction = false; - - /** - * the smart transaction nesting depth - * @var int - * @access protected - */ - public $nested_transaction_counter = null; - - /** - * the first error that occured inside a nested transaction - * @var MDB2_Error|bool - * @access protected - */ - protected $has_transaction_error = false; - - /** - * result offset used in the next query - * @var int - * @access public - */ - public $offset = 0; - - /** - * result limit used in the next query - * @var int - * @access public - */ - public $limit = 0; - - /** - * Database backend used in PHP (mysql, odbc etc.) - * @var string - * @access public - */ - public $phptype; - - /** - * Database used with regards to SQL syntax etc. - * @var string - * @access public - */ - public $dbsyntax; - - /** - * the last query sent to the driver - * @var string - * @access public - */ - public $last_query; - - /** - * the default fetchmode used - * @var int - * @access public - */ - public $fetchmode = MDB2_FETCHMODE_ORDERED; - - /** - * array of module instances - * @var array - * @access protected - */ - protected $modules = array(); - - /** - * determines of the PHP4 destructor emulation has been enabled yet - * @var array - * @access protected - */ - protected $destructor_registered = true; - - /** - * @var PEAR - */ - protected $pear; - - // }}} - // {{{ constructor: function __construct() - - /** - * Constructor - */ - function __construct() - { - end($GLOBALS['_MDB2_databases']); - $db_index = key($GLOBALS['_MDB2_databases']) + 1; - $GLOBALS['_MDB2_databases'][$db_index] = &$this; - $this->db_index = $db_index; - $this->pear = new PEAR; - } - - // }}} - // {{{ destructor: function __destruct() - - /** - * Destructor - */ - function __destruct() - { - $this->disconnect(false); - } - - // }}} - // {{{ function free() - - /** - * Free the internal references so that the instance can be destroyed - * - * @return bool true on success, false if result is invalid - * - * @access public - */ - function free() - { - unset($GLOBALS['_MDB2_databases'][$this->db_index]); - unset($this->db_index); - return MDB2_OK; - } - - // }}} - // {{{ function __toString() - - /** - * String conversation - * - * @return string representation of the object - * - * @access public - */ - function __toString() - { - $info = get_class($this); - $info.= ': (phptype = '.$this->phptype.', dbsyntax = '.$this->dbsyntax.')'; - if ($this->connection) { - $info.= ' [connected]'; - } - return $info; - } - - // }}} - // {{{ function errorInfo($error = null) - - /** - * This method is used to collect information about an error - * - * @param mixed error code or resource - * - * @return array with MDB2 errorcode, native error code, native message - * - * @access public - */ - function errorInfo($error = null) - { - return array($error, null, null); - } - - // }}} - // {{{ function &raiseError($code = null, $mode = null, $options = null, $userinfo = null) - - /** - * This method is used to communicate an error and invoke error - * callbacks etc. Basically a wrapper for PEAR::raiseError - * without the message string. - * - * @param mixed $code integer error code, or a PEAR error object (all - * other parameters are ignored if this parameter is - * an object - * @param int $mode error mode, see PEAR_Error docs - * @param mixed $options If error mode is PEAR_ERROR_TRIGGER, this is the - * error level (E_USER_NOTICE etc). If error mode is - * PEAR_ERROR_CALLBACK, this is the callback function, - * either as a function name, or as an array of an - * object and method name. For other error modes this - * parameter is ignored. - * @param string $userinfo Extra debug information. Defaults to the last - * query and native error code. - * @param string $method name of the method that triggered the error - * @param string $dummy1 not used - * @param bool $dummy2 not used - * - * @return PEAR_Error instance of a PEAR Error object - * @access public - * @see PEAR_Error - */ - function &raiseError($code = null, - $mode = null, - $options = null, - $userinfo = null, - $method = null, - $dummy1 = null, - $dummy2 = false - ) { - $userinfo = "[Error message: $userinfo]\n"; - // The error is yet a MDB2 error object - if (MDB2::isError($code)) { - // because we use the static PEAR::raiseError, our global - // handler should be used if it is set - if ((null === $mode) && !empty($this->_default_error_mode)) { - $mode = $this->_default_error_mode; - $options = $this->_default_error_options; - } - if (null === $userinfo) { - $userinfo = $code->getUserinfo(); - } - $code = $code->getCode(); - } elseif ($code == MDB2_ERROR_NOT_FOUND) { - // extension not loaded: don't call $this->errorInfo() or the script - // will die - } elseif (isset($this->connection)) { - if (!empty($this->last_query)) { - $userinfo.= "[Last executed query: {$this->last_query}]\n"; - } - $native_errno = $native_msg = null; - list($code, $native_errno, $native_msg) = $this->errorInfo($code); - if ((null !== $native_errno) && $native_errno !== '') { - $userinfo.= "[Native code: $native_errno]\n"; - } - if ((null !== $native_msg) && $native_msg !== '') { - $userinfo.= "[Native message: ". strip_tags($native_msg) ."]\n"; - } - if (null !== $method) { - $userinfo = $method.': '.$userinfo; - } - } - - $err = $this->pear->raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true); - if ($err->getMode() !== PEAR_ERROR_RETURN - && isset($this->nested_transaction_counter) && !$this->has_transaction_error) { - $this->has_transaction_error = $err; - } - return $err; - } - - // }}} - // {{{ function resetWarnings() - - /** - * reset the warning array - * - * @return void - * - * @access public - */ - function resetWarnings() - { - $this->warnings = array(); - } - - // }}} - // {{{ function getWarnings() - - /** - * Get all warnings in reverse order. - * This means that the last warning is the first element in the array - * - * @return array with warnings - * - * @access public - * @see resetWarnings() - */ - function getWarnings() - { - return array_reverse($this->warnings); - } - - // }}} - // {{{ function setFetchMode($fetchmode, $object_class = 'stdClass') - - /** - * Sets which fetch mode should be used by default on queries - * on this connection - * - * @param int MDB2_FETCHMODE_ORDERED, MDB2_FETCHMODE_ASSOC - * or MDB2_FETCHMODE_OBJECT - * @param string the class name of the object to be returned - * by the fetch methods when the - * MDB2_FETCHMODE_OBJECT mode is selected. - * If no class is specified by default a cast - * to object from the assoc array row will be - * done. There is also the possibility to use - * and extend the 'MDB2_row' class. - * - * @return mixed MDB2_OK or MDB2 Error Object - * - * @access public - * @see MDB2_FETCHMODE_ORDERED, MDB2_FETCHMODE_ASSOC, MDB2_FETCHMODE_OBJECT - */ - function setFetchMode($fetchmode, $object_class = 'stdClass') - { - switch ($fetchmode) { - case MDB2_FETCHMODE_OBJECT: - $this->options['fetch_class'] = $object_class; - case MDB2_FETCHMODE_ORDERED: - case MDB2_FETCHMODE_ASSOC: - $this->fetchmode = $fetchmode; - break; - default: - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'invalid fetchmode mode', __FUNCTION__); - } - - return MDB2_OK; - } - - // }}} - // {{{ function setOption($option, $value) - - /** - * set the option for the db class - * - * @param string option name - * @param mixed value for the option - * - * @return mixed MDB2_OK or MDB2 Error Object - * - * @access public - */ - function setOption($option, $value) - { - if (array_key_exists($option, $this->options)) { - $this->options[$option] = $value; - return MDB2_OK; - } - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - "unknown option $option", __FUNCTION__); - } - - // }}} - // {{{ function getOption($option) - - /** - * Returns the value of an option - * - * @param string option name - * - * @return mixed the option value or error object - * - * @access public - */ - function getOption($option) - { - if (array_key_exists($option, $this->options)) { - return $this->options[$option]; - } - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - "unknown option $option", __FUNCTION__); - } - - // }}} - // {{{ function debug($message, $scope = '', $is_manip = null) - - /** - * set a debug message - * - * @param string message that should be appended to the debug variable - * @param string usually the method name that triggered the debug call: - * for example 'query', 'prepare', 'execute', 'parameters', - * 'beginTransaction', 'commit', 'rollback' - * @param array contains context information about the debug() call - * common keys are: is_manip, time, result etc. - * - * @return void - * - * @access public - */ - function debug($message, $scope = '', $context = array()) - { - if ($this->options['debug'] && $this->options['debug_handler']) { - if (!$this->options['debug_expanded_output']) { - if (!empty($context['when']) && $context['when'] !== 'pre') { - return null; - } - $context = empty($context['is_manip']) ? false : $context['is_manip']; - } - return call_user_func_array($this->options['debug_handler'], array(&$this, $scope, $message, $context)); - } - return null; - } - - // }}} - // {{{ function getDebugOutput() - - /** - * output debug info - * - * @return string content of the debug_output class variable - * - * @access public - */ - function getDebugOutput() - { - return $this->debug_output; - } - - // }}} - // {{{ function escape($text) - - /** - * Quotes a string so it can be safely used in a query. It will quote - * the text so it can safely be used within a query. - * - * @param string the input string to quote - * @param bool escape wildcards - * - * @return string quoted string - * - * @access public - */ - function escape($text, $escape_wildcards = false) - { - if ($escape_wildcards) { - $text = $this->escapePattern($text); - } - - $text = str_replace($this->string_quoting['end'], $this->string_quoting['escape'] . $this->string_quoting['end'], $text); - return $text; - } - - // }}} - // {{{ function escapePattern($text) - - /** - * Quotes pattern (% and _) characters in a string) - * - * @param string the input string to quote - * - * @return string quoted string - * - * @access public - */ - function escapePattern($text) - { - if ($this->string_quoting['escape_pattern']) { - $text = str_replace($this->string_quoting['escape_pattern'], $this->string_quoting['escape_pattern'] . $this->string_quoting['escape_pattern'], $text); - foreach ($this->wildcards as $wildcard) { - $text = str_replace($wildcard, $this->string_quoting['escape_pattern'] . $wildcard, $text); - } - } - return $text; - } - - // }}} - // {{{ function quoteIdentifier($str, $check_option = false) - - /** - * Quote a string so it can be safely used as a table or column name - * - * Delimiting style depends on which database driver is being used. - * - * NOTE: just because you CAN use delimited identifiers doesn't mean - * you SHOULD use them. In general, they end up causing way more - * problems than they solve. - * - * NOTE: if you have table names containing periods, don't use this method - * (@see bug #11906) - * - * Portability is broken by using the following characters inside - * delimited identifiers: - * + backtick (`) -- due to MySQL - * + double quote (") -- due to Oracle - * + brackets ([ or ]) -- due to Access - * - * Delimited identifiers are known to generally work correctly under - * the following drivers: - * + mssql - * + mysql - * + mysqli - * + oci8 - * + pgsql - * + sqlite - * - * InterBase doesn't seem to be able to use delimited identifiers - * via PHP 4. They work fine under PHP 5. - * - * @param string identifier name to be quoted - * @param bool check the 'quote_identifier' option - * - * @return string quoted identifier string - * - * @access public - */ - function quoteIdentifier($str, $check_option = false) - { - if ($check_option && !$this->options['quote_identifier']) { - return $str; - } - $str = str_replace($this->identifier_quoting['end'], $this->identifier_quoting['escape'] . $this->identifier_quoting['end'], $str); - $parts = explode('.', $str); - foreach (array_keys($parts) as $k) { - $parts[$k] = $this->identifier_quoting['start'] . $parts[$k] . $this->identifier_quoting['end']; - } - return implode('.', $parts); - } - - // }}} - // {{{ function getAsKeyword() - - /** - * Gets the string to alias column - * - * @return string to use when aliasing a column - */ - function getAsKeyword() - { - return $this->as_keyword; - } - - // }}} - // {{{ function getConnection() - - /** - * Returns a native connection - * - * @return mixed a valid MDB2 connection object, - * or a MDB2 error object on error - * - * @access public - */ - function getConnection() - { - $result = $this->connect(); - if (MDB2::isError($result)) { - return $result; - } - return $this->connection; - } - - // }}} - // {{{ function _fixResultArrayValues(&$row, $mode) - - /** - * Do all necessary conversions on result arrays to fix DBMS quirks - * - * @param array the array to be fixed (passed by reference) - * @param array bit-wise addition of the required portability modes - * - * @return void - * - * @access protected - */ - function _fixResultArrayValues(&$row, $mode) - { - switch ($mode) { - case MDB2_PORTABILITY_EMPTY_TO_NULL: - foreach ($row as $key => $value) { - if ($value === '') { - $row[$key] = null; - } - } - break; - case MDB2_PORTABILITY_RTRIM: - foreach ($row as $key => $value) { - if (is_string($value)) { - $row[$key] = rtrim($value); - } - } - break; - case MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES: - $tmp_row = array(); - foreach ($row as $key => $value) { - $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value; - } - $row = $tmp_row; - break; - case (MDB2_PORTABILITY_RTRIM + MDB2_PORTABILITY_EMPTY_TO_NULL): - foreach ($row as $key => $value) { - if ($value === '') { - $row[$key] = null; - } elseif (is_string($value)) { - $row[$key] = rtrim($value); - } - } - break; - case (MDB2_PORTABILITY_RTRIM + MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES): - $tmp_row = array(); - foreach ($row as $key => $value) { - if (is_string($value)) { - $value = rtrim($value); - } - $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value; - } - $row = $tmp_row; - break; - case (MDB2_PORTABILITY_EMPTY_TO_NULL + MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES): - $tmp_row = array(); - foreach ($row as $key => $value) { - if ($value === '') { - $value = null; - } - $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value; - } - $row = $tmp_row; - break; - case (MDB2_PORTABILITY_RTRIM + MDB2_PORTABILITY_EMPTY_TO_NULL + MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES): - $tmp_row = array(); - foreach ($row as $key => $value) { - if ($value === '') { - $value = null; - } elseif (is_string($value)) { - $value = rtrim($value); - } - $tmp_row[preg_replace('/^(?:.*\.)?([^.]+)$/', '\\1', $key)] = $value; - } - $row = $tmp_row; - break; - } - } - - // }}} - // {{{ function loadModule($module, $property = null, $phptype_specific = null) - - /** - * loads a module - * - * @param string name of the module that should be loaded - * (only used for error messages) - * @param string name of the property into which the class will be loaded - * @param bool if the class to load for the module is specific to the - * phptype - * - * @return object on success a reference to the given module is returned - * and on failure a PEAR error - * - * @access public - */ - function loadModule($module, $property = null, $phptype_specific = null) - { - if (!$property) { - $property = strtolower($module); - } - - if (!isset($this->{$property})) { - $version = $phptype_specific; - if ($phptype_specific !== false) { - $version = true; - $class_name = 'MDB2_Driver_'.$module.'_'.$this->phptype; - $file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php'; - } - if ($phptype_specific === false - || (!MDB2::classExists($class_name) && !MDB2::fileExists($file_name)) - ) { - $version = false; - $class_name = 'MDB2_'.$module; - $file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php'; - } - - $err = MDB2::loadClass($class_name, $this->getOption('debug')); - if (MDB2::isError($err)) { - return $err; - } - - // load module in a specific version - if ($version) { - if (method_exists($class_name, 'getClassName')) { - $class_name_new = call_user_func(array($class_name, 'getClassName'), $this->db_index); - if ($class_name != $class_name_new) { - $class_name = $class_name_new; - $err = MDB2::loadClass($class_name, $this->getOption('debug')); - if (MDB2::isError($err)) { - return $err; - } - } - } - } - - if (!MDB2::classExists($class_name)) { - $err = $this->raiseError(MDB2_ERROR_LOADMODULE, null, null, - "unable to load module '$module' into property '$property'", __FUNCTION__); - return $err; - } - $this->{$property} = new $class_name($this->db_index); - $this->modules[$module] = $this->{$property}; - if ($version) { - // this will be used in the connect method to determine if the module - // needs to be loaded with a different version if the server - // version changed in between connects - $this->loaded_version_modules[] = $property; - } - } - - return $this->{$property}; - } - - // }}} - // {{{ function __call($method, $params) - - /** - * Calls a module method using the __call magic method - * - * @param string Method name. - * @param array Arguments. - * - * @return mixed Returned value. - */ - function __call($method, $params) - { - $module = null; - if (preg_match('/^([a-z]+)([A-Z])(.*)$/', $method, $match) - && isset($this->options['modules'][$match[1]]) - ) { - $module = $this->options['modules'][$match[1]]; - $method = strtolower($match[2]).$match[3]; - if (!isset($this->modules[$module]) || !is_object($this->modules[$module])) { - $result = $this->loadModule($module); - if (MDB2::isError($result)) { - return $result; - } - } - } else { - foreach ($this->modules as $key => $foo) { - if (is_object($this->modules[$key]) - && method_exists($this->modules[$key], $method) - ) { - $module = $key; - break; - } - } - } - if (null !== $module) { - return call_user_func_array(array(&$this->modules[$module], $method), $params); - } - - $class = get_class($this); - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - $loc = 'in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line']; - if ($method == 'isError') { - trigger_error("Deprecated: $class::isError() is deprecated, use MDB2::isError() $loc", E_USER_DEPRECATED); - if (!array_key_exists(0, $params)) { - trigger_error("Missing argument 1 for $class::$method, called $loc", E_USER_ERROR); - } - return MDB2::isError($params[0]); - } - trigger_error("Call to undefined function: $class::$method() $loc.", E_USER_ERROR); - } - - // }}} - // {{{ function __callStatic($method, $params) - - /** - * Calls a module method using the __callStatic magic method - * - * @param string Method name. - * @param array Arguments. - * - * @return mixed Returned value. - */ - public static function __callStatic($method, $params) - { - $class = get_called_class(); - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - $loc = 'in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line']; - if ($method == 'isError') { - trigger_error("Deprecated: $class::isError() is deprecated, use MDB2::isError() $loc", E_USER_DEPRECATED); - if (!array_key_exists(0, $params)) { - trigger_error("Missing argument 1 for $class::$method, called $loc", E_USER_ERROR); - } - return MDB2::isError($params[0]); - } - trigger_error("Call to undefined function: $class::$method() $loc.", E_USER_ERROR); - } - - // }}} - // {{{ function beginTransaction($savepoint = null) - - /** - * Start a transaction or set a savepoint. - * - * @param string name of a savepoint to set - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function beginTransaction($savepoint = null) - { - $this->debug('Starting transaction', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'transactions are not supported', __FUNCTION__); - } - - // }}} - // {{{ function commit($savepoint = null) - - /** - * Commit the database changes done during a transaction that is in - * progress or release a savepoint. This function may only be called when - * auto-committing is disabled, otherwise it will fail. Therefore, a new - * transaction is implicitly started after committing the pending changes. - * - * @param string name of a savepoint to release - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function commit($savepoint = null) - { - $this->debug('Committing transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'commiting transactions is not supported', __FUNCTION__); - } - - // }}} - // {{{ function rollback($savepoint = null) - - /** - * Cancel any database changes done during a transaction or since a specific - * savepoint that is in progress. This function may only be called when - * auto-committing is disabled, otherwise it will fail. Therefore, a new - * transaction is implicitly started after canceling the pending changes. - * - * @param string name of a savepoint to rollback to - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function rollback($savepoint = null) - { - $this->debug('Rolling back transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'rolling back transactions is not supported', __FUNCTION__); - } - - // }}} - // {{{ function inTransaction($ignore_nested = false) - - /** - * If a transaction is currently open. - * - * @param bool if the nested transaction count should be ignored - * @return int|bool - an integer with the nesting depth is returned if a - * nested transaction is open - * - true is returned for a normal open transaction - * - false is returned if no transaction is open - * - * @access public - */ - function inTransaction($ignore_nested = false) - { - if (!$ignore_nested && isset($this->nested_transaction_counter)) { - return $this->nested_transaction_counter; - } - return $this->in_transaction; - } - - // }}} - // {{{ function setTransactionIsolation($isolation) - - /** - * Set the transacton isolation level. - * - * @param string standard isolation level - * READ UNCOMMITTED (allows dirty reads) - * READ COMMITTED (prevents dirty reads) - * REPEATABLE READ (prevents nonrepeatable reads) - * SERIALIZABLE (prevents phantom reads) - * @param array some transaction options: - * 'wait' => 'WAIT' | 'NO WAIT' - * 'rw' => 'READ WRITE' | 'READ ONLY' - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - * @since 2.1.1 - */ - function setTransactionIsolation($isolation, $options = array()) - { - $this->debug('Setting transaction isolation level', __FUNCTION__, array('is_manip' => true)); - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'isolation level setting is not supported', __FUNCTION__); - } - - // }}} - // {{{ function beginNestedTransaction($savepoint = false) - - /** - * Start a nested transaction. - * - * @return mixed MDB2_OK on success/savepoint name, a MDB2 error on failure - * - * @access public - * @since 2.1.1 - */ - function beginNestedTransaction() - { - if ($this->in_transaction) { - ++$this->nested_transaction_counter; - $savepoint = sprintf($this->options['savepoint_format'], $this->nested_transaction_counter); - if ($this->supports('savepoints') && $savepoint) { - return $this->beginTransaction($savepoint); - } - return MDB2_OK; - } - $this->has_transaction_error = false; - $result = $this->beginTransaction(); - $this->nested_transaction_counter = 1; - return $result; - } - - // }}} - // {{{ function completeNestedTransaction($force_rollback = false, $release = false) - - /** - * Finish a nested transaction by rolling back if an error occured or - * committing otherwise. - * - * @param bool if the transaction should be rolled back regardless - * even if no error was set within the nested transaction - * @return mixed MDB_OK on commit/counter decrementing, false on rollback - * and a MDB2 error on failure - * - * @access public - * @since 2.1.1 - */ - function completeNestedTransaction($force_rollback = false) - { - if ($this->nested_transaction_counter > 1) { - $savepoint = sprintf($this->options['savepoint_format'], $this->nested_transaction_counter); - if ($this->supports('savepoints') && $savepoint) { - if ($force_rollback || $this->has_transaction_error) { - $result = $this->rollback($savepoint); - if (!MDB2::isError($result)) { - $result = false; - $this->has_transaction_error = false; - } - } else { - $result = $this->commit($savepoint); - } - } else { - $result = MDB2_OK; - } - --$this->nested_transaction_counter; - return $result; - } - - $this->nested_transaction_counter = null; - $result = MDB2_OK; - - // transaction has not yet been rolled back - if ($this->in_transaction) { - if ($force_rollback || $this->has_transaction_error) { - $result = $this->rollback(); - if (!MDB2::isError($result)) { - $result = false; - } - } else { - $result = $this->commit(); - } - } - $this->has_transaction_error = false; - return $result; - } - - // }}} - // {{{ function failNestedTransaction($error = null, $immediately = false) - - /** - * Force setting nested transaction to failed. - * - * @param mixed value to return in getNestededTransactionError() - * @param bool if the transaction should be rolled back immediately - * @return bool MDB2_OK - * - * @access public - * @since 2.1.1 - */ - function failNestedTransaction($error = null, $immediately = false) - { - if (null !== $error) { - $error = $this->has_transaction_error ? $this->has_transaction_error : true; - } elseif (!$error) { - $error = true; - } - $this->has_transaction_error = $error; - if (!$immediately) { - return MDB2_OK; - } - return $this->rollback(); - } - - // }}} - // {{{ function getNestedTransactionError() - - /** - * The first error that occured since the transaction start. - * - * @return MDB2_Error|bool MDB2 error object if an error occured or false. - * - * @access public - * @since 2.1.1 - */ - function getNestedTransactionError() - { - return $this->has_transaction_error; - } - - // }}} - // {{{ connect() - - /** - * Connect to the database - * - * @return true on success, MDB2 Error Object on failure - */ - function connect() - { - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ databaseExists() - - /** - * check if given database name is exists? - * - * @param string $name name of the database that should be checked - * - * @return mixed true/false on success, a MDB2 error on failure - * @access public - */ - function databaseExists($name) - { - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ setCharset($charset, $connection = null) - - /** - * Set the charset on the current connection - * - * @param string charset - * @param resource connection handle - * - * @return true on success, MDB2 Error Object on failure - */ - function setCharset($charset, $connection = null) - { - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ function disconnect($force = true) - - /** - * Log out and disconnect from the database. - * - * @param boolean $force whether the disconnect should be forced even if the - * connection is opened persistently - * - * @return mixed true on success, false if not connected and error object on error - * - * @access public - */ - function disconnect($force = true) - { - $this->connection = 0; - $this->connected_dsn = array(); - $this->connected_database_name = ''; - $this->opened_persistent = null; - $this->connected_server_info = ''; - $this->in_transaction = null; - $this->nested_transaction_counter = null; - return MDB2_OK; - } - - // }}} - // {{{ function setDatabase($name) - - /** - * Select a different database - * - * @param string name of the database that should be selected - * - * @return string name of the database previously connected to - * - * @access public - */ - function setDatabase($name) - { - $previous_database_name = (isset($this->database_name)) ? $this->database_name : ''; - $this->database_name = $name; - if (!empty($this->connected_database_name) && ($this->connected_database_name != $this->database_name)) { - $this->disconnect(false); - } - return $previous_database_name; - } - - // }}} - // {{{ function getDatabase() - - /** - * Get the current database - * - * @return string name of the database - * - * @access public - */ - function getDatabase() - { - return $this->database_name; - } - - // }}} - // {{{ function setDSN($dsn) - - /** - * set the DSN - * - * @param mixed DSN string or array - * - * @return MDB2_OK - * - * @access public - */ - function setDSN($dsn) - { - $dsn_default = $GLOBALS['_MDB2_dsninfo_default']; - $dsn = MDB2::parseDSN($dsn); - if (array_key_exists('database', $dsn)) { - $this->database_name = $dsn['database']; - unset($dsn['database']); - } - $this->dsn = array_merge($dsn_default, $dsn); - return $this->disconnect(false); - } - - // }}} - // {{{ function getDSN($type = 'string', $hidepw = false) - - /** - * return the DSN as a string - * - * @param string format to return ("array", "string") - * @param string string to hide the password with - * - * @return mixed DSN in the chosen type - * - * @access public - */ - function getDSN($type = 'string', $hidepw = false) - { - $dsn = array_merge($GLOBALS['_MDB2_dsninfo_default'], $this->dsn); - $dsn['phptype'] = $this->phptype; - $dsn['database'] = $this->database_name; - if ($hidepw) { - $dsn['password'] = $hidepw; - } - switch ($type) { - // expand to include all possible options - case 'string': - $dsn = $dsn['phptype']. - ($dsn['dbsyntax'] ? ('('.$dsn['dbsyntax'].')') : ''). - '://'.$dsn['username'].':'. - $dsn['password'].'@'.$dsn['hostspec']. - ($dsn['port'] ? (':'.$dsn['port']) : ''). - '/'.$dsn['database']; - break; - case 'array': - default: - break; - } - return $dsn; - } - - // }}} - // {{{ _isNewLinkSet() - - /** - * Check if the 'new_link' option is set - * - * @return boolean - * - * @access protected - */ - function _isNewLinkSet() - { - return (isset($this->dsn['new_link']) - && ($this->dsn['new_link'] === true - || (is_string($this->dsn['new_link']) && preg_match('/^true$/i', $this->dsn['new_link'])) - || (is_numeric($this->dsn['new_link']) && 0 != (int)$this->dsn['new_link']) - ) - ); - } - - // }}} - // {{{ function &standaloneQuery($query, $types = null, $is_manip = false) - - /** - * execute a query as database administrator - * - * @param string the SQL query - * @param mixed array that contains the types of the columns in - * the result set - * @param bool if the query is a manipulation query - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function standaloneQuery($query, $types = null, $is_manip = false) - { - $offset = $this->offset; - $limit = $this->limit; - $this->offset = $this->limit = 0; - $query = $this->_modifyQuery($query, $is_manip, $limit, $offset); - - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - - $result = $this->_doQuery($query, $is_manip, $connection, false); - if (MDB2::isError($result)) { - return $result; - } - - if ($is_manip) { - $affected_rows = $this->_affectedRows($connection, $result); - return $affected_rows; - } - $result = $this->_wrapResult($result, $types, true, true, $limit, $offset); - return $result; - } - - // }}} - // {{{ function _modifyQuery($query, $is_manip, $limit, $offset) - - /** - * Changes a query string for various DBMS specific reasons - * - * @param string query to modify - * @param bool if it is a DML query - * @param int limit the number of rows - * @param int start reading from given offset - * - * @return string modified query - * - * @access protected - */ - function _modifyQuery($query, $is_manip, $limit, $offset) - { - return $query; - } - - // }}} - // {{{ function &_doQuery($query, $is_manip = false, $connection = null, $database_name = null) - - /** - * Execute a query - * @param string query - * @param bool if the query is a manipulation query - * @param resource connection handle - * @param string database name - * - * @return result or error object - * - * @access protected - */ - function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) - { - $this->last_query = $query; - $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre')); - if ($result) { - if (MDB2::isError($result)) { - return $result; - } - $query = $result; - } - $err = MDB2_Driver_Common::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - return $err; - } - - // }}} - // {{{ function _affectedRows($connection, $result = null) - - /** - * Returns the number of rows affected - * - * @param resource result handle - * @param resource connection handle - * - * @return mixed MDB2 Error Object or the number of rows affected - * - * @access private - */ - function _affectedRows($connection, $result = null) - { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ function &exec($query) - - /** - * Execute a manipulation query to the database and return the number of affected rows - * - * @param string the SQL query - * - * @return mixed number of affected rows on success, a MDB2 error on failure - * - * @access public - */ - function exec($query) - { - $offset = $this->offset; - $limit = $this->limit; - $this->offset = $this->limit = 0; - $query = $this->_modifyQuery($query, true, $limit, $offset); - - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - - $result = $this->_doQuery($query, true, $connection, $this->database_name); - if (MDB2::isError($result)) { - return $result; - } - - $affectedRows = $this->_affectedRows($connection, $result); - return $affectedRows; - } - - // }}} - // {{{ function &query($query, $types = null, $result_class = true, $result_wrap_class = false) - - /** - * Send a query to the database and return any results - * - * @param string the SQL query - * @param mixed array that contains the types of the columns in - * the result set - * @param mixed string which specifies which result class to use - * @param mixed string which specifies which class to wrap results in - * - * @return mixed an MDB2_Result handle on success, a MDB2 error on failure - * - * @access public - */ - function query($query, $types = null, $result_class = true, $result_wrap_class = true) - { - $offset = $this->offset; - $limit = $this->limit; - $this->offset = $this->limit = 0; - $query = $this->_modifyQuery($query, false, $limit, $offset); - - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - - $result = $this->_doQuery($query, false, $connection, $this->database_name); - if (MDB2::isError($result)) { - return $result; - } - - $result = $this->_wrapResult($result, $types, $result_class, $result_wrap_class, $limit, $offset); - return $result; - } - - // }}} - // {{{ function _wrapResult($result_resource, $types = array(), $result_class = true, $result_wrap_class = false, $limit = null, $offset = null) - - /** - * wrap a result set into the correct class - * - * @param resource result handle - * @param mixed array that contains the types of the columns in - * the result set - * @param mixed string which specifies which result class to use - * @param mixed string which specifies which class to wrap results in - * @param string number of rows to select - * @param string first row to select - * - * @return mixed an MDB2_Result, a MDB2 error on failure - * - * @access protected - */ - function _wrapResult($result_resource, $types = array(), $result_class = true, - $result_wrap_class = true, $limit = null, $offset = null) - { - if ($types === true) { - if ($this->supports('result_introspection')) { - $this->loadModule('Reverse', null, true); - $tableInfo = $this->reverse->tableInfo($result_resource); - if (MDB2::isError($tableInfo)) { - return $tableInfo; - } - $types = array(); - $types_assoc = array(); - foreach ($tableInfo as $field) { - $types[] = $field['mdb2type']; - $types_assoc[$field['name']] = $field['mdb2type']; - } - } else { - $types = null; - } - } - - if ($result_class === true) { - $result_class = $this->options['result_buffering'] - ? $this->options['buffered_result_class'] : $this->options['result_class']; - } - - if ($result_class) { - $class_name = sprintf($result_class, $this->phptype); - if (!MDB2::classExists($class_name)) { - $err = MDB2_Driver_Common::raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'result class does not exist '.$class_name, __FUNCTION__); - return $err; - } - $result = new $class_name($this, $result_resource, $limit, $offset); - if (!MDB2::isResultCommon($result)) { - $err = MDB2_Driver_Common::raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'result class is not extended from MDB2_Result_Common', __FUNCTION__); - return $err; - } - - if (!empty($types)) { - $err = $result->setResultTypes($types); - if (MDB2::isError($err)) { - $result->free(); - return $err; - } - } - if (!empty($types_assoc)) { - $err = $result->setResultTypes($types_assoc); - if (MDB2::isError($err)) { - $result->free(); - return $err; - } - } - - if ($result_wrap_class === true) { - $result_wrap_class = $this->options['result_wrap_class']; - } - if ($result_wrap_class) { - if (!MDB2::classExists($result_wrap_class)) { - $err = MDB2_Driver_Common::raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'result wrap class does not exist '.$result_wrap_class, __FUNCTION__); - return $err; - } - $result = new $result_wrap_class($result, $this->fetchmode); - } - - return $result; - } - - return $result_resource; - } - - // }}} - // {{{ function getServerVersion($native = false) - - /** - * return version information about the server - * - * @param bool determines if the raw version string should be returned - * - * @return mixed array with version information or row string - * - * @access public - */ - function getServerVersion($native = false) - { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ function setLimit($limit, $offset = null) - - /** - * set the range of the next query - * - * @param string number of rows to select - * @param string first row to select - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function setLimit($limit, $offset = null) - { - if (!$this->supports('limit_queries')) { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'limit is not supported by this driver', __FUNCTION__); - } - $limit = (int)$limit; - if ($limit < 0) { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_SYNTAX, null, null, - 'it was not specified a valid selected range row limit', __FUNCTION__); - } - $this->limit = $limit; - if (null !== $offset) { - $offset = (int)$offset; - if ($offset < 0) { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_SYNTAX, null, null, - 'it was not specified a valid first selected range row', __FUNCTION__); - } - $this->offset = $offset; - } - return MDB2_OK; - } - - // }}} - // {{{ function subSelect($query, $type = false) - - /** - * simple subselect emulation: leaves the query untouched for all RDBMS - * that support subselects - * - * @param string the SQL query for the subselect that may only - * return a column - * @param string determines type of the field - * - * @return string the query - * - * @access public - */ - function subSelect($query, $type = false) - { - if ($this->supports('sub_selects') === true) { - return $query; - } - - if (!$this->supports('sub_selects')) { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - $col = $this->queryCol($query, $type); - if (MDB2::isError($col)) { - return $col; - } - if (!is_array($col) || count($col) == 0) { - return 'NULL'; - } - if ($type) { - $this->loadModule('Datatype', null, true); - return $this->datatype->implodeArray($col, $type); - } - return implode(', ', $col); - } - - // }}} - // {{{ function replace($table, $fields) - - /** - * Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT - * query, except that if there is already a row in the table with the same - * key field values, the old row is deleted before the new row is inserted. - * - * The REPLACE type of query does not make part of the SQL standards. Since - * practically only MySQL and SQLite implement it natively, this type of - * query isemulated through this method for other DBMS using standard types - * of queries inside a transaction to assure the atomicity of the operation. - * - * @param string name of the table on which the REPLACE query will - * be executed. - * @param array associative array that describes the fields and the - * values that will be inserted or updated in the specified table. The - * indexes of the array are the names of all the fields of the table. - * The values of the array are also associative arrays that describe - * the values and other properties of the table fields. - * - * Here follows a list of field properties that need to be specified: - * - * value - * Value to be assigned to the specified field. This value may be - * of specified in database independent type format as this - * function can perform the necessary datatype conversions. - * - * Default: this property is required unless the Null property is - * set to 1. - * - * type - * Name of the type of the field. Currently, all types MDB2 - * are supported except for clob and blob. - * - * Default: no type conversion - * - * null - * bool property that indicates that the value for this field - * should be set to null. - * - * The default value for fields missing in INSERT queries may be - * specified the definition of a table. Often, the default value - * is already null, but since the REPLACE may be emulated using - * an UPDATE query, make sure that all fields of the table are - * listed in this function argument array. - * - * Default: 0 - * - * key - * bool property that indicates that this field should be - * handled as a primary key or at least as part of the compound - * unique index of the table that will determine the row that will - * updated if it exists or inserted a new row otherwise. - * - * This function will fail if no key field is specified or if the - * value of a key field is set to null because fields that are - * part of unique index they may not be null. - * - * Default: 0 - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function replace($table, $fields) - { - if (!$this->supports('replace')) { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'replace query is not supported', __FUNCTION__); - } - $count = count($fields); - $condition = $values = array(); - for ($colnum = 0, reset($fields); $colnum < $count; next($fields), $colnum++) { - $name = key($fields); - if (isset($fields[$name]['null']) && $fields[$name]['null']) { - $value = 'NULL'; - } else { - $type = isset($fields[$name]['type']) ? $fields[$name]['type'] : null; - $value = $this->quote($fields[$name]['value'], $type); - } - $values[$name] = $value; - if (isset($fields[$name]['key']) && $fields[$name]['key']) { - if ($value === 'NULL') { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null, - 'key value '.$name.' may not be NULL', __FUNCTION__); - } - $condition[] = $this->quoteIdentifier($name, true) . '=' . $value; - } - } - if (empty($condition)) { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null, - 'not specified which fields are keys', __FUNCTION__); - } - - $result = null; - $in_transaction = $this->in_transaction; - if (!$in_transaction && MDB2::isError($result = $this->beginTransaction())) { - return $result; - } - - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - - $condition = ' WHERE '.implode(' AND ', $condition); - $query = 'DELETE FROM ' . $this->quoteIdentifier($table, true) . $condition; - $result = $this->_doQuery($query, true, $connection); - if (!MDB2::isError($result)) { - $affected_rows = $this->_affectedRows($connection, $result); - $insert = ''; - foreach ($values as $key => $value) { - $insert .= ($insert?', ':'') . $this->quoteIdentifier($key, true); - } - $values = implode(', ', $values); - $query = 'INSERT INTO '. $this->quoteIdentifier($table, true) . "($insert) VALUES ($values)"; - $result = $this->_doQuery($query, true, $connection); - if (!MDB2::isError($result)) { - $affected_rows += $this->_affectedRows($connection, $result);; - } - } - - if (!$in_transaction) { - if (MDB2::isError($result)) { - $this->rollback(); - } else { - $result = $this->commit(); - } - } - - if (MDB2::isError($result)) { - return $result; - } - - return $affected_rows; - } - - // }}} - // {{{ function &prepare($query, $types = null, $result_types = null, $lobs = array()) - - /** - * Prepares a query for multiple execution with execute(). - * With some database backends, this is emulated. - * prepare() requires a generic query as string like - * 'INSERT INTO numbers VALUES(?,?)' or - * 'INSERT INTO numbers VALUES(:foo,:bar)'. - * The ? and :name and are placeholders which can be set using - * bindParam() and the query can be sent off using the execute() method. - * The allowed format for :name can be set with the 'bindname_format' option. - * - * @param string the query to prepare - * @param mixed array that contains the types of the placeholders - * @param mixed array that contains the types of the columns in - * the result set or MDB2_PREPARE_RESULT, if set to - * MDB2_PREPARE_MANIP the query is handled as a manipulation query - * @param mixed key (field) value (parameter) pair for all lob placeholders - * - * @return mixed resource handle for the prepared query on success, - * a MDB2 error on failure - * - * @access public - * @see bindParam, execute - */ - function prepare($query, $types = null, $result_types = null, $lobs = array()) - { - $is_manip = ($result_types === MDB2_PREPARE_MANIP); - $offset = $this->offset; - $limit = $this->limit; - $this->offset = $this->limit = 0; - $result = $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'pre')); - if ($result) { - if (MDB2::isError($result)) { - return $result; - } - $query = $result; - } - $placeholder_type_guess = $placeholder_type = null; - $question = '?'; - $colon = ':'; - $positions = array(); - $position = 0; - while ($position < strlen($query)) { - $q_position = strpos($query, $question, $position); - $c_position = strpos($query, $colon, $position); - if ($q_position && $c_position) { - $p_position = min($q_position, $c_position); - } elseif ($q_position) { - $p_position = $q_position; - } elseif ($c_position) { - $p_position = $c_position; - } else { - break; - } - if (null === $placeholder_type) { - $placeholder_type_guess = $query[$p_position]; - } - - $new_pos = $this->_skipDelimitedStrings($query, $position, $p_position); - if (MDB2::isError($new_pos)) { - return $new_pos; - } - if ($new_pos != $position) { - $position = $new_pos; - continue; //evaluate again starting from the new position - } - - if ($query[$position] == $placeholder_type_guess) { - if (null === $placeholder_type) { - $placeholder_type = $query[$p_position]; - $question = $colon = $placeholder_type; - if (!empty($types) && is_array($types)) { - if ($placeholder_type == ':') { - if (is_int(key($types))) { - $types_tmp = $types; - $types = array(); - $count = -1; - } - } else { - $types = array_values($types); - } - } - } - if ($placeholder_type == ':') { - $regexp = '/^.{'.($position+1).'}('.$this->options['bindname_format'].').*$/s'; - $parameter = preg_replace($regexp, '\\1', $query); - if ($parameter === '') { - $err = MDB2_Driver_Common::raiseError(MDB2_ERROR_SYNTAX, null, null, - 'named parameter name must match "bindname_format" option', __FUNCTION__); - return $err; - } - $positions[$p_position] = $parameter; - $query = substr_replace($query, '?', $position, strlen($parameter)+1); - // use parameter name in type array - if (isset($count) && isset($types_tmp[++$count])) { - $types[$parameter] = $types_tmp[$count]; - } - } else { - $positions[$p_position] = count($positions); - } - $position = $p_position + 1; - } else { - $position = $p_position; - } - } - $class_name = 'MDB2_Statement_'.$this->phptype; - $statement = null; - $obj = new $class_name($this, $statement, $positions, $query, $types, $result_types, $is_manip, $limit, $offset); - $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'post', 'result' => $obj)); - return $obj; - } - - // }}} - // {{{ function _skipDelimitedStrings($query, $position, $p_position) - - /** - * Utility method, used by prepare() to avoid replacing placeholders within delimited strings. - * Check if the placeholder is contained within a delimited string. - * If so, skip it and advance the position, otherwise return the current position, - * which is valid - * - * @param string $query - * @param integer $position current string cursor position - * @param integer $p_position placeholder position - * - * @return mixed integer $new_position on success - * MDB2_Error on failure - * - * @access protected - */ - function _skipDelimitedStrings($query, $position, $p_position) - { - $ignores = array(); - $ignores[] = $this->string_quoting; - $ignores[] = $this->identifier_quoting; - $ignores = array_merge($ignores, $this->sql_comments); - - foreach ($ignores as $ignore) { - if (!empty($ignore['start'])) { - if (is_int($start_quote = strpos($query, $ignore['start'], $position)) && $start_quote < $p_position) { - $end_quote = $start_quote; - do { - if (!is_int($end_quote = strpos($query, $ignore['end'], $end_quote + 1))) { - if ($ignore['end'] === "\n") { - $end_quote = strlen($query) - 1; - } else { - $err = MDB2_Driver_Common::raiseError(MDB2_ERROR_SYNTAX, null, null, - 'query with an unterminated text string specified', __FUNCTION__); - return $err; - } - } - } while ($ignore['escape'] - && $end_quote-1 != $start_quote - && $query[($end_quote - 1)] == $ignore['escape'] - && ( $ignore['escape_pattern'] !== $ignore['escape'] - || $query[($end_quote - 2)] != $ignore['escape']) - ); - - $position = $end_quote + 1; - return $position; - } - } - } - return $position; - } - - // }}} - // {{{ function quote($value, $type = null, $quote = true) - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string text string value that is intended to be converted. - * @param string type to which the value should be converted to - * @param bool quote - * @param bool escape wildcards - * - * @return string text string that represents the given argument value in - * a DBMS specific format. - * - * @access public - */ - function quote($value, $type = null, $quote = true, $escape_wildcards = false) - { - $result = $this->loadModule('Datatype', null, true); - if (MDB2::isError($result)) { - return $result; - } - - return $this->datatype->quote($value, $type, $quote, $escape_wildcards); - } - - // }}} - // {{{ function getDeclaration($type, $name, $field) - - /** - * Obtain DBMS specific SQL code portion needed to declare - * of the given type - * - * @param string type to which the value should be converted to - * @param string name the field to be declared. - * @param string definition of the field - * - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * - * @access public - */ - function getDeclaration($type, $name, $field) - { - $result = $this->loadModule('Datatype', null, true); - if (MDB2::isError($result)) { - return $result; - } - return $this->datatype->getDeclaration($type, $name, $field); - } - - // }}} - // {{{ function compareDefinition($current, $previous) - - /** - * Obtain an array of changes that may need to applied - * - * @param array new definition - * @param array old definition - * - * @return array containing all changes that will need to be applied - * - * @access public - */ - function compareDefinition($current, $previous) - { - $result = $this->loadModule('Datatype', null, true); - if (MDB2::isError($result)) { - return $result; - } - return $this->datatype->compareDefinition($current, $previous); - } - - // }}} - // {{{ function supports($feature) - - /** - * Tell whether a DB implementation or its backend extension - * supports a given feature. - * - * @param string name of the feature (see the MDB2 class doc) - * - * @return bool|string if this DB implementation supports a given feature - * false means no, true means native, - * 'emulated' means emulated - * - * @access public - */ - function supports($feature) - { - if (array_key_exists($feature, $this->supported)) { - return $this->supported[$feature]; - } - return MDB2_Driver_Common::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - "unknown support feature $feature", __FUNCTION__); - } - - // }}} - // {{{ function getSequenceName($sqn) - - /** - * adds sequence name formatting to a sequence name - * - * @param string name of the sequence - * - * @return string formatted sequence name - * - * @access public - */ - function getSequenceName($sqn) - { - return sprintf($this->options['seqname_format'], - preg_replace('/[^a-z0-9_\-\$.]/i', '_', $sqn)); - } - - // }}} - // {{{ function getIndexName($idx) - - /** - * adds index name formatting to a index name - * - * @param string name of the index - * - * @return string formatted index name - * - * @access public - */ - function getIndexName($idx) - { - return sprintf($this->options['idxname_format'], - preg_replace('/[^a-z0-9_\-\$.]/i', '_', $idx)); - } - - // }}} - // {{{ function nextID($seq_name, $ondemand = true) - - /** - * Returns the next free id of a sequence - * - * @param string name of the sequence - * @param bool when true missing sequences are automatic created - * - * @return mixed MDB2 Error Object or id - * - * @access public - */ - function nextID($seq_name, $ondemand = true) - { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ function lastInsertID($table = null, $field = null) - - /** - * Returns the autoincrement ID if supported or $id or fetches the current - * ID in a sequence called: $table.(empty($field) ? '' : '_'.$field) - * - * @param string name of the table into which a new row was inserted - * @param string name of the field into which a new row was inserted - * - * @return mixed MDB2 Error Object or id - * - * @access public - */ - function lastInsertID($table = null, $field = null) - { - return MDB2_Driver_Common::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ function currID($seq_name) - - /** - * Returns the current id of a sequence - * - * @param string name of the sequence - * - * @return mixed MDB2 Error Object or id - * - * @access public - */ - function currID($seq_name) - { - $this->warnings[] = 'database does not support getting current - sequence value, the sequence value was incremented'; - return $this->nextID($seq_name); - } - - // }}} - // {{{ function queryOne($query, $type = null, $colnum = 0) - - /** - * Execute the specified query, fetch the value from the first column of - * the first row of the result set and then frees - * the result set. - * - * @param string $query the SELECT query statement to be executed. - * @param string $type optional argument that specifies the expected - * datatype of the result set field, so that an eventual - * conversion may be performed. The default datatype is - * text, meaning that no conversion is performed - * @param mixed $colnum the column number (or name) to fetch - * - * @return mixed MDB2_OK or field value on success, a MDB2 error on failure - * - * @access public - */ - function queryOne($query, $type = null, $colnum = 0) - { - $result = $this->query($query, $type); - if (!MDB2::isResultCommon($result)) { - return $result; - } - - $one = $result->fetchOne($colnum); - $result->free(); - return $one; - } - - // }}} - // {{{ function queryRow($query, $types = null, $fetchmode = MDB2_FETCHMODE_DEFAULT) - - /** - * Execute the specified query, fetch the values from the first - * row of the result set into an array and then frees - * the result set. - * - * @param string the SELECT query statement to be executed. - * @param array optional array argument that specifies a list of - * expected datatypes of the result set columns, so that the eventual - * conversions may be performed. The default list of datatypes is - * empty, meaning that no conversion is performed. - * @param int how the array data should be indexed - * - * @return mixed MDB2_OK or data array on success, a MDB2 error on failure - * - * @access public - */ - function queryRow($query, $types = null, $fetchmode = MDB2_FETCHMODE_DEFAULT) - { - $result = $this->query($query, $types); - if (!MDB2::isResultCommon($result)) { - return $result; - } - - $row = $result->fetchRow($fetchmode); - $result->free(); - return $row; - } - - // }}} - // {{{ function queryCol($query, $type = null, $colnum = 0) - - /** - * Execute the specified query, fetch the value from the first column of - * each row of the result set into an array and then frees the result set. - * - * @param string $query the SELECT query statement to be executed. - * @param string $type optional argument that specifies the expected - * datatype of the result set field, so that an eventual - * conversion may be performed. The default datatype is text, - * meaning that no conversion is performed - * @param mixed $colnum the column number (or name) to fetch - * - * @return mixed MDB2_OK or data array on success, a MDB2 error on failure - * @access public - */ - function queryCol($query, $type = null, $colnum = 0) - { - $result = $this->query($query, $type); - if (!MDB2::isResultCommon($result)) { - return $result; - } - - $col = $result->fetchCol($colnum); - $result->free(); - return $col; - } - - // }}} - // {{{ function queryAll($query, $types = null, $fetchmode = MDB2_FETCHMODE_DEFAULT, $rekey = false, $force_array = false, $group = false) - - /** - * Execute the specified query, fetch all the rows of the result set into - * a two dimensional array and then frees the result set. - * - * @param string the SELECT query statement to be executed. - * @param array optional array argument that specifies a list of - * expected datatypes of the result set columns, so that the eventual - * conversions may be performed. The default list of datatypes is - * empty, meaning that no conversion is performed. - * @param int how the array data should be indexed - * @param bool if set to true, the $all will have the first - * column as its first dimension - * @param bool used only when the query returns exactly - * two columns. If true, the values of the returned array will be - * one-element arrays instead of scalars. - * @param bool if true, the values of the returned array is - * wrapped in another array. If the same key value (in the first - * column) repeats itself, the values will be appended to this array - * instead of overwriting the existing values. - * - * @return mixed MDB2_OK or data array on success, a MDB2 error on failure - * - * @access public - */ - function queryAll($query, $types = null, $fetchmode = MDB2_FETCHMODE_DEFAULT, - $rekey = false, $force_array = false, $group = false) - { - $result = $this->query($query, $types); - if (!MDB2::isResultCommon($result)) { - return $result; - } - - $all = $result->fetchAll($fetchmode, $rekey, $force_array, $group); - $result->free(); - return $all; - } - - // }}} - // {{{ function delExpect($error_code) - - /** - * This method deletes all occurences of the specified element from - * the expected error codes stack. - * - * @param mixed $error_code error code that should be deleted - * @return mixed list of error codes that were deleted or error - * - * @uses PEAR::delExpect() - */ - public function delExpect($error_code) - { - return $this->pear->delExpect($error_code); - } - - // }}} - // {{{ function expectError($code) - - /** - * This method is used to tell which errors you expect to get. - * Expected errors are always returned with error mode - * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, - * and this method pushes a new element onto it. The list of - * expected errors are in effect until they are popped off the - * stack with the popExpect() method. - * - * Note that this method can not be called statically - * - * @param mixed $code a single error code or an array of error codes to expect - * - * @return int the new depth of the "expected errors" stack - * - * @uses PEAR::expectError() - */ - public function expectError($code = '*') - { - return $this->pear->expectError($code); - } - - // }}} - // {{{ function getStaticProperty($class, $var) - - /** - * If you have a class that's mostly/entirely static, and you need static - * properties, you can use this method to simulate them. Eg. in your method(s) - * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); - * You MUST use a reference, or they will not persist! - * - * @param string $class The calling classname, to prevent clashes - * @param string $var The variable to retrieve. - * @return mixed A reference to the variable. If not set it will be - * auto initialised to NULL. - * - * @uses PEAR::getStaticProperty() - */ - public function &getStaticProperty($class, $var) - { - $tmp =& $this->pear->getStaticProperty($class, $var); - return $tmp; - } - - // }}} - // {{{ function popErrorHandling() - - /** - * Pop the last error handler used - * - * @return bool Always true - * - * @see PEAR::pushErrorHandling - * @uses PEAR::popErrorHandling() - */ - public function popErrorHandling() - { - return $this->pear->popErrorHandling(); - } - - // }}} - // {{{ function popExpect() - - /** - * This method pops one element off the expected error codes - * stack. - * - * @return array the list of error codes that were popped - * - * @uses PEAR::popExpect() - */ - public function popExpect() - { - return $this->pear->popExpect(); - } - - // }}} - // {{{ function pushErrorHandling($mode, $options = null) - - /** - * Push a new error handler on top of the error handler options stack. With this - * you can easily override the actual error handler for some code and restore - * it later with popErrorHandling. - * - * @param mixed $mode (same as setErrorHandling) - * @param mixed $options (same as setErrorHandling) - * - * @return bool Always true - * - * @see PEAR::setErrorHandling - * @uses PEAR::pushErrorHandling() - */ - public function pushErrorHandling($mode, $options = null) - { - return $this->pear->pushErrorHandling($mode, $options); - } - - // }}} - // {{{ function registerShutdownFunc($func, $args = array()) - - /** - * Use this function to register a shutdown method for static - * classes. - * - * @param mixed $func The function name (or array of class/method) to call - * @param mixed $args The arguments to pass to the function - * @return void - * - * @uses PEAR::registerShutdownFunc() - */ - public function registerShutdownFunc($func, $args = array()) - { - return $this->pear->registerShutdownFunc($func, $args); - } - - // }}} - // {{{ function setErrorHandling($mode = null, $options = null) - - /** - * Sets how errors generated by this object should be handled. - * Can be invoked both in objects and statically. If called - * statically, setErrorHandling sets the default behaviour for all - * PEAR objects. If called in an object, setErrorHandling sets - * the default behaviour for that object. - * - * @param int $mode - * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. - * - * @param mixed $options - * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one - * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * - * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected - * to be the callback function or method. A callback - * function is a string with the name of the function, a - * callback method is an array of two elements: the element - * at index 0 is the object, and the element at index 1 is - * the name of the method to call in the object. - * - * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is - * a printf format string used when printing the error - * message. - * - * @access public - * @return void - * @see PEAR_ERROR_RETURN - * @see PEAR_ERROR_PRINT - * @see PEAR_ERROR_TRIGGER - * @see PEAR_ERROR_DIE - * @see PEAR_ERROR_CALLBACK - * @see PEAR_ERROR_EXCEPTION - * - * @since PHP 4.0.5 - * @uses PEAR::setErrorHandling($mode, $options) - */ - public function setErrorHandling($mode = null, $options = null) - { - return $this->pear->setErrorHandling($mode, $options); - } - - /** - * @uses PEAR::staticPopErrorHandling() - */ - public function staticPopErrorHandling() - { - return $this->pear->staticPopErrorHandling(); - } - - // }}} - // {{{ function staticPushErrorHandling($mode, $options = null) - - /** - * @uses PEAR::staticPushErrorHandling($mode, $options) - */ - public function staticPushErrorHandling($mode, $options = null) - { - return $this->pear->staticPushErrorHandling($mode, $options); - } - - // }}} - // {{{ function &throwError($message = null, $code = null, $userinfo = null) - - /** - * Simpler form of raiseError with fewer options. In most cases - * message, code and userinfo are enough. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @return object a PEAR error object - * @see PEAR::raiseError - * @uses PEAR::&throwError() - */ - public function &throwError($message = null, $code = null, $userinfo = null) - { - $tmp =& $this->pear->throwError($message, $code, $userinfo); - return $tmp; - } - - // }}} -} - -// }}} -// {{{ class MDB2_Result - -/** - * The dummy class that all user space result classes should extend from - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Result -{ -} - -// }}} -// {{{ class MDB2_Result_Common extends MDB2_Result - -/** - * The common result class for MDB2 result objects - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Result_Common extends MDB2_Result -{ - // {{{ Variables (Properties) - - public $db; - public $result; - public $rownum = -1; - public $types = array(); - public $types_assoc = array(); - public $values = array(); - public $offset; - public $offset_count = 0; - public $limit; - public $column_names; - - // }}} - // {{{ constructor: function __construct($db, &$result, $limit = 0, $offset = 0) - - /** - * Constructor - */ - function __construct($db, &$result, $limit = 0, $offset = 0) - { - $this->db = $db; - $this->result = $result; - $this->offset = $offset; - $this->limit = max(0, $limit - 1); - } - - // }}} - // {{{ function setResultTypes($types) - - /** - * Define the list of types to be associated with the columns of a given - * result set. - * - * This function may be called before invoking fetchRow(), fetchOne(), - * fetchCol() and fetchAll() so that the necessary data type - * conversions are performed on the data to be retrieved by them. If this - * function is not called, the type of all result set columns is assumed - * to be text, thus leading to not perform any conversions. - * - * @param array variable that lists the - * data types to be expected in the result set columns. If this array - * contains less types than the number of columns that are returned - * in the result set, the remaining columns are assumed to be of the - * type text. Currently, the types clob and blob are not fully - * supported. - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function setResultTypes($types) - { - $load = $this->db->loadModule('Datatype', null, true); - if (MDB2::isError($load)) { - return $load; - } - $types = $this->db->datatype->checkResultTypes($types); - if (MDB2::isError($types)) { - return $types; - } - foreach ($types as $key => $value) { - if (is_numeric($key)) { - $this->types[$key] = $value; - } else { - $this->types_assoc[$key] = $value; - } - } - return MDB2_OK; - } - - // }}} - // {{{ function seek($rownum = 0) - - /** - * Seek to a specific row in a result set - * - * @param int number of the row where the data can be found - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function seek($rownum = 0) - { - $target_rownum = $rownum - 1; - if ($this->rownum > $target_rownum) { - return MDB2::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'seeking to previous rows not implemented', __FUNCTION__); - } - while ($this->rownum < $target_rownum) { - $this->fetchRow(); - } - return MDB2_OK; - } - - // }}} - // {{{ function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) - - /** - * Fetch and return a row of data - * - * @param int how the array data should be indexed - * @param int number of the row where the data can be found - * - * @return int data array on success, a MDB2 error on failure - * - * @access public - */ - function fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) - { - $err = MDB2::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - return $err; - } - - // }}} - // {{{ function fetchOne($colnum = 0) - - /** - * fetch single column from the next row from a result set - * - * @param int|string the column number (or name) to fetch - * @param int number of the row where the data can be found - * - * @return string data on success, a MDB2 error on failure - * @access public - */ - function fetchOne($colnum = 0, $rownum = null) - { - $fetchmode = is_numeric($colnum) ? MDB2_FETCHMODE_ORDERED : MDB2_FETCHMODE_ASSOC; - $row = $this->fetchRow($fetchmode, $rownum); - if (!is_array($row) || MDB2::isError($row)) { - return $row; - } - if (!array_key_exists($colnum, $row)) { - return MDB2::raiseError(MDB2_ERROR_TRUNCATED, null, null, - 'column is not defined in the result set: '.$colnum, __FUNCTION__); - } - return $row[$colnum]; - } - - // }}} - // {{{ function fetchCol($colnum = 0) - - /** - * Fetch and return a column from the current row pointer position - * - * @param int|string the column number (or name) to fetch - * - * @return mixed data array on success, a MDB2 error on failure - * @access public - */ - function fetchCol($colnum = 0) - { - $column = array(); - $fetchmode = is_numeric($colnum) ? MDB2_FETCHMODE_ORDERED : MDB2_FETCHMODE_ASSOC; - $row = $this->fetchRow($fetchmode); - if (is_array($row)) { - if (!array_key_exists($colnum, $row)) { - return MDB2::raiseError(MDB2_ERROR_TRUNCATED, null, null, - 'column is not defined in the result set: '.$colnum, __FUNCTION__); - } - do { - $column[] = $row[$colnum]; - } while (is_array($row = $this->fetchRow($fetchmode))); - } - if (MDB2::isError($row)) { - return $row; - } - return $column; - } - - // }}} - // {{{ function fetchAll($fetchmode = MDB2_FETCHMODE_DEFAULT, $rekey = false, $force_array = false, $group = false) - - /** - * Fetch and return all rows from the current row pointer position - * - * @param int $fetchmode the fetch mode to use: - * + MDB2_FETCHMODE_ORDERED - * + MDB2_FETCHMODE_ASSOC - * + MDB2_FETCHMODE_ORDERED | MDB2_FETCHMODE_FLIPPED - * + MDB2_FETCHMODE_ASSOC | MDB2_FETCHMODE_FLIPPED - * @param bool if set to true, the $all will have the first - * column as its first dimension - * @param bool used only when the query returns exactly - * two columns. If true, the values of the returned array will be - * one-element arrays instead of scalars. - * @param bool if true, the values of the returned array is - * wrapped in another array. If the same key value (in the first - * column) repeats itself, the values will be appended to this array - * instead of overwriting the existing values. - * - * @return mixed data array on success, a MDB2 error on failure - * - * @access public - * @see getAssoc() - */ - function fetchAll($fetchmode = MDB2_FETCHMODE_DEFAULT, $rekey = false, - $force_array = false, $group = false) - { - $all = array(); - $row = $this->fetchRow($fetchmode); - if (MDB2::isError($row)) { - return $row; - } elseif (!$row) { - return $all; - } - - $shift_array = $rekey ? false : null; - if (null !== $shift_array) { - if (is_object($row)) { - $colnum = count(get_object_vars($row)); - } else { - $colnum = count($row); - } - if ($colnum < 2) { - return MDB2::raiseError(MDB2_ERROR_TRUNCATED, null, null, - 'rekey feature requires atleast 2 column', __FUNCTION__); - } - $shift_array = (!$force_array && $colnum == 2); - } - - if ($rekey) { - do { - if (is_object($row)) { - $arr = get_object_vars($row); - $key = reset($arr); - unset($row->{$key}); - } else { - if ( $fetchmode == MDB2_FETCHMODE_ASSOC - || $fetchmode == MDB2_FETCHMODE_OBJECT - ) { - $key = reset($row); - unset($row[key($row)]); - } else { - $key = array_shift($row); - } - if ($shift_array) { - $row = array_shift($row); - } - } - if ($group) { - $all[$key][] = $row; - } else { - $all[$key] = $row; - } - } while (($row = $this->fetchRow($fetchmode))); - } elseif ($fetchmode == MDB2_FETCHMODE_FLIPPED) { - do { - foreach ($row as $key => $val) { - $all[$key][] = $val; - } - } while (($row = $this->fetchRow($fetchmode))); - } else { - do { - $all[] = $row; - } while (($row = $this->fetchRow($fetchmode))); - } - - return $all; - } - - // }}} - // {{{ function rowCount() - /** - * Returns the actual row number that was last fetched (count from 0) - * @return int - * - * @access public - */ - function rowCount() - { - return $this->rownum + 1; - } - - // }}} - // {{{ function numRows() - - /** - * Returns the number of rows in a result object - * - * @return mixed MDB2 Error Object or the number of rows - * - * @access public - */ - function numRows() - { - return MDB2::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ function nextResult() - - /** - * Move the internal result pointer to the next available result - * - * @return true on success, false if there is no more result set or an error object on failure - * - * @access public - */ - function nextResult() - { - return MDB2::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ function getColumnNames() - - /** - * Retrieve the names of columns returned by the DBMS in a query result or - * from the cache. - * - * @param bool If set to true the values are the column names, - * otherwise the names of the columns are the keys. - * @return mixed Array variable that holds the names of columns or an - * MDB2 error on failure. - * Some DBMS may not return any columns when the result set - * does not contain any rows. - * - * @access public - */ - function getColumnNames($flip = false) - { - if (!isset($this->column_names)) { - $result = $this->_getColumnNames(); - if (MDB2::isError($result)) { - return $result; - } - $this->column_names = $result; - } - if ($flip) { - return array_flip($this->column_names); - } - return $this->column_names; - } - - // }}} - // {{{ function _getColumnNames() - - /** - * Retrieve the names of columns returned by the DBMS in a query result. - * - * @return mixed Array variable that holds the names of columns as keys - * or an MDB2 error on failure. - * Some DBMS may not return any columns when the result set - * does not contain any rows. - * - * @access private - */ - function _getColumnNames() - { - return MDB2::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ function numCols() - - /** - * Count the number of columns returned by the DBMS in a query result. - * - * @return mixed integer value with the number of columns, a MDB2 error - * on failure - * - * @access public - */ - function numCols() - { - return MDB2::raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ function getResource() - - /** - * return the resource associated with the result object - * - * @return resource - * - * @access public - */ - function getResource() - { - return $this->result; - } - - // }}} - // {{{ function bindColumn($column, &$value, $type = null) - - /** - * Set bind variable to a column. - * - * @param int column number or name - * @param mixed variable reference - * @param string specifies the type of the field - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function bindColumn($column, &$value, $type = null) - { - if (!is_numeric($column)) { - $column_names = $this->getColumnNames(); - if ($this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($this->db->options['field_case'] == CASE_LOWER) { - $column = strtolower($column); - } else { - $column = strtoupper($column); - } - } - $column = $column_names[$column]; - } - $this->values[$column] =& $value; - if (null !== $type) { - $this->types[$column] = $type; - } - return MDB2_OK; - } - - // }}} - // {{{ function _assignBindColumns($row) - - /** - * Bind a variable to a value in the result row. - * - * @param array row data - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access private - */ - function _assignBindColumns($row) - { - $row = array_values($row); - foreach ($row as $column => $value) { - if (array_key_exists($column, $this->values)) { - $this->values[$column] = $value; - } - } - return MDB2_OK; - } - - // }}} - // {{{ function free() - - /** - * Free the internal resources associated with result. - * - * @return bool true on success, false if result is invalid - * - * @access public - */ - function free() - { - $this->result = false; - return MDB2_OK; - } - - // }}} -} - -// }}} -// {{{ class MDB2_Row - -/** - * The simple class that accepts row data as an array - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Row -{ - // {{{ constructor: function __construct(&$row) - - /** - * constructor - * - * @param resource row data as array - */ - function __construct(&$row) - { - foreach ($row as $key => $value) { - $this->$key = &$row[$key]; - } - } - - // }}} -} - -// }}} -// {{{ class MDB2_Statement_Common - -/** - * The common statement class for MDB2 statement objects - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Statement_Common -{ - // {{{ Variables (Properties) - - var $db; - var $statement; - var $query; - var $result_types; - var $types; - var $values = array(); - var $limit; - var $offset; - var $is_manip; - - // }}} - // {{{ constructor: function __construct($db, $statement, $positions, $query, $types, $result_types, $is_manip = false, $limit = null, $offset = null) - - /** - * Constructor - */ - function __construct($db, $statement, $positions, $query, $types, $result_types, $is_manip = false, $limit = null, $offset = null) - { - $this->db = $db; - $this->statement = $statement; - $this->positions = $positions; - $this->query = $query; - $this->types = (array)$types; - $this->result_types = (array)$result_types; - $this->limit = $limit; - $this->is_manip = $is_manip; - $this->offset = $offset; - } - - // }}} - // {{{ function bindValue($parameter, &$value, $type = null) - - /** - * Set the value of a parameter of a prepared query. - * - * @param int the order number of the parameter in the query - * statement. The order number of the first parameter is 1. - * @param mixed value that is meant to be assigned to specified - * parameter. The type of the value depends on the $type argument. - * @param string specifies the type of the field - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function bindValue($parameter, $value, $type = null) - { - if (!is_numeric($parameter)) { - if (strpos($parameter, ':') === 0) { - $parameter = substr($parameter, 1); - } - } - if (!in_array($parameter, $this->positions)) { - return MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__); - } - $this->values[$parameter] = $value; - if (null !== $type) { - $this->types[$parameter] = $type; - } - return MDB2_OK; - } - - // }}} - // {{{ function bindValueArray($values, $types = null) - - /** - * Set the values of multiple a parameter of a prepared query in bulk. - * - * @param array specifies all necessary information - * for bindValue() the array elements must use keys corresponding to - * the number of the position of the parameter. - * @param array specifies the types of the fields - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - * @see bindParam() - */ - function bindValueArray($values, $types = null) - { - $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null); - $parameters = array_keys($values); - $this->db->pushErrorHandling(PEAR_ERROR_RETURN); - $this->db->expectError(MDB2_ERROR_NOT_FOUND); - foreach ($parameters as $key => $parameter) { - $err = $this->bindValue($parameter, $values[$parameter], $types[$key]); - if (MDB2::isError($err)) { - if ($err->getCode() == MDB2_ERROR_NOT_FOUND) { - //ignore (extra value for missing placeholder) - continue; - } - $this->db->popExpect(); - $this->db->popErrorHandling(); - return $err; - } - } - $this->db->popExpect(); - $this->db->popErrorHandling(); - return MDB2_OK; - } - - // }}} - // {{{ function bindParam($parameter, &$value, $type = null) - - /** - * Bind a variable to a parameter of a prepared query. - * - * @param int the order number of the parameter in the query - * statement. The order number of the first parameter is 1. - * @param mixed variable that is meant to be bound to specified - * parameter. The type of the value depends on the $type argument. - * @param string specifies the type of the field - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function bindParam($parameter, &$value, $type = null) - { - if (!is_numeric($parameter)) { - if (strpos($parameter, ':') === 0) { - $parameter = substr($parameter, 1); - } - } - if (!in_array($parameter, $this->positions)) { - return MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__); - } - $this->values[$parameter] =& $value; - if (null !== $type) { - $this->types[$parameter] = $type; - } - return MDB2_OK; - } - - // }}} - // {{{ function bindParamArray(&$values, $types = null) - - /** - * Bind the variables of multiple a parameter of a prepared query in bulk. - * - * @param array specifies all necessary information - * for bindParam() the array elements must use keys corresponding to - * the number of the position of the parameter. - * @param array specifies the types of the fields - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - * @see bindParam() - */ - function bindParamArray(&$values, $types = null) - { - $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null); - $parameters = array_keys($values); - foreach ($parameters as $key => $parameter) { - $err = $this->bindParam($parameter, $values[$parameter], $types[$key]); - if (MDB2::isError($err)) { - return $err; - } - } - return MDB2_OK; - } - - // }}} - // {{{ function &execute($values = null, $result_class = true, $result_wrap_class = false) - - /** - * Execute a prepared query statement. - * - * @param array specifies all necessary information - * for bindParam() the array elements must use keys corresponding - * to the number of the position of the parameter. - * @param mixed specifies which result class to use - * @param mixed specifies which class to wrap results in - * - * @return mixed MDB2_Result or integer (affected rows) on success, - * a MDB2 error on failure - * @access public - */ - function execute($values = null, $result_class = true, $result_wrap_class = false) - { - if (null === $this->positions) { - return MDB2::raiseError(MDB2_ERROR, null, null, - 'Prepared statement has already been freed', __FUNCTION__); - } - - $values = (array)$values; - if (!empty($values)) { - $err = $this->bindValueArray($values); - if (MDB2::isError($err)) { - return MDB2::raiseError(MDB2_ERROR, null, null, - 'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__); - } - } - $result = $this->_execute($result_class, $result_wrap_class); - return $result; - } - - // }}} - // {{{ function _execute($result_class = true, $result_wrap_class = false) - - /** - * Execute a prepared query statement helper method. - * - * @param mixed specifies which result class to use - * @param mixed specifies which class to wrap results in - * - * @return mixed MDB2_Result or integer (affected rows) on success, - * a MDB2 error on failure - * @access private - */ - function _execute($result_class = true, $result_wrap_class = false) - { - $this->last_query = $this->query; - $query = ''; - $last_position = 0; - foreach ($this->positions as $current_position => $parameter) { - if (!array_key_exists($parameter, $this->values)) { - return MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__); - } - $value = $this->values[$parameter]; - $query.= substr($this->query, $last_position, $current_position - $last_position); - if (!isset($value)) { - $value_quoted = 'NULL'; - } else { - $type = !empty($this->types[$parameter]) ? $this->types[$parameter] : null; - $value_quoted = $this->db->quote($value, $type); - if (MDB2::isError($value_quoted)) { - return $value_quoted; - } - } - $query.= $value_quoted; - $last_position = $current_position + 1; - } - $query.= substr($this->query, $last_position); - - $this->db->offset = $this->offset; - $this->db->limit = $this->limit; - if ($this->is_manip) { - $result = $this->db->exec($query); - } else { - $result = $this->db->query($query, $this->result_types, $result_class, $result_wrap_class); - } - return $result; - } - - // }}} - // {{{ function free() - - /** - * Release resources allocated for the specified prepared query. - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function free() - { - if (null === $this->positions) { - return MDB2::raiseError(MDB2_ERROR, null, null, - 'Prepared statement has already been freed', __FUNCTION__); - } - - $this->statement = null; - $this->positions = null; - $this->query = null; - $this->types = null; - $this->result_types = null; - $this->limit = null; - $this->is_manip = null; - $this->offset = null; - $this->values = null; - - return MDB2_OK; - } - - // }}} -} - -// }}} -// {{{ class MDB2_Module_Common - -/** - * The common modules class for MDB2 module objects - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Module_Common -{ - // {{{ Variables (Properties) - - /** - * contains the key to the global MDB2 instance array of the associated - * MDB2 instance - * - * @var int - * @access protected - */ - protected $db_index; - - // }}} - // {{{ constructor: function __construct($db_index) - - /** - * Constructor - */ - function __construct($db_index) - { - $this->db_index = $db_index; - } - - // }}} - // {{{ function getDBInstance() - - /** - * Get the instance of MDB2 associated with the module instance - * - * @return object MDB2 instance or a MDB2 error on failure - * - * @access public - */ - function getDBInstance() - { - if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) { - $result = $GLOBALS['_MDB2_databases'][$this->db_index]; - } else { - $result = MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'could not find MDB2 instance'); - } - return $result; - } - - // }}} -} - -// }}} -// {{{ function MDB2_closeOpenTransactions() - -/** - * Close any open transactions form persistent connections - * - * @return void - * - * @access public - */ - -function MDB2_closeOpenTransactions() -{ - reset($GLOBALS['_MDB2_databases']); - while (next($GLOBALS['_MDB2_databases'])) { - $key = key($GLOBALS['_MDB2_databases']); - if ($GLOBALS['_MDB2_databases'][$key]->opened_persistent - && $GLOBALS['_MDB2_databases'][$key]->in_transaction - ) { - $GLOBALS['_MDB2_databases'][$key]->rollback(); - } - } -} - -// }}} -// {{{ function MDB2_defaultDebugOutput(&$db, $scope, $message, $is_manip = null) - -/** - * default debug output handler - * - * @param object reference to an MDB2 database object - * @param string usually the method name that triggered the debug call: - * for example 'query', 'prepare', 'execute', 'parameters', - * 'beginTransaction', 'commit', 'rollback' - * @param string message that should be appended to the debug variable - * @param array contains context information about the debug() call - * common keys are: is_manip, time, result etc. - * - * @return void|string optionally return a modified message, this allows - * rewriting a query before being issued or prepared - * - * @access public - */ -function MDB2_defaultDebugOutput(&$db, $scope, $message, $context = array()) -{ - $db->debug_output.= $scope.'('.$db->db_index.'): '; - $db->debug_output.= $message.$db->getOption('log_line_break'); - return $message; -} - -// }}} -?> diff --git a/data/module/MDB2/Date.php b/data/module/MDB2/Date.php deleted file mode 100644 index e867e48e5bc..00000000000 --- a/data/module/MDB2/Date.php +++ /dev/null @@ -1,183 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Date.php 327316 2012-08-27 15:17:02Z danielc $ -// - -/** - * @package MDB2 - * @category Database - * @author Lukas Smith - */ - -/** - * Several methods to convert the MDB2 native timestamp format (ISO based) - * to and from data structures that are convenient to worth with in side of php. - * For more complex date arithmetic please take a look at the Date package in PEAR - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Date -{ - // {{{ mdbNow() - - /** - * return the current datetime - * - * @return string current datetime in the MDB2 format - * @access public - */ - public static function mdbNow() - { - return date('Y-m-d H:i:s'); - } - // }}} - - // {{{ mdbToday() - - /** - * return the current date - * - * @return string current date in the MDB2 format - * @access public - */ - public static function mdbToday() - { - return date('Y-m-d'); - } - // }}} - - // {{{ mdbTime() - - /** - * return the current time - * - * @return string current time in the MDB2 format - * @access public - */ - public static function mdbTime() - { - return date('H:i:s'); - } - // }}} - - // {{{ date2Mdbstamp() - - /** - * convert a date into a MDB2 timestamp - * - * @param int hour of the date - * @param int minute of the date - * @param int second of the date - * @param int month of the date - * @param int day of the date - * @param int year of the date - * - * @return string a valid MDB2 timestamp - * @access public - */ - public static function date2Mdbstamp($hour = null, $minute = null, $second = null, - $month = null, $day = null, $year = null) - { - return MDB2_Date::unix2Mdbstamp(mktime($hour, $minute, $second, $month, $day, $year, -1)); - } - // }}} - - // {{{ unix2Mdbstamp() - - /** - * convert a unix timestamp into a MDB2 timestamp - * - * @param int a valid unix timestamp - * - * @return string a valid MDB2 timestamp - * @access public - */ - public static function unix2Mdbstamp($unix_timestamp) - { - return date('Y-m-d H:i:s', $unix_timestamp); - } - // }}} - - // {{{ mdbstamp2Unix() - - /** - * convert a MDB2 timestamp into a unix timestamp - * - * @param int a valid MDB2 timestamp - * @return string unix timestamp with the time stored in the MDB2 format - * - * @access public - */ - public static function mdbstamp2Unix($mdb_timestamp) - { - $arr = MDB2_Date::mdbstamp2Date($mdb_timestamp); - - return mktime($arr['hour'], $arr['minute'], $arr['second'], $arr['month'], $arr['day'], $arr['year'], -1); - } - // }}} - - // {{{ mdbstamp2Date() - - /** - * convert a MDB2 timestamp into an array containing all - * values necessary to pass to php's date() function - * - * @param int a valid MDB2 timestamp - * - * @return array with the time split - * @access public - */ - public static function mdbstamp2Date($mdb_timestamp) - { - list($arr['year'], $arr['month'], $arr['day'], $arr['hour'], $arr['minute'], $arr['second']) = - sscanf($mdb_timestamp, "%04u-%02u-%02u %02u:%02u:%02u"); - return $arr; - } - // }}} -} - -?> diff --git a/data/module/MDB2/Driver/Datatype/Common.php b/data/module/MDB2/Driver/Datatype/Common.php deleted file mode 100644 index a06e37ceafb..00000000000 --- a/data/module/MDB2/Driver/Datatype/Common.php +++ /dev/null @@ -1,1847 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Common.php 328137 2012-10-25 02:26:35Z danielc $ - -require_once 'MDB2/LOB.php'; - -/** - * @package MDB2 - * @category Database - * @author Lukas Smith - */ - -/** - * MDB2_Driver_Common: Base class that is extended by each MDB2 driver - * - * To load this module in the MDB2 object: - * $mdb->loadModule('Datatype'); - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Datatype_Common extends MDB2_Module_Common -{ - var $valid_default_values = array( - 'text' => '', - 'boolean' => true, - 'integer' => 0, - 'decimal' => 0.0, - 'float' => 0.0, - 'timestamp' => '1970-01-01 00:00:00', - 'time' => '00:00:00', - 'date' => '1970-01-01', - 'clob' => '', - 'blob' => '', - ); - - /** - * contains all LOB objects created with this MDB2 instance - * @var array - * @access protected - */ - var $lobs = array(); - - // }}} - // {{{ getValidTypes() - - /** - * Get the list of valid types - * - * This function returns an array of valid types as keys with the values - * being possible default values for all native datatypes and mapped types - * for custom datatypes. - * - * @return mixed array on success, a MDB2 error on failure - * @access public - */ - function getValidTypes() - { - $types = $this->valid_default_values; - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if (!empty($db->options['datatype_map'])) { - foreach ($db->options['datatype_map'] as $type => $mapped_type) { - if (array_key_exists($mapped_type, $types)) { - $types[$type] = $types[$mapped_type]; - } elseif (!empty($db->options['datatype_map_callback'][$type])) { - $parameter = array('type' => $type, 'mapped_type' => $mapped_type); - $default = call_user_func_array($db->options['datatype_map_callback'][$type], array(&$db, __FUNCTION__, $parameter)); - $types[$type] = $default; - } - } - } - return $types; - } - - // }}} - // {{{ checkResultTypes() - - /** - * Define the list of types to be associated with the columns of a given - * result set. - * - * This function may be called before invoking fetchRow(), fetchOne() - * fetchCole() and fetchAll() so that the necessary data type - * conversions are performed on the data to be retrieved by them. If this - * function is not called, the type of all result set columns is assumed - * to be text, thus leading to not perform any conversions. - * - * @param array $types array variable that lists the - * data types to be expected in the result set columns. If this array - * contains less types than the number of columns that are returned - * in the result set, the remaining columns are assumed to be of the - * type text. Currently, the types clob and blob are not fully - * supported. - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function checkResultTypes($types) - { - $types = is_array($types) ? $types : array($types); - foreach ($types as $key => $type) { - if (!isset($this->valid_default_values[$type])) { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if (empty($db->options['datatype_map'][$type])) { - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - $type.' for '.$key.' is not a supported column type', __FUNCTION__); - } - } - } - return $types; - } - - // }}} - // {{{ _baseConvertResult() - - /** - * General type conversion method - * - * @param mixed $value reference to a value to be converted - * @param string $type specifies which type to convert to - * @param boolean $rtrim [optional] when TRUE [default], apply rtrim() to text - * @return object an MDB2 error on failure - * @access protected - */ - function _baseConvertResult($value, $type, $rtrim = true) - { - switch ($type) { - case 'text': - if ($rtrim) { - $value = rtrim($value); - } - return $value; - case 'integer': - return intval($value); - case 'boolean': - return !empty($value); - case 'decimal': - return $value; - case 'float': - return doubleval($value); - case 'date': - return $value; - case 'time': - return $value; - case 'timestamp': - return $value; - case 'clob': - case 'blob': - $this->lobs[] = array( - 'buffer' => null, - 'position' => 0, - 'lob_index' => null, - 'endOfLOB' => false, - 'resource' => $value, - 'value' => null, - 'loaded' => false, - ); - end($this->lobs); - $lob_index = key($this->lobs); - $this->lobs[$lob_index]['lob_index'] = $lob_index; - return fopen('MDB2LOB://'.$lob_index.'@'.$this->db_index, 'r+'); - } - - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_INVALID, null, null, - 'attempt to convert result value to an unknown type :' . $type, __FUNCTION__); - } - - // }}} - // {{{ convertResult() - - /** - * Convert a value to a RDBMS indipendent MDB2 type - * - * @param mixed $value value to be converted - * @param string $type specifies which type to convert to - * @param boolean $rtrim [optional] when TRUE [default], apply rtrim() to text - * @return mixed converted value - * @access public - */ - function convertResult($value, $type, $rtrim = true) - { - if (null === $value) { - return null; - } - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if (!empty($db->options['datatype_map'][$type])) { - $type = $db->options['datatype_map'][$type]; - if (!empty($db->options['datatype_map_callback'][$type])) { - $parameter = array('type' => $type, 'value' => $value, 'rtrim' => $rtrim); - return call_user_func_array($db->options['datatype_map_callback'][$type], array(&$db, __FUNCTION__, $parameter)); - } - } - return $this->_baseConvertResult($value, $type, $rtrim); - } - - // }}} - // {{{ convertResultRow() - - /** - * Convert a result row - * - * @param array $types - * @param array $row specifies the types to convert to - * @param boolean $rtrim [optional] when TRUE [default], apply rtrim() to text - * @return mixed MDB2_OK on success, an MDB2 error on failure - * @access public - */ - function convertResultRow($types, $row, $rtrim = true) - { - //$types = $this->_sortResultFieldTypes(array_keys($row), $types); - $keys = array_keys($row); - if (is_int($keys[0])) { - $types = $this->_sortResultFieldTypes($keys, $types); - } - foreach ($row as $key => $value) { - if (empty($types[$key])) { - continue; - } - $value = $this->convertResult($row[$key], $types[$key], $rtrim); - if (MDB2::isError($value)) { - return $value; - } - $row[$key] = $value; - } - return $row; - } - - // }}} - // {{{ _sortResultFieldTypes() - - /** - * convert a result row - * - * @param array $types - * @param array $row specifies the types to convert to - * @param bool $rtrim if to rtrim text values or not - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function _sortResultFieldTypes($columns, $types) - { - $n_cols = count($columns); - $n_types = count($types); - if ($n_cols > $n_types) { - for ($i= $n_cols - $n_types; $i >= 0; $i--) { - $types[] = null; - } - } - $sorted_types = array(); - foreach ($columns as $col) { - $sorted_types[$col] = null; - } - foreach ($types as $name => $type) { - if (array_key_exists($name, $sorted_types)) { - $sorted_types[$name] = $type; - unset($types[$name]); - } - } - // if there are left types in the array, fill the null values of the - // sorted array with them, in order. - if (count($types)) { - reset($types); - foreach (array_keys($sorted_types) as $k) { - if (null === $sorted_types[$k]) { - $sorted_types[$k] = current($types); - next($types); - } - } - } - return $sorted_types; - } - - // }}} - // {{{ getDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare - * of the given type - * - * @param string $type type to which the value should be converted to - * @param string $name name the field to be declared. - * @param string $field definition of the field - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access public - */ - function getDeclaration($type, $name, $field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if (!empty($db->options['datatype_map'][$type])) { - $type = $db->options['datatype_map'][$type]; - if (!empty($db->options['datatype_map_callback'][$type])) { - $parameter = array('type' => $type, 'name' => $name, 'field' => $field); - return call_user_func_array($db->options['datatype_map_callback'][$type], array(&$db, __FUNCTION__, $parameter)); - } - $field['type'] = $type; - } - - if (!method_exists($this, "_get{$type}Declaration")) { - return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'type not defined: '.$type, __FUNCTION__); - } - return $this->{"_get{$type}Declaration"}($name, $field); - } - - // }}} - // {{{ getTypeDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an text type - * field to be used in statements like CREATE TABLE. - * - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * length - * Integer value that determines the maximum length of the text - * field. If this argument is missing the field should be - * declared to have the longest length allowed by the DBMS. - * - * default - * Text value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access public - */ - function getTypeDeclaration($field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - switch ($field['type']) { - case 'text': - $length = !empty($field['length']) ? $field['length'] : $db->options['default_text_field_length']; - $fixed = !empty($field['fixed']) ? $field['fixed'] : false; - return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')') - : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); - case 'clob': - return 'TEXT'; - case 'blob': - return 'TEXT'; - case 'integer': - return 'INT'; - case 'boolean': - return 'INT'; - case 'date': - return 'CHAR ('.strlen('YYYY-MM-DD').')'; - case 'time': - return 'CHAR ('.strlen('HH:MM:SS').')'; - case 'timestamp': - return 'CHAR ('.strlen('YYYY-MM-DD HH:MM:SS').')'; - case 'float': - return 'TEXT'; - case 'decimal': - return 'TEXT'; - } - return ''; - } - - // }}} - // {{{ _getDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare a generic type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * length - * Integer value that determines the maximum length of the text - * field. If this argument is missing the field should be - * declared to have the longest length allowed by the DBMS. - * - * default - * Text value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * charset - * Text value with the default CHARACTER SET for this field. - * collation - * Text value with the default COLLATION for this field. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field, or a MDB2_Error on failure - * @access protected - */ - function _getDeclaration($name, $field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($name, true); - $declaration_options = $db->datatype->_getDeclarationOptions($field); - if (MDB2::isError($declaration_options)) { - return $declaration_options; - } - return $name.' '.$this->getTypeDeclaration($field).$declaration_options; - } - - // }}} - // {{{ _getDeclarationOptions() - - /** - * Obtain DBMS specific SQL code portion needed to declare a generic type - * field to be used in statement like CREATE TABLE, without the field name - * and type values (ie. just the character set, default value, if the - * field is permitted to be NULL or not, and the collation options). - * - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * default - * Text value to be used as default for this field. - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * charset - * Text value with the default CHARACTER SET for this field. - * collation - * Text value with the default COLLATION for this field. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field's options. - * @access protected - */ - function _getDeclarationOptions($field) - { - $charset = empty($field['charset']) ? '' : - ' '.$this->_getCharsetFieldDeclaration($field['charset']); - - $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; - $default = ''; - if (array_key_exists('default', $field)) { - if ($field['default'] === '') { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - $valid_default_values = $this->getValidTypes(); - $field['default'] = $valid_default_values[$field['type']]; - if ($field['default'] === '' && ($db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL)) { - $field['default'] = ' '; - } - } - if (null !== $field['default']) { - $default = ' DEFAULT ' . $this->quote($field['default'], $field['type']); - } - } - - $collation = empty($field['collation']) ? '' : - ' '.$this->_getCollationFieldDeclaration($field['collation']); - - return $charset.$default.$notnull.$collation; - } - - // }}} - // {{{ _getCharsetFieldDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to set the CHARACTER SET - * of a field declaration to be used in statements like CREATE TABLE. - * - * @param string $charset name of the charset - * @return string DBMS specific SQL code portion needed to set the CHARACTER SET - * of a field declaration. - */ - function _getCharsetFieldDeclaration($charset) - { - return ''; - } - - // }}} - // {{{ _getCollationFieldDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to set the COLLATION - * of a field declaration to be used in statements like CREATE TABLE. - * - * @param string $collation name of the collation - * @return string DBMS specific SQL code portion needed to set the COLLATION - * of a field declaration. - */ - function _getCollationFieldDeclaration($collation) - { - return ''; - } - - // }}} - // {{{ _getIntegerDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an integer type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * unsigned - * Boolean flag that indicates whether the field should be - * declared as unsigned integer if possible. - * - * default - * Integer value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getIntegerDeclaration($name, $field) - { - if (!empty($field['unsigned'])) { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $db->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer"; - } - return $this->_getDeclaration($name, $field); - } - - // }}} - // {{{ _getTextDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an text type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * length - * Integer value that determines the maximum length of the text - * field. If this argument is missing the field should be - * declared to have the longest length allowed by the DBMS. - * - * default - * Text value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getTextDeclaration($name, $field) - { - return $this->_getDeclaration($name, $field); - } - - // }}} - // {{{ _getCLOBDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an character - * large object type field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * length - * Integer value that determines the maximum length of the large - * object field. If this argument is missing the field should be - * declared to have the longest length allowed by the DBMS. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access public - */ - function _getCLOBDeclaration($name, $field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; - $name = $db->quoteIdentifier($name, true); - return $name.' '.$this->getTypeDeclaration($field).$notnull; - } - - // }}} - // {{{ _getBLOBDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an binary large - * object type field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * length - * Integer value that determines the maximum length of the large - * object field. If this argument is missing the field should be - * declared to have the longest length allowed by the DBMS. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getBLOBDeclaration($name, $field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; - $name = $db->quoteIdentifier($name, true); - return $name.' '.$this->getTypeDeclaration($field).$notnull; - } - - // }}} - // {{{ _getBooleanDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare a boolean type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * default - * Boolean value to be used as default for this field. - * - * notnullL - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getBooleanDeclaration($name, $field) - { - return $this->_getDeclaration($name, $field); - } - - // }}} - // {{{ _getDateDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare a date type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * default - * Date value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getDateDeclaration($name, $field) - { - return $this->_getDeclaration($name, $field); - } - - // }}} - // {{{ _getTimestampDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare a timestamp - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * default - * Timestamp value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getTimestampDeclaration($name, $field) - { - return $this->_getDeclaration($name, $field); - } - - // }}} - // {{{ _getTimeDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare a time - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * default - * Time value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getTimeDeclaration($name, $field) - { - return $this->_getDeclaration($name, $field); - } - - // }}} - // {{{ _getFloatDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare a float type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * default - * Float value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getFloatDeclaration($name, $field) - { - return $this->_getDeclaration($name, $field); - } - - // }}} - // {{{ _getDecimalDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare a decimal type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * default - * Decimal value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getDecimalDeclaration($name, $field) - { - return $this->_getDeclaration($name, $field); - } - - // }}} - // {{{ compareDefinition() - - /** - * Obtain an array of changes that may need to applied - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access public - */ - function compareDefinition($current, $previous) - { - $type = !empty($current['type']) ? $current['type'] : null; - - if (!method_exists($this, "_compare{$type}Definition")) { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if (!empty($db->options['datatype_map_callback'][$type])) { - $parameter = array('current' => $current, 'previous' => $previous); - $change = call_user_func_array($db->options['datatype_map_callback'][$type], array(&$db, __FUNCTION__, $parameter)); - return $change; - } - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'type "'.$current['type'].'" is not yet supported', __FUNCTION__); - } - - if (empty($previous['type']) || $previous['type'] != $type) { - return $current; - } - - $change = $this->{"_compare{$type}Definition"}($current, $previous); - - if ($previous['type'] != $type) { - $change['type'] = true; - } - - $previous_notnull = !empty($previous['notnull']) ? $previous['notnull'] : false; - $notnull = !empty($current['notnull']) ? $current['notnull'] : false; - if ($previous_notnull != $notnull) { - $change['notnull'] = true; - } - - $previous_default = array_key_exists('default', $previous) ? $previous['default'] : - null; - $default = array_key_exists('default', $current) ? $current['default'] : - null; - if ($previous_default !== $default) { - $change['default'] = true; - } - - return $change; - } - - // }}} - // {{{ _compareIntegerDefinition() - - /** - * Obtain an array of changes that may need to applied to an integer field - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access protected - */ - function _compareIntegerDefinition($current, $previous) - { - $change = array(); - $previous_length = !empty($previous['length']) ? $previous['length'] : 4; - $length = !empty($current['length']) ? $current['length'] : 4; - if ($previous_length != $length) { - $change['length'] = $length; - } - $previous_unsigned = !empty($previous['unsigned']) ? $previous['unsigned'] : false; - $unsigned = !empty($current['unsigned']) ? $current['unsigned'] : false; - if ($previous_unsigned != $unsigned) { - $change['unsigned'] = true; - } - $previous_autoincrement = !empty($previous['autoincrement']) ? $previous['autoincrement'] : false; - $autoincrement = !empty($current['autoincrement']) ? $current['autoincrement'] : false; - if ($previous_autoincrement != $autoincrement) { - $change['autoincrement'] = true; - } - return $change; - } - - // }}} - // {{{ _compareTextDefinition() - - /** - * Obtain an array of changes that may need to applied to an text field - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access protected - */ - function _compareTextDefinition($current, $previous) - { - $change = array(); - $previous_length = !empty($previous['length']) ? $previous['length'] : 0; - $length = !empty($current['length']) ? $current['length'] : 0; - if ($previous_length != $length) { - $change['length'] = true; - } - $previous_fixed = !empty($previous['fixed']) ? $previous['fixed'] : 0; - $fixed = !empty($current['fixed']) ? $current['fixed'] : 0; - if ($previous_fixed != $fixed) { - $change['fixed'] = true; - } - return $change; - } - - // }}} - // {{{ _compareCLOBDefinition() - - /** - * Obtain an array of changes that may need to applied to an CLOB field - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access protected - */ - function _compareCLOBDefinition($current, $previous) - { - return $this->_compareTextDefinition($current, $previous); - } - - // }}} - // {{{ _compareBLOBDefinition() - - /** - * Obtain an array of changes that may need to applied to an BLOB field - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access protected - */ - function _compareBLOBDefinition($current, $previous) - { - return $this->_compareTextDefinition($current, $previous); - } - - // }}} - // {{{ _compareDateDefinition() - - /** - * Obtain an array of changes that may need to applied to an date field - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access protected - */ - function _compareDateDefinition($current, $previous) - { - return array(); - } - - // }}} - // {{{ _compareTimeDefinition() - - /** - * Obtain an array of changes that may need to applied to an time field - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access protected - */ - function _compareTimeDefinition($current, $previous) - { - return array(); - } - - // }}} - // {{{ _compareTimestampDefinition() - - /** - * Obtain an array of changes that may need to applied to an timestamp field - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access protected - */ - function _compareTimestampDefinition($current, $previous) - { - return array(); - } - - // }}} - // {{{ _compareBooleanDefinition() - - /** - * Obtain an array of changes that may need to applied to an boolean field - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access protected - */ - function _compareBooleanDefinition($current, $previous) - { - return array(); - } - - // }}} - // {{{ _compareFloatDefinition() - - /** - * Obtain an array of changes that may need to applied to an float field - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access protected - */ - function _compareFloatDefinition($current, $previous) - { - return array(); - } - - // }}} - // {{{ _compareDecimalDefinition() - - /** - * Obtain an array of changes that may need to applied to an decimal field - * - * @param array $current new definition - * @param array $previous old definition - * @return array containing all changes that will need to be applied - * @access protected - */ - function _compareDecimalDefinition($current, $previous) - { - return array(); - } - - // }}} - // {{{ quote() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param string $type type to which the value should be converted to - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access public - */ - function quote($value, $type = null, $quote = true, $escape_wildcards = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if ((null === $value) - || ($value === '' && $db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL) - ) { - if (!$quote) { - return null; - } - return 'NULL'; - } - - if (null === $type) { - switch (gettype($value)) { - case 'integer': - $type = 'integer'; - break; - case 'double': - // todo: default to decimal as float is quite unusual - // $type = 'float'; - $type = 'decimal'; - break; - case 'boolean': - $type = 'boolean'; - break; - case 'array': - $value = serialize($value); - case 'object': - $type = 'text'; - break; - default: - if (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/', $value)) { - $type = 'timestamp'; - } elseif (preg_match('/^\d{2}:\d{2}$/', $value)) { - $type = 'time'; - } elseif (preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) { - $type = 'date'; - } else { - $type = 'text'; - } - break; - } - } elseif (!empty($db->options['datatype_map'][$type])) { - $type = $db->options['datatype_map'][$type]; - if (!empty($db->options['datatype_map_callback'][$type])) { - $parameter = array('type' => $type, 'value' => $value, 'quote' => $quote, 'escape_wildcards' => $escape_wildcards); - return call_user_func_array($db->options['datatype_map_callback'][$type], array(&$db, __FUNCTION__, $parameter)); - } - } - - if (!method_exists($this, "_quote{$type}")) { - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'type not defined: '.$type, __FUNCTION__); - } - $value = $this->{"_quote{$type}"}($value, $quote, $escape_wildcards); - if ($quote && $escape_wildcards && $db->string_quoting['escape_pattern'] - && $db->string_quoting['escape'] !== $db->string_quoting['escape_pattern'] - ) { - $value.= $this->patternEscapeString(); - } - return $value; - } - - // }}} - // {{{ _quoteInteger() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteInteger($value, $quote, $escape_wildcards) - { - return (int)$value; - } - - // }}} - // {{{ _quoteText() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that already contains any DBMS specific - * escaped character sequences. - * @access protected - */ - function _quoteText($value, $quote, $escape_wildcards) - { - if (!$quote) { - return $value; - } - - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $value = $db->escape($value, $escape_wildcards); - if (MDB2::isError($value)) { - return $value; - } - return "'".$value."'"; - } - - // }}} - // {{{ _readFile() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _readFile($value) - { - $close = false; - if (preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) { - $close = true; - if (strtolower($match[1]) == 'file://') { - $value = $match[2]; - } - $value = @fopen($value, 'r'); - } - - if (is_resource($value)) { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $fp = $value; - $value = ''; - while (!@feof($fp)) { - $value.= @fread($fp, $db->options['lob_buffer_length']); - } - if ($close) { - @fclose($fp); - } - } - - return $value; - } - - // }}} - // {{{ _quoteLOB() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteLOB($value, $quote, $escape_wildcards) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if ($db->options['lob_allow_url_include']) { - $value = $this->_readFile($value); - if (MDB2::isError($value)) { - return $value; - } - } - return $this->_quoteText($value, $quote, $escape_wildcards); - } - - // }}} - // {{{ _quoteCLOB() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteCLOB($value, $quote, $escape_wildcards) - { - return $this->_quoteLOB($value, $quote, $escape_wildcards); - } - - // }}} - // {{{ _quoteBLOB() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteBLOB($value, $quote, $escape_wildcards) - { - return $this->_quoteLOB($value, $quote, $escape_wildcards); - } - - // }}} - // {{{ _quoteBoolean() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteBoolean($value, $quote, $escape_wildcards) - { - return ($value ? 1 : 0); - } - - // }}} - // {{{ _quoteDate() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteDate($value, $quote, $escape_wildcards) - { - if ($value === 'CURRENT_DATE') { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if (isset($db->function) && is_object($this->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { - return $db->function->now('date'); - } - return 'CURRENT_DATE'; - } - return $this->_quoteText($value, $quote, $escape_wildcards); - } - - // }}} - // {{{ _quoteTimestamp() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteTimestamp($value, $quote, $escape_wildcards) - { - if ($value === 'CURRENT_TIMESTAMP') { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if (isset($db->function) && is_object($db->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { - return $db->function->now('timestamp'); - } - return 'CURRENT_TIMESTAMP'; - } - return $this->_quoteText($value, $quote, $escape_wildcards); - } - - // }}} - // {{{ _quoteTime() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteTime($value, $quote, $escape_wildcards) - { - if ($value === 'CURRENT_TIME') { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if (isset($db->function) && is_object($this->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { - return $db->function->now('time'); - } - return 'CURRENT_TIME'; - } - return $this->_quoteText($value, $quote, $escape_wildcards); - } - - // }}} - // {{{ _quoteFloat() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteFloat($value, $quote, $escape_wildcards) - { - if (preg_match('/^(.*)e([-+])(\d+)$/i', $value, $matches)) { - $decimal = $this->_quoteDecimal($matches[1], $quote, $escape_wildcards); - $sign = $matches[2]; - $exponent = str_pad($matches[3], 2, '0', STR_PAD_LEFT); - $value = $decimal.'E'.$sign.$exponent; - } else { - $value = $this->_quoteDecimal($value, $quote, $escape_wildcards); - } - return $value; - } - - // }}} - // {{{ _quoteDecimal() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteDecimal($value, $quote, $escape_wildcards) - { - $value = (string)$value; - $value = preg_replace('/[^\d\.,\-+eE]/', '', $value); - if (preg_match('/[^\.\d]/', $value)) { - if (strpos($value, ',')) { - // 1000,00 - if (!strpos($value, '.')) { - // convert the last "," to a "." - $value = strrev(str_replace(',', '.', strrev($value))); - // 1.000,00 - } elseif (strpos($value, '.') && strpos($value, '.') < strpos($value, ',')) { - $value = str_replace('.', '', $value); - // convert the last "," to a "." - $value = strrev(str_replace(',', '.', strrev($value))); - // 1,000.00 - } else { - $value = str_replace(',', '', $value); - } - } - } - return $value; - } - - // }}} - // {{{ writeLOBToFile() - - /** - * retrieve LOB from the database - * - * @param resource $lob stream handle - * @param string $file name of the file into which the LOb should be fetched - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access protected - */ - function writeLOBToFile($lob, $file) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if (preg_match('/^(\w+:\/\/)(.*)$/', $file, $match)) { - if ($match[1] == 'file://') { - $file = $match[2]; - } - } - - $fp = @fopen($file, 'wb'); - while (!@feof($lob)) { - $result = @fread($lob, $db->options['lob_buffer_length']); - $read = strlen($result); - if (@fwrite($fp, $result, $read) != $read) { - @fclose($fp); - return $db->raiseError(MDB2_ERROR, null, null, - 'could not write to the output file', __FUNCTION__); - } - } - @fclose($fp); - return MDB2_OK; - } - - // }}} - // {{{ _retrieveLOB() - - /** - * retrieve LOB from the database - * - * @param array $lob array - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access protected - */ - function _retrieveLOB(&$lob) - { - if (null === $lob['value']) { - $lob['value'] = $lob['resource']; - } - $lob['loaded'] = true; - return MDB2_OK; - } - - // }}} - // {{{ readLOB() - - /** - * Read data from large object input stream. - * - * @param resource $lob stream handle - * @param string $data reference to a variable that will hold data - * to be read from the large object input stream - * @param integer $length value that indicates the largest ammount ofdata - * to be read from the large object input stream. - * @return mixed the effective number of bytes read from the large object - * input stream on sucess or an MDB2 error object. - * @access public - * @see endOfLOB() - */ - function _readLOB($lob, $length) - { - return substr($lob['value'], $lob['position'], $length); - } - - // }}} - // {{{ _endOfLOB() - - /** - * Determine whether it was reached the end of the large object and - * therefore there is no more data to be read for the its input stream. - * - * @param array $lob array - * @return mixed true or false on success, a MDB2 error on failure - * @access protected - */ - function _endOfLOB($lob) - { - return $lob['endOfLOB']; - } - - // }}} - // {{{ destroyLOB() - - /** - * Free any resources allocated during the lifetime of the large object - * handler object. - * - * @param resource $lob stream handle - * @access public - */ - function destroyLOB($lob) - { - $lob_data = stream_get_meta_data($lob); - $lob_index = $lob_data['wrapper_data']->lob_index; - fclose($lob); - if (isset($this->lobs[$lob_index])) { - $this->_destroyLOB($this->lobs[$lob_index]); - unset($this->lobs[$lob_index]); - } - return MDB2_OK; - } - - // }}} - // {{{ _destroyLOB() - - /** - * Free any resources allocated during the lifetime of the large object - * handler object. - * - * @param array $lob array - * @access private - */ - function _destroyLOB(&$lob) - { - return MDB2_OK; - } - - // }}} - // {{{ implodeArray() - - /** - * apply a type to all values of an array and return as a comma seperated string - * useful for generating IN statements - * - * @access public - * - * @param array $array data array - * @param string $type determines type of the field - * - * @return string comma seperated values - */ - function implodeArray($array, $type = false) - { - if (!is_array($array) || empty($array)) { - return 'NULL'; - } - if ($type) { - foreach ($array as $value) { - $return[] = $this->quote($value, $type); - } - } else { - $return = $array; - } - return implode(', ', $return); - } - - // }}} - // {{{ matchPattern() - - /** - * build a pattern matching string - * - * @access public - * - * @param array $pattern even keys are strings, odd are patterns (% and _) - * @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future) - * @param string $field optional field name that is being matched against - * (might be required when emulating ILIKE) - * - * @return string SQL pattern - */ - function matchPattern($pattern, $operator = null, $field = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $match = ''; - if (null !== $operator) { - $operator = strtoupper($operator); - switch ($operator) { - // case insensitive - case 'ILIKE': - if (null === $field) { - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'case insensitive LIKE matching requires passing the field name', __FUNCTION__); - } - $db->loadModule('Function', null, true); - $match = $db->function->lower($field).' LIKE '; - break; - case 'NOT ILIKE': - if (null === $field) { - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'case insensitive NOT ILIKE matching requires passing the field name', __FUNCTION__); - } - $db->loadModule('Function', null, true); - $match = $db->function->lower($field).' NOT LIKE '; - break; - // case sensitive - case 'LIKE': - $match = (null === $field) ? 'LIKE ' : ($field.' LIKE '); - break; - case 'NOT LIKE': - $match = (null === $field) ? 'NOT LIKE ' : ($field.' NOT LIKE '); - break; - default: - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'not a supported operator type:'. $operator, __FUNCTION__); - } - } - $match.= "'"; - foreach ($pattern as $key => $value) { - if ($key % 2) { - $match.= $value; - } else { - $escaped = $db->escape($value); - if (MDB2::isError($escaped)) { - return $escaped; - } - $match.= $db->escapePattern($escaped); - } - } - $match.= "'"; - $match.= $this->patternEscapeString(); - return $match; - } - - // }}} - // {{{ patternEscapeString() - - /** - * build string to define pattern escape character - * - * @access public - * - * @return string define pattern escape character - */ - function patternEscapeString() - { - return ''; - } - - // }}} - // {{{ mapNativeDatatype() - - /** - * Maps a native array description of a field to a MDB2 datatype and length - * - * @param array $field native field description - * @return array containing the various possible types, length, sign, fixed - * @access public - */ - function mapNativeDatatype($field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - // If the user has specified an option to map the native field - // type to a custom MDB2 datatype... - $db_type = strtok($field['type'], '(), '); - if (!empty($db->options['nativetype_map_callback'][$db_type])) { - return call_user_func_array($db->options['nativetype_map_callback'][$db_type], array($db, $field)); - } - - // Otherwise perform the built-in (i.e. normal) MDB2 native type to - // MDB2 datatype conversion - return $this->_mapNativeDatatype($field); - } - - // }}} - // {{{ _mapNativeDatatype() - - /** - * Maps a native array description of a field to a MDB2 datatype and length - * - * @param array $field native field description - * @return array containing the various possible types, length, sign, fixed - * @access public - */ - function _mapNativeDatatype($field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ mapPrepareDatatype() - - /** - * Maps an mdb2 datatype to mysqli prepare type - * - * @param string $type - * @return string - * @access public - */ - function mapPrepareDatatype($type) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if (!empty($db->options['datatype_map'][$type])) { - $type = $db->options['datatype_map'][$type]; - if (!empty($db->options['datatype_map_callback'][$type])) { - $parameter = array('type' => $type); - return call_user_func_array($db->options['datatype_map_callback'][$type], array(&$db, __FUNCTION__, $parameter)); - } - } - - return $type; - } -} -?> diff --git a/data/module/MDB2/Driver/Datatype/mysql.php b/data/module/MDB2/Driver/Datatype/mysql.php deleted file mode 100644 index 5d2385ddb8e..00000000000 --- a/data/module/MDB2/Driver/Datatype/mysql.php +++ /dev/null @@ -1,602 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: mysql.php 327310 2012-08-27 15:16:18Z danielc $ -// - -require_once 'MDB2/Driver/Datatype/Common.php'; - -/** - * MDB2 MySQL driver - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Datatype_mysql extends MDB2_Driver_Datatype_Common -{ - // {{{ _getCharsetFieldDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to set the CHARACTER SET - * of a field declaration to be used in statements like CREATE TABLE. - * - * @param string $charset name of the charset - * @return string DBMS specific SQL code portion needed to set the CHARACTER SET - * of a field declaration. - */ - function _getCharsetFieldDeclaration($charset) - { - return 'CHARACTER SET '.$charset; - } - - // }}} - // {{{ _getCollationFieldDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to set the COLLATION - * of a field declaration to be used in statements like CREATE TABLE. - * - * @param string $collation name of the collation - * @return string DBMS specific SQL code portion needed to set the COLLATION - * of a field declaration. - */ - function _getCollationFieldDeclaration($collation) - { - return 'COLLATE '.$collation; - } - - // }}} - // {{{ getDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare - * of the given type - * - * @param string $type type to which the value should be converted to - * @param string $name name the field to be declared. - * @param string $field definition of the field - * - * @return string DBMS-specific SQL code portion that should be used to - * declare the specified field. - * @access public - */ - function getDeclaration($type, $name, $field) - { - // MySQL DDL syntax forbids combining NOT NULL with DEFAULT NULL. - // To get a default of NULL for NOT NULL columns, omit it. - if ( isset($field['notnull']) - && !empty($field['notnull']) - && array_key_exists('default', $field) // do not use isset() here! - && null === $field['default'] - ) { - unset($field['default']); - } - return parent::getDeclaration($type, $name, $field); - } - - // }}} - // {{{ getTypeDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an text type - * field to be used in statements like CREATE TABLE. - * - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * length - * Integer value that determines the maximum length of the text - * field. If this argument is missing the field should be - * declared to have the longest length allowed by the DBMS. - * - * default - * Text value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access public - */ - function getTypeDeclaration($field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - switch ($field['type']) { - case 'text': - if (empty($field['length']) && array_key_exists('default', $field)) { - $field['length'] = $db->varchar_max_length; - } - $length = !empty($field['length']) ? $field['length'] : false; - $fixed = !empty($field['fixed']) ? $field['fixed'] : false; - return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR(255)') - : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); - case 'clob': - if (!empty($field['length'])) { - $length = $field['length']; - if ($length <= 255) { - return 'TINYTEXT'; - } elseif ($length <= 65532) { - return 'TEXT'; - } elseif ($length <= 16777215) { - return 'MEDIUMTEXT'; - } - } - return 'LONGTEXT'; - case 'blob': - if (!empty($field['length'])) { - $length = $field['length']; - if ($length <= 255) { - return 'TINYBLOB'; - } elseif ($length <= 65532) { - return 'BLOB'; - } elseif ($length <= 16777215) { - return 'MEDIUMBLOB'; - } - } - return 'LONGBLOB'; - case 'integer': - if (!empty($field['length'])) { - $length = $field['length']; - if ($length <= 1) { - return 'TINYINT'; - } elseif ($length == 2) { - return 'SMALLINT'; - } elseif ($length == 3) { - return 'MEDIUMINT'; - } elseif ($length == 4) { - return 'INT'; - } elseif ($length > 4) { - return 'BIGINT'; - } - } - return 'INT'; - case 'boolean': - return 'TINYINT(1)'; - case 'date': - return 'DATE'; - case 'time': - return 'TIME'; - case 'timestamp': - return 'DATETIME'; - case 'float': - $l = ''; - if (!empty($field['length'])) { - $l = '(' . $field['length']; - if (!empty($field['scale'])) { - $l .= ',' . $field['scale']; - } - $l .= ')'; - } - return 'DOUBLE' . $l; - case 'decimal': - $length = !empty($field['length']) ? $field['length'] : 18; - $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; - return 'DECIMAL('.$length.','.$scale.')'; - } - return ''; - } - - // }}} - // {{{ _getIntegerDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an integer type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param string $field associative array with the name of the properties - * of the field being declared as array indexes. - * Currently, the types of supported field - * properties are as follows: - * - * unsigned - * Boolean flag that indicates whether the field - * should be declared as unsigned integer if - * possible. - * - * default - * Integer value to be used as default for this - * field. - * - * notnull - * Boolean flag that indicates whether this field is - * constrained to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getIntegerDeclaration($name, $field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $default = $autoinc = ''; - if (!empty($field['autoincrement'])) { - $autoinc = ' AUTO_INCREMENT PRIMARY KEY'; - } elseif (array_key_exists('default', $field)) { - if ($field['default'] === '') { - $field['default'] = empty($field['notnull']) ? null : 0; - } - $default = ' DEFAULT '.$this->quote($field['default'], 'integer'); - } - - $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; - $unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED'; - if (empty($default) && empty($notnull)) { - $default = ' DEFAULT NULL'; - } - $name = $db->quoteIdentifier($name, true); - return $name.' '.$this->getTypeDeclaration($field).$unsigned.$default.$notnull.$autoinc; - } - - // }}} - // {{{ _getFloatDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an float type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param string $field associative array with the name of the properties - * of the field being declared as array indexes. - * Currently, the types of supported field - * properties are as follows: - * - * unsigned - * Boolean flag that indicates whether the field - * should be declared as unsigned float if - * possible. - * - * default - * float value to be used as default for this - * field. - * - * notnull - * Boolean flag that indicates whether this field is - * constrained to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getFloatDeclaration($name, $field) - { - // Since AUTO_INCREMENT can be used for integer or floating-point types, - // reuse the INTEGER declaration - // @see http://bugs.mysql.com/bug.php?id=31032 - return $this->_getIntegerDeclaration($name, $field); - } - - // }}} - // {{{ _getDecimalDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an decimal type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param string $field associative array with the name of the properties - * of the field being declared as array indexes. - * Currently, the types of supported field - * properties are as follows: - * - * unsigned - * Boolean flag that indicates whether the field - * should be declared as unsigned integer if - * possible. - * - * default - * Decimal value to be used as default for this - * field. - * - * notnull - * Boolean flag that indicates whether this field is - * constrained to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getDecimalDeclaration($name, $field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $default = ''; - if (array_key_exists('default', $field)) { - if ($field['default'] === '') { - $field['default'] = empty($field['notnull']) ? null : 0; - } - $default = ' DEFAULT '.$this->quote($field['default'], 'integer'); - } elseif (empty($field['notnull'])) { - $default = ' DEFAULT NULL'; - } - - $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; - $unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED'; - $name = $db->quoteIdentifier($name, true); - return $name.' '.$this->getTypeDeclaration($field).$unsigned.$default.$notnull; - } - - // }}} - // {{{ matchPattern() - - /** - * build a pattern matching string - * - * @access public - * - * @param array $pattern even keys are strings, odd are patterns (% and _) - * @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future) - * @param string $field optional field name that is being matched against - * (might be required when emulating ILIKE) - * - * @return string SQL pattern - */ - function matchPattern($pattern, $operator = null, $field = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $match = ''; - if (null !== $operator) { - $field = (null === $field) ? '' : $field.' '; - $operator = strtoupper($operator); - switch ($operator) { - // case insensitive - case 'ILIKE': - $match = $field.'LIKE '; - break; - case 'NOT ILIKE': - $match = $field.'NOT LIKE '; - break; - // case sensitive - case 'LIKE': - $match = $field.'LIKE BINARY '; - break; - case 'NOT LIKE': - $match = $field.'NOT LIKE BINARY '; - break; - default: - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'not a supported operator type:'. $operator, __FUNCTION__); - } - } - $match.= "'"; - foreach ($pattern as $key => $value) { - if ($key % 2) { - $match.= $value; - } else { - $match.= $db->escapePattern($db->escape($value)); - } - } - $match.= "'"; - $match.= $this->patternEscapeString(); - return $match; - } - - // }}} - // {{{ _mapNativeDatatype() - - /** - * Maps a native array description of a field to a MDB2 datatype and length - * - * @param array $field native field description - * @return array containing the various possible types, length, sign, fixed - * @access public - */ - function _mapNativeDatatype($field) - { - $db_type = strtolower($field['type']); - $db_type = strtok($db_type, '(), '); - if ($db_type == 'national') { - $db_type = strtok('(), '); - } - if (!empty($field['length'])) { - $length = strtok($field['length'], ', '); - $decimal = strtok(', '); - } else { - $length = strtok('(), '); - $decimal = strtok('(), '); - } - $type = array(); - $unsigned = $fixed = null; - switch ($db_type) { - case 'tinyint': - $type[] = 'integer'; - $type[] = 'boolean'; - if (preg_match('/^(is|has)/', $field['name'])) { - $type = array_reverse($type); - } - $unsigned = preg_match('/ unsigned/i', $field['type']); - $length = 1; - break; - case 'smallint': - $type[] = 'integer'; - $unsigned = preg_match('/ unsigned/i', $field['type']); - $length = 2; - break; - case 'mediumint': - $type[] = 'integer'; - $unsigned = preg_match('/ unsigned/i', $field['type']); - $length = 3; - break; - case 'int': - case 'integer': - $type[] = 'integer'; - $unsigned = preg_match('/ unsigned/i', $field['type']); - $length = 4; - break; - case 'bigint': - $type[] = 'integer'; - $unsigned = preg_match('/ unsigned/i', $field['type']); - $length = 8; - break; - case 'tinytext': - case 'mediumtext': - case 'longtext': - case 'text': - case 'varchar': - $fixed = false; - case 'string': - case 'char': - $type[] = 'text'; - if ($length == '1') { - $type[] = 'boolean'; - if (preg_match('/^(is|has)/', $field['name'])) { - $type = array_reverse($type); - } - } elseif (strstr($db_type, 'text')) { - $type[] = 'clob'; - if ($decimal == 'binary') { - $type[] = 'blob'; - } - $type = array_reverse($type); - } - if ($fixed !== false) { - $fixed = true; - } - break; - case 'enum': - $type[] = 'text'; - preg_match_all('/\'.+\'/U', $field['type'], $matches); - $length = 0; - $fixed = false; - if (is_array($matches)) { - foreach ($matches[0] as $value) { - $length = max($length, strlen($value)-2); - } - if ($length == '1' && count($matches[0]) == 2) { - $type[] = 'boolean'; - if (preg_match('/^(is|has)/', $field['name'])) { - $type = array_reverse($type); - } - } - } - $type[] = 'integer'; - case 'set': - $fixed = false; - $type[] = 'text'; - $type[] = 'integer'; - break; - case 'date': - $type[] = 'date'; - $length = null; - break; - case 'datetime': - case 'timestamp': - $type[] = 'timestamp'; - $length = null; - break; - case 'time': - $type[] = 'time'; - $length = null; - break; - case 'float': - case 'double': - case 'real': - $type[] = 'float'; - $unsigned = preg_match('/ unsigned/i', $field['type']); - if ($decimal !== false) { - $length = $length.','.$decimal; - } - break; - case 'unknown': - case 'decimal': - case 'numeric': - $type[] = 'decimal'; - $unsigned = preg_match('/ unsigned/i', $field['type']); - if ($decimal !== false) { - $length = $length.','.$decimal; - } - break; - case 'tinyblob': - case 'mediumblob': - case 'longblob': - case 'blob': - $type[] = 'blob'; - $length = null; - break; - case 'binary': - case 'varbinary': - $type[] = 'blob'; - break; - case 'year': - $type[] = 'integer'; - $type[] = 'date'; - $length = null; - break; - default: - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'unknown database attribute type: '.$db_type, __FUNCTION__); - } - - if ((int)$length <= 0) { - $length = null; - } - - return array($type, $length, $unsigned, $fixed); - } - - // }}} -} - -?> diff --git a/data/module/MDB2/Driver/Datatype/pgsql.php b/data/module/MDB2/Driver/Datatype/pgsql.php deleted file mode 100644 index 7b9ef8da712..00000000000 --- a/data/module/MDB2/Driver/Datatype/pgsql.php +++ /dev/null @@ -1,579 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: pgsql.php 327310 2012-08-27 15:16:18Z danielc $ - -require_once 'MDB2/Driver/Datatype/Common.php'; - -/** - * MDB2 PostGreSQL driver - * - * @package MDB2 - * @category Database - * @author Paul Cooper - */ -class MDB2_Driver_Datatype_pgsql extends MDB2_Driver_Datatype_Common -{ - // {{{ _baseConvertResult() - - /** - * General type conversion method - * - * @param mixed $value refernce to a value to be converted - * @param string $type specifies which type to convert to - * @param boolean $rtrim [optional] when TRUE [default], apply rtrim() to text - * @return object a MDB2 error on failure - * @access protected - */ - function _baseConvertResult($value, $type, $rtrim = true) - { - if (null === $value) { - return null; - } - switch ($type) { - case 'boolean': - return ($value == 'f')? false : !empty($value); - case 'float': - return doubleval($value); - case 'date': - return $value; - case 'time': - return substr($value, 0, strlen('HH:MM:SS')); - case 'timestamp': - return substr($value, 0, strlen('YYYY-MM-DD HH:MM:SS')); - case 'blob': - $value = pg_unescape_bytea($value); - return parent::_baseConvertResult($value, $type, $rtrim); - } - return parent::_baseConvertResult($value, $type, $rtrim); - } - - // }}} - // {{{ getTypeDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an text type - * field to be used in statements like CREATE TABLE. - * - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * length - * Integer value that determines the maximum length of the text - * field. If this argument is missing the field should be - * declared to have the longest length allowed by the DBMS. - * - * default - * Text value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access public - */ - function getTypeDeclaration($field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - switch ($field['type']) { - case 'text': - $length = !empty($field['length']) ? $field['length'] : false; - $fixed = !empty($field['fixed']) ? $field['fixed'] : false; - return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')') - : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); - case 'clob': - return 'TEXT'; - case 'blob': - return 'BYTEA'; - case 'integer': - if (!empty($field['autoincrement'])) { - if (!empty($field['length'])) { - $length = $field['length']; - if ($length > 4) { - return 'BIGSERIAL PRIMARY KEY'; - } - } - return 'SERIAL PRIMARY KEY'; - } - if (!empty($field['length'])) { - $length = $field['length']; - if ($length <= 2) { - return 'SMALLINT'; - } elseif ($length == 3 || $length == 4) { - return 'INT'; - } elseif ($length > 4) { - return 'BIGINT'; - } - } - return 'INT'; - case 'boolean': - return 'BOOLEAN'; - case 'date': - return 'DATE'; - case 'time': - return 'TIME without time zone'; - case 'timestamp': - return 'TIMESTAMP without time zone'; - case 'float': - return 'FLOAT8'; - case 'decimal': - $length = !empty($field['length']) ? $field['length'] : 18; - $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; - return 'NUMERIC('.$length.','.$scale.')'; - } - } - - // }}} - // {{{ _getIntegerDeclaration() - - /** - * Obtain DBMS specific SQL code portion needed to declare an integer type - * field to be used in statements like CREATE TABLE. - * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * unsigned - * Boolean flag that indicates whether the field should be - * declared as unsigned integer if possible. - * - * default - * Integer value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * @return string DBMS specific SQL code portion that should be used to - * declare the specified field. - * @access protected - */ - function _getIntegerDeclaration($name, $field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if (!empty($field['unsigned'])) { - $db->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer"; - } - if (!empty($field['autoincrement'])) { - $name = $db->quoteIdentifier($name, true); - return $name.' '.$this->getTypeDeclaration($field); - } - $default = ''; - if (array_key_exists('default', $field)) { - if ($field['default'] === '') { - $field['default'] = empty($field['notnull']) ? null : 0; - } - $default = ' DEFAULT '.$this->quote($field['default'], 'integer'); - } - - $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; - if (empty($default) && empty($notnull)) { - $default = ' DEFAULT NULL'; - } - $name = $db->quoteIdentifier($name, true); - return $name.' '.$this->getTypeDeclaration($field).$default.$notnull; - } - - // }}} - // {{{ _quoteCLOB() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteCLOB($value, $quote, $escape_wildcards) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if ($db->options['lob_allow_url_include']) { - $value = $this->_readFile($value); - if (MDB2::isError($value)) { - return $value; - } - } - return $this->_quoteText($value, $quote, $escape_wildcards); - } - - // }}} - // {{{ _quoteBLOB() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteBLOB($value, $quote, $escape_wildcards) - { - if (!$quote) { - return $value; - } - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if ($db->options['lob_allow_url_include']) { - $value = $this->_readFile($value); - if (MDB2::isError($value)) { - return $value; - } - } - if (version_compare(PHP_VERSION, '5.2.0RC6', '>=')) { - $connection = $db->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - $value = @pg_escape_bytea($connection, $value); - } else { - $value = @pg_escape_bytea($value); - } - return "'".$value."'"; - } - - // }}} - // {{{ _quoteBoolean() - - /** - * Convert a text value into a DBMS specific format that is suitable to - * compose query statements. - * - * @param string $value text string value that is intended to be converted. - * @param bool $quote determines if the value should be quoted and escaped - * @param bool $escape_wildcards if to escape escape wildcards - * @return string text string that represents the given argument value in - * a DBMS specific format. - * @access protected - */ - function _quoteBoolean($value, $quote, $escape_wildcards) - { - $value = $value ? 't' : 'f'; - if (!$quote) { - return $value; - } - return "'".$value."'"; - } - - // }}} - // {{{ matchPattern() - - /** - * build a pattern matching string - * - * @access public - * - * @param array $pattern even keys are strings, odd are patterns (% and _) - * @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future) - * @param string $field optional field name that is being matched against - * (might be required when emulating ILIKE) - * - * @return string SQL pattern - */ - function matchPattern($pattern, $operator = null, $field = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $match = ''; - if (null !== $operator) { - $field = (null === $field) ? '' : $field.' '; - $operator = strtoupper($operator); - switch ($operator) { - // case insensitive - case 'ILIKE': - $match = $field.'ILIKE '; - break; - case 'NOT ILIKE': - $match = $field.'NOT ILIKE '; - break; - // case sensitive - case 'LIKE': - $match = $field.'LIKE '; - break; - case 'NOT LIKE': - $match = $field.'NOT LIKE '; - break; - default: - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'not a supported operator type:'. $operator, __FUNCTION__); - } - } - $match.= "'"; - foreach ($pattern as $key => $value) { - if ($key % 2) { - $match.= $value; - } else { - $match.= $db->escapePattern($db->escape($value)); - } - } - $match.= "'"; - $match.= $this->patternEscapeString(); - return $match; - } - - // }}} - // {{{ patternEscapeString() - - /** - * build string to define escape pattern string - * - * @access public - * - * - * @return string define escape pattern - */ - function patternEscapeString() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - return ' ESCAPE '.$this->quote($db->string_quoting['escape_pattern']); - } - - // }}} - // {{{ _mapNativeDatatype() - - /** - * Maps a native array description of a field to a MDB2 datatype and length - * - * @param array $field native field description - * @return array containing the various possible types, length, sign, fixed - * @access public - */ - function _mapNativeDatatype($field) - { - $db_type = strtolower($field['type']); - $length = $field['length']; - $type = array(); - $unsigned = $fixed = null; - switch ($db_type) { - case 'smallint': - case 'int2': - $type[] = 'integer'; - $unsigned = false; - $length = 2; - if ($length == '2') { - $type[] = 'boolean'; - if (preg_match('/^(is|has)/', $field['name'])) { - $type = array_reverse($type); - } - } - break; - case 'int': - case 'int4': - case 'integer': - case 'serial': - case 'serial4': - $type[] = 'integer'; - $unsigned = false; - $length = 4; - break; - case 'bigint': - case 'int8': - case 'bigserial': - case 'serial8': - $type[] = 'integer'; - $unsigned = false; - $length = 8; - break; - case 'bool': - case 'boolean': - $type[] = 'boolean'; - $length = null; - break; - case 'text': - case 'varchar': - $fixed = false; - case 'unknown': - case 'char': - case 'bpchar': - $type[] = 'text'; - if ($length == '1') { - $type[] = 'boolean'; - if (preg_match('/^(is|has)/', $field['name'])) { - $type = array_reverse($type); - } - } elseif (strstr($db_type, 'text')) { - $type[] = 'clob'; - $type = array_reverse($type); - } - if ($fixed !== false) { - $fixed = true; - } - break; - case 'date': - $type[] = 'date'; - $length = null; - break; - case 'datetime': - case 'timestamp': - case 'timestamptz': - $type[] = 'timestamp'; - $length = null; - break; - case 'time': - $type[] = 'time'; - $length = null; - break; - case 'float': - case 'float4': - case 'float8': - case 'double': - case 'real': - $type[] = 'float'; - break; - case 'decimal': - case 'money': - case 'numeric': - $type[] = 'decimal'; - if (isset($field['scale'])) { - $length = $length.','.$field['scale']; - } - break; - case 'tinyblob': - case 'mediumblob': - case 'longblob': - case 'blob': - case 'bytea': - $type[] = 'blob'; - $length = null; - break; - case 'oid': - $type[] = 'blob'; - $type[] = 'clob'; - $length = null; - break; - case 'year': - $type[] = 'integer'; - $type[] = 'date'; - $length = null; - break; - default: - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'unknown database attribute type: '.$db_type, __FUNCTION__); - } - - if ((int)$length <= 0) { - $length = null; - } - - return array($type, $length, $unsigned, $fixed); - } - - // }}} - // {{{ mapPrepareDatatype() - - /** - * Maps an mdb2 datatype to native prepare type - * - * @param string $type - * @return string - * @access public - */ - function mapPrepareDatatype($type) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if (!empty($db->options['datatype_map'][$type])) { - $type = $db->options['datatype_map'][$type]; - if (!empty($db->options['datatype_map_callback'][$type])) { - $parameter = array('type' => $type); - return call_user_func_array($db->options['datatype_map_callback'][$type], array(&$db, __FUNCTION__, $parameter)); - } - } - - switch ($type) { - case 'integer': - return 'int'; - case 'boolean': - return 'bool'; - case 'decimal': - case 'float': - return 'numeric'; - case 'clob': - return 'text'; - case 'blob': - return 'bytea'; - default: - break; - } - return $type; - } - // }}} -} -?> diff --git a/data/module/MDB2/Driver/Function/Common.php b/data/module/MDB2/Driver/Function/Common.php deleted file mode 100644 index d62dc26e91c..00000000000 --- a/data/module/MDB2/Driver/Function/Common.php +++ /dev/null @@ -1,293 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Common.php 327310 2012-08-27 15:16:18Z danielc $ -// - -/** - * @package MDB2 - * @category Database - * @author Lukas Smith - */ - -/** - * Base class for the function modules that is extended by each MDB2 driver - * - * To load this module in the MDB2 object: - * $mdb->loadModule('Function'); - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Function_Common extends MDB2_Module_Common -{ - // {{{ executeStoredProc() - - /** - * Execute a stored procedure and return any results - * - * @param string $name string that identifies the function to execute - * @param mixed $params array that contains the paramaters to pass the stored proc - * @param mixed $types array that contains the types of the columns in - * the result set - * @param mixed $result_class string which specifies which result class to use - * @param mixed $result_wrap_class string which specifies which class to wrap results in - * - * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $error = $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - return $error; - } - - // }}} - // {{{ functionTable() - - /** - * return string for internal table used when calling only a function - * - * @return string for internal table used when calling only a function - * @access public - */ - function functionTable() - { - return ''; - } - - // }}} - // {{{ now() - - /** - * Return string to call a variable with the current timestamp inside an SQL statement - * There are three special variables for current date and time: - * - CURRENT_TIMESTAMP (date and time, TIMESTAMP type) - * - CURRENT_DATE (date, DATE type) - * - CURRENT_TIME (time, TIME type) - * - * @param string $type 'timestamp' | 'time' | 'date' - * - * @return string to call a variable with the current timestamp - * @access public - */ - function now($type = 'timestamp') - { - switch ($type) { - case 'time': - return 'CURRENT_TIME'; - case 'date': - return 'CURRENT_DATE'; - case 'timestamp': - default: - return 'CURRENT_TIMESTAMP'; - } - } - - // }}} - // {{{ unixtimestamp() - - /** - * return string to call a function to get the unix timestamp from a iso timestamp - * - * @param string $expression - * - * @return string to call a variable with the timestamp - * @access public - */ - function unixtimestamp($expression) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $error = $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - return $error; - } - - // }}} - // {{{ substring() - - /** - * return string to call a function to get a substring inside an SQL statement - * - * @return string to call a function to get a substring - * @access public - */ - function substring($value, $position = 1, $length = null) - { - if (null !== $length) { - return "SUBSTRING($value FROM $position FOR $length)"; - } - return "SUBSTRING($value FROM $position)"; - } - - // }}} - // {{{ replace() - - /** - * return string to call a function to get replace inside an SQL statement. - * - * @return string to call a function to get a replace - * @access public - */ - function replace($str, $from_str, $to_str) - { - return "REPLACE($str, $from_str , $to_str)"; - } - - // }}} - // {{{ concat() - - /** - * Returns string to concatenate two or more string parameters - * - * @param string $value1 - * @param string $value2 - * @param string $values... - * - * @return string to concatenate two strings - * @access public - */ - function concat($value1, $value2) - { - $args = func_get_args(); - return "(".implode(' || ', $args).")"; - } - - // }}} - // {{{ random() - - /** - * return string to call a function to get random value inside an SQL statement - * - * @return return string to generate float between 0 and 1 - * @access public - */ - function random() - { - return 'RAND()'; - } - - // }}} - // {{{ lower() - - /** - * return string to call a function to lower the case of an expression - * - * @param string $expression - * - * @return return string to lower case of an expression - * @access public - */ - function lower($expression) - { - return "LOWER($expression)"; - } - - // }}} - // {{{ upper() - - /** - * return string to call a function to upper the case of an expression - * - * @param string $expression - * - * @return return string to upper case of an expression - * @access public - */ - function upper($expression) - { - return "UPPER($expression)"; - } - - // }}} - // {{{ length() - - /** - * return string to call a function to get the length of a string expression - * - * @param string $expression - * - * @return return string to get the string expression length - * @access public - */ - function length($expression) - { - return "LENGTH($expression)"; - } - - // }}} - // {{{ guid() - - /** - * Returns global unique identifier - * - * @return string to get global unique identifier - * @access public - */ - function guid() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $error = $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - return $error; - } - - // }}} -} -?> diff --git a/data/module/MDB2/Driver/Function/mysql.php b/data/module/MDB2/Driver/Function/mysql.php deleted file mode 100644 index 6ac2441dcdf..00000000000 --- a/data/module/MDB2/Driver/Function/mysql.php +++ /dev/null @@ -1,136 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: mysql.php 327310 2012-08-27 15:16:18Z danielc $ -// - -require_once 'MDB2/Driver/Function/Common.php'; - -/** - * MDB2 MySQL driver for the function modules - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Function_mysql extends MDB2_Driver_Function_Common -{ - // }}} - // {{{ executeStoredProc() - - /** - * Execute a stored procedure and return any results - * - * @param string $name string that identifies the function to execute - * @param mixed $params array that contains the paramaters to pass the stored proc - * @param mixed $types array that contains the types of the columns in - * the result set - * @param mixed $result_class string which specifies which result class to use - * @param mixed $result_wrap_class string which specifies which class to wrap results in - * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = 'CALL '.$name; - $query .= $params ? '('.implode(', ', $params).')' : '()'; - return $db->query($query, $types, $result_class, $result_wrap_class); - } - - // }}} - // {{{ unixtimestamp() - - /** - * return string to call a function to get the unix timestamp from a iso timestamp - * - * @param string $expression - * - * @return string to call a variable with the timestamp - * @access public - */ - function unixtimestamp($expression) - { - return 'UNIX_TIMESTAMP('. $expression.')'; - } - - // }}} - // {{{ concat() - - /** - * Returns string to concatenate two or more string parameters - * - * @param string $value1 - * @param string $value2 - * @param string $values... - * @return string to concatenate two strings - * @access public - **/ - function concat($value1, $value2) - { - $args = func_get_args(); - return "CONCAT(".implode(', ', $args).")"; - } - - // }}} - // {{{ guid() - - /** - * Returns global unique identifier - * - * @return string to get global unique identifier - * @access public - */ - function guid() - { - return 'UUID()'; - } - - // }}} -} -?> diff --git a/data/module/MDB2/Driver/Function/pgsql.php b/data/module/MDB2/Driver/Function/pgsql.php deleted file mode 100644 index a346c52bec1..00000000000 --- a/data/module/MDB2/Driver/Function/pgsql.php +++ /dev/null @@ -1,132 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: pgsql.php 327310 2012-08-27 15:16:18Z danielc $ - -require_once 'MDB2/Driver/Function/Common.php'; - -/** - * MDB2 MySQL driver for the function modules - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Function_pgsql extends MDB2_Driver_Function_Common -{ - // {{{ executeStoredProc() - - /** - * Execute a stored procedure and return any results - * - * @param string $name string that identifies the function to execute - * @param mixed $params array that contains the paramaters to pass the stored proc - * @param mixed $types array that contains the types of the columns in - * the result set - * @param mixed $result_class string which specifies which result class to use - * @param mixed $result_wrap_class string which specifies which class to wrap results in - * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = 'SELECT * FROM '.$name; - $query .= $params ? '('.implode(', ', $params).')' : '()'; - return $db->query($query, $types, $result_class, $result_wrap_class); - } - // }}} - // {{{ unixtimestamp() - - /** - * return string to call a function to get the unix timestamp from a iso timestamp - * - * @param string $expression - * - * @return string to call a variable with the timestamp - * @access public - */ - function unixtimestamp($expression) - { - return 'EXTRACT(EPOCH FROM DATE_TRUNC(\'seconds\', CAST ((' . $expression . ') AS TIMESTAMP)))'; - } - - // }}} - // {{{ substring() - - /** - * return string to call a function to get a substring inside an SQL statement - * - * @return string to call a function to get a substring - * @access public - */ - function substring($value, $position = 1, $length = null) - { - if (null !== $length) { - return "SUBSTRING(CAST($value AS VARCHAR) FROM $position FOR $length)"; - } - return "SUBSTRING(CAST($value AS VARCHAR) FROM $position)"; - } - - // }}} - // {{{ random() - - /** - * return string to call a function to get random value inside an SQL statement - * - * @return return string to generate float between 0 and 1 - * @access public - */ - function random() - { - return 'RANDOM()'; - } - - // }}} -} -?> diff --git a/data/module/MDB2/Driver/Manager/Common.php b/data/module/MDB2/Driver/Manager/Common.php deleted file mode 100644 index c9d95524d1f..00000000000 --- a/data/module/MDB2/Driver/Manager/Common.php +++ /dev/null @@ -1,1038 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: Common.php 327310 2012-08-27 15:16:18Z danielc $ -// - -/** - * @package MDB2 - * @category Database - * @author Lukas Smith - * @author Lorenzo Alberton - */ - -/** - * Base class for the management modules that is extended by each MDB2 driver - * - * To load this module in the MDB2 object: - * $mdb->loadModule('Manager'); - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Manager_Common extends MDB2_Module_Common -{ - // {{{ splitTableSchema() - - /** - * Split the "[owner|schema].table" notation into an array - * - * @param string $table [schema and] table name - * - * @return array array(schema, table) - * @access private - */ - function splitTableSchema($table) - { - $ret = array(); - if (strpos($table, '.') !== false) { - return explode('.', $table); - } - return array(null, $table); - } - - // }}} - // {{{ getFieldDeclarationList() - - /** - * Get declaration of a number of field in bulk - * - * @param array $fields a multidimensional associative array. - * The first dimension determines the field name, while the second - * dimension is keyed with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: - * - * default - * Boolean value to be used as default for this field. - * - * notnull - * Boolean flag that indicates whether this field is constrained - * to not be set to null. - * - * @return mixed string on success, a MDB2 error on failure - * @access public - */ - function getFieldDeclarationList($fields) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if (!is_array($fields) || empty($fields)) { - return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'missing any fields', __FUNCTION__); - } - foreach ($fields as $field_name => $field) { - $query = $db->getDeclaration($field['type'], $field_name, $field); - if (MDB2::isError($query)) { - return $query; - } - $query_fields[] = $query; - } - return implode(', ', $query_fields); - } - - // }}} - // {{{ _fixSequenceName() - - /** - * Removes any formatting in an sequence name using the 'seqname_format' option - * - * @param string $sqn string that containts name of a potential sequence - * @param bool $check if only formatted sequences should be returned - * @return string name of the sequence with possible formatting removed - * @access protected - */ - function _fixSequenceName($sqn, $check = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $seq_pattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $db->options['seqname_format']).'$/i'; - $seq_name = preg_replace($seq_pattern, '\\1', $sqn); - if ($seq_name && !strcasecmp($sqn, $db->getSequenceName($seq_name))) { - return $seq_name; - } - if ($check) { - return false; - } - return $sqn; - } - - // }}} - // {{{ _fixIndexName() - - /** - * Removes any formatting in an index name using the 'idxname_format' option - * - * @param string $idx string that containts name of anl index - * @return string name of the index with eventual formatting removed - * @access protected - */ - function _fixIndexName($idx) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $idx_pattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $db->options['idxname_format']).'$/i'; - $idx_name = preg_replace($idx_pattern, '\\1', $idx); - if ($idx_name && !strcasecmp($idx, $db->getIndexName($idx_name))) { - return $idx_name; - } - return $idx; - } - - // }}} - // {{{ createDatabase() - - /** - * create a new database - * - * @param string $name name of the database that should be created - * @param array $options array with charset, collation info - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createDatabase($database, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ alterDatabase() - - /** - * alter an existing database - * - * @param string $name name of the database that should be created - * @param array $options array with charset, collation info - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function alterDatabase($database, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ dropDatabase() - - /** - * drop an existing database - * - * @param string $name name of the database that should be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropDatabase($database) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ _getCreateTableQuery() - - /** - * Create a basic SQL query for a new table creation - * - * @param string $name Name of the database that should be created - * @param array $fields Associative array that contains the definition of each field of the new table - * @param array $options An associative array of table options - * - * @return mixed string (the SQL query) on success, a MDB2 error on failure - * @see createTable() - */ - function _getCreateTableQuery($name, $fields, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if (!$name) { - return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null, - 'no valid table name specified', __FUNCTION__); - } - if (empty($fields)) { - return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null, - 'no fields specified for table "'.$name.'"', __FUNCTION__); - } - $query_fields = $this->getFieldDeclarationList($fields); - if (MDB2::isError($query_fields)) { - return $query_fields; - } - if (!empty($options['primary'])) { - $query_fields.= ', PRIMARY KEY ('.implode(', ', array_keys($options['primary'])).')'; - } - - $name = $db->quoteIdentifier($name, true); - $result = 'CREATE '; - if (!empty($options['temporary'])) { - $result .= $this->_getTemporaryTableQuery(); - } - $result .= " TABLE $name ($query_fields)"; - return $result; - } - - // }}} - // {{{ _getTemporaryTableQuery() - - /** - * A method to return the required SQL string that fits between CREATE ... TABLE - * to create the table as a temporary table. - * - * Should be overridden in driver classes to return the correct string for the - * specific database type. - * - * The default is to return the string "TEMPORARY" - this will result in a - * SQL error for any database that does not support temporary tables, or that - * requires a different SQL command from "CREATE TEMPORARY TABLE". - * - * @return string The string required to be placed between "CREATE" and "TABLE" - * to generate a temporary table, if possible. - */ - function _getTemporaryTableQuery() - { - return 'TEMPORARY'; - } - - // }}} - // {{{ createTable() - - /** - * create a new table - * - * @param string $name Name of the database that should be created - * @param array $fields Associative array that contains the definition of each field of the new table - * The indexes of the array entries are the names of the fields of the table an - * the array entry values are associative arrays like those that are meant to be - * passed with the field definitions to get[Type]Declaration() functions. - * array( - * 'id' => array( - * 'type' => 'integer', - * 'unsigned' => 1 - * 'notnull' => 1 - * 'default' => 0 - * ), - * 'name' => array( - * 'type' => 'text', - * 'length' => 12 - * ), - * 'password' => array( - * 'type' => 'text', - * 'length' => 12 - * ) - * ); - * @param array $options An associative array of table options: - * array( - * 'comment' => 'Foo', - * 'temporary' => true|false, - * ); - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createTable($name, $fields, $options = array()) - { - $query = $this->_getCreateTableQuery($name, $fields, $options); - if (MDB2::isError($query)) { - return $query; - } - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - $result = $db->exec($query); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ dropTable() - - /** - * drop an existing table - * - * @param string $name name of the table that should be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropTable($name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($name, true); - $result = $db->exec("DROP TABLE $name"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ truncateTable() - - /** - * Truncate an existing table (if the TRUNCATE TABLE syntax is not supported, - * it falls back to a DELETE FROM TABLE query) - * - * @param string $name name of the table that should be truncated - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function truncateTable($name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($name, true); - $result = $db->exec("DELETE FROM $name"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ vacuum() - - /** - * Optimize (vacuum) all the tables in the db (or only the specified table) - * and optionally run ANALYZE. - * - * @param string $table table name (all the tables if empty) - * @param array $options an array with driver-specific options: - * - timeout [int] (in seconds) [mssql-only] - * - analyze [boolean] [pgsql and mysql] - * - full [boolean] [pgsql-only] - * - freeze [boolean] [pgsql-only] - * - * @return mixed MDB2_OK success, a MDB2 error on failure - * @access public - */ - function vacuum($table = null, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ alterTable() - - /** - * alter an existing table - * - * @param string $name name of the table that is intended to be changed. - * @param array $changes associative array that contains the details of each type - * of change that is intended to be performed. The types of - * changes that are currently supported are defined as follows: - * - * name - * - * New name for the table. - * - * add - * - * Associative array with the names of fields to be added as - * indexes of the array. The value of each entry of the array - * should be set to another associative array with the properties - * of the fields to be added. The properties of the fields should - * be the same as defined by the MDB2 parser. - * - * - * remove - * - * Associative array with the names of fields to be removed as indexes - * of the array. Currently the values assigned to each entry are ignored. - * An empty array should be used for future compatibility. - * - * rename - * - * Associative array with the names of fields to be renamed as indexes - * of the array. The value of each entry of the array should be set to - * another associative array with the entry named name with the new - * field name and the entry named Declaration that is expected to contain - * the portion of the field declaration already in DBMS specific SQL code - * as it is used in the CREATE TABLE statement. - * - * change - * - * Associative array with the names of the fields to be changed as indexes - * of the array. Keep in mind that if it is intended to change either the - * name of a field and any other properties, the change array entries - * should have the new names of the fields as array indexes. - * - * The value of each entry of the array should be set to another associative - * array with the properties of the fields to that are meant to be changed as - * array entries. These entries should be assigned to the new values of the - * respective properties. The properties of the fields should be the same - * as defined by the MDB2 parser. - * - * Example - * array( - * 'name' => 'userlist', - * 'add' => array( - * 'quota' => array( - * 'type' => 'integer', - * 'unsigned' => 1 - * ) - * ), - * 'remove' => array( - * 'file_limit' => array(), - * 'time_limit' => array() - * ), - * 'change' => array( - * 'name' => array( - * 'length' => '20', - * 'definition' => array( - * 'type' => 'text', - * 'length' => 20, - * ), - * ) - * ), - * 'rename' => array( - * 'sex' => array( - * 'name' => 'gender', - * 'definition' => array( - * 'type' => 'text', - * 'length' => 1, - * 'default' => 'M', - * ), - * ) - * ) - * ) - * - * @param boolean $check indicates whether the function should just check if the DBMS driver - * can perform the requested table alterations if the value is true or - * actually perform them otherwise. - * @access public - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - */ - function alterTable($name, $changes, $check) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ listDatabases() - - /** - * list all databases - * - * @return mixed array of database names on success, a MDB2 error on failure - * @access public - */ - function listDatabases() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implementedd', __FUNCTION__); - } - - // }}} - // {{{ listUsers() - - /** - * list all users - * - * @return mixed array of user names on success, a MDB2 error on failure - * @access public - */ - function listUsers() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ listViews() - - /** - * list all views in the current database - * - * @param string database, the current is default - * NB: not all the drivers can get the view names from - * a database other than the current one - * @return mixed array of view names on success, a MDB2 error on failure - * @access public - */ - function listViews($database = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ listTableViews() - - /** - * list the views in the database that reference a given table - * - * @param string table for which all referenced views should be found - * @return mixed array of view names on success, a MDB2 error on failure - * @access public - */ - function listTableViews($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ listTableTriggers() - - /** - * list all triggers in the database that reference a given table - * - * @param string table for which all referenced triggers should be found - * @return mixed array of trigger names on success, a MDB2 error on failure - * @access public - */ - function listTableTriggers($table = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ listFunctions() - - /** - * list all functions in the current database - * - * @return mixed array of function names on success, a MDB2 error on failure - * @access public - */ - function listFunctions() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ listTables() - - /** - * list all tables in the current database - * - * @param string database, the current is default. - * NB: not all the drivers can get the table names from - * a database other than the current one - * @return mixed array of table names on success, a MDB2 error on failure - * @access public - */ - function listTables($database = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ listTableFields() - - /** - * list all fields in a table in the current database - * - * @param string $table name of table that should be used in method - * @return mixed array of field names on success, a MDB2 error on failure - * @access public - */ - function listTableFields($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ createIndex() - - /** - * Get the stucture of a field into an array - * - * @param string $table name of the table on which the index is to be created - * @param string $name name of the index to be created - * @param array $definition associative array that defines properties of the index to be created. - * Currently, only one property named FIELDS is supported. This property - * is also an associative with the names of the index fields as array - * indexes. Each entry of this array is set to another type of associative - * array that specifies properties of the index that are specific to - * each field. - * - * Currently, only the sorting property is supported. It should be used - * to define the sorting direction of the index. It may be set to either - * ascending or descending. - * - * Not all DBMS support index sorting direction configuration. The DBMS - * drivers of those that do not support it ignore this property. Use the - * function supports() to determine whether the DBMS driver can manage indexes. - * - * Example - * array( - * 'fields' => array( - * 'user_name' => array( - * 'sorting' => 'ascending' - * ), - * 'last_login' => array() - * ) - * ) - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createIndex($table, $name, $definition) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $table = $db->quoteIdentifier($table, true); - $name = $db->quoteIdentifier($db->getIndexName($name), true); - $query = "CREATE INDEX $name ON $table"; - $fields = array(); - foreach (array_keys($definition['fields']) as $field) { - $fields[] = $db->quoteIdentifier($field, true); - } - $query .= ' ('. implode(', ', $fields) . ')'; - $result = $db->exec($query); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ dropIndex() - - /** - * drop existing index - * - * @param string $table name of table that should be used in method - * @param string $name name of the index to be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropIndex($table, $name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($db->getIndexName($name), true); - $result = $db->exec("DROP INDEX $name"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ listTableIndexes() - - /** - * list all indexes in a table - * - * @param string $table name of table that should be used in method - * @return mixed array of index names on success, a MDB2 error on failure - * @access public - */ - function listTableIndexes($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ _getAdvancedFKOptions() - - /** - * Return the FOREIGN KEY query section dealing with non-standard options - * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... - * - * @param array $definition - * @return string - * @access protected - */ - function _getAdvancedFKOptions($definition) - { - return ''; - } - - // }}} - // {{{ createConstraint() - - /** - * create a constraint on a table - * - * @param string $table name of the table on which the constraint is to be created - * @param string $name name of the constraint to be created - * @param array $definition associative array that defines properties of the constraint to be created. - * The full structure of the array looks like this: - *
-     *          array (
-     *              [primary] => 0
-     *              [unique]  => 0
-     *              [foreign] => 1
-     *              [check]   => 0
-     *              [fields] => array (
-     *                  [field1name] => array() // one entry per each field covered
-     *                  [field2name] => array() // by the index
-     *                  [field3name] => array(
-     *                      [sorting]  => ascending
-     *                      [position] => 3
-     *                  )
-     *              )
-     *              [references] => array(
-     *                  [table] => name
-     *                  [fields] => array(
-     *                      [field1name] => array(  //one entry per each referenced field
-     *                           [position] => 1
-     *                      )
-     *                  )
-     *              )
-     *              [deferrable] => 0
-     *              [initiallydeferred] => 0
-     *              [onupdate] => CASCADE|RESTRICT|SET NULL|SET DEFAULT|NO ACTION
-     *              [ondelete] => CASCADE|RESTRICT|SET NULL|SET DEFAULT|NO ACTION
-     *              [match] => SIMPLE|PARTIAL|FULL
-     *          );
-     *          
- * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createConstraint($table, $name, $definition) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - $table = $db->quoteIdentifier($table, true); - $name = $db->quoteIdentifier($db->getIndexName($name), true); - $query = "ALTER TABLE $table ADD CONSTRAINT $name"; - if (!empty($definition['primary'])) { - $query.= ' PRIMARY KEY'; - } elseif (!empty($definition['unique'])) { - $query.= ' UNIQUE'; - } elseif (!empty($definition['foreign'])) { - $query.= ' FOREIGN KEY'; - } - $fields = array(); - foreach (array_keys($definition['fields']) as $field) { - $fields[] = $db->quoteIdentifier($field, true); - } - $query .= ' ('. implode(', ', $fields) . ')'; - if (!empty($definition['foreign'])) { - $query.= ' REFERENCES ' . $db->quoteIdentifier($definition['references']['table'], true); - $referenced_fields = array(); - foreach (array_keys($definition['references']['fields']) as $field) { - $referenced_fields[] = $db->quoteIdentifier($field, true); - } - $query .= ' ('. implode(', ', $referenced_fields) . ')'; - $query .= $this->_getAdvancedFKOptions($definition); - } - $result = $db->exec($query); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ dropConstraint() - - /** - * drop existing constraint - * - * @param string $table name of table that should be used in method - * @param string $name name of the constraint to be dropped - * @param string $primary hint if the constraint is primary - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropConstraint($table, $name, $primary = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $table = $db->quoteIdentifier($table, true); - $name = $db->quoteIdentifier($db->getIndexName($name), true); - $result = $db->exec("ALTER TABLE $table DROP CONSTRAINT $name"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ listTableConstraints() - - /** - * list all constraints in a table - * - * @param string $table name of table that should be used in method - * @return mixed array of constraint names on success, a MDB2 error on failure - * @access public - */ - function listTableConstraints($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ createSequence() - - /** - * create sequence - * - * @param string $seq_name name of the sequence to be created - * @param string $start start value of the sequence; default is 1 - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createSequence($seq_name, $start = 1) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ dropSequence() - - /** - * drop existing sequence - * - * @param string $seq_name name of the sequence to be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropSequence($name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ listSequences() - - /** - * list all sequences in the current database - * - * @param string database, the current is default - * NB: not all the drivers can get the sequence names from - * a database other than the current one - * @return mixed array of sequence names on success, a MDB2 error on failure - * @access public - */ - function listSequences($database = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} -} -?> diff --git a/data/module/MDB2/Driver/Manager/mysql.php b/data/module/MDB2/Driver/Manager/mysql.php deleted file mode 100644 index 2f33c559e98..00000000000 --- a/data/module/MDB2/Driver/Manager/mysql.php +++ /dev/null @@ -1,1471 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: mysql.php 327310 2012-08-27 15:16:18Z danielc $ -// - -require_once 'MDB2/Driver/Manager/Common.php'; - -/** - * MDB2 MySQL driver for the management modules - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Manager_mysql extends MDB2_Driver_Manager_Common -{ - - // }}} - // {{{ createDatabase() - - /** - * create a new database - * - * @param string $name name of the database that should be created - * @param array $options array with charset, collation info - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createDatabase($name, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($name, true); - $query = 'CREATE DATABASE ' . $name; - if (!empty($options['charset'])) { - $query .= ' DEFAULT CHARACTER SET ' . $db->quote($options['charset'], 'text'); - } - if (!empty($options['collation'])) { - $query .= ' COLLATE ' . $db->quote($options['collation'], 'text'); - } - return $db->standaloneQuery($query, null, true); - } - - // }}} - // {{{ alterDatabase() - - /** - * alter an existing database - * - * @param string $name name of the database that is intended to be changed - * @param array $options array with charset, collation info - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function alterDatabase($name, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = 'ALTER DATABASE '. $db->quoteIdentifier($name, true); - if (!empty($options['charset'])) { - $query .= ' DEFAULT CHARACTER SET ' . $db->quote($options['charset'], 'text'); - } - if (!empty($options['collation'])) { - $query .= ' COLLATE ' . $db->quote($options['collation'], 'text'); - } - return $db->standaloneQuery($query, null, true); - } - - // }}} - // {{{ dropDatabase() - - /** - * drop an existing database - * - * @param string $name name of the database that should be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropDatabase($name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($name, true); - $query = "DROP DATABASE $name"; - return $db->standaloneQuery($query, null, true); - } - - // }}} - // {{{ _getAdvancedFKOptions() - - /** - * Return the FOREIGN KEY query section dealing with non-standard options - * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... - * - * @param array $definition - * @return string - * @access protected - */ - function _getAdvancedFKOptions($definition) - { - $query = ''; - if (!empty($definition['match'])) { - $query .= ' MATCH '.$definition['match']; - } - if (!empty($definition['onupdate'])) { - $query .= ' ON UPDATE '.$definition['onupdate']; - } - if (!empty($definition['ondelete'])) { - $query .= ' ON DELETE '.$definition['ondelete']; - } - return $query; - } - - // }}} - // {{{ createTable() - - /** - * create a new table - * - * @param string $name Name of the database that should be created - * @param array $fields Associative array that contains the definition of each field of the new table - * The indexes of the array entries are the names of the fields of the table an - * the array entry values are associative arrays like those that are meant to be - * passed with the field definitions to get[Type]Declaration() functions. - * array( - * 'id' => array( - * 'type' => 'integer', - * 'unsigned' => 1 - * 'notnull' => 1 - * 'default' => 0 - * ), - * 'name' => array( - * 'type' => 'text', - * 'length' => 12 - * ), - * 'password' => array( - * 'type' => 'text', - * 'length' => 12 - * ) - * ); - * @param array $options An associative array of table options: - * array( - * 'comment' => 'Foo', - * 'charset' => 'utf8', - * 'collate' => 'utf8_unicode_ci', - * 'type' => 'innodb', - * ); - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createTable($name, $fields, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - // if we have an AUTO_INCREMENT column and a PK on more than one field, - // we have to handle it differently... - $autoincrement = null; - if (empty($options['primary'])) { - $pk_fields = array(); - foreach ($fields as $fieldname => $def) { - if (!empty($def['primary'])) { - $pk_fields[$fieldname] = true; - } - if (!empty($def['autoincrement'])) { - $autoincrement = $fieldname; - } - } - if ((null !== $autoincrement) && count($pk_fields) > 1) { - $options['primary'] = $pk_fields; - } else { - // the PK constraint is on max one field => OK - $autoincrement = null; - } - } - - $query = $this->_getCreateTableQuery($name, $fields, $options); - if (MDB2::isError($query)) { - return $query; - } - - if (null !== $autoincrement) { - // we have to remove the PK clause added by _getIntegerDeclaration() - $query = str_replace('AUTO_INCREMENT PRIMARY KEY', 'AUTO_INCREMENT', $query); - } - - $options_strings = array(); - - if (!empty($options['comment'])) { - $options_strings['comment'] = 'COMMENT = '.$db->quote($options['comment'], 'text'); - } - - if (!empty($options['charset'])) { - $options_strings['charset'] = 'DEFAULT CHARACTER SET '.$options['charset']; - if (!empty($options['collate'])) { - $options_strings['charset'].= ' COLLATE '.$options['collate']; - } - } - - $type = false; - if (!empty($options['type'])) { - $type = $options['type']; - } elseif ($db->options['default_table_type']) { - $type = $db->options['default_table_type']; - } - if ($type) { - $options_strings[] = "ENGINE = $type"; - } - - if (!empty($options_strings)) { - $query .= ' '.implode(' ', $options_strings); - } - $result = $db->exec($query); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ dropTable() - - /** - * drop an existing table - * - * @param string $name name of the table that should be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropTable($name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - //delete the triggers associated to existing FK constraints - $constraints = $this->listTableConstraints($name); - if (!MDB2::isError($constraints) && !empty($constraints)) { - $db->loadModule('Reverse', null, true); - foreach ($constraints as $constraint) { - $definition = $db->reverse->getTableConstraintDefinition($name, $constraint); - if (!MDB2::isError($definition) && !empty($definition['foreign'])) { - $result = $this->_dropFKTriggers($name, $constraint, $definition['references']['table']); - if (MDB2::isError($result)) { - return $result; - } - } - } - } - - return parent::dropTable($name); - } - - // }}} - // {{{ truncateTable() - - /** - * Truncate an existing table (if the TRUNCATE TABLE syntax is not supported, - * it falls back to a DELETE FROM TABLE query) - * - * @param string $name name of the table that should be truncated - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function truncateTable($name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($name, true); - $result = $db->exec("TRUNCATE TABLE $name"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ vacuum() - - /** - * Optimize (vacuum) all the tables in the db (or only the specified table) - * and optionally run ANALYZE. - * - * @param string $table table name (all the tables if empty) - * @param array $options an array with driver-specific options: - * - timeout [int] (in seconds) [mssql-only] - * - analyze [boolean] [pgsql and mysql] - * - full [boolean] [pgsql-only] - * - freeze [boolean] [pgsql-only] - * - * @return mixed MDB2_OK success, a MDB2 error on failure - * @access public - */ - function vacuum($table = null, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if (empty($table)) { - $table = $this->listTables(); - if (MDB2::isError($table)) { - return $table; - } - } - if (is_array($table)) { - foreach (array_keys($table) as $k) { - $table[$k] = $db->quoteIdentifier($table[$k], true); - } - $table = implode(', ', $table); - } else { - $table = $db->quoteIdentifier($table, true); - } - - $result = $db->exec('OPTIMIZE TABLE '.$table); - if (MDB2::isError($result)) { - return $result; - } - if (!empty($options['analyze'])) { - $result = $db->exec('ANALYZE TABLE '.$table); - if (MDB2::isError($result)) { - return $result; - } - } - return MDB2_OK; - } - - // }}} - // {{{ alterTable() - - /** - * alter an existing table - * - * @param string $name name of the table that is intended to be changed. - * @param array $changes associative array that contains the details of each type - * of change that is intended to be performed. The types of - * changes that are currently supported are defined as follows: - * - * name - * - * New name for the table. - * - * add - * - * Associative array with the names of fields to be added as - * indexes of the array. The value of each entry of the array - * should be set to another associative array with the properties - * of the fields to be added. The properties of the fields should - * be the same as defined by the MDB2 parser. - * - * - * remove - * - * Associative array with the names of fields to be removed as indexes - * of the array. Currently the values assigned to each entry are ignored. - * An empty array should be used for future compatibility. - * - * rename - * - * Associative array with the names of fields to be renamed as indexes - * of the array. The value of each entry of the array should be set to - * another associative array with the entry named name with the new - * field name and the entry named Declaration that is expected to contain - * the portion of the field declaration already in DBMS specific SQL code - * as it is used in the CREATE TABLE statement. - * - * change - * - * Associative array with the names of the fields to be changed as indexes - * of the array. Keep in mind that if it is intended to change either the - * name of a field and any other properties, the change array entries - * should have the new names of the fields as array indexes. - * - * The value of each entry of the array should be set to another associative - * array with the properties of the fields to that are meant to be changed as - * array entries. These entries should be assigned to the new values of the - * respective properties. The properties of the fields should be the same - * as defined by the MDB2 parser. - * - * Example - * array( - * 'name' => 'userlist', - * 'add' => array( - * 'quota' => array( - * 'type' => 'integer', - * 'unsigned' => 1 - * ) - * ), - * 'remove' => array( - * 'file_limit' => array(), - * 'time_limit' => array() - * ), - * 'change' => array( - * 'name' => array( - * 'length' => '20', - * 'definition' => array( - * 'type' => 'text', - * 'length' => 20, - * ), - * ) - * ), - * 'rename' => array( - * 'sex' => array( - * 'name' => 'gender', - * 'definition' => array( - * 'type' => 'text', - * 'length' => 1, - * 'default' => 'M', - * ), - * ) - * ) - * ) - * - * @param boolean $check indicates whether the function should just check if the DBMS driver - * can perform the requested table alterations if the value is true or - * actually perform them otherwise. - * @access public - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - */ - function alterTable($name, $changes, $check) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - foreach ($changes as $change_name => $change) { - switch ($change_name) { - case 'add': - case 'remove': - case 'change': - case 'rename': - case 'name': - break; - default: - return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, - 'change type "'.$change_name.'" not yet supported', __FUNCTION__); - } - } - - if ($check) { - return MDB2_OK; - } - - $query = ''; - if (!empty($changes['name'])) { - $change_name = $db->quoteIdentifier($changes['name'], true); - $query .= 'RENAME TO ' . $change_name; - } - - if (!empty($changes['add']) && is_array($changes['add'])) { - foreach ($changes['add'] as $field_name => $field) { - if ($query) { - $query.= ', '; - } - $query.= 'ADD ' . $db->getDeclaration($field['type'], $field_name, $field); - } - } - - if (!empty($changes['remove']) && is_array($changes['remove'])) { - foreach ($changes['remove'] as $field_name => $field) { - if ($query) { - $query.= ', '; - } - $field_name = $db->quoteIdentifier($field_name, true); - $query.= 'DROP ' . $field_name; - } - } - - $rename = array(); - if (!empty($changes['rename']) && is_array($changes['rename'])) { - foreach ($changes['rename'] as $field_name => $field) { - $rename[$field['name']] = $field_name; - } - } - - if (!empty($changes['change']) && is_array($changes['change'])) { - foreach ($changes['change'] as $field_name => $field) { - if ($query) { - $query.= ', '; - } - if (isset($rename[$field_name])) { - $old_field_name = $rename[$field_name]; - unset($rename[$field_name]); - } else { - $old_field_name = $field_name; - } - $old_field_name = $db->quoteIdentifier($old_field_name, true); - $query.= "CHANGE $old_field_name " . $db->getDeclaration($field['definition']['type'], $field_name, $field['definition']); - } - } - - if (!empty($rename) && is_array($rename)) { - foreach ($rename as $rename_name => $renamed_field) { - if ($query) { - $query.= ', '; - } - $field = $changes['rename'][$renamed_field]; - $renamed_field = $db->quoteIdentifier($renamed_field, true); - $query.= 'CHANGE ' . $renamed_field . ' ' . $db->getDeclaration($field['definition']['type'], $field['name'], $field['definition']); - } - } - - if (!$query) { - return MDB2_OK; - } - - $name = $db->quoteIdentifier($name, true); - $result = $db->exec("ALTER TABLE $name $query"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ listDatabases() - - /** - * list all databases - * - * @return mixed array of database names on success, a MDB2 error on failure - * @access public - */ - function listDatabases() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $result = $db->queryCol('SHOW DATABASES'); - if (MDB2::isError($result)) { - return $result; - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listUsers() - - /** - * list all users - * - * @return mixed array of user names on success, a MDB2 error on failure - * @access public - */ - function listUsers() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->queryCol('SELECT DISTINCT USER FROM mysql.USER'); - } - - // }}} - // {{{ listFunctions() - - /** - * list all functions in the current database - * - * @return mixed array of function names on success, a MDB2 error on failure - * @access public - */ - function listFunctions() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = "SELECT name FROM mysql.proc"; - /* - SELECT ROUTINE_NAME - FROM INFORMATION_SCHEMA.ROUTINES - WHERE ROUTINE_TYPE = 'FUNCTION' - */ - $result = $db->queryCol($query); - if (MDB2::isError($result)) { - return $result; - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listTableTriggers() - - /** - * list all triggers in the database that reference a given table - * - * @param string table for which all referenced triggers should be found - * @return mixed array of trigger names on success, a MDB2 error on failure - * @access public - */ - function listTableTriggers($table = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = 'SHOW TRIGGERS'; - if (null !== $table) { - $table = $db->quote($table, 'text'); - $query .= " LIKE $table"; - } - $result = $db->queryCol($query); - if (MDB2::isError($result)) { - return $result; - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listTables() - - /** - * list all tables in the current database - * - * @param string database, the current is default - * @return mixed array of table names on success, a MDB2 error on failure - * @access public - */ - function listTables($database = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = "SHOW /*!50002 FULL*/ TABLES"; - if (null !== $database) { - $query .= " FROM $database"; - } - $query.= "/*!50002 WHERE Table_type = 'BASE TABLE'*/"; - - $table_names = $db->queryAll($query, null, MDB2_FETCHMODE_ORDERED); - if (MDB2::isError($table_names)) { - return $table_names; - } - - $result = array(); - foreach ($table_names as $table) { - if (!$this->_fixSequenceName($table[0], true)) { - $result[] = $table[0]; - } - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listViews() - - /** - * list all views in the current database - * - * @param string database, the current is default - * @return mixed array of view names on success, a MDB2 error on failure - * @access public - */ - function listViews($database = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = 'SHOW FULL TABLES'; - if (null !== $database) { - $query.= " FROM $database"; - } - $query.= " WHERE Table_type = 'VIEW'"; - - $result = $db->queryCol($query); - if (MDB2::isError($result)) { - return $result; - } - - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listTableFields() - - /** - * list all fields in a table in the current database - * - * @param string $table name of table that should be used in method - * @return mixed array of field names on success, a MDB2 error on failure - * @access public - */ - function listTableFields($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $table = $db->quoteIdentifier($table, true); - $result = $db->queryCol("SHOW COLUMNS FROM $table"); - if (MDB2::isError($result)) { - return $result; - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ createIndex() - - /** - * Get the stucture of a field into an array - * - * @author Leoncx - * @param string $table name of the table on which the index is to be created - * @param string $name name of the index to be created - * @param array $definition associative array that defines properties of the index to be created. - * Currently, only one property named FIELDS is supported. This property - * is also an associative with the names of the index fields as array - * indexes. Each entry of this array is set to another type of associative - * array that specifies properties of the index that are specific to - * each field. - * - * Currently, only the sorting property is supported. It should be used - * to define the sorting direction of the index. It may be set to either - * ascending or descending. - * - * Not all DBMS support index sorting direction configuration. The DBMS - * drivers of those that do not support it ignore this property. Use the - * function supports() to determine whether the DBMS driver can manage indexes. - * - * Example - * array( - * 'fields' => array( - * 'user_name' => array( - * 'sorting' => 'ascending' - * 'length' => 10 - * ), - * 'last_login' => array() - * ) - * ) - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createIndex($table, $name, $definition) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $table = $db->quoteIdentifier($table, true); - $name = $db->quoteIdentifier($db->getIndexName($name), true); - $query = "CREATE INDEX $name ON $table"; - $fields = array(); - foreach ($definition['fields'] as $field => $fieldinfo) { - if (!empty($fieldinfo['length'])) { - $fields[] = $db->quoteIdentifier($field, true) . '(' . $fieldinfo['length'] . ')'; - } else { - $fields[] = $db->quoteIdentifier($field, true); - } - } - $query .= ' ('. implode(', ', $fields) . ')'; - $result = $db->exec($query); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ dropIndex() - - /** - * drop existing index - * - * @param string $table name of table that should be used in method - * @param string $name name of the index to be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropIndex($table, $name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $table = $db->quoteIdentifier($table, true); - $name = $db->quoteIdentifier($db->getIndexName($name), true); - $result = $db->exec("DROP INDEX $name ON $table"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ listTableIndexes() - - /** - * list all indexes in a table - * - * @param string $table name of table that should be used in method - * @return mixed array of index names on success, a MDB2 error on failure - * @access public - */ - function listTableIndexes($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $key_name = 'Key_name'; - $non_unique = 'Non_unique'; - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $key_name = strtolower($key_name); - $non_unique = strtolower($non_unique); - } else { - $key_name = strtoupper($key_name); - $non_unique = strtoupper($non_unique); - } - } - - $table = $db->quoteIdentifier($table, true); - $query = "SHOW INDEX FROM $table"; - $indexes = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC); - if (MDB2::isError($indexes)) { - return $indexes; - } - - $result = array(); - foreach ($indexes as $index_data) { - if ($index_data[$non_unique] && ($index = $this->_fixIndexName($index_data[$key_name]))) { - $result[$index] = true; - } - } - - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_change_key_case($result, $db->options['field_case']); - } - return array_keys($result); - } - - // }}} - // {{{ createConstraint() - - /** - * create a constraint on a table - * - * @param string $table name of the table on which the constraint is to be created - * @param string $name name of the constraint to be created - * @param array $definition associative array that defines properties of the constraint to be created. - * Currently, only one property named FIELDS is supported. This property - * is also an associative with the names of the constraint fields as array - * constraints. Each entry of this array is set to another type of associative - * array that specifies properties of the constraint that are specific to - * each field. - * - * Example - * array( - * 'fields' => array( - * 'user_name' => array(), - * 'last_login' => array() - * ) - * ) - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createConstraint($table, $name, $definition) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $type = ''; - $idx_name = $db->quoteIdentifier($db->getIndexName($name), true); - if (!empty($definition['primary'])) { - $type = 'PRIMARY'; - $idx_name = 'KEY'; - } elseif (!empty($definition['unique'])) { - $type = 'UNIQUE'; - } elseif (!empty($definition['foreign'])) { - $type = 'CONSTRAINT'; - } - if (empty($type)) { - return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'invalid definition, could not create constraint', __FUNCTION__); - } - - $table_quoted = $db->quoteIdentifier($table, true); - $query = "ALTER TABLE $table_quoted ADD $type $idx_name"; - if (!empty($definition['foreign'])) { - $query .= ' FOREIGN KEY'; - } - $fields = array(); - foreach ($definition['fields'] as $field => $fieldinfo) { - $quoted = $db->quoteIdentifier($field, true); - if (!empty($fieldinfo['length'])) { - $quoted .= '(' . $fieldinfo['length'] . ')'; - } - $fields[] = $quoted; - } - $query .= ' ('. implode(', ', $fields) . ')'; - if (!empty($definition['foreign'])) { - $query.= ' REFERENCES ' . $db->quoteIdentifier($definition['references']['table'], true); - $referenced_fields = array(); - foreach (array_keys($definition['references']['fields']) as $field) { - $referenced_fields[] = $db->quoteIdentifier($field, true); - } - $query .= ' ('. implode(', ', $referenced_fields) . ')'; - $query .= $this->_getAdvancedFKOptions($definition); - - // add index on FK column(s) or we can't add a FK constraint - // @see http://forums.mysql.com/read.php?22,19755,226009 - $result = $this->createIndex($table, $name.'_fkidx', $definition); - if (MDB2::isError($result)) { - return $result; - } - } - $res = $db->exec($query); - if (MDB2::isError($res)) { - return $res; - } - if (!empty($definition['foreign'])) { - return $this->_createFKTriggers($table, array($name => $definition)); - } - return MDB2_OK; - } - - // }}} - // {{{ dropConstraint() - - /** - * drop existing constraint - * - * @param string $table name of table that should be used in method - * @param string $name name of the constraint to be dropped - * @param string $primary hint if the constraint is primary - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropConstraint($table, $name, $primary = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if ($primary || strtolower($name) == 'primary') { - $query = 'ALTER TABLE '. $db->quoteIdentifier($table, true) .' DROP PRIMARY KEY'; - $result = $db->exec($query); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - //is it a FK constraint? If so, also delete the associated triggers - $db->loadModule('Reverse', null, true); - $definition = $db->reverse->getTableConstraintDefinition($table, $name); - if (!MDB2::isError($definition) && !empty($definition['foreign'])) { - //first drop the FK enforcing triggers - $result = $this->_dropFKTriggers($table, $name, $definition['references']['table']); - if (MDB2::isError($result)) { - return $result; - } - //then drop the constraint itself - $table = $db->quoteIdentifier($table, true); - $name = $db->quoteIdentifier($db->getIndexName($name), true); - $query = "ALTER TABLE $table DROP FOREIGN KEY $name"; - $result = $db->exec($query); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - $table = $db->quoteIdentifier($table, true); - $name = $db->quoteIdentifier($db->getIndexName($name), true); - $query = "ALTER TABLE $table DROP INDEX $name"; - $result = $db->exec($query); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ _createFKTriggers() - - /** - * Create triggers to enforce the FOREIGN KEY constraint on the table - * - * NB: since there's no RAISE_APPLICATION_ERROR facility in mysql, - * we call a non-existent procedure to raise the FK violation message. - * @see http://forums.mysql.com/read.php?99,55108,71877#msg-71877 - * - * @param string $table table name - * @param array $foreign_keys FOREIGN KEY definitions - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access private - */ - function _createFKTriggers($table, $foreign_keys) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - // create triggers to enforce FOREIGN KEY constraints - if ($db->supports('triggers') && !empty($foreign_keys)) { - $table_quoted = $db->quoteIdentifier($table, true); - foreach ($foreign_keys as $fkname => $fkdef) { - if (empty($fkdef)) { - continue; - } - //set actions to default if not set - $fkdef['onupdate'] = empty($fkdef['onupdate']) ? $db->options['default_fk_action_onupdate'] : strtoupper($fkdef['onupdate']); - $fkdef['ondelete'] = empty($fkdef['ondelete']) ? $db->options['default_fk_action_ondelete'] : strtoupper($fkdef['ondelete']); - - $trigger_names = array( - 'insert' => $fkname.'_insert_trg', - 'update' => $fkname.'_update_trg', - 'pk_update' => $fkname.'_pk_update_trg', - 'pk_delete' => $fkname.'_pk_delete_trg', - ); - $table_fields = array_keys($fkdef['fields']); - $referenced_fields = array_keys($fkdef['references']['fields']); - - //create the ON [UPDATE|DELETE] triggers on the primary table - $restrict_action = ' IF (SELECT '; - $aliased_fields = array(); - foreach ($table_fields as $field) { - $aliased_fields[] = $table_quoted .'.'.$field .' AS '.$field; - } - $restrict_action .= implode(',', $aliased_fields) - .' FROM '.$table_quoted - .' WHERE '; - $conditions = array(); - $new_values = array(); - $null_values = array(); - for ($i=0; $i OLD.'.$referenced_fields[$i]; - } - - $restrict_action .= implode(' AND ', $conditions).') IS NOT NULL'; - $restrict_action2 = empty($conditions2) ? '' : ' AND (' .implode(' OR ', $conditions2) .')'; - $restrict_action3 = ' THEN CALL %s_ON_TABLE_'.$table.'_VIOLATES_FOREIGN_KEY_CONSTRAINT();' - .' END IF;'; - - $restrict_action_update = $restrict_action . $restrict_action2 . $restrict_action3; - $restrict_action_delete = $restrict_action . $restrict_action3; // There is no NEW row in on DELETE trigger - - $cascade_action_update = 'UPDATE '.$table_quoted.' SET '.implode(', ', $new_values) .' WHERE '.implode(' AND ', $conditions). ';'; - $cascade_action_delete = 'DELETE FROM '.$table_quoted.' WHERE '.implode(' AND ', $conditions). ';'; - $setnull_action = 'UPDATE '.$table_quoted.' SET '.implode(', ', $null_values).' WHERE '.implode(' AND ', $conditions). ';'; - - if ('SET DEFAULT' == $fkdef['onupdate'] || 'SET DEFAULT' == $fkdef['ondelete']) { - $db->loadModule('Reverse', null, true); - $default_values = array(); - foreach ($table_fields as $table_field) { - $field_definition = $db->reverse->getTableFieldDefinition($table, $field); - if (MDB2::isError($field_definition)) { - return $field_definition; - } - $default_values[] = $table_field .' = '. $field_definition[0]['default']; - } - $setdefault_action = 'UPDATE '.$table_quoted.' SET '.implode(', ', $default_values).' WHERE '.implode(' AND ', $conditions). ';'; - } - - $query = 'CREATE TRIGGER %s' - .' %s ON '.$fkdef['references']['table'] - .' FOR EACH ROW BEGIN ' - .' SET FOREIGN_KEY_CHECKS = 0; '; //only really needed for ON UPDATE CASCADE - - if ('CASCADE' == $fkdef['onupdate']) { - $sql_update = sprintf($query, $trigger_names['pk_update'], 'BEFORE UPDATE', 'update') . $cascade_action_update; - } elseif ('SET NULL' == $fkdef['onupdate']) { - $sql_update = sprintf($query, $trigger_names['pk_update'], 'BEFORE UPDATE', 'update') . $setnull_action; - } elseif ('SET DEFAULT' == $fkdef['onupdate']) { - $sql_update = sprintf($query, $trigger_names['pk_update'], 'BEFORE UPDATE', 'update') . $setdefault_action; - } elseif ('NO ACTION' == $fkdef['onupdate']) { - $sql_update = sprintf($query.$restrict_action_update, $trigger_names['pk_update'], 'AFTER UPDATE', 'update'); - } elseif ('RESTRICT' == $fkdef['onupdate']) { - $sql_update = sprintf($query.$restrict_action_update, $trigger_names['pk_update'], 'BEFORE UPDATE', 'update'); - } - if ('CASCADE' == $fkdef['ondelete']) { - $sql_delete = sprintf($query, $trigger_names['pk_delete'], 'BEFORE DELETE', 'delete') . $cascade_action_delete; - } elseif ('SET NULL' == $fkdef['ondelete']) { - $sql_delete = sprintf($query, $trigger_names['pk_delete'], 'BEFORE DELETE', 'delete') . $setnull_action; - } elseif ('SET DEFAULT' == $fkdef['ondelete']) { - $sql_delete = sprintf($query, $trigger_names['pk_delete'], 'BEFORE DELETE', 'delete') . $setdefault_action; - } elseif ('NO ACTION' == $fkdef['ondelete']) { - $sql_delete = sprintf($query.$restrict_action_delete, $trigger_names['pk_delete'], 'AFTER DELETE', 'delete'); - } elseif ('RESTRICT' == $fkdef['ondelete']) { - $sql_delete = sprintf($query.$restrict_action_delete, $trigger_names['pk_delete'], 'BEFORE DELETE', 'delete'); - } - $sql_update .= ' SET FOREIGN_KEY_CHECKS = 1; END;'; - $sql_delete .= ' SET FOREIGN_KEY_CHECKS = 1; END;'; - - $db->pushErrorHandling(PEAR_ERROR_RETURN); - $db->expectError(MDB2_ERROR_CANNOT_CREATE); - $result = $db->exec($sql_delete); - $expected_errmsg = 'This MySQL version doesn\'t support multiple triggers with the same action time and event for one table'; - $db->popExpect(); - $db->popErrorHandling(); - if (MDB2::isError($result)) { - if ($result->getCode() != MDB2_ERROR_CANNOT_CREATE) { - return $result; - } - $db->warnings[] = $expected_errmsg; - } - $db->pushErrorHandling(PEAR_ERROR_RETURN); - $db->expectError(MDB2_ERROR_CANNOT_CREATE); - $result = $db->exec($sql_update); - $db->popExpect(); - $db->popErrorHandling(); - if (MDB2::isError($result) && $result->getCode() != MDB2_ERROR_CANNOT_CREATE) { - if ($result->getCode() != MDB2_ERROR_CANNOT_CREATE) { - return $result; - } - $db->warnings[] = $expected_errmsg; - } - } - } - return MDB2_OK; - } - - // }}} - // {{{ _dropFKTriggers() - - /** - * Drop the triggers created to enforce the FOREIGN KEY constraint on the table - * - * @param string $table table name - * @param string $fkname FOREIGN KEY constraint name - * @param string $referenced_table referenced table name - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access private - */ - function _dropFKTriggers($table, $fkname, $referenced_table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $triggers = $this->listTableTriggers($table); - $triggers2 = $this->listTableTriggers($referenced_table); - if (!MDB2::isError($triggers2) && !MDB2::isError($triggers)) { - $triggers = array_merge($triggers, $triggers2); - $pattern = '/^'.$fkname.'(_pk)?_(insert|update|delete)_trg$/i'; - foreach ($triggers as $trigger) { - if (preg_match($pattern, $trigger)) { - $result = $db->exec('DROP TRIGGER '.$trigger); - if (MDB2::isError($result)) { - return $result; - } - } - } - } - return MDB2_OK; - } - - // }}} - // {{{ listTableConstraints() - - /** - * list all constraints in a table - * - * @param string $table name of table that should be used in method - * @return mixed array of constraint names on success, a MDB2 error on failure - * @access public - */ - function listTableConstraints($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $key_name = 'Key_name'; - $non_unique = 'Non_unique'; - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $key_name = strtolower($key_name); - $non_unique = strtolower($non_unique); - } else { - $key_name = strtoupper($key_name); - $non_unique = strtoupper($non_unique); - } - } - - $query = 'SHOW INDEX FROM ' . $db->quoteIdentifier($table, true); - $indexes = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC); - if (MDB2::isError($indexes)) { - return $indexes; - } - - $result = array(); - foreach ($indexes as $index_data) { - if (!$index_data[$non_unique]) { - if ($index_data[$key_name] !== 'PRIMARY') { - $index = $this->_fixIndexName($index_data[$key_name]); - } else { - $index = 'PRIMARY'; - } - if (!empty($index)) { - $result[$index] = true; - } - } - } - - //list FOREIGN KEY constraints... - $query = 'SHOW CREATE TABLE '. $db->escape($table); - $definition = $db->queryOne($query, 'text', 1); - if (!MDB2::isError($definition) && !empty($definition)) { - $pattern = '/\bCONSTRAINT\b\s+([^\s]+)\s+\bFOREIGN KEY\b/Uims'; - if (preg_match_all($pattern, str_replace('`', '', $definition), $matches) > 0) { - foreach ($matches[1] as $constraint) { - $result[$constraint] = true; - } - } - } - - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_change_key_case($result, $db->options['field_case']); - } - return array_keys($result); - } - - // }}} - // {{{ createSequence() - - /** - * create sequence - * - * @param string $seq_name name of the sequence to be created - * @param string $start start value of the sequence; default is 1 - * @param array $options An associative array of table options: - * array( - * 'comment' => 'Foo', - * 'charset' => 'utf8', - * 'collate' => 'utf8_unicode_ci', - * 'type' => 'innodb', - * ); - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createSequence($seq_name, $start = 1, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true); - $seqcol_name = $db->quoteIdentifier($db->options['seqcol_name'], true); - - $options_strings = array(); - - if (!empty($options['comment'])) { - $options_strings['comment'] = 'COMMENT = '.$db->quote($options['comment'], 'text'); - } - - if (!empty($options['charset'])) { - $options_strings['charset'] = 'DEFAULT CHARACTER SET '.$options['charset']; - if (!empty($options['collate'])) { - $options_strings['charset'].= ' COLLATE '.$options['collate']; - } - } - - $type = false; - if (!empty($options['type'])) { - $type = $options['type']; - } elseif ($db->options['default_table_type']) { - $type = $db->options['default_table_type']; - } - if ($type) { - $options_strings[] = "ENGINE = $type"; - } - - $query = "CREATE TABLE $sequence_name ($seqcol_name INT NOT NULL AUTO_INCREMENT, PRIMARY KEY ($seqcol_name))"; - if (!empty($options_strings)) { - $query .= ' '.implode(' ', $options_strings); - } - $res = $db->exec($query); - if (MDB2::isError($res)) { - return $res; - } - - if ($start == 1) { - return MDB2_OK; - } - - $query = "INSERT INTO $sequence_name ($seqcol_name) VALUES (".($start-1).')'; - $res = $db->exec($query); - if (!MDB2::isError($res)) { - return MDB2_OK; - } - - // Handle error - $result = $db->exec("DROP TABLE $sequence_name"); - if (MDB2::isError($result)) { - return $db->raiseError($result, null, null, - 'could not drop inconsistent sequence table', __FUNCTION__); - } - - return $db->raiseError($res, null, null, - 'could not create sequence table', __FUNCTION__); - } - - // }}} - // {{{ dropSequence() - - /** - * drop existing sequence - * - * @param string $seq_name name of the sequence to be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropSequence($seq_name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true); - $result = $db->exec("DROP TABLE $sequence_name"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ listSequences() - - /** - * list all sequences in the current database - * - * @param string database, the current is default - * @return mixed array of sequence names on success, a MDB2 error on failure - * @access public - */ - function listSequences($database = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = "SHOW TABLES"; - if (null !== $database) { - $query .= " FROM $database"; - } - $table_names = $db->queryCol($query); - if (MDB2::isError($table_names)) { - return $table_names; - } - - $result = array(); - foreach ($table_names as $table_name) { - if ($sqn = $this->_fixSequenceName($table_name, true)) { - $result[] = $sqn; - } - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} -} -?> diff --git a/data/module/MDB2/Driver/Manager/pgsql.php b/data/module/MDB2/Driver/Manager/pgsql.php deleted file mode 100644 index 75c4e757e15..00000000000 --- a/data/module/MDB2/Driver/Manager/pgsql.php +++ /dev/null @@ -1,978 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: pgsql.php 327310 2012-08-27 15:16:18Z danielc $ - -require_once 'MDB2/Driver/Manager/Common.php'; - -/** - * MDB2 MySQL driver for the management modules - * - * @package MDB2 - * @category Database - * @author Paul Cooper - */ -class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common -{ - // {{{ createDatabase() - - /** - * create a new database - * - * @param string $name name of the database that should be created - * @param array $options array with charset info - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createDatabase($name, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($name, true); - $query = 'CREATE DATABASE ' . $name; - if (!empty($options['charset'])) { - $query .= ' WITH ENCODING ' . $db->quote($options['charset'], 'text'); - } - return $db->standaloneQuery($query, null, true); - } - - // }}} - // {{{ alterDatabase() - - /** - * alter an existing database - * - * @param string $name name of the database that is intended to be changed - * @param array $options array with name, owner info - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function alterDatabase($name, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = ''; - if (!empty($options['name'])) { - $query .= ' RENAME TO ' . $options['name']; - } - if (!empty($options['owner'])) { - $query .= ' OWNER TO ' . $options['owner']; - } - - if (empty($query)) { - return MDB2_OK; - } - - $query = 'ALTER DATABASE '. $db->quoteIdentifier($name, true) . $query; - return $db->standaloneQuery($query, null, true); - } - - // }}} - // {{{ dropDatabase() - - /** - * drop an existing database - * - * @param string $name name of the database that should be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropDatabase($name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($name, true); - $query = "DROP DATABASE $name"; - return $db->standaloneQuery($query, null, true); - } - - // }}} - // {{{ _getAdvancedFKOptions() - - /** - * Return the FOREIGN KEY query section dealing with non-standard options - * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... - * - * @param array $definition - * @return string - * @access protected - */ - function _getAdvancedFKOptions($definition) - { - $query = ''; - if (!empty($definition['match'])) { - $query .= ' MATCH '.$definition['match']; - } - if (!empty($definition['onupdate'])) { - $query .= ' ON UPDATE '.$definition['onupdate']; - } - if (!empty($definition['ondelete'])) { - $query .= ' ON DELETE '.$definition['ondelete']; - } - if (!empty($definition['deferrable'])) { - $query .= ' DEFERRABLE'; - } else { - $query .= ' NOT DEFERRABLE'; - } - if (!empty($definition['initiallydeferred'])) { - $query .= ' INITIALLY DEFERRED'; - } else { - $query .= ' INITIALLY IMMEDIATE'; - } - return $query; - } - - // }}} - // {{{ truncateTable() - - /** - * Truncate an existing table (if the TRUNCATE TABLE syntax is not supported, - * it falls back to a DELETE FROM TABLE query) - * - * @param string $name name of the table that should be truncated - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function truncateTable($name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($name, true); - $result = $db->exec("TRUNCATE TABLE $name"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ vacuum() - - /** - * Optimize (vacuum) all the tables in the db (or only the specified table) - * and optionally run ANALYZE. - * - * @param string $table table name (all the tables if empty) - * @param array $options an array with driver-specific options: - * - timeout [int] (in seconds) [mssql-only] - * - analyze [boolean] [pgsql and mysql] - * - full [boolean] [pgsql-only] - * - freeze [boolean] [pgsql-only] - * - * @return mixed MDB2_OK success, a MDB2 error on failure - * @access public - */ - function vacuum($table = null, $options = array()) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - $query = 'VACUUM'; - - if (!empty($options['full'])) { - $query .= ' FULL'; - } - if (!empty($options['freeze'])) { - $query .= ' FREEZE'; - } - if (!empty($options['analyze'])) { - $query .= ' ANALYZE'; - } - - if (!empty($table)) { - $query .= ' '.$db->quoteIdentifier($table, true); - } - $result = $db->exec($query); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ alterTable() - - /** - * alter an existing table - * - * @param string $name name of the table that is intended to be changed. - * @param array $changes associative array that contains the details of each type - * of change that is intended to be performed. The types of - * changes that are currently supported are defined as follows: - * - * name - * - * New name for the table. - * - * add - * - * Associative array with the names of fields to be added as - * indexes of the array. The value of each entry of the array - * should be set to another associative array with the properties - * of the fields to be added. The properties of the fields should - * be the same as defined by the MDB2 parser. - * - * - * remove - * - * Associative array with the names of fields to be removed as indexes - * of the array. Currently the values assigned to each entry are ignored. - * An empty array should be used for future compatibility. - * - * rename - * - * Associative array with the names of fields to be renamed as indexes - * of the array. The value of each entry of the array should be set to - * another associative array with the entry named name with the new - * field name and the entry named Declaration that is expected to contain - * the portion of the field declaration already in DBMS specific SQL code - * as it is used in the CREATE TABLE statement. - * - * change - * - * Associative array with the names of the fields to be changed as indexes - * of the array. Keep in mind that if it is intended to change either the - * name of a field and any other properties, the change array entries - * should have the new names of the fields as array indexes. - * - * The value of each entry of the array should be set to another associative - * array with the properties of the fields to that are meant to be changed as - * array entries. These entries should be assigned to the new values of the - * respective properties. The properties of the fields should be the same - * as defined by the MDB2 parser. - * - * Example - * array( - * 'name' => 'userlist', - * 'add' => array( - * 'quota' => array( - * 'type' => 'integer', - * 'unsigned' => 1 - * ) - * ), - * 'remove' => array( - * 'file_limit' => array(), - * 'time_limit' => array() - * ), - * 'change' => array( - * 'name' => array( - * 'length' => '20', - * 'definition' => array( - * 'type' => 'text', - * 'length' => 20, - * ), - * ) - * ), - * 'rename' => array( - * 'sex' => array( - * 'name' => 'gender', - * 'definition' => array( - * 'type' => 'text', - * 'length' => 1, - * 'default' => 'M', - * ), - * ) - * ) - * ) - * - * @param boolean $check indicates whether the function should just check if the DBMS driver - * can perform the requested table alterations if the value is true or - * actually perform them otherwise. - * @access public - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - */ - function alterTable($name, $changes, $check) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - foreach ($changes as $change_name => $change) { - switch ($change_name) { - case 'add': - case 'remove': - case 'change': - case 'name': - case 'rename': - break; - default: - return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, - 'change type "'.$change_name.'\" not yet supported', __FUNCTION__); - } - } - - if ($check) { - return MDB2_OK; - } - - $name = $db->quoteIdentifier($name, true); - - if (!empty($changes['remove']) && is_array($changes['remove'])) { - foreach ($changes['remove'] as $field_name => $field) { - $field_name = $db->quoteIdentifier($field_name, true); - $query = 'DROP ' . $field_name; - $result = $db->exec("ALTER TABLE $name $query"); - if (MDB2::isError($result)) { - return $result; - } - } - } - - if (!empty($changes['rename']) && is_array($changes['rename'])) { - foreach ($changes['rename'] as $field_name => $field) { - $field_name = $db->quoteIdentifier($field_name, true); - $result = $db->exec("ALTER TABLE $name RENAME COLUMN $field_name TO ".$db->quoteIdentifier($field['name'], true)); - if (MDB2::isError($result)) { - return $result; - } - } - } - - if (!empty($changes['add']) && is_array($changes['add'])) { - foreach ($changes['add'] as $field_name => $field) { - $query = 'ADD ' . $db->getDeclaration($field['type'], $field_name, $field); - $result = $db->exec("ALTER TABLE $name $query"); - if (MDB2::isError($result)) { - return $result; - } - } - } - - if (!empty($changes['change']) && is_array($changes['change'])) { - foreach ($changes['change'] as $field_name => $field) { - $field_name = $db->quoteIdentifier($field_name, true); - if (!empty($field['definition']['type'])) { - $server_info = $db->getServerVersion(); - if (MDB2::isError($server_info)) { - return $server_info; - } - if (is_array($server_info) && $server_info['major'] < 8) { - return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, - 'changing column type for "'.$change_name.'\" requires PostgreSQL 8.0 or above', __FUNCTION__); - } - $db->loadModule('Datatype', null, true); - $type = $db->datatype->getTypeDeclaration($field['definition']); - $query = "ALTER $field_name TYPE $type USING CAST($field_name AS $type)"; - $result = $db->exec("ALTER TABLE $name $query"); - if (MDB2::isError($result)) { - return $result; - } - } - if (array_key_exists('default', $field['definition'])) { - $query = "ALTER $field_name SET DEFAULT ".$db->quote($field['definition']['default'], $field['definition']['type']); - $result = $db->exec("ALTER TABLE $name $query"); - if (MDB2::isError($result)) { - return $result; - } - } - if (array_key_exists('notnull', $field['definition'])) { - $query = "ALTER $field_name ".($field['definition']['notnull'] ? 'SET' : 'DROP').' NOT NULL'; - $result = $db->exec("ALTER TABLE $name $query"); - if (MDB2::isError($result)) { - return $result; - } - } - } - } - - if (!empty($changes['name'])) { - $change_name = $db->quoteIdentifier($changes['name'], true); - $result = $db->exec("ALTER TABLE $name RENAME TO ".$change_name); - if (MDB2::isError($result)) { - return $result; - } - } - - return MDB2_OK; - } - - // }}} - // {{{ listDatabases() - - /** - * list all databases - * - * @return mixed array of database names on success, a MDB2 error on failure - * @access public - */ - function listDatabases() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = 'SELECT datname FROM pg_database'; - $result2 = $db->standaloneQuery($query, array('text'), false); - if (!MDB2::isResultCommon($result2)) { - return $result2; - } - - $result = $result2->fetchCol(); - $result2->free(); - if (MDB2::isError($result)) { - return $result; - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listUsers() - - /** - * list all users - * - * @return mixed array of user names on success, a MDB2 error on failure - * @access public - */ - function listUsers() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = 'SELECT usename FROM pg_user'; - $result2 = $db->standaloneQuery($query, array('text'), false); - if (!MDB2::isResultCommon($result2)) { - return $result2; - } - - $result = $result2->fetchCol(); - $result2->free(); - return $result; - } - - // }}} - // {{{ listViews() - - /** - * list all views in the current database - * - * @return mixed array of view names on success, a MDB2 error on failure - * @access public - */ - function listViews() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = "SELECT viewname - FROM pg_views - WHERE schemaname NOT IN ('pg_catalog', 'information_schema') - AND viewname !~ '^pg_'"; - $result = $db->queryCol($query); - if (MDB2::isError($result)) { - return $result; - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listTableViews() - - /** - * list the views in the database that reference a given table - * - * @param string table for which all referenced views should be found - * @return mixed array of view names on success, a MDB2 error on failure - * @access public - */ - function listTableViews($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = 'SELECT viewname FROM pg_views NATURAL JOIN pg_tables'; - $query.= ' WHERE tablename ='.$db->quote($table, 'text'); - $result = $db->queryCol($query); - if (MDB2::isError($result)) { - return $result; - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listFunctions() - - /** - * list all functions in the current database - * - * @return mixed array of function names on success, a MDB2 error on failure - * @access public - */ - function listFunctions() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = " - SELECT - proname - FROM - pg_proc pr, - pg_type tp - WHERE - tp.oid = pr.prorettype - AND pr.proisagg = FALSE - AND tp.typname <> 'trigger' - AND pr.pronamespace IN - (SELECT oid FROM pg_namespace WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema')"; - $result = $db->queryCol($query); - if (MDB2::isError($result)) { - return $result; - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listTableTriggers() - - /** - * list all triggers in the database that reference a given table - * - * @param string table for which all referenced triggers should be found - * @return mixed array of trigger names on success, a MDB2 error on failure - * @access public - */ - function listTableTriggers($table = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = 'SELECT trg.tgname AS trigger_name - FROM pg_trigger trg, - pg_class tbl - WHERE trg.tgrelid = tbl.oid'; - if (null !== $table) { - $table = $db->quote(strtoupper($table), 'text'); - $query .= " AND UPPER(tbl.relname) = $table"; - } - $result = $db->queryCol($query); - if (MDB2::isError($result)) { - return $result; - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listTables() - - /** - * list all tables in the current database - * - * @return mixed array of table names on success, a MDB2 error on failure - * @access public - */ - function listTables() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - // gratuitously stolen from PEAR DB _getSpecialQuery in pgsql.php - $query = 'SELECT c.relname AS "Name"' - . ' FROM pg_class c, pg_user u' - . ' WHERE c.relowner = u.usesysid' - . " AND c.relkind = 'r'" - . ' AND NOT EXISTS' - . ' (SELECT 1 FROM pg_views' - . ' WHERE viewname = c.relname)' - . " AND c.relname !~ '^(pg_|sql_)'" - . ' UNION' - . ' SELECT c.relname AS "Name"' - . ' FROM pg_class c' - . " WHERE c.relkind = 'r'" - . ' AND NOT EXISTS' - . ' (SELECT 1 FROM pg_views' - . ' WHERE viewname = c.relname)' - . ' AND NOT EXISTS' - . ' (SELECT 1 FROM pg_user' - . ' WHERE usesysid = c.relowner)' - . " AND c.relname !~ '^pg_'"; - $result = $db->queryCol($query); - if (MDB2::isError($result)) { - return $result; - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } - - // }}} - // {{{ listTableFields() - - /** - * list all fields in a table in the current database - * - * @param string $table name of table that should be used in method - * @return mixed array of field names on success, a MDB2 error on failure - * @access public - */ - function listTableFields($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - list($schema, $table) = $this->splitTableSchema($table); - - $table = $db->quoteIdentifier($table, true); - if (!empty($schema)) { - $table = $db->quoteIdentifier($schema, true) . '.' .$table; - } - $db->setLimit(1); - $result2 = $db->query("SELECT * FROM $table"); - if (MDB2::isError($result2)) { - return $result2; - } - $result = $result2->getColumnNames(); - $result2->free(); - if (MDB2::isError($result)) { - return $result; - } - return array_flip($result); - } - - // }}} - // {{{ listTableIndexes() - - /** - * list all indexes in a table - * - * @param string $table name of table that should be used in method - * @return mixed array of index names on success, a MDB2 error on failure - * @access public - */ - function listTableIndexes($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - list($schema, $table) = $this->splitTableSchema($table); - - $table = $db->quote($table, 'text'); - $subquery = "SELECT indexrelid - FROM pg_index - LEFT JOIN pg_class ON pg_class.oid = pg_index.indrelid - LEFT JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid - WHERE pg_class.relname = $table - AND indisunique != 't' - AND indisprimary != 't'"; - if (!empty($schema)) { - $subquery .= ' AND pg_namespace.nspname = '.$db->quote($schema, 'text'); - } - $query = "SELECT relname FROM pg_class WHERE oid IN ($subquery)"; - $indexes = $db->queryCol($query, 'text'); - if (MDB2::isError($indexes)) { - return $indexes; - } - - $result = array(); - foreach ($indexes as $index) { - $index = $this->_fixIndexName($index); - if (!empty($index)) { - $result[$index] = true; - } - } - - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_change_key_case($result, $db->options['field_case']); - } - return array_keys($result); - } - - // }}} - // {{{ dropConstraint() - - /** - * drop existing constraint - * - * @param string $table name of table that should be used in method - * @param string $name name of the constraint to be dropped - * @param string $primary hint if the constraint is primary - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropConstraint($table, $name, $primary = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - // is it an UNIQUE index? - $query = 'SELECT relname - FROM pg_class - WHERE oid IN ( - SELECT indexrelid - FROM pg_index, pg_class - WHERE pg_class.relname = '.$db->quote($table, 'text').' - AND pg_class.oid = pg_index.indrelid - AND indisunique = \'t\') - EXCEPT - SELECT conname - FROM pg_constraint, pg_class - WHERE pg_constraint.conrelid = pg_class.oid - AND relname = '. $db->quote($table, 'text'); - $unique = $db->queryCol($query, 'text'); - if (MDB2::isError($unique) || empty($unique)) { - // not an UNIQUE index, maybe a CONSTRAINT - return parent::dropConstraint($table, $name, $primary); - } - - if (in_array($name, $unique)) { - $result = $db->exec('DROP INDEX '.$db->quoteIdentifier($name, true)); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - $idxname = $db->getIndexName($name); - if (in_array($idxname, $unique)) { - $result = $db->exec('DROP INDEX '.$db->quoteIdentifier($idxname, true)); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - $name . ' is not an existing constraint for table ' . $table, __FUNCTION__); - } - - // }}} - // {{{ listTableConstraints() - - /** - * list all constraints in a table - * - * @param string $table name of table that should be used in method - * @return mixed array of constraint names on success, a MDB2 error on failure - * @access public - */ - function listTableConstraints($table) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - list($schema, $table) = $this->splitTableSchema($table); - - $table = $db->quote($table, 'text'); - $query = 'SELECT conname - FROM pg_constraint - LEFT JOIN pg_class ON pg_constraint.conrelid = pg_class.oid - LEFT JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid - WHERE relname = ' .$table; - if (!empty($schema)) { - $query .= ' AND pg_namespace.nspname = ' . $db->quote($schema, 'text'); - } - $query .= ' - UNION DISTINCT - SELECT relname - FROM pg_class - WHERE oid IN ( - SELECT indexrelid - FROM pg_index - LEFT JOIN pg_class ON pg_class.oid = pg_index.indrelid - LEFT JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid - WHERE pg_class.relname = '.$table.' - AND indisunique = \'t\''; - if (!empty($schema)) { - $query .= ' AND pg_namespace.nspname = ' . $db->quote($schema, 'text'); - } - $query .= ')'; - $constraints = $db->queryCol($query); - if (MDB2::isError($constraints)) { - return $constraints; - } - - $result = array(); - foreach ($constraints as $constraint) { - $constraint = $this->_fixIndexName($constraint); - if (!empty($constraint)) { - $result[$constraint] = true; - } - } - - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE - && $db->options['field_case'] == CASE_LOWER - ) { - $result = array_change_key_case($result, $db->options['field_case']); - } - return array_keys($result); - } - - // }}} - // {{{ createSequence() - - /** - * create sequence - * - * @param string $seq_name name of the sequence to be created - * @param string $start start value of the sequence; default is 1 - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function createSequence($seq_name, $start = 1) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true); - $result = $db->exec("CREATE SEQUENCE $sequence_name INCREMENT 1". - ($start < 1 ? " MINVALUE $start" : '')." START $start"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ dropSequence() - - /** - * drop existing sequence - * - * @param string $seq_name name of the sequence to be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropSequence($seq_name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true); - $result = $db->exec("DROP SEQUENCE $sequence_name"); - if (MDB2::isError($result)) { - return $result; - } - return MDB2_OK; - } - - // }}} - // {{{ listSequences() - - /** - * list all sequences in the current database - * - * @return mixed array of sequence names on success, a MDB2 error on failure - * @access public - */ - function listSequences() - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = "SELECT relname FROM pg_class WHERE relkind = 'S' AND relnamespace IN"; - $query.= "(SELECT oid FROM pg_namespace WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema')"; - $table_names = $db->queryCol($query); - if (MDB2::isError($table_names)) { - return $table_names; - } - $result = array(); - foreach ($table_names as $table_name) { - $result[] = $this->_fixSequenceName($table_name); - } - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); - } - return $result; - } -} -?> diff --git a/data/module/MDB2/Driver/Native/Common.php b/data/module/MDB2/Driver/Native/Common.php deleted file mode 100644 index 20e652e3e17..00000000000 --- a/data/module/MDB2/Driver/Native/Common.php +++ /dev/null @@ -1,61 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Common.php 242348 2007-09-09 13:47:36Z quipo $ -// - -/** - * Base class for the natuve modules that is extended by each MDB2 driver - * - * To load this module in the MDB2 object: - * $mdb->loadModule('Native'); - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Native_Common extends MDB2_Module_Common -{ -} -?> \ No newline at end of file diff --git a/data/module/MDB2/Driver/Native/mysql.php b/data/module/MDB2/Driver/Native/mysql.php deleted file mode 100644 index 2d4ffe09d4c..00000000000 --- a/data/module/MDB2/Driver/Native/mysql.php +++ /dev/null @@ -1,60 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: mysql.php 215004 2006-06-18 21:59:05Z lsmith $ -// - -require_once 'MDB2/Driver/Native/Common.php'; - -/** - * MDB2 MySQL driver for the native module - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Native_mysql extends MDB2_Driver_Native_Common -{ -} -?> \ No newline at end of file diff --git a/data/module/MDB2/Driver/Native/pgsql.php b/data/module/MDB2/Driver/Native/pgsql.php deleted file mode 100644 index a20b6d04f10..00000000000 --- a/data/module/MDB2/Driver/Native/pgsql.php +++ /dev/null @@ -1,88 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: pgsql.php 327310 2012-08-27 15:16:18Z danielc $ - -require_once 'MDB2/Driver/Native/Common.php'; - -/** - * MDB2 PostGreSQL driver for the native module - * - * @package MDB2 - * @category Database - * @author Paul Cooper - */ -class MDB2_Driver_Native_pgsql extends MDB2_Driver_Native_Common -{ - // }}} - // {{{ deleteOID() - - /** - * delete an OID - * - * @param integer $OID - * @return mixed MDB2_OK on success or MDB2 Error Object on failure - * @access public - */ - function deleteOID($OID) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $connection = $db->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - - if (!@pg_lo_unlink($connection, $OID)) { - return $db->raiseError(null, null, null, - 'Unable to unlink OID: '.$OID, __FUNCTION__); - } - return MDB2_OK; - } - -} -?> diff --git a/data/module/MDB2/Driver/Reverse/Common.php b/data/module/MDB2/Driver/Reverse/Common.php deleted file mode 100644 index e31cb5a4595..00000000000 --- a/data/module/MDB2/Driver/Reverse/Common.php +++ /dev/null @@ -1,517 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Common.php 327310 2012-08-27 15:16:18Z danielc $ -// - -/** - * @package MDB2 - * @category Database - */ - -/** - * These are constants for the tableInfo-function - * they are bitwised or'ed. so if there are more constants to be defined - * in the future, adjust MDB2_TABLEINFO_FULL accordingly - */ - -define('MDB2_TABLEINFO_ORDER', 1); -define('MDB2_TABLEINFO_ORDERTABLE', 2); -define('MDB2_TABLEINFO_FULL', 3); - -/** - * Base class for the schema reverse engineering module that is extended by each MDB2 driver - * - * To load this module in the MDB2 object: - * $mdb->loadModule('Reverse'); - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Reverse_Common extends MDB2_Module_Common -{ - // {{{ splitTableSchema() - - /** - * Split the "[owner|schema].table" notation into an array - * - * @param string $table [schema and] table name - * - * @return array array(schema, table) - * @access private - */ - function splitTableSchema($table) - { - $ret = array(); - if (strpos($table, '.') !== false) { - return explode('.', $table); - } - return array(null, $table); - } - - // }}} - // {{{ getTableFieldDefinition() - - /** - * Get the structure of a field into an array - * - * @param string $table name of table that should be used in method - * @param string $field name of field that should be used in method - * @return mixed data array on success, a MDB2 error on failure. - * The returned array contains an array for each field definition, - * with all or some of these indices, depending on the field data type: - * [notnull] [nativetype] [length] [fixed] [default] [type] [mdb2type] - * @access public - */ - function getTableFieldDefinition($table, $field) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ getTableIndexDefinition() - - /** - * Get the structure of an index into an array - * - * @param string $table name of table that should be used in method - * @param string $index name of index that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * The returned array has this structure: - * - * array ( - * [fields] => array ( - * [field1name] => array() // one entry per each field covered - * [field2name] => array() // by the index - * [field3name] => array( - * [sorting] => ascending - * ) - * ) - * ); - * - * @access public - */ - function getTableIndexDefinition($table, $index) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ getTableConstraintDefinition() - - /** - * Get the structure of an constraints into an array - * - * @param string $table name of table that should be used in method - * @param string $index name of index that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * The returned array has this structure: - *
-     *          array (
-     *              [primary] => 0
-     *              [unique]  => 0
-     *              [foreign] => 1
-     *              [check]   => 0
-     *              [fields] => array (
-     *                  [field1name] => array() // one entry per each field covered
-     *                  [field2name] => array() // by the index
-     *                  [field3name] => array(
-     *                      [sorting]  => ascending
-     *                      [position] => 3
-     *                  )
-     *              )
-     *              [references] => array(
-     *                  [table] => name
-     *                  [fields] => array(
-     *                      [field1name] => array(  //one entry per each referenced field
-     *                           [position] => 1
-     *                      )
-     *                  )
-     *              )
-     *              [deferrable] => 0
-     *              [initiallydeferred] => 0
-     *              [onupdate] => CASCADE|RESTRICT|SET NULL|SET DEFAULT|NO ACTION
-     *              [ondelete] => CASCADE|RESTRICT|SET NULL|SET DEFAULT|NO ACTION
-     *              [match] => SIMPLE|PARTIAL|FULL
-     *          );
-     *          
- * @access public - */ - function getTableConstraintDefinition($table, $index) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ getSequenceDefinition() - - /** - * Get the structure of a sequence into an array - * - * @param string $sequence name of sequence that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * The returned array has this structure: - *
-     *          array (
-     *              [start] => n
-     *          );
-     *          
- * @access public - */ - function getSequenceDefinition($sequence) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $start = $db->currId($sequence); - if (MDB2::isError($start)) { - return $start; - } - if ($db->supports('current_id')) { - $start++; - } else { - $db->warnings[] = 'database does not support getting current - sequence value, the sequence value was incremented'; - } - $definition = array(); - if ($start != 1) { - $definition = array('start' => $start); - } - return $definition; - } - - // }}} - // {{{ getTriggerDefinition() - - /** - * Get the structure of a trigger into an array - * - * EXPERIMENTAL - * - * WARNING: this function is experimental and may change the returned value - * at any time until labelled as non-experimental - * - * @param string $trigger name of trigger that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * The returned array has this structure: - *
-     *          array (
-     *              [trigger_name]    => 'trigger name',
-     *              [table_name]      => 'table name',
-     *              [trigger_body]    => 'trigger body definition',
-     *              [trigger_type]    => 'BEFORE' | 'AFTER',
-     *              [trigger_event]   => 'INSERT' | 'UPDATE' | 'DELETE'
-     *                  //or comma separated list of multiple events, when supported
-     *              [trigger_enabled] => true|false
-     *              [trigger_comment] => 'trigger comment',
-     *          );
-     *          
- * The oci8 driver also returns a [when_clause] index. - * @access public - */ - function getTriggerDefinition($trigger) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - // }}} - // {{{ tableInfo() - - /** - * Returns information about a table or a result set - * - * The format of the resulting array depends on which $mode - * you select. The sample output below is based on this query: - *
-     *    SELECT tblFoo.fldID, tblFoo.fldPhone, tblBar.fldId
-     *    FROM tblFoo
-     *    JOIN tblBar ON tblFoo.fldId = tblBar.fldId
-     * 
- * - *
    - *
  • - * - * null (default) - *
    -     *   [0] => Array (
    -     *       [table] => tblFoo
    -     *       [name] => fldId
    -     *       [type] => int
    -     *       [len] => 11
    -     *       [flags] => primary_key not_null
    -     *   )
    -     *   [1] => Array (
    -     *       [table] => tblFoo
    -     *       [name] => fldPhone
    -     *       [type] => string
    -     *       [len] => 20
    -     *       [flags] =>
    -     *   )
    -     *   [2] => Array (
    -     *       [table] => tblBar
    -     *       [name] => fldId
    -     *       [type] => int
    -     *       [len] => 11
    -     *       [flags] => primary_key not_null
    -     *   )
    -     *   
    - * - *
  • - * - * MDB2_TABLEINFO_ORDER - * - *

    In addition to the information found in the default output, - * a notation of the number of columns is provided by the - * num_fields element while the order - * element provides an array with the column names as the keys and - * their location index number (corresponding to the keys in the - * the default output) as the values.

    - * - *

    If a result set has identical field names, the last one is - * used.

    - * - *
    -     *   [num_fields] => 3
    -     *   [order] => Array (
    -     *       [fldId] => 2
    -     *       [fldTrans] => 1
    -     *   )
    -     *   
    - * - *
  • - * - * MDB2_TABLEINFO_ORDERTABLE - * - *

    Similar to MDB2_TABLEINFO_ORDER but adds more - * dimensions to the array in which the table names are keys and - * the field names are sub-keys. This is helpful for queries that - * join tables which have identical field names.

    - * - *
    -     *   [num_fields] => 3
    -     *   [ordertable] => Array (
    -     *       [tblFoo] => Array (
    -     *           [fldId] => 0
    -     *           [fldPhone] => 1
    -     *       )
    -     *       [tblBar] => Array (
    -     *           [fldId] => 2
    -     *       )
    -     *   )
    -     *   
    - * - *
  • - *
- * - * The flags element contains a space separated list - * of extra information about the field. This data is inconsistent - * between DBMS's due to the way each DBMS works. - * + primary_key - * + unique_key - * + multiple_key - * + not_null - * - * Most DBMS's only provide the table and flags - * elements if $result is a table name. The following DBMS's - * provide full information from queries: - * + fbsql - * + mysql - * - * If the 'portability' option has MDB2_PORTABILITY_FIX_CASE - * turned on, the names of tables and fields will be lower or upper cased. - * - * @param object|string $result MDB2_result object from a query or a - * string containing the name of a table. - * While this also accepts a query result - * resource identifier, this behavior is - * deprecated. - * @param int $mode either unused or one of the tableInfo modes: - * MDB2_TABLEINFO_ORDERTABLE, - * MDB2_TABLEINFO_ORDER or - * MDB2_TABLEINFO_FULL (which does both). - * These are bitwise, so the first two can be - * combined using |. - * - * @return array an associative array with the information requested. - * A MDB2_Error object on failure. - * - * @see MDB2_Driver_Common::setOption() - */ - function tableInfo($result, $mode = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if (!is_string($result)) { - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'method not implemented', __FUNCTION__); - } - - $db->loadModule('Manager', null, true); - $fields = $db->manager->listTableFields($result); - if (MDB2::isError($fields)) { - return $fields; - } - - $flags = array(); - - $idxname_format = $db->getOption('idxname_format'); - $db->setOption('idxname_format', '%s'); - - $indexes = $db->manager->listTableIndexes($result); - if (MDB2::isError($indexes)) { - $db->setOption('idxname_format', $idxname_format); - return $indexes; - } - - foreach ($indexes as $index) { - $definition = $this->getTableIndexDefinition($result, $index); - if (MDB2::isError($definition)) { - $db->setOption('idxname_format', $idxname_format); - return $definition; - } - if (count($definition['fields']) > 1) { - foreach ($definition['fields'] as $field => $sort) { - $flags[$field] = 'multiple_key'; - } - } - } - - $constraints = $db->manager->listTableConstraints($result); - if (MDB2::isError($constraints)) { - return $constraints; - } - - foreach ($constraints as $constraint) { - $definition = $this->getTableConstraintDefinition($result, $constraint); - if (MDB2::isError($definition)) { - $db->setOption('idxname_format', $idxname_format); - return $definition; - } - $flag = !empty($definition['primary']) - ? 'primary_key' : (!empty($definition['unique']) - ? 'unique_key' : false); - if ($flag) { - foreach ($definition['fields'] as $field => $sort) { - if (empty($flags[$field]) || $flags[$field] != 'primary_key') { - $flags[$field] = $flag; - } - } - } - } - - $res = array(); - - if ($mode) { - $res['num_fields'] = count($fields); - } - - foreach ($fields as $i => $field) { - $definition = $this->getTableFieldDefinition($result, $field); - if (MDB2::isError($definition)) { - $db->setOption('idxname_format', $idxname_format); - return $definition; - } - $res[$i] = $definition[0]; - $res[$i]['name'] = $field; - $res[$i]['table'] = $result; - $res[$i]['type'] = preg_replace('/^([a-z]+).*$/i', '\\1', trim($definition[0]['nativetype'])); - // 'primary_key', 'unique_key', 'multiple_key' - $res[$i]['flags'] = empty($flags[$field]) ? '' : $flags[$field]; - // not_null', 'unsigned', 'auto_increment', 'default_[rawencodedvalue]' - if (!empty($res[$i]['notnull'])) { - $res[$i]['flags'].= ' not_null'; - } - if (!empty($res[$i]['unsigned'])) { - $res[$i]['flags'].= ' unsigned'; - } - if (!empty($res[$i]['auto_increment'])) { - $res[$i]['flags'].= ' autoincrement'; - } - if (!empty($res[$i]['default'])) { - $res[$i]['flags'].= ' default_'.rawurlencode($res[$i]['default']); - } - - if ($mode & MDB2_TABLEINFO_ORDER) { - $res['order'][$res[$i]['name']] = $i; - } - if ($mode & MDB2_TABLEINFO_ORDERTABLE) { - $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i; - } - } - - $db->setOption('idxname_format', $idxname_format); - return $res; - } -} -?> diff --git a/data/module/MDB2/Driver/Reverse/mysql.php b/data/module/MDB2/Driver/Reverse/mysql.php deleted file mode 100644 index 3aea5a7aa92..00000000000 --- a/data/module/MDB2/Driver/Reverse/mysql.php +++ /dev/null @@ -1,546 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: mysql.php 327310 2012-08-27 15:16:18Z danielc $ -// - -require_once 'MDB2/Driver/Reverse/Common.php'; - -/** - * MDB2 MySQL driver for the schema reverse engineering module - * - * @package MDB2 - * @category Database - * @author Lukas Smith - * @author Lorenzo Alberton - */ -class MDB2_Driver_Reverse_mysql extends MDB2_Driver_Reverse_Common -{ - // {{{ getTableFieldDefinition() - - /** - * Get the structure of a field into an array - * - * @param string $table_name name of table that should be used in method - * @param string $field_name name of field that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * @access public - */ - function getTableFieldDefinition($table_name, $field_name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $result = $db->loadModule('Datatype', null, true); - if (MDB2::isError($result)) { - return $result; - } - - list($schema, $table) = $this->splitTableSchema($table_name); - - $table = $db->quoteIdentifier($table, true); - $query = "SHOW FULL COLUMNS FROM $table LIKE ".$db->quote($field_name); - $columns = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC); - if (MDB2::isError($columns)) { - return $columns; - } - foreach ($columns as $column) { - $column = array_change_key_case($column, CASE_LOWER); - $column['name'] = $column['field']; - unset($column['field']); - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $column['name'] = strtolower($column['name']); - } else { - $column['name'] = strtoupper($column['name']); - } - } else { - $column = array_change_key_case($column, $db->options['field_case']); - } - if ($field_name == $column['name']) { - $mapped_datatype = $db->datatype->mapNativeDatatype($column); - if (MDB2::isError($mapped_datatype)) { - return $mapped_datatype; - } - list($types, $length, $unsigned, $fixed) = $mapped_datatype; - $notnull = false; - if (empty($column['null']) || $column['null'] !== 'YES') { - $notnull = true; - } - $default = false; - if (array_key_exists('default', $column)) { - $default = $column['default']; - if ((null === $default) && $notnull) { - $default = ''; - } - } - $definition[0] = array( - 'notnull' => $notnull, - 'nativetype' => preg_replace('/^([a-z]+)[^a-z].*/i', '\\1', $column['type']) - ); - $autoincrement = false; - if (!empty($column['extra'])) { - if ($column['extra'] == 'auto_increment') { - $autoincrement = true; - } else { - $definition[0]['extra'] = $column['extra']; - } - } - $collate = null; - if (!empty($column['collation'])) { - $collate = $column['collation']; - $charset = preg_replace('/(.+?)(_.+)?/', '$1', $collate); - } - - if (null !== $length) { - $definition[0]['length'] = $length; - } - if (null !== $unsigned) { - $definition[0]['unsigned'] = $unsigned; - } - if (null !== $fixed) { - $definition[0]['fixed'] = $fixed; - } - if ($default !== false) { - $definition[0]['default'] = $default; - } - if ($autoincrement !== false) { - $definition[0]['autoincrement'] = $autoincrement; - } - if (null !== $collate) { - $definition[0]['collate'] = $collate; - $definition[0]['charset'] = $charset; - } - foreach ($types as $key => $type) { - $definition[$key] = $definition[0]; - if ($type == 'clob' || $type == 'blob') { - unset($definition[$key]['default']); - } elseif ($type == 'timestamp' && $notnull && empty($definition[$key]['default'])) { - $definition[$key]['default'] = '0000-00-00 00:00:00'; - } - $definition[$key]['type'] = $type; - $definition[$key]['mdb2type'] = $type; - } - return $definition; - } - } - - return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'it was not specified an existing table column', __FUNCTION__); - } - - // }}} - // {{{ getTableIndexDefinition() - - /** - * Get the structure of an index into an array - * - * @param string $table_name name of table that should be used in method - * @param string $index_name name of index that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * @access public - */ - function getTableIndexDefinition($table_name, $index_name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - list($schema, $table) = $this->splitTableSchema($table_name); - - $table = $db->quoteIdentifier($table, true); - $query = "SHOW INDEX FROM $table /*!50002 WHERE Key_name = %s */"; - $index_name_mdb2 = $db->getIndexName($index_name); - $result = $db->queryRow(sprintf($query, $db->quote($index_name_mdb2))); - if (!MDB2::isError($result) && (null !== $result)) { - // apply 'idxname_format' only if the query succeeded, otherwise - // fallback to the given $index_name, without transformation - $index_name = $index_name_mdb2; - } - $result = $db->query(sprintf($query, $db->quote($index_name))); - if (MDB2::isError($result)) { - return $result; - } - $colpos = 1; - $definition = array(); - while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) { - $row = array_change_key_case($row, CASE_LOWER); - $key_name = $row['key_name']; - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $key_name = strtolower($key_name); - } else { - $key_name = strtoupper($key_name); - } - } - if ($index_name == $key_name) { - if (!$row['non_unique']) { - return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - $index_name . ' is not an existing table index', __FUNCTION__); - } - $column_name = $row['column_name']; - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $column_name = strtolower($column_name); - } else { - $column_name = strtoupper($column_name); - } - } - $definition['fields'][$column_name] = array( - 'position' => $colpos++ - ); - if (!empty($row['collation'])) { - $definition['fields'][$column_name]['sorting'] = ($row['collation'] == 'A' - ? 'ascending' : 'descending'); - } - } - } - $result->free(); - if (empty($definition['fields'])) { - return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - $index_name . ' is not an existing table index', __FUNCTION__); - } - return $definition; - } - - // }}} - // {{{ getTableConstraintDefinition() - - /** - * Get the structure of a constraint into an array - * - * @param string $table_name name of table that should be used in method - * @param string $constraint_name name of constraint that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * @access public - */ - function getTableConstraintDefinition($table_name, $constraint_name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - list($schema, $table) = $this->splitTableSchema($table_name); - $constraint_name_original = $constraint_name; - - $table = $db->quoteIdentifier($table, true); - $query = "SHOW INDEX FROM $table /*!50002 WHERE Key_name = %s */"; - if (strtolower($constraint_name) != 'primary') { - $constraint_name_mdb2 = $db->getIndexName($constraint_name); - $result = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2))); - if (!MDB2::isError($result) && (null !== $result)) { - // apply 'idxname_format' only if the query succeeded, otherwise - // fallback to the given $index_name, without transformation - $constraint_name = $constraint_name_mdb2; - } - } - $result = $db->query(sprintf($query, $db->quote($constraint_name))); - if (MDB2::isError($result)) { - return $result; - } - $colpos = 1; - //default values, eventually overridden - $definition = array( - 'primary' => false, - 'unique' => false, - 'foreign' => false, - 'check' => false, - 'fields' => array(), - 'references' => array( - 'table' => '', - 'fields' => array(), - ), - 'onupdate' => '', - 'ondelete' => '', - 'match' => '', - 'deferrable' => false, - 'initiallydeferred' => false, - ); - while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) { - $row = array_change_key_case($row, CASE_LOWER); - $key_name = $row['key_name']; - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $key_name = strtolower($key_name); - } else { - $key_name = strtoupper($key_name); - } - } - if ($constraint_name == $key_name) { - if ($row['non_unique']) { - //FOREIGN KEY? - return $this->_getTableFKConstraintDefinition($table, $constraint_name_original, $definition); - } - if ($row['key_name'] == 'PRIMARY') { - $definition['primary'] = true; - } elseif (!$row['non_unique']) { - $definition['unique'] = true; - } - $column_name = $row['column_name']; - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $column_name = strtolower($column_name); - } else { - $column_name = strtoupper($column_name); - } - } - $definition['fields'][$column_name] = array( - 'position' => $colpos++ - ); - if (!empty($row['collation'])) { - $definition['fields'][$column_name]['sorting'] = ($row['collation'] == 'A' - ? 'ascending' : 'descending'); - } - } - } - $result->free(); - if (empty($definition['fields'])) { - return $this->_getTableFKConstraintDefinition($table, $constraint_name_original, $definition); - } - return $definition; - } - - // }}} - // {{{ _getTableFKConstraintDefinition() - - /** - * Get the FK definition from the CREATE TABLE statement - * - * @param string $table table name - * @param string $constraint_name constraint name - * @param array $definition default values for constraint definition - * - * @return array|PEAR_Error - * @access private - */ - function _getTableFKConstraintDefinition($table, $constraint_name, $definition) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - //Use INFORMATION_SCHEMA instead? - //SELECT * - // FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS - // WHERE CONSTRAINT_SCHEMA = '$dbname' - // AND TABLE_NAME = '$table' - // AND CONSTRAINT_NAME = '$constraint_name'; - $query = 'SHOW CREATE TABLE '. $db->escape($table); - $constraint = $db->queryOne($query, 'text', 1); - if (!MDB2::isError($constraint) && !empty($constraint)) { - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $constraint = strtolower($constraint); - } else { - $constraint = strtoupper($constraint); - } - } - $constraint_name_original = $constraint_name; - $constraint_name = $db->getIndexName($constraint_name); - $pattern = '/\bCONSTRAINT\s+'.$constraint_name.'\s+FOREIGN KEY\s+\(([^\)]+)\) \bREFERENCES\b ([^\s]+) \(([^\)]+)\)(?: ON DELETE ([^\s]+))?(?: ON UPDATE ([^\s]+))?/i'; - if (!preg_match($pattern, str_replace('`', '', $constraint), $matches)) { - //fallback to original constraint name - $pattern = '/\bCONSTRAINT\s+'.$constraint_name_original.'\s+FOREIGN KEY\s+\(([^\)]+)\) \bREFERENCES\b ([^\s]+) \(([^\)]+)\)(?: ON DELETE ([^\s]+))?(?: ON UPDATE ([^\s]+))?/i'; - } - if (preg_match($pattern, str_replace('`', '', $constraint), $matches)) { - $definition['foreign'] = true; - $column_names = explode(',', $matches[1]); - $referenced_cols = explode(',', $matches[3]); - $definition['references'] = array( - 'table' => $matches[2], - 'fields' => array(), - ); - $colpos = 1; - foreach ($column_names as $column_name) { - $definition['fields'][trim($column_name)] = array( - 'position' => $colpos++ - ); - } - $colpos = 1; - foreach ($referenced_cols as $column_name) { - $definition['references']['fields'][trim($column_name)] = array( - 'position' => $colpos++ - ); - } - $definition['ondelete'] = empty($matches[4]) ? 'RESTRICT' : strtoupper($matches[4]); - $definition['onupdate'] = empty($matches[5]) ? 'RESTRICT' : strtoupper($matches[5]); - $definition['match'] = 'SIMPLE'; - return $definition; - } - } - return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - $constraint_name . ' is not an existing table constraint', __FUNCTION__); - } - - // }}} - // {{{ getTriggerDefinition() - - /** - * Get the structure of a trigger into an array - * - * EXPERIMENTAL - * - * WARNING: this function is experimental and may change the returned value - * at any time until labelled as non-experimental - * - * @param string $trigger name of trigger that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * @access public - */ - function getTriggerDefinition($trigger) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = 'SELECT trigger_name, - event_object_table AS table_name, - action_statement AS trigger_body, - action_timing AS trigger_type, - event_manipulation AS trigger_event - FROM information_schema.triggers - WHERE trigger_name = '. $db->quote($trigger, 'text'); - $types = array( - 'trigger_name' => 'text', - 'table_name' => 'text', - 'trigger_body' => 'text', - 'trigger_type' => 'text', - 'trigger_event' => 'text', - ); - $def = $db->queryRow($query, $types, MDB2_FETCHMODE_ASSOC); - if (MDB2::isError($def)) { - return $def; - } - $def['trigger_comment'] = ''; - $def['trigger_enabled'] = true; - return $def; - } - - // }}} - // {{{ tableInfo() - - /** - * Returns information about a table or a result set - * - * @param object|string $result MDB2_result object from a query or a - * string containing the name of a table. - * While this also accepts a query result - * resource identifier, this behavior is - * deprecated. - * @param int $mode a valid tableInfo mode - * - * @return array an associative array with the information requested. - * A MDB2_Error object on failure. - * - * @see MDB2_Driver_Common::setOption() - */ - function tableInfo($result, $mode = null) - { - if (is_string($result)) { - return parent::tableInfo($result, $mode); - } - - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $resource = MDB2::isResultCommon($result) ? $result->getResource() : $result; - if (!is_resource($resource)) { - return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'Could not generate result resource', __FUNCTION__); - } - - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $case_func = 'strtolower'; - } else { - $case_func = 'strtoupper'; - } - } else { - $case_func = 'strval'; - } - - $count = @mysql_num_fields($resource); - $res = array(); - if ($mode) { - $res['num_fields'] = $count; - } - - $db->loadModule('Datatype', null, true); - for ($i = 0; $i < $count; $i++) { - $res[$i] = array( - 'table' => $case_func(@mysql_field_table($resource, $i)), - 'name' => $case_func(@mysql_field_name($resource, $i)), - 'type' => @mysql_field_type($resource, $i), - 'length' => @mysql_field_len($resource, $i), - 'flags' => @mysql_field_flags($resource, $i), - ); - if ($res[$i]['type'] == 'string') { - $res[$i]['type'] = 'char'; - } elseif ($res[$i]['type'] == 'unknown') { - $res[$i]['type'] = 'decimal'; - } - $mdb2type_info = $db->datatype->mapNativeDatatype($res[$i]); - if (MDB2::isError($mdb2type_info)) { - return $mdb2type_info; - } - $res[$i]['mdb2type'] = $mdb2type_info[0][0]; - if ($mode & MDB2_TABLEINFO_ORDER) { - $res['order'][$res[$i]['name']] = $i; - } - if ($mode & MDB2_TABLEINFO_ORDERTABLE) { - $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i; - } - } - - return $res; - } -} -?> diff --git a/data/module/MDB2/Driver/Reverse/pgsql.php b/data/module/MDB2/Driver/Reverse/pgsql.php deleted file mode 100644 index dd3596a67a8..00000000000 --- a/data/module/MDB2/Driver/Reverse/pgsql.php +++ /dev/null @@ -1,574 +0,0 @@ - | -// | Lorenzo Alberton | -// +----------------------------------------------------------------------+ -// -// $Id: pgsql.php 327310 2012-08-27 15:16:18Z danielc $ - -require_once 'MDB2/Driver/Reverse/Common.php'; - -/** - * MDB2 PostGreSQL driver for the schema reverse engineering module - * - * @package MDB2 - * @category Database - * @author Paul Cooper - * @author Lorenzo Alberton - */ -class MDB2_Driver_Reverse_pgsql extends MDB2_Driver_Reverse_Common -{ - // {{{ getTableFieldDefinition() - - /** - * Get the structure of a field into an array - * - * @param string $table_name name of table that should be used in method - * @param string $field_name name of field that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * @access public - */ - function getTableFieldDefinition($table_name, $field_name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $result = $db->loadModule('Datatype', null, true); - if (MDB2::isError($result)) { - return $result; - } - - list($schema, $table) = $this->splitTableSchema($table_name); - - $query = "SELECT a.attname AS name, - t.typname AS type, - CASE a.attlen - WHEN -1 THEN - CASE t.typname - WHEN 'numeric' THEN (a.atttypmod / 65536) - WHEN 'decimal' THEN (a.atttypmod / 65536) - WHEN 'money' THEN (a.atttypmod / 65536) - ELSE CASE a.atttypmod - WHEN -1 THEN NULL - ELSE a.atttypmod - 4 - END - END - ELSE a.attlen - END AS length, - CASE t.typname - WHEN 'numeric' THEN (a.atttypmod % 65536) - 4 - WHEN 'decimal' THEN (a.atttypmod % 65536) - 4 - WHEN 'money' THEN (a.atttypmod % 65536) - 4 - ELSE 0 - END AS scale, - a.attnotnull, - a.atttypmod, - a.atthasdef, - (SELECT substring(pg_get_expr(d.adbin, d.adrelid) for 128) - FROM pg_attrdef d - WHERE d.adrelid = a.attrelid - AND d.adnum = a.attnum - AND a.atthasdef - ) as default - FROM pg_attribute a, - pg_class c, - pg_type t - WHERE c.relname = ".$db->quote($table, 'text')." - AND a.atttypid = t.oid - AND c.oid = a.attrelid - AND NOT a.attisdropped - AND a.attnum > 0 - AND a.attname = ".$db->quote($field_name, 'text')." - ORDER BY a.attnum"; - $column = $db->queryRow($query, null, MDB2_FETCHMODE_ASSOC); - if (MDB2::isError($column)) { - return $column; - } - - if (empty($column)) { - return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'it was not specified an existing table column', __FUNCTION__); - } - - $column = array_change_key_case($column, CASE_LOWER); - $mapped_datatype = $db->datatype->mapNativeDatatype($column); - if (MDB2::isError($mapped_datatype)) { - return $mapped_datatype; - } - list($types, $length, $unsigned, $fixed) = $mapped_datatype; - $notnull = false; - if (!empty($column['attnotnull']) && $column['attnotnull'] == 't') { - $notnull = true; - } - $default = null; - if ($column['atthasdef'] === 't' - && strpos($column['default'], 'NULL') !== 0 - && !preg_match("/nextval\('([^']+)'/", $column['default']) - ) { - $pattern = '/^\'(.*)\'::[\w ]+$/i'; - $default = $column['default'];#substr($column['adsrc'], 1, -1); - if ((null === $default) && $notnull) { - $default = ''; - } elseif (!empty($default) && preg_match($pattern, $default)) { - //remove data type cast - $default = preg_replace ($pattern, '\\1', $default); - } - } - $autoincrement = false; - if (preg_match("/nextval\('([^']+)'/", $column['default'], $nextvals)) { - $autoincrement = true; - } - $definition[0] = array('notnull' => $notnull, 'nativetype' => $column['type']); - if (null !== $length) { - $definition[0]['length'] = $length; - } - if (null !== $unsigned) { - $definition[0]['unsigned'] = $unsigned; - } - if (null !== $fixed) { - $definition[0]['fixed'] = $fixed; - } - if ($default !== false) { - $definition[0]['default'] = $default; - } - if ($autoincrement !== false) { - $definition[0]['autoincrement'] = $autoincrement; - } - foreach ($types as $key => $type) { - $definition[$key] = $definition[0]; - if ($type == 'clob' || $type == 'blob') { - unset($definition[$key]['default']); - } - $definition[$key]['type'] = $type; - $definition[$key]['mdb2type'] = $type; - } - return $definition; - } - - // }}} - // {{{ getTableIndexDefinition() - - /** - * Get the structure of an index into an array - * - * @param string $table_name name of table that should be used in method - * @param string $index_name name of index that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * @access public - */ - function getTableIndexDefinition($table_name, $index_name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - list($schema, $table) = $this->splitTableSchema($table_name); - - $query = 'SELECT relname, indkey FROM pg_index, pg_class'; - $query.= ' WHERE pg_class.oid = pg_index.indexrelid'; - $query.= " AND indisunique != 't' AND indisprimary != 't'"; - $query.= ' AND pg_class.relname = %s'; - $index_name_mdb2 = $db->getIndexName($index_name); - $row = $db->queryRow(sprintf($query, $db->quote($index_name_mdb2, 'text')), null, MDB2_FETCHMODE_ASSOC); - if (MDB2::isError($row) || empty($row)) { - // fallback to the given $index_name, without transformation - $row = $db->queryRow(sprintf($query, $db->quote($index_name, 'text')), null, MDB2_FETCHMODE_ASSOC); - } - if (MDB2::isError($row)) { - return $row; - } - - if (empty($row)) { - return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'it was not specified an existing table index', __FUNCTION__); - } - - $row = array_change_key_case($row, CASE_LOWER); - - $db->loadModule('Manager', null, true); - $columns = $db->manager->listTableFields($table_name); - - $definition = array(); - - $index_column_numbers = explode(' ', $row['indkey']); - - $colpos = 1; - foreach ($index_column_numbers as $number) { - $definition['fields'][$columns[($number - 1)]] = array( - 'position' => $colpos++, - 'sorting' => 'ascending', - ); - } - return $definition; - } - - // }}} - // {{{ getTableConstraintDefinition() - - /** - * Get the structure of a constraint into an array - * - * @param string $table_name name of table that should be used in method - * @param string $constraint_name name of constraint that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * @access public - */ - function getTableConstraintDefinition($table_name, $constraint_name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - list($schema, $table) = $this->splitTableSchema($table_name); - - $query = "SELECT c.oid, - c.conname AS constraint_name, - CASE WHEN c.contype = 'c' THEN 1 ELSE 0 END AS \"check\", - CASE WHEN c.contype = 'f' THEN 1 ELSE 0 END AS \"foreign\", - CASE WHEN c.contype = 'p' THEN 1 ELSE 0 END AS \"primary\", - CASE WHEN c.contype = 'u' THEN 1 ELSE 0 END AS \"unique\", - CASE WHEN c.condeferrable = 'f' THEN 0 ELSE 1 END AS deferrable, - CASE WHEN c.condeferred = 'f' THEN 0 ELSE 1 END AS initiallydeferred, - --array_to_string(c.conkey, ' ') AS constraint_key, - t.relname AS table_name, - t2.relname AS references_table, - CASE confupdtype - WHEN 'a' THEN 'NO ACTION' - WHEN 'r' THEN 'RESTRICT' - WHEN 'c' THEN 'CASCADE' - WHEN 'n' THEN 'SET NULL' - WHEN 'd' THEN 'SET DEFAULT' - END AS onupdate, - CASE confdeltype - WHEN 'a' THEN 'NO ACTION' - WHEN 'r' THEN 'RESTRICT' - WHEN 'c' THEN 'CASCADE' - WHEN 'n' THEN 'SET NULL' - WHEN 'd' THEN 'SET DEFAULT' - END AS ondelete, - CASE confmatchtype - WHEN 'u' THEN 'UNSPECIFIED' - WHEN 'f' THEN 'FULL' - WHEN 'p' THEN 'PARTIAL' - END AS match, - --array_to_string(c.confkey, ' ') AS fk_constraint_key, - consrc - FROM pg_constraint c - LEFT JOIN pg_class t ON c.conrelid = t.oid - LEFT JOIN pg_class t2 ON c.confrelid = t2.oid - WHERE c.conname = %s - AND t.relname = " . $db->quote($table, 'text'); - $constraint_name_mdb2 = $db->getIndexName($constraint_name); - $row = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null, MDB2_FETCHMODE_ASSOC); - if (MDB2::isError($row) || empty($row)) { - // fallback to the given $index_name, without transformation - $constraint_name_mdb2 = $constraint_name; - $row = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null, MDB2_FETCHMODE_ASSOC); - } - if (MDB2::isError($row)) { - return $row; - } - $uniqueIndex = false; - if (empty($row)) { - // We might be looking for a UNIQUE index that was not created - // as a constraint but should be treated as such. - $query = 'SELECT relname AS constraint_name, - indkey, - 0 AS "check", - 0 AS "foreign", - 0 AS "primary", - 1 AS "unique", - 0 AS deferrable, - 0 AS initiallydeferred, - NULL AS references_table, - NULL AS onupdate, - NULL AS ondelete, - NULL AS match - FROM pg_index, pg_class - WHERE pg_class.oid = pg_index.indexrelid - AND indisunique = \'t\' - AND pg_class.relname = %s'; - $constraint_name_mdb2 = $db->getIndexName($constraint_name); - $row = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null, MDB2_FETCHMODE_ASSOC); - if (MDB2::isError($row) || empty($row)) { - // fallback to the given $index_name, without transformation - $constraint_name_mdb2 = $constraint_name; - $row = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null, MDB2_FETCHMODE_ASSOC); - } - if (MDB2::isError($row)) { - return $row; - } - if (empty($row)) { - return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - $constraint_name . ' is not an existing table constraint', __FUNCTION__); - } - $uniqueIndex = true; - } - - $row = array_change_key_case($row, CASE_LOWER); - - $definition = array( - 'primary' => (boolean)$row['primary'], - 'unique' => (boolean)$row['unique'], - 'foreign' => (boolean)$row['foreign'], - 'check' => (boolean)$row['check'], - 'fields' => array(), - 'references' => array( - 'table' => $row['references_table'], - 'fields' => array(), - ), - 'deferrable' => (boolean)$row['deferrable'], - 'initiallydeferred' => (boolean)$row['initiallydeferred'], - 'onupdate' => $row['onupdate'], - 'ondelete' => $row['ondelete'], - 'match' => $row['match'], - ); - - if ($uniqueIndex) { - $db->loadModule('Manager', null, true); - $columns = $db->manager->listTableFields($table_name); - $index_column_numbers = explode(' ', $row['indkey']); - $colpos = 1; - foreach ($index_column_numbers as $number) { - $definition['fields'][$columns[($number - 1)]] = array( - 'position' => $colpos++, - 'sorting' => 'ascending', - ); - } - return $definition; - } - - $query = 'SELECT a.attname - FROM pg_constraint c - LEFT JOIN pg_class t ON c.conrelid = t.oid - LEFT JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(c.conkey) - WHERE c.conname = %s - AND t.relname = ' . $db->quote($table, 'text'); - $fields = $db->queryCol(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null); - if (MDB2::isError($fields)) { - return $fields; - } - $colpos = 1; - foreach ($fields as $field) { - $definition['fields'][$field] = array( - 'position' => $colpos++, - 'sorting' => 'ascending', - ); - } - - if ($definition['foreign']) { - $query = 'SELECT a.attname - FROM pg_constraint c - LEFT JOIN pg_class t ON c.confrelid = t.oid - LEFT JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(c.confkey) - WHERE c.conname = %s - AND t.relname = ' . $db->quote($definition['references']['table'], 'text'); - $foreign_fields = $db->queryCol(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null); - if (MDB2::isError($foreign_fields)) { - return $foreign_fields; - } - $colpos = 1; - foreach ($foreign_fields as $foreign_field) { - $definition['references']['fields'][$foreign_field] = array( - 'position' => $colpos++, - ); - } - } - - if ($definition['check']) { - $check_def = $db->queryOne("SELECT pg_get_constraintdef(" . $row['oid'] . ", 't')"); - // ... - } - return $definition; - } - - // }}} - // {{{ getTriggerDefinition() - - /** - * Get the structure of a trigger into an array - * - * EXPERIMENTAL - * - * WARNING: this function is experimental and may change the returned value - * at any time until labelled as non-experimental - * - * @param string $trigger name of trigger that should be used in method - * @return mixed data array on success, a MDB2 error on failure - * @access public - * - * @TODO: add support for plsql functions and functions with args - */ - function getTriggerDefinition($trigger) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $query = "SELECT trg.tgname AS trigger_name, - tbl.relname AS table_name, - CASE - WHEN p.proname IS NOT NULL THEN 'EXECUTE PROCEDURE ' || p.proname || '();' - ELSE '' - END AS trigger_body, - CASE trg.tgtype & cast(2 as int2) - WHEN 0 THEN 'AFTER' - ELSE 'BEFORE' - END AS trigger_type, - CASE trg.tgtype & cast(28 as int2) - WHEN 16 THEN 'UPDATE' - WHEN 8 THEN 'DELETE' - WHEN 4 THEN 'INSERT' - WHEN 20 THEN 'INSERT, UPDATE' - WHEN 28 THEN 'INSERT, UPDATE, DELETE' - WHEN 24 THEN 'UPDATE, DELETE' - WHEN 12 THEN 'INSERT, DELETE' - END AS trigger_event, - CASE trg.tgenabled - WHEN 'O' THEN 't' - ELSE trg.tgenabled - END AS trigger_enabled, - obj_description(trg.oid, 'pg_trigger') AS trigger_comment - FROM pg_trigger trg, - pg_class tbl, - pg_proc p - WHERE trg.tgrelid = tbl.oid - AND trg.tgfoid = p.oid - AND trg.tgname = ". $db->quote($trigger, 'text'); - $types = array( - 'trigger_name' => 'text', - 'table_name' => 'text', - 'trigger_body' => 'text', - 'trigger_type' => 'text', - 'trigger_event' => 'text', - 'trigger_comment' => 'text', - 'trigger_enabled' => 'boolean', - ); - return $db->queryRow($query, $types, MDB2_FETCHMODE_ASSOC); - } - - // }}} - // {{{ tableInfo() - - /** - * Returns information about a table or a result set - * - * NOTE: only supports 'table' and 'flags' if $result - * is a table name. - * - * @param object|string $result MDB2_result object from a query or a - * string containing the name of a table. - * While this also accepts a query result - * resource identifier, this behavior is - * deprecated. - * @param int $mode a valid tableInfo mode - * - * @return array an associative array with the information requested. - * A MDB2_Error object on failure. - * - * @see MDB2_Driver_Common::tableInfo() - */ - function tableInfo($result, $mode = null) - { - if (is_string($result)) { - return parent::tableInfo($result, $mode); - } - - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $resource = MDB2::isResultCommon($result) ? $result->getResource() : $result; - if (!is_resource($resource)) { - return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'Could not generate result resource', __FUNCTION__); - } - - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $case_func = 'strtolower'; - } else { - $case_func = 'strtoupper'; - } - } else { - $case_func = 'strval'; - } - - $count = @pg_num_fields($resource); - $res = array(); - - if ($mode) { - $res['num_fields'] = $count; - } - - $db->loadModule('Datatype', null, true); - for ($i = 0; $i < $count; $i++) { - $res[$i] = array( - 'table' => function_exists('pg_field_table') ? @pg_field_table($resource, $i) : '', - 'name' => $case_func(@pg_field_name($resource, $i)), - 'type' => @pg_field_type($resource, $i), - 'length' => @pg_field_size($resource, $i), - 'flags' => '', - ); - $mdb2type_info = $db->datatype->mapNativeDatatype($res[$i]); - if (MDB2::isError($mdb2type_info)) { - return $mdb2type_info; - } - $res[$i]['mdb2type'] = $mdb2type_info[0][0]; - if ($mode & MDB2_TABLEINFO_ORDER) { - $res['order'][$res[$i]['name']] = $i; - } - if ($mode & MDB2_TABLEINFO_ORDERTABLE) { - $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i; - } - } - - return $res; - } -} -?> diff --git a/data/module/MDB2/Driver/mysql.php b/data/module/MDB2/Driver/mysql.php deleted file mode 100644 index 2dc51b12b52..00000000000 --- a/data/module/MDB2/Driver/mysql.php +++ /dev/null @@ -1,1729 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: mysql.php 327320 2012-08-27 15:52:50Z danielc $ -// - -/** - * MDB2 MySQL driver - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_mysql extends MDB2_Driver_Common -{ - // {{{ properties - - public $string_quoting = array( - 'start' => "'", - 'end' => "'", - 'escape' => '\\', - 'escape_pattern' => '\\', - ); - - public $identifier_quoting = array( - 'start' => '`', - 'end' => '`', - 'escape' => '`', - ); - - public $sql_comments = array( - array('start' => '-- ', 'end' => "\n", 'escape' => false), - array('start' => '#', 'end' => "\n", 'escape' => false), - array('start' => '/*', 'end' => '*/', 'escape' => false), - ); - - protected $server_capabilities_checked = false; - - protected $start_transaction = false; - - public $varchar_max_length = 255; - - // }}} - // {{{ constructor - - /** - * Constructor - */ - function __construct() - { - parent::__construct(); - - $this->phptype = 'mysql'; - $this->dbsyntax = 'mysql'; - - $this->supported['sequences'] = 'emulated'; - $this->supported['indexes'] = true; - $this->supported['affected_rows'] = true; - $this->supported['transactions'] = false; - $this->supported['savepoints'] = false; - $this->supported['summary_functions'] = true; - $this->supported['order_by_text'] = true; - $this->supported['current_id'] = 'emulated'; - $this->supported['limit_queries'] = true; - $this->supported['LOBs'] = true; - $this->supported['replace'] = true; - $this->supported['sub_selects'] = 'emulated'; - $this->supported['triggers'] = false; - $this->supported['auto_increment'] = true; - $this->supported['primary_key'] = true; - $this->supported['result_introspection'] = true; - $this->supported['prepared_statements'] = 'emulated'; - $this->supported['identifier_quoting'] = true; - $this->supported['pattern_escaping'] = true; - $this->supported['new_link'] = true; - - $this->options['DBA_username'] = false; - $this->options['DBA_password'] = false; - $this->options['default_table_type'] = ''; - $this->options['max_identifiers_length'] = 64; - - $this->_reCheckSupportedOptions(); - } - - // }}} - // {{{ _reCheckSupportedOptions() - - /** - * If the user changes certain options, other capabilities may depend - * on the new settings, so we need to check them (again). - * - * @access private - */ - function _reCheckSupportedOptions() - { - $this->supported['transactions'] = $this->options['use_transactions']; - $this->supported['savepoints'] = $this->options['use_transactions']; - if ($this->options['default_table_type']) { - switch (strtoupper($this->options['default_table_type'])) { - case 'BLACKHOLE': - case 'MEMORY': - case 'ARCHIVE': - case 'CSV': - case 'HEAP': - case 'ISAM': - case 'MERGE': - case 'MRG_ISAM': - case 'ISAM': - case 'MRG_MYISAM': - case 'MYISAM': - $this->supported['savepoints'] = false; - $this->supported['transactions'] = false; - $this->warnings[] = $this->options['default_table_type'] . - ' is not a supported default table type'; - break; - } - } - } - - // }}} - // {{{ function setOption($option, $value) - - /** - * set the option for the db class - * - * @param string option name - * @param mixed value for the option - * - * @return mixed MDB2_OK or MDB2 Error Object - * - * @access public - */ - function setOption($option, $value) - { - $res = parent::setOption($option, $value); - $this->_reCheckSupportedOptions(); - } - - // }}} - // {{{ errorInfo() - - /** - * This method is used to collect information about an error - * - * @param integer $error - * @return array - * @access public - */ - function errorInfo($error = null) - { - if ($this->connection) { - $native_code = @mysql_errno($this->connection); - $native_msg = @mysql_error($this->connection); - } else { - $native_code = @mysql_errno(); - $native_msg = @mysql_error(); - } - if (is_null($error)) { - static $ecode_map; - if (empty($ecode_map)) { - $ecode_map = array( - 1000 => MDB2_ERROR_INVALID, //hashchk - 1001 => MDB2_ERROR_INVALID, //isamchk - 1004 => MDB2_ERROR_CANNOT_CREATE, - 1005 => MDB2_ERROR_CANNOT_CREATE, - 1006 => MDB2_ERROR_CANNOT_CREATE, - 1007 => MDB2_ERROR_ALREADY_EXISTS, - 1008 => MDB2_ERROR_CANNOT_DROP, - 1009 => MDB2_ERROR_CANNOT_DROP, - 1010 => MDB2_ERROR_CANNOT_DROP, - 1011 => MDB2_ERROR_CANNOT_DELETE, - 1022 => MDB2_ERROR_ALREADY_EXISTS, - 1029 => MDB2_ERROR_NOT_FOUND, - 1032 => MDB2_ERROR_NOT_FOUND, - 1044 => MDB2_ERROR_ACCESS_VIOLATION, - 1045 => MDB2_ERROR_ACCESS_VIOLATION, - 1046 => MDB2_ERROR_NODBSELECTED, - 1048 => MDB2_ERROR_CONSTRAINT, - 1049 => MDB2_ERROR_NOSUCHDB, - 1050 => MDB2_ERROR_ALREADY_EXISTS, - 1051 => MDB2_ERROR_NOSUCHTABLE, - 1054 => MDB2_ERROR_NOSUCHFIELD, - 1060 => MDB2_ERROR_ALREADY_EXISTS, - 1061 => MDB2_ERROR_ALREADY_EXISTS, - 1062 => MDB2_ERROR_ALREADY_EXISTS, - 1064 => MDB2_ERROR_SYNTAX, - 1067 => MDB2_ERROR_INVALID, - 1072 => MDB2_ERROR_NOT_FOUND, - 1086 => MDB2_ERROR_ALREADY_EXISTS, - 1091 => MDB2_ERROR_NOT_FOUND, - 1100 => MDB2_ERROR_NOT_LOCKED, - 1109 => MDB2_ERROR_NOT_FOUND, - 1125 => MDB2_ERROR_ALREADY_EXISTS, - 1136 => MDB2_ERROR_VALUE_COUNT_ON_ROW, - 1138 => MDB2_ERROR_INVALID, - 1142 => MDB2_ERROR_ACCESS_VIOLATION, - 1143 => MDB2_ERROR_ACCESS_VIOLATION, - 1146 => MDB2_ERROR_NOSUCHTABLE, - 1149 => MDB2_ERROR_SYNTAX, - 1169 => MDB2_ERROR_CONSTRAINT, - 1176 => MDB2_ERROR_NOT_FOUND, - 1177 => MDB2_ERROR_NOSUCHTABLE, - 1213 => MDB2_ERROR_DEADLOCK, - 1216 => MDB2_ERROR_CONSTRAINT, - 1217 => MDB2_ERROR_CONSTRAINT, - 1227 => MDB2_ERROR_ACCESS_VIOLATION, - 1235 => MDB2_ERROR_CANNOT_CREATE, - 1299 => MDB2_ERROR_INVALID_DATE, - 1300 => MDB2_ERROR_INVALID, - 1304 => MDB2_ERROR_ALREADY_EXISTS, - 1305 => MDB2_ERROR_NOT_FOUND, - 1306 => MDB2_ERROR_CANNOT_DROP, - 1307 => MDB2_ERROR_CANNOT_CREATE, - 1334 => MDB2_ERROR_CANNOT_ALTER, - 1339 => MDB2_ERROR_NOT_FOUND, - 1356 => MDB2_ERROR_INVALID, - 1359 => MDB2_ERROR_ALREADY_EXISTS, - 1360 => MDB2_ERROR_NOT_FOUND, - 1363 => MDB2_ERROR_NOT_FOUND, - 1365 => MDB2_ERROR_DIVZERO, - 1451 => MDB2_ERROR_CONSTRAINT, - 1452 => MDB2_ERROR_CONSTRAINT, - 1542 => MDB2_ERROR_CANNOT_DROP, - 1546 => MDB2_ERROR_CONSTRAINT, - 1582 => MDB2_ERROR_CONSTRAINT, - 2003 => MDB2_ERROR_CONNECT_FAILED, - 2019 => MDB2_ERROR_INVALID, - ); - } - if ($this->options['portability'] & MDB2_PORTABILITY_ERRORS) { - $ecode_map[1022] = MDB2_ERROR_CONSTRAINT; - $ecode_map[1048] = MDB2_ERROR_CONSTRAINT_NOT_NULL; - $ecode_map[1062] = MDB2_ERROR_CONSTRAINT; - } else { - // Doing this in case mode changes during runtime. - $ecode_map[1022] = MDB2_ERROR_ALREADY_EXISTS; - $ecode_map[1048] = MDB2_ERROR_CONSTRAINT; - $ecode_map[1062] = MDB2_ERROR_ALREADY_EXISTS; - } - if (isset($ecode_map[$native_code])) { - $error = $ecode_map[$native_code]; - } - } - return array($error, $native_code, $native_msg); - } - - // }}} - // {{{ escape() - - /** - * Quotes a string so it can be safely used in a query. It will quote - * the text so it can safely be used within a query. - * - * @param string the input string to quote - * @param bool escape wildcards - * - * @return string quoted string - * - * @access public - */ - function escape($text, $escape_wildcards = false) - { - if ($escape_wildcards) { - $text = $this->escapePattern($text); - } - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - $text = @mysql_real_escape_string($text, $connection); - return $text; - } - - // }}} - // {{{ beginTransaction() - - /** - * Start a transaction or set a savepoint. - * - * @param string name of a savepoint to set - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function beginTransaction($savepoint = null) - { - $this->debug('Starting transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); - $this->_getServerCapabilities(); - if (!is_null($savepoint)) { - if (!$this->supports('savepoints')) { - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'savepoints are not supported', __FUNCTION__); - } - if (!$this->in_transaction) { - return $this->raiseError(MDB2_ERROR_INVALID, null, null, - 'savepoint cannot be released when changes are auto committed', __FUNCTION__); - } - $query = 'SAVEPOINT '.$savepoint; - return $this->_doQuery($query, true); - } elseif ($this->in_transaction) { - return MDB2_OK; //nothing to do - } - if (!$this->destructor_registered && $this->opened_persistent) { - $this->destructor_registered = true; - register_shutdown_function('MDB2_closeOpenTransactions'); - } - $query = $this->start_transaction ? 'START TRANSACTION' : 'SET AUTOCOMMIT = 0'; - $result = $this->_doQuery($query, true); - if (MDB2::isError($result)) { - return $result; - } - $this->in_transaction = true; - return MDB2_OK; - } - - // }}} - // {{{ commit() - - /** - * Commit the database changes done during a transaction that is in - * progress or release a savepoint. This function may only be called when - * auto-committing is disabled, otherwise it will fail. Therefore, a new - * transaction is implicitly started after committing the pending changes. - * - * @param string name of a savepoint to release - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function commit($savepoint = null) - { - $this->debug('Committing transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); - if (!$this->in_transaction) { - return $this->raiseError(MDB2_ERROR_INVALID, null, null, - 'commit/release savepoint cannot be done changes are auto committed', __FUNCTION__); - } - if (!is_null($savepoint)) { - if (!$this->supports('savepoints')) { - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'savepoints are not supported', __FUNCTION__); - } - $server_info = $this->getServerVersion(); - if (version_compare($server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch'], '5.0.3', '<')) { - return MDB2_OK; - } - $query = 'RELEASE SAVEPOINT '.$savepoint; - return $this->_doQuery($query, true); - } - - if (!$this->supports('transactions')) { - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'transactions are not supported', __FUNCTION__); - } - - $result = $this->_doQuery('COMMIT', true); - if (MDB2::isError($result)) { - return $result; - } - if (!$this->start_transaction) { - $query = 'SET AUTOCOMMIT = 1'; - $result = $this->_doQuery($query, true); - if (MDB2::isError($result)) { - return $result; - } - } - $this->in_transaction = false; - return MDB2_OK; - } - - // }}} - // {{{ rollback() - - /** - * Cancel any database changes done during a transaction or since a specific - * savepoint that is in progress. This function may only be called when - * auto-committing is disabled, otherwise it will fail. Therefore, a new - * transaction is implicitly started after canceling the pending changes. - * - * @param string name of a savepoint to rollback to - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function rollback($savepoint = null) - { - $this->debug('Rolling back transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); - if (!$this->in_transaction) { - return $this->raiseError(MDB2_ERROR_INVALID, null, null, - 'rollback cannot be done changes are auto committed', __FUNCTION__); - } - if (!is_null($savepoint)) { - if (!$this->supports('savepoints')) { - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'savepoints are not supported', __FUNCTION__); - } - $query = 'ROLLBACK TO SAVEPOINT '.$savepoint; - return $this->_doQuery($query, true); - } - - $query = 'ROLLBACK'; - $result = $this->_doQuery($query, true); - if (MDB2::isError($result)) { - return $result; - } - if (!$this->start_transaction) { - $query = 'SET AUTOCOMMIT = 1'; - $result = $this->_doQuery($query, true); - if (MDB2::isError($result)) { - return $result; - } - } - $this->in_transaction = false; - return MDB2_OK; - } - - // }}} - // {{{ function setTransactionIsolation() - - /** - * Set the transacton isolation level. - * - * @param string standard isolation level - * READ UNCOMMITTED (allows dirty reads) - * READ COMMITTED (prevents dirty reads) - * REPEATABLE READ (prevents nonrepeatable reads) - * SERIALIZABLE (prevents phantom reads) - * @param array some transaction options: - * 'wait' => 'WAIT' | 'NO WAIT' - * 'rw' => 'READ WRITE' | 'READ ONLY' - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - * @since 2.1.1 - */ - function setTransactionIsolation($isolation, $options = array()) - { - $this->debug('Setting transaction isolation level', __FUNCTION__, array('is_manip' => true)); - if (!$this->supports('transactions')) { - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'transactions are not supported', __FUNCTION__); - } - switch ($isolation) { - case 'READ UNCOMMITTED': - case 'READ COMMITTED': - case 'REPEATABLE READ': - case 'SERIALIZABLE': - break; - default: - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'isolation level is not supported: '.$isolation, __FUNCTION__); - } - - $query = "SET SESSION TRANSACTION ISOLATION LEVEL $isolation"; - return $this->_doQuery($query, true); - } - - // }}} - // {{{ _doConnect() - - /** - * do the grunt work of the connect - * - * @return connection on success or MDB2 Error Object on failure - * @access protected - */ - function _doConnect($username, $password, $persistent = false) - { - if (!extension_loaded($this->phptype)) { - return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'extension '.$this->phptype.' is not compiled into PHP', __FUNCTION__); - } - - $params = array(); - $unix = ($this->dsn['protocol'] && $this->dsn['protocol'] == 'unix'); - if (empty($this->dsn['hostspec'])) { - $this->dsn['hostspec'] = $unix ? '' : 'localhost'; - } - if ($this->dsn['hostspec']) { - $params[0] = $this->dsn['hostspec'] . ($this->dsn['port'] ? ':' . $this->dsn['port'] : ''); - } else { - $params[0] = ':' . $this->dsn['socket']; - } - $params[] = $username ? $username : null; - $params[] = $password ? $password : null; - if (!$persistent) { - if ($this->_isNewLinkSet()) { - $params[] = true; - } else { - $params[] = false; - } - } - if (version_compare(phpversion(), '4.3.0', '>=')) { - $params[] = isset($this->dsn['client_flags']) - ? $this->dsn['client_flags'] : null; - } - $connect_function = $persistent ? 'mysql_pconnect' : 'mysql_connect'; - - $connection = @call_user_func_array($connect_function, $params); - if (!$connection) { - if (($err = @mysql_error()) != '') { - return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, - $err, __FUNCTION__); - } else { - return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, - 'unable to establish a connection', __FUNCTION__); - } - } - - if (!empty($this->dsn['charset'])) { - $result = $this->setCharset($this->dsn['charset'], $connection); - if (MDB2::isError($result)) { - $this->disconnect(false); - return $result; - } - } - - return $connection; - } - - // }}} - // {{{ connect() - - /** - * Connect to the database - * - * @return MDB2_OK on success, MDB2 Error Object on failure - * @access public - */ - function connect() - { - if (is_resource($this->connection)) { - //if (count(array_diff($this->connected_dsn, $this->dsn)) == 0 - if (MDB2::areEquals($this->connected_dsn, $this->dsn) - && $this->opened_persistent == $this->options['persistent'] - ) { - return MDB2_OK; - } - $this->disconnect(false); - } - - $connection = $this->_doConnect( - $this->dsn['username'], - $this->dsn['password'], - $this->options['persistent'] - ); - if (MDB2::isError($connection)) { - return $connection; - } - - $this->connection = $connection; - $this->connected_dsn = $this->dsn; - $this->connected_database_name = ''; - $this->opened_persistent = $this->options['persistent']; - $this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype; - - if ($this->database_name) { - if ($this->database_name != $this->connected_database_name) { - if (!@mysql_select_db($this->database_name, $connection)) { - $err = $this->raiseError(null, null, null, - 'Could not select the database: '.$this->database_name, __FUNCTION__); - return $err; - } - $this->connected_database_name = $this->database_name; - } - } - - $this->_getServerCapabilities(); - - return MDB2_OK; - } - - // }}} - // {{{ setCharset() - - /** - * Set the charset on the current connection - * - * @param string charset (or array(charset, collation)) - * @param resource connection handle - * - * @return true on success, MDB2 Error Object on failure - */ - function setCharset($charset, $connection = null) - { - if (is_null($connection)) { - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - } - $collation = null; - if (is_array($charset) && 2 == count($charset)) { - $collation = array_pop($charset); - $charset = array_pop($charset); - } - $client_info = mysql_get_client_info(); - if (function_exists('mysql_set_charset') && version_compare($client_info, '5.0.6')) { - if (!$result = mysql_set_charset($charset, $connection)) { - $err = $this->raiseError(null, null, null, - 'Could not set client character set', __FUNCTION__); - return $err; - } - return $result; - } - $query = "SET NAMES '".mysql_real_escape_string($charset, $connection)."'"; - if (!is_null($collation)) { - $query .= " COLLATE '".mysql_real_escape_string($collation, $connection)."'"; - } - return $this->_doQuery($query, true, $connection); - } - - // }}} - // {{{ databaseExists() - - /** - * check if given database name is exists? - * - * @param string $name name of the database that should be checked - * - * @return mixed true/false on success, a MDB2 error on failure - * @access public - */ - function databaseExists($name) - { - $connection = $this->_doConnect($this->dsn['username'], - $this->dsn['password'], - $this->options['persistent']); - if (MDB2::isError($connection)) { - return $connection; - } - - $result = @mysql_select_db($name, $connection); - @mysql_close($connection); - - return $result; - } - - // }}} - // {{{ disconnect() - - /** - * Log out and disconnect from the database. - * - * @param boolean $force if the disconnect should be forced even if the - * connection is opened persistently - * @return mixed true on success, false if not connected and error - * object on error - * @access public - */ - function disconnect($force = true) - { - if (is_resource($this->connection)) { - if ($this->in_transaction) { - $dsn = $this->dsn; - $database_name = $this->database_name; - $persistent = $this->options['persistent']; - $this->dsn = $this->connected_dsn; - $this->database_name = $this->connected_database_name; - $this->options['persistent'] = $this->opened_persistent; - $this->rollback(); - $this->dsn = $dsn; - $this->database_name = $database_name; - $this->options['persistent'] = $persistent; - } - - if (!$this->opened_persistent || $force) { - $ok = @mysql_close($this->connection); - if (!$ok) { - return $this->raiseError(MDB2_ERROR_DISCONNECT_FAILED, - null, null, null, __FUNCTION__); - } - } - } else { - return false; - } - return parent::disconnect($force); - } - - // }}} - // {{{ standaloneQuery() - - /** - * execute a query as DBA - * - * @param string $query the SQL query - * @param mixed $types array that contains the types of the columns in - * the result set - * @param boolean $is_manip if the query is a manipulation query - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function standaloneQuery($query, $types = null, $is_manip = false) - { - $user = $this->options['DBA_username']? $this->options['DBA_username'] : $this->dsn['username']; - $pass = $this->options['DBA_password']? $this->options['DBA_password'] : $this->dsn['password']; - $connection = $this->_doConnect($user, $pass, $this->options['persistent']); - if (MDB2::isError($connection)) { - return $connection; - } - - $offset = $this->offset; - $limit = $this->limit; - $this->offset = $this->limit = 0; - $query = $this->_modifyQuery($query, $is_manip, $limit, $offset); - - $result = $this->_doQuery($query, $is_manip, $connection, $this->database_name); - if (!MDB2::isError($result)) { - $result = $this->_affectedRows($connection, $result); - } - - @mysql_close($connection); - return $result; - } - - // }}} - // {{{ _doQuery() - - /** - * Execute a query - * @param string $query query - * @param boolean $is_manip if the query is a manipulation query - * @param resource $connection - * @param string $database_name - * @return result or error object - * @access protected - */ - function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) - { - $this->last_query = $query; - $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre')); - if ($result) { - if (MDB2::isError($result)) { - return $result; - } - $query = $result; - } - if ($this->options['disable_query']) { - $result = $is_manip ? 0 : null; - return $result; - } - - if (is_null($connection)) { - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - } - if (is_null($database_name)) { - $database_name = $this->database_name; - } - - if ($database_name) { - if ($database_name != $this->connected_database_name) { - if (!@mysql_select_db($database_name, $connection)) { - $err = $this->raiseError(null, null, null, - 'Could not select the database: '.$database_name, __FUNCTION__); - return $err; - } - $this->connected_database_name = $database_name; - } - } - - $function = $this->options['result_buffering'] - ? 'mysql_query' : 'mysql_unbuffered_query'; - $result = @$function($query, $connection); - if (!$result && 0 !== mysql_errno($connection)) { - $err = $this->raiseError(null, null, null, - 'Could not execute statement', __FUNCTION__); - return $err; - } - - $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'post', 'result' => $result)); - return $result; - } - - // }}} - // {{{ _affectedRows() - - /** - * Returns the number of rows affected - * - * @param resource $result - * @param resource $connection - * @return mixed MDB2 Error Object or the number of rows affected - * @access private - */ - function _affectedRows($connection, $result = null) - { - if (is_null($connection)) { - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - } - return @mysql_affected_rows($connection); - } - - // }}} - // {{{ _modifyQuery() - - /** - * Changes a query string for various DBMS specific reasons - * - * @param string $query query to modify - * @param boolean $is_manip if it is a DML query - * @param integer $limit limit the number of rows - * @param integer $offset start reading from given offset - * @return string modified query - * @access protected - */ - function _modifyQuery($query, $is_manip, $limit, $offset) - { - if ($this->options['portability'] & MDB2_PORTABILITY_DELETE_COUNT) { - // "DELETE FROM table" gives 0 affected rows in MySQL. - // This little hack lets you know how many rows were deleted. - if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) { - $query = preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/', - 'DELETE FROM \1 WHERE 1=1', $query); - } - } - if ($limit > 0 - && !preg_match('/LIMIT\s*\d(?:\s*(?:,|OFFSET)\s*\d+)?(?:[^\)]*)?$/i', $query) - ) { - $query = rtrim($query); - if (substr($query, -1) == ';') { - $query = substr($query, 0, -1); - } - - // LIMIT doesn't always come last in the query - // @see http://dev.mysql.com/doc/refman/5.0/en/select.html - $after = ''; - if (preg_match('/(\s+INTO\s+(?:OUT|DUMP)FILE\s.*)$/ims', $query, $matches)) { - $after = $matches[0]; - $query = preg_replace('/(\s+INTO\s+(?:OUT|DUMP)FILE\s.*)$/ims', '', $query); - } elseif (preg_match('/(\s+FOR\s+UPDATE\s*)$/i', $query, $matches)) { - $after = $matches[0]; - $query = preg_replace('/(\s+FOR\s+UPDATE\s*)$/im', '', $query); - } elseif (preg_match('/(\s+LOCK\s+IN\s+SHARE\s+MODE\s*)$/im', $query, $matches)) { - $after = $matches[0]; - $query = preg_replace('/(\s+LOCK\s+IN\s+SHARE\s+MODE\s*)$/im', '', $query); - } - - if ($is_manip) { - return $query . " LIMIT $limit" . $after; - } else { - return $query . " LIMIT $offset, $limit" . $after; - } - } - return $query; - } - - // }}} - // {{{ getServerVersion() - - /** - * return version information about the server - * - * @param bool $native determines if the raw version string should be returned - * @return mixed array/string with version information or MDB2 error object - * @access public - */ - function getServerVersion($native = false) - { - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - if ($this->connected_server_info) { - $server_info = $this->connected_server_info; - } else { - $server_info = @mysql_get_server_info($connection); - } - if (!$server_info) { - return $this->raiseError(null, null, null, - 'Could not get server information', __FUNCTION__); - } - // cache server_info - $this->connected_server_info = $server_info; - if (!$native) { - $tmp = explode('.', $server_info, 3); - if (isset($tmp[2]) && strpos($tmp[2], '-')) { - $tmp2 = explode('-', @$tmp[2], 2); - } else { - $tmp2[0] = isset($tmp[2]) ? $tmp[2] : null; - $tmp2[1] = null; - } - $server_info = array( - 'major' => isset($tmp[0]) ? $tmp[0] : null, - 'minor' => isset($tmp[1]) ? $tmp[1] : null, - 'patch' => $tmp2[0], - 'extra' => $tmp2[1], - 'native' => $server_info, - ); - } - return $server_info; - } - - // }}} - // {{{ _getServerCapabilities() - - /** - * Fetch some information about the server capabilities - * (transactions, subselects, prepared statements, etc). - * - * @access private - */ - function _getServerCapabilities() - { - if (!$this->server_capabilities_checked) { - $this->server_capabilities_checked = true; - - //set defaults - $this->supported['sub_selects'] = 'emulated'; - $this->supported['prepared_statements'] = 'emulated'; - $this->supported['triggers'] = false; - $this->start_transaction = false; - $this->varchar_max_length = 255; - - $server_info = $this->getServerVersion(); - if (is_array($server_info)) { - $server_version = $server_info['major'].'.'.$server_info['minor'].'.'.$server_info['patch']; - - if (!version_compare($server_version, '4.1.0', '<')) { - $this->supported['sub_selects'] = true; - $this->supported['prepared_statements'] = true; - } - - // SAVEPOINTs were introduced in MySQL 4.0.14 and 4.1.1 (InnoDB) - if (version_compare($server_version, '4.1.0', '>=')) { - if (version_compare($server_version, '4.1.1', '<')) { - $this->supported['savepoints'] = false; - } - } elseif (version_compare($server_version, '4.0.14', '<')) { - $this->supported['savepoints'] = false; - } - - if (!version_compare($server_version, '4.0.11', '<')) { - $this->start_transaction = true; - } - - if (!version_compare($server_version, '5.0.3', '<')) { - $this->varchar_max_length = 65532; - } - - if (!version_compare($server_version, '5.0.2', '<')) { - $this->supported['triggers'] = true; - } - } - } - } - - // }}} - // {{{ function _skipUserDefinedVariable($query, $position) - - /** - * Utility method, used by prepare() to avoid misinterpreting MySQL user - * defined variables (SELECT @x:=5) for placeholders. - * Check if the placeholder is a false positive, i.e. if it is an user defined - * variable instead. If so, skip it and advance the position, otherwise - * return the current position, which is valid - * - * @param string $query - * @param integer $position current string cursor position - * @return integer $new_position - * @access protected - */ - function _skipUserDefinedVariable($query, $position) - { - $found = strpos(strrev(substr($query, 0, $position)), '@'); - if ($found === false) { - return $position; - } - $pos = strlen($query) - strlen(substr($query, $position)) - $found - 1; - $substring = substr($query, $pos, $position - $pos + 2); - if (preg_match('/^@\w+\s*:=$/', $substring)) { - return $position + 1; //found an user defined variable: skip it - } - return $position; - } - - // }}} - // {{{ prepare() - - /** - * Prepares a query for multiple execution with execute(). - * With some database backends, this is emulated. - * prepare() requires a generic query as string like - * 'INSERT INTO numbers VALUES(?,?)' or - * 'INSERT INTO numbers VALUES(:foo,:bar)'. - * The ? and :name and are placeholders which can be set using - * bindParam() and the query can be sent off using the execute() method. - * The allowed format for :name can be set with the 'bindname_format' option. - * - * @param string $query the query to prepare - * @param mixed $types array that contains the types of the placeholders - * @param mixed $result_types array that contains the types of the columns in - * the result set or MDB2_PREPARE_RESULT, if set to - * MDB2_PREPARE_MANIP the query is handled as a manipulation query - * @param mixed $lobs key (field) value (parameter) pair for all lob placeholders - * @return mixed resource handle for the prepared query on success, a MDB2 - * error on failure - * @access public - * @see bindParam, execute - */ - function prepare($query, $types = null, $result_types = null, $lobs = array()) - { - // connect to get server capabilities (http://pear.php.net/bugs/16147) - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - - if ($this->options['emulate_prepared'] - || $this->supported['prepared_statements'] !== true - ) { - return parent::prepare($query, $types, $result_types, $lobs); - } - $is_manip = ($result_types === MDB2_PREPARE_MANIP); - $offset = $this->offset; - $limit = $this->limit; - $this->offset = $this->limit = 0; - $query = $this->_modifyQuery($query, $is_manip, $limit, $offset); - $result = $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'pre')); - if ($result) { - if (MDB2::isError($result)) { - return $result; - } - $query = $result; - } - $placeholder_type_guess = $placeholder_type = null; - $question = '?'; - $colon = ':'; - $positions = array(); - $position = 0; - while ($position < strlen($query)) { - $q_position = strpos($query, $question, $position); - $c_position = strpos($query, $colon, $position); - if ($q_position && $c_position) { - $p_position = min($q_position, $c_position); - } elseif ($q_position) { - $p_position = $q_position; - } elseif ($c_position) { - $p_position = $c_position; - } else { - break; - } - if (is_null($placeholder_type)) { - $placeholder_type_guess = $query[$p_position]; - } - - $new_pos = $this->_skipDelimitedStrings($query, $position, $p_position); - if (MDB2::isError($new_pos)) { - return $new_pos; - } - if ($new_pos != $position) { - $position = $new_pos; - continue; //evaluate again starting from the new position - } - - //make sure this is not part of an user defined variable - $new_pos = $this->_skipUserDefinedVariable($query, $position); - if ($new_pos != $position) { - $position = $new_pos; - continue; //evaluate again starting from the new position - } - - if ($query[$position] == $placeholder_type_guess) { - if (is_null($placeholder_type)) { - $placeholder_type = $query[$p_position]; - $question = $colon = $placeholder_type; - } - if ($placeholder_type == ':') { - $regexp = '/^.{'.($position+1).'}('.$this->options['bindname_format'].').*$/s'; - $parameter = preg_replace($regexp, '\\1', $query); - if ($parameter === '') { - $err = $this->raiseError(MDB2_ERROR_SYNTAX, null, null, - 'named parameter name must match "bindname_format" option', __FUNCTION__); - return $err; - } - $positions[$p_position] = $parameter; - $query = substr_replace($query, '?', $position, strlen($parameter)+1); - } else { - $positions[$p_position] = count($positions); - } - $position = $p_position + 1; - } else { - $position = $p_position; - } - } - - static $prep_statement_counter = 1; - $statement_name = sprintf($this->options['statement_format'], $this->phptype, $prep_statement_counter++ . sha1(microtime() + mt_rand())); - $statement_name = substr(strtolower($statement_name), 0, $this->options['max_identifiers_length']); - $query = "PREPARE $statement_name FROM ".$this->quote($query, 'text'); - $statement = $this->_doQuery($query, true, $connection); - if (MDB2::isError($statement)) { - return $statement; - } - - $class_name = 'MDB2_Statement_'.$this->phptype; - $obj = new $class_name($this, $statement_name, $positions, $query, $types, $result_types, $is_manip, $limit, $offset); - $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'post', 'result' => $obj)); - return $obj; - } - - // }}} - // {{{ replace() - - /** - * Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT - * query, except that if there is already a row in the table with the same - * key field values, the old row is deleted before the new row is inserted. - * - * The REPLACE type of query does not make part of the SQL standards. Since - * practically only MySQL implements it natively, this type of query is - * emulated through this method for other DBMS using standard types of - * queries inside a transaction to assure the atomicity of the operation. - * - * @access public - * - * @param string $table name of the table on which the REPLACE query will - * be executed. - * @param array $fields associative array that describes the fields and the - * values that will be inserted or updated in the specified table. The - * indexes of the array are the names of all the fields of the table. The - * values of the array are also associative arrays that describe the - * values and other properties of the table fields. - * - * Here follows a list of field properties that need to be specified: - * - * value: - * Value to be assigned to the specified field. This value may be - * of specified in database independent type format as this - * function can perform the necessary datatype conversions. - * - * Default: - * this property is required unless the Null property - * is set to 1. - * - * type - * Name of the type of the field. Currently, all types Metabase - * are supported except for clob and blob. - * - * Default: no type conversion - * - * null - * Boolean property that indicates that the value for this field - * should be set to null. - * - * The default value for fields missing in INSERT queries may be - * specified the definition of a table. Often, the default value - * is already null, but since the REPLACE may be emulated using - * an UPDATE query, make sure that all fields of the table are - * listed in this function argument array. - * - * Default: 0 - * - * key - * Boolean property that indicates that this field should be - * handled as a primary key or at least as part of the compound - * unique index of the table that will determine the row that will - * updated if it exists or inserted a new row otherwise. - * - * This function will fail if no key field is specified or if the - * value of a key field is set to null because fields that are - * part of unique index they may not be null. - * - * Default: 0 - * - * @see http://dev.mysql.com/doc/refman/5.0/en/replace.html - * @return mixed MDB2_OK on success, a MDB2 error on failure - */ - function replace($table, $fields) - { - $count = count($fields); - $query = $values = ''; - $keys = $colnum = 0; - for (reset($fields); $colnum < $count; next($fields), $colnum++) { - $name = key($fields); - if ($colnum > 0) { - $query .= ','; - $values.= ','; - } - $query.= $this->quoteIdentifier($name, true); - if (isset($fields[$name]['null']) && $fields[$name]['null']) { - $value = 'NULL'; - } else { - $type = isset($fields[$name]['type']) ? $fields[$name]['type'] : null; - $value = $this->quote($fields[$name]['value'], $type); - if (MDB2::isError($value)) { - return $value; - } - } - $values.= $value; - if (isset($fields[$name]['key']) && $fields[$name]['key']) { - if ($value === 'NULL') { - return $this->raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null, - 'key value '.$name.' may not be NULL', __FUNCTION__); - } - $keys++; - } - } - if ($keys == 0) { - return $this->raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null, - 'not specified which fields are keys', __FUNCTION__); - } - - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - - $table = $this->quoteIdentifier($table, true); - $query = "REPLACE INTO $table ($query) VALUES ($values)"; - $result = $this->_doQuery($query, true, $connection); - if (MDB2::isError($result)) { - return $result; - } - return $this->_affectedRows($connection, $result); - } - - // }}} - // {{{ nextID() - - /** - * Returns the next free id of a sequence - * - * @param string $seq_name name of the sequence - * @param boolean $ondemand when true the sequence is - * automatic created, if it - * not exists - * - * @return mixed MDB2 Error Object or id - * @access public - */ - function nextID($seq_name, $ondemand = true) - { - $sequence_name = $this->quoteIdentifier($this->getSequenceName($seq_name), true); - $seqcol_name = $this->quoteIdentifier($this->options['seqcol_name'], true); - $query = "INSERT INTO $sequence_name ($seqcol_name) VALUES (NULL)"; - $this->pushErrorHandling(PEAR_ERROR_RETURN); - $this->expectError(MDB2_ERROR_NOSUCHTABLE); - $result = $this->_doQuery($query, true); - $this->popExpect(); - $this->popErrorHandling(); - if (MDB2::isError($result)) { - if ($ondemand && $result->getCode() == MDB2_ERROR_NOSUCHTABLE) { - $this->loadModule('Manager', null, true); - $result = $this->manager->createSequence($seq_name); - if (MDB2::isError($result)) { - return $this->raiseError($result, null, null, - 'on demand sequence '.$seq_name.' could not be created', __FUNCTION__); - } else { - return $this->nextID($seq_name, false); - } - } - return $result; - } - $value = $this->lastInsertID(); - if (is_numeric($value)) { - $query = "DELETE FROM $sequence_name WHERE $seqcol_name < $value"; - $result = $this->_doQuery($query, true); - if (MDB2::isError($result)) { - $this->warnings[] = 'nextID: could not delete previous sequence table values from '.$seq_name; - } - } - return $value; - } - - // }}} - // {{{ lastInsertID() - - /** - * Returns the autoincrement ID if supported or $id or fetches the current - * ID in a sequence called: $table.(empty($field) ? '' : '_'.$field) - * - * @param string $table name of the table into which a new row was inserted - * @param string $field name of the field into which a new row was inserted - * @return mixed MDB2 Error Object or id - * @access public - */ - function lastInsertID($table = null, $field = null) - { - // not using mysql_insert_id() due to http://pear.php.net/bugs/bug.php?id=8051 - // not casting to integer to handle BIGINT http://pear.php.net/bugs/bug.php?id=17650 - return $this->queryOne('SELECT LAST_INSERT_ID()'); - } - - // }}} - // {{{ currID() - - /** - * Returns the current id of a sequence - * - * @param string $seq_name name of the sequence - * @return mixed MDB2 Error Object or id - * @access public - */ - function currID($seq_name) - { - $sequence_name = $this->quoteIdentifier($this->getSequenceName($seq_name), true); - $seqcol_name = $this->quoteIdentifier($this->options['seqcol_name'], true); - $query = "SELECT MAX($seqcol_name) FROM $sequence_name"; - return $this->queryOne($query, 'integer'); - } -} - -/** - * MDB2 MySQL result driver - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Result_mysql extends MDB2_Result_Common -{ - // }}} - // {{{ fetchRow() - - /** - * Fetch a row and insert the data into an existing array. - * - * @param int $fetchmode how the array data should be indexed - * @param int $rownum number of the row where the data can be found - * @return int data array on success, a MDB2 error on failure - * @access public - */ - function fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) - { - if (!is_null($rownum)) { - $seek = $this->seek($rownum); - if (MDB2::isError($seek)) { - return $seek; - } - } - if ($fetchmode == MDB2_FETCHMODE_DEFAULT) { - $fetchmode = $this->db->fetchmode; - } - if ( $fetchmode == MDB2_FETCHMODE_ASSOC - || $fetchmode == MDB2_FETCHMODE_OBJECT - ) { - $row = @mysql_fetch_assoc($this->result); - if (is_array($row) - && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE - ) { - $row = array_change_key_case($row, $this->db->options['field_case']); - } - } else { - $row = @mysql_fetch_row($this->result); - } - - if (!$row) { - if ($this->result === false) { - $err = $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'resultset has already been freed', __FUNCTION__); - return $err; - } - return null; - } - $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; - $rtrim = false; - if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) { - if (empty($this->types)) { - $mode += MDB2_PORTABILITY_RTRIM; - } else { - $rtrim = true; - } - } - if ($mode) { - $this->db->_fixResultArrayValues($row, $mode); - } - if ( ( $fetchmode != MDB2_FETCHMODE_ASSOC - && $fetchmode != MDB2_FETCHMODE_OBJECT) - && !empty($this->types) - ) { - $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); - } elseif (($fetchmode == MDB2_FETCHMODE_ASSOC - || $fetchmode == MDB2_FETCHMODE_OBJECT) - && !empty($this->types_assoc) - ) { - $row = $this->db->datatype->convertResultRow($this->types_assoc, $row, $rtrim); - } - if (!empty($this->values)) { - $this->_assignBindColumns($row); - } - if ($fetchmode === MDB2_FETCHMODE_OBJECT) { - $object_class = $this->db->options['fetch_class']; - if ($object_class == 'stdClass') { - $row = (object) $row; - } else { - $rowObj = new $object_class($row); - $row = $rowObj; - } - } - ++$this->rownum; - return $row; - } - - // }}} - // {{{ _getColumnNames() - - /** - * Retrieve the names of columns returned by the DBMS in a query result. - * - * @return mixed Array variable that holds the names of columns as keys - * or an MDB2 error on failure. - * Some DBMS may not return any columns when the result set - * does not contain any rows. - * @access private - */ - function _getColumnNames() - { - $columns = array(); - $numcols = $this->numCols(); - if (MDB2::isError($numcols)) { - return $numcols; - } - for ($column = 0; $column < $numcols; $column++) { - $column_name = @mysql_field_name($this->result, $column); - $columns[$column_name] = $column; - } - if ($this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $columns = array_change_key_case($columns, $this->db->options['field_case']); - } - return $columns; - } - - // }}} - // {{{ numCols() - - /** - * Count the number of columns returned by the DBMS in a query result. - * - * @return mixed integer value with the number of columns, a MDB2 error - * on failure - * @access public - */ - function numCols() - { - $cols = @mysql_num_fields($this->result); - if (is_null($cols)) { - if ($this->result === false) { - return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'resultset has already been freed', __FUNCTION__); - } elseif (is_null($this->result)) { - return count($this->types); - } - return $this->db->raiseError(null, null, null, - 'Could not get column count', __FUNCTION__); - } - return $cols; - } - - // }}} - // {{{ free() - - /** - * Free the internal resources associated with result. - * - * @return boolean true on success, false if result is invalid - * @access public - */ - function free() - { - if (is_resource($this->result) && $this->db->connection) { - $free = @mysql_free_result($this->result); - if ($free === false) { - return $this->db->raiseError(null, null, null, - 'Could not free result', __FUNCTION__); - } - } - $this->result = false; - return MDB2_OK; - } -} - -/** - * MDB2 MySQL buffered result driver - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_BufferedResult_mysql extends MDB2_Result_mysql -{ - // }}} - // {{{ seek() - - /** - * Seek to a specific row in a result set - * - * @param int $rownum number of the row where the data can be found - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function seek($rownum = 0) - { - if ($this->rownum != ($rownum - 1) && !@mysql_data_seek($this->result, $rownum)) { - if ($this->result === false) { - return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'resultset has already been freed', __FUNCTION__); - } elseif (is_null($this->result)) { - return MDB2_OK; - } - return $this->db->raiseError(MDB2_ERROR_INVALID, null, null, - 'tried to seek to an invalid row number ('.$rownum.')', __FUNCTION__); - } - $this->rownum = $rownum - 1; - return MDB2_OK; - } - - // }}} - // {{{ valid() - - /** - * Check if the end of the result set has been reached - * - * @return mixed true or false on sucess, a MDB2 error on failure - * @access public - */ - function valid() - { - $numrows = $this->numRows(); - if (MDB2::isError($numrows)) { - return $numrows; - } - return $this->rownum < ($numrows - 1); - } - - // }}} - // {{{ numRows() - - /** - * Returns the number of rows in a result object - * - * @return mixed MDB2 Error Object or the number of rows - * @access public - */ - function numRows() - { - $rows = @mysql_num_rows($this->result); - if (false === $rows) { - if (false === $this->result) { - return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'resultset has already been freed', __FUNCTION__); - } elseif (is_null($this->result)) { - return 0; - } - return $this->db->raiseError(null, null, null, - 'Could not get row count', __FUNCTION__); - } - return $rows; - } - - // }}} -} - -/** - * MDB2 MySQL statement driver - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Statement_mysql extends MDB2_Statement_Common -{ - // {{{ _execute() - - /** - * Execute a prepared query statement helper method. - * - * @param mixed $result_class string which specifies which result class to use - * @param mixed $result_wrap_class string which specifies which class to wrap results in - * - * @return mixed MDB2_Result or integer (affected rows) on success, - * a MDB2 error on failure - * @access private - */ - function _execute($result_class = true, $result_wrap_class = true) - { - if (is_null($this->statement)) { - $result = parent::_execute($result_class, $result_wrap_class); - return $result; - } - $this->db->last_query = $this->query; - $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'pre', 'parameters' => $this->values)); - if ($this->db->getOption('disable_query')) { - $result = $this->is_manip ? 0 : null; - return $result; - } - - $connection = $this->db->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - - $query = 'EXECUTE '.$this->statement; - if (!empty($this->positions)) { - $parameters = array(); - foreach ($this->positions as $parameter) { - if (!array_key_exists($parameter, $this->values)) { - return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__); - } - $close = false; - $value = $this->values[$parameter]; - $type = array_key_exists($parameter, $this->types) ? $this->types[$parameter] : null; - if (is_resource($value) || $type == 'clob' || $type == 'blob' && $this->db->options['lob_allow_url_include']) { - if (!is_resource($value) && preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) { - if ($match[1] == 'file://') { - $value = $match[2]; - } - $value = @fopen($value, 'r'); - $close = true; - } - if (is_resource($value)) { - $data = ''; - while (!@feof($value)) { - $data.= @fread($value, $this->db->options['lob_buffer_length']); - } - if ($close) { - @fclose($value); - } - $value = $data; - } - } - $quoted = $this->db->quote($value, $type); - if (MDB2::isError($quoted)) { - return $quoted; - } - $param_query = 'SET @'.$parameter.' = '.$quoted; - $result = $this->db->_doQuery($param_query, true, $connection); - if (MDB2::isError($result)) { - return $result; - } - } - $query.= ' USING @'.implode(', @', array_values($this->positions)); - } - - $result = $this->db->_doQuery($query, $this->is_manip, $connection); - if (MDB2::isError($result)) { - return $result; - } - - if ($this->is_manip) { - $affected_rows = $this->db->_affectedRows($connection, $result); - return $affected_rows; - } - - $result = $this->db->_wrapResult($result, $this->result_types, - $result_class, $result_wrap_class, $this->limit, $this->offset); - $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'post', 'result' => $result)); - return $result; - } - - // }}} - // {{{ free() - - /** - * Release resources allocated for the specified prepared query. - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function free() - { - if (is_null($this->positions)) { - return $this->db->raiseError(MDB2_ERROR, null, null, - 'Prepared statement has already been freed', __FUNCTION__); - } - $result = MDB2_OK; - - if (!is_null($this->statement)) { - $connection = $this->db->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - $query = 'DEALLOCATE PREPARE '.$this->statement; - $result = $this->db->_doQuery($query, true, $connection); - } - - parent::free(); - return $result; - } -} -?> diff --git a/data/module/MDB2/Driver/pgsql.php b/data/module/MDB2/Driver/pgsql.php deleted file mode 100644 index 87b65c369ae..00000000000 --- a/data/module/MDB2/Driver/pgsql.php +++ /dev/null @@ -1,1583 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: pgsql.php 327317 2012-08-27 15:17:08Z danielc $ - -/** - * MDB2 PostGreSQL driver - * - * @package MDB2 - * @category Database - * @author Paul Cooper - */ -class MDB2_Driver_pgsql extends MDB2_Driver_Common -{ - // {{{ properties - var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => '\\'); - - var $identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"'); - // }}} - // {{{ constructor - - /** - * Constructor - */ - function __construct() - { - parent::__construct(); - - $this->phptype = 'pgsql'; - $this->dbsyntax = 'pgsql'; - - $this->supported['sequences'] = true; - $this->supported['indexes'] = true; - $this->supported['affected_rows'] = true; - $this->supported['summary_functions'] = true; - $this->supported['order_by_text'] = true; - $this->supported['transactions'] = true; - $this->supported['savepoints'] = true; - $this->supported['current_id'] = true; - $this->supported['limit_queries'] = true; - $this->supported['LOBs'] = true; - $this->supported['replace'] = 'emulated'; - $this->supported['sub_selects'] = true; - $this->supported['triggers'] = true; - $this->supported['auto_increment'] = 'emulated'; - $this->supported['primary_key'] = true; - $this->supported['result_introspection'] = true; - $this->supported['prepared_statements'] = true; - $this->supported['identifier_quoting'] = true; - $this->supported['pattern_escaping'] = true; - $this->supported['new_link'] = true; - - $this->options['DBA_username'] = false; - $this->options['DBA_password'] = false; - $this->options['multi_query'] = false; - $this->options['disable_smart_seqname'] = true; - $this->options['max_identifiers_length'] = 63; - } - - // }}} - // {{{ errorInfo() - - /** - * This method is used to collect information about an error - * - * @param integer $error - * @return array - * @access public - */ - function errorInfo($error = null) - { - // Fall back to MDB2_ERROR if there was no mapping. - $error_code = MDB2_ERROR; - - $native_msg = ''; - if (is_resource($error)) { - $native_msg = @pg_result_error($error); - } elseif ($this->connection) { - $native_msg = @pg_last_error($this->connection); - if (!$native_msg && @pg_connection_status($this->connection) === PGSQL_CONNECTION_BAD) { - $native_msg = 'Database connection has been lost.'; - $error_code = MDB2_ERROR_CONNECT_FAILED; - } - } else { - $native_msg = @pg_last_error(); - } - - static $error_regexps; - if (empty($error_regexps)) { - $error_regexps = array( - '/column .* (of relation .*)?does not exist/i' - => MDB2_ERROR_NOSUCHFIELD, - '/(relation|sequence|table).*does not exist|class .* not found/i' - => MDB2_ERROR_NOSUCHTABLE, - '/database .* does not exist/' - => MDB2_ERROR_NOT_FOUND, - '/constraint .* does not exist/' - => MDB2_ERROR_NOT_FOUND, - '/index .* does not exist/' - => MDB2_ERROR_NOT_FOUND, - '/database .* already exists/i' - => MDB2_ERROR_ALREADY_EXISTS, - '/relation .* already exists/i' - => MDB2_ERROR_ALREADY_EXISTS, - '/(divide|division) by zero$/i' - => MDB2_ERROR_DIVZERO, - '/pg_atoi: error in .*: can\'t parse /i' - => MDB2_ERROR_INVALID_NUMBER, - '/invalid input syntax for( type)? (integer|numeric)/i' - => MDB2_ERROR_INVALID_NUMBER, - '/value .* is out of range for type \w*int/i' - => MDB2_ERROR_INVALID_NUMBER, - '/integer out of range/i' - => MDB2_ERROR_INVALID_NUMBER, - '/value too long for type character/i' - => MDB2_ERROR_INVALID, - '/attribute .* not found|relation .* does not have attribute/i' - => MDB2_ERROR_NOSUCHFIELD, - '/column .* specified in USING clause does not exist in (left|right) table/i' - => MDB2_ERROR_NOSUCHFIELD, - '/parser: parse error at or near/i' - => MDB2_ERROR_SYNTAX, - '/syntax error at/' - => MDB2_ERROR_SYNTAX, - '/column reference .* is ambiguous/i' - => MDB2_ERROR_SYNTAX, - '/permission denied/' - => MDB2_ERROR_ACCESS_VIOLATION, - '/violates not-null constraint/' - => MDB2_ERROR_CONSTRAINT_NOT_NULL, - '/violates [\w ]+ constraint/' - => MDB2_ERROR_CONSTRAINT, - '/referential integrity violation/' - => MDB2_ERROR_CONSTRAINT, - '/more expressions than target columns/i' - => MDB2_ERROR_VALUE_COUNT_ON_ROW, - ); - } - if (is_numeric($error) && $error < 0) { - $error_code = $error; - } else { - foreach ($error_regexps as $regexp => $code) { - if (preg_match($regexp, $native_msg)) { - $error_code = $code; - break; - } - } - } - return array($error_code, null, $native_msg); - } - - // }}} - // {{{ escape() - - /** - * Quotes a string so it can be safely used in a query. It will quote - * the text so it can safely be used within a query. - * - * @param string the input string to quote - * @param bool escape wildcards - * - * @return string quoted string - * - * @access public - */ - function escape($text, $escape_wildcards = false) - { - if ($escape_wildcards) { - $text = $this->escapePattern($text); - } - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - if (is_resource($connection) && version_compare(PHP_VERSION, '5.2.0RC5', '>=')) { - $text = @pg_escape_string($connection, $text); - } else { - $text = @pg_escape_string($text); - } - return $text; - } - - // }}} - // {{{ beginTransaction() - - /** - * Start a transaction or set a savepoint. - * - * @param string name of a savepoint to set - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function beginTransaction($savepoint = null) - { - $this->debug('Starting transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); - if (null !== $savepoint) { - if (!$this->in_transaction) { - return $this->raiseError(MDB2_ERROR_INVALID, null, null, - 'savepoint cannot be released when changes are auto committed', __FUNCTION__); - } - $query = 'SAVEPOINT '.$savepoint; - return $this->_doQuery($query, true); - } - if ($this->in_transaction) { - return MDB2_OK; //nothing to do - } - if (!$this->destructor_registered && $this->opened_persistent) { - $this->destructor_registered = true; - register_shutdown_function('MDB2_closeOpenTransactions'); - } - $result = $this->_doQuery('BEGIN', true); - if (MDB2::isError($result)) { - return $result; - } - $this->in_transaction = true; - return MDB2_OK; - } - - // }}} - // {{{ commit() - - /** - * Commit the database changes done during a transaction that is in - * progress or release a savepoint. This function may only be called when - * auto-committing is disabled, otherwise it will fail. Therefore, a new - * transaction is implicitly started after committing the pending changes. - * - * @param string name of a savepoint to release - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function commit($savepoint = null) - { - $this->debug('Committing transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); - if (!$this->in_transaction) { - return $this->raiseError(MDB2_ERROR_INVALID, null, null, - 'commit/release savepoint cannot be done changes are auto committed', __FUNCTION__); - } - if (null !== $savepoint) { - $query = 'RELEASE SAVEPOINT '.$savepoint; - return $this->_doQuery($query, true); - } - - $result = $this->_doQuery('COMMIT', true); - if (MDB2::isError($result)) { - return $result; - } - $this->in_transaction = false; - return MDB2_OK; - } - - // }}} - // {{{ rollback() - - /** - * Cancel any database changes done during a transaction or since a specific - * savepoint that is in progress. This function may only be called when - * auto-committing is disabled, otherwise it will fail. Therefore, a new - * transaction is implicitly started after canceling the pending changes. - * - * @param string name of a savepoint to rollback to - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - */ - function rollback($savepoint = null) - { - $this->debug('Rolling back transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); - if (!$this->in_transaction) { - return $this->raiseError(MDB2_ERROR_INVALID, null, null, - 'rollback cannot be done changes are auto committed', __FUNCTION__); - } - if (null !== $savepoint) { - $query = 'ROLLBACK TO SAVEPOINT '.$savepoint; - return $this->_doQuery($query, true); - } - - $query = 'ROLLBACK'; - $result = $this->_doQuery($query, true); - if (MDB2::isError($result)) { - return $result; - } - $this->in_transaction = false; - return MDB2_OK; - } - - // }}} - // {{{ function setTransactionIsolation() - - /** - * Set the transacton isolation level. - * - * @param string standard isolation level - * READ UNCOMMITTED (allows dirty reads) - * READ COMMITTED (prevents dirty reads) - * REPEATABLE READ (prevents nonrepeatable reads) - * SERIALIZABLE (prevents phantom reads) - * @param array some transaction options: - * 'wait' => 'WAIT' | 'NO WAIT' - * 'rw' => 'READ WRITE' | 'READ ONLY' - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * - * @access public - * @since 2.1.1 - */ - function setTransactionIsolation($isolation, $options = array()) - { - $this->debug('Setting transaction isolation level', __FUNCTION__, array('is_manip' => true)); - switch ($isolation) { - case 'READ UNCOMMITTED': - case 'READ COMMITTED': - case 'REPEATABLE READ': - case 'SERIALIZABLE': - break; - default: - return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'isolation level is not supported: '.$isolation, __FUNCTION__); - } - - $query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL $isolation"; - return $this->_doQuery($query, true); - } - - // }}} - // {{{ _doConnect() - - /** - * Do the grunt work of connecting to the database - * - * @return mixed connection resource on success, MDB2 Error Object on failure - * @access protected - */ - function _doConnect($username, $password, $database_name, $persistent = false) - { - if (!extension_loaded($this->phptype)) { - return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'extension '.$this->phptype.' is not compiled into PHP', __FUNCTION__); - } - - if ($database_name == '') { - $database_name = 'template1'; - } - - $protocol = $this->dsn['protocol'] ? $this->dsn['protocol'] : 'tcp'; - - $params = array(''); - if ($protocol == 'tcp') { - if ($this->dsn['hostspec']) { - $params[0].= 'host=' . $this->dsn['hostspec']; - } - if ($this->dsn['port']) { - $params[0].= ' port=' . $this->dsn['port']; - } - } elseif ($protocol == 'unix') { - // Allow for pg socket in non-standard locations. - if ($this->dsn['socket']) { - $params[0].= 'host=' . $this->dsn['socket']; - } - if ($this->dsn['port']) { - $params[0].= ' port=' . $this->dsn['port']; - } - } - if ($database_name) { - $params[0].= ' dbname=\'' . addslashes($database_name) . '\''; - } - if ($username) { - $params[0].= ' user=\'' . addslashes($username) . '\''; - } - if ($password) { - $params[0].= ' password=\'' . addslashes($password) . '\''; - } - if (!empty($this->dsn['options'])) { - $params[0].= ' options=' . $this->dsn['options']; - } - if (!empty($this->dsn['tty'])) { - $params[0].= ' tty=' . $this->dsn['tty']; - } - if (!empty($this->dsn['connect_timeout'])) { - $params[0].= ' connect_timeout=' . $this->dsn['connect_timeout']; - } - if (!empty($this->dsn['sslmode'])) { - $params[0].= ' sslmode=' . $this->dsn['sslmode']; - } - if (!empty($this->dsn['service'])) { - $params[0].= ' service=' . $this->dsn['service']; - } - - if ($this->_isNewLinkSet()) { - if (version_compare(phpversion(), '4.3.0', '>=')) { - $params[] = PGSQL_CONNECT_FORCE_NEW; - } - } - - $connect_function = $persistent ? 'pg_pconnect' : 'pg_connect'; - $connection = @call_user_func_array($connect_function, $params); - if (!$connection) { - return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, - 'unable to establish a connection', __FUNCTION__); - } - - if (empty($this->dsn['disable_iso_date'])) { - if (!@pg_query($connection, "SET SESSION DATESTYLE = 'ISO'")) { - return $this->raiseError(null, null, null, - 'Unable to set date style to iso', __FUNCTION__); - } - } - - if (!empty($this->dsn['charset'])) { - $result = $this->setCharset($this->dsn['charset'], $connection); - if (MDB2::isError($result)) { - return $result; - } - } - - // Enable extra compatibility settings on 8.2 and later - if (function_exists('pg_parameter_status')) { - $version = pg_parameter_status($connection, 'server_version'); - if ($version == false) { - return $this->raiseError(null, null, null, - 'Unable to retrieve server version', __FUNCTION__); - } - $version = explode ('.', $version); - if ( $version['0'] > 8 - || ($version['0'] == 8 && $version['1'] >= 2) - ) { - if (!@pg_query($connection, "SET SESSION STANDARD_CONFORMING_STRINGS = OFF")) { - return $this->raiseError(null, null, null, - 'Unable to set standard_conforming_strings to off', __FUNCTION__); - } - - if (!@pg_query($connection, "SET SESSION ESCAPE_STRING_WARNING = OFF")) { - return $this->raiseError(null, null, null, - 'Unable to set escape_string_warning to off', __FUNCTION__); - } - } - } - - return $connection; - } - - // }}} - // {{{ connect() - - /** - * Connect to the database - * - * @return true on success, MDB2 Error Object on failure - * @access public - */ - function connect() - { - if (is_resource($this->connection)) { - //if (count(array_diff($this->connected_dsn, $this->dsn)) == 0 - if (MDB2::areEquals($this->connected_dsn, $this->dsn) - && $this->connected_database_name == $this->database_name - && ($this->opened_persistent == $this->options['persistent']) - ) { - return MDB2_OK; - } - $this->disconnect(false); - } - - if ($this->database_name) { - $connection = $this->_doConnect($this->dsn['username'], - $this->dsn['password'], - $this->database_name, - $this->options['persistent']); - if (MDB2::isError($connection)) { - return $connection; - } - - $this->connection = $connection; - $this->connected_dsn = $this->dsn; - $this->connected_database_name = $this->database_name; - $this->opened_persistent = $this->options['persistent']; - $this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype; - } - - return MDB2_OK; - } - - // }}} - // {{{ setCharset() - - /** - * Set the charset on the current connection - * - * @param string charset - * @param resource connection handle - * - * @return true on success, MDB2 Error Object on failure - */ - function setCharset($charset, $connection = null) - { - if (null === $connection) { - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - } - if (is_array($charset)) { - $charset = array_shift($charset); - $this->warnings[] = 'postgresql does not support setting client collation'; - } - $result = @pg_set_client_encoding($connection, $charset); - if ($result == -1) { - return $this->raiseError(null, null, null, - 'Unable to set client charset: '.$charset, __FUNCTION__); - } - return MDB2_OK; - } - - // }}} - // {{{ databaseExists() - - /** - * check if given database name is exists? - * - * @param string $name name of the database that should be checked - * - * @return mixed true/false on success, a MDB2 error on failure - * @access public - */ - function databaseExists($name) - { - $res = $this->_doConnect($this->dsn['username'], - $this->dsn['password'], - $this->escape($name), - $this->options['persistent']); - if (!MDB2::isError($res)) { - return true; - } - - return false; - } - - // }}} - // {{{ disconnect() - - /** - * Log out and disconnect from the database. - * - * @param boolean $force if the disconnect should be forced even if the - * connection is opened persistently - * @return mixed true on success, false if not connected and error - * object on error - * @access public - */ - function disconnect($force = true) - { - if (is_resource($this->connection)) { - if ($this->in_transaction) { - $dsn = $this->dsn; - $database_name = $this->database_name; - $persistent = $this->options['persistent']; - $this->dsn = $this->connected_dsn; - $this->database_name = $this->connected_database_name; - $this->options['persistent'] = $this->opened_persistent; - $this->rollback(); - $this->dsn = $dsn; - $this->database_name = $database_name; - $this->options['persistent'] = $persistent; - } - - if (!$this->opened_persistent || $force) { - $ok = @pg_close($this->connection); - if (!$ok) { - return $this->raiseError(MDB2_ERROR_DISCONNECT_FAILED, - null, null, null, __FUNCTION__); - } - } - } else { - return false; - } - return parent::disconnect($force); - } - - // }}} - // {{{ standaloneQuery() - - /** - * execute a query as DBA - * - * @param string $query the SQL query - * @param mixed $types array that contains the types of the columns in - * the result set - * @param boolean $is_manip if the query is a manipulation query - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function standaloneQuery($query, $types = null, $is_manip = false) - { - $user = $this->options['DBA_username']? $this->options['DBA_username'] : $this->dsn['username']; - $pass = $this->options['DBA_password']? $this->options['DBA_password'] : $this->dsn['password']; - $connection = $this->_doConnect($user, $pass, $this->database_name, $this->options['persistent']); - if (MDB2::isError($connection)) { - return $connection; - } - - $offset = $this->offset; - $limit = $this->limit; - $this->offset = $this->limit = 0; - $query = $this->_modifyQuery($query, $is_manip, $limit, $offset); - - $result = $this->_doQuery($query, $is_manip, $connection, $this->database_name); - if (!MDB2::isError($result)) { - if ($is_manip) { - $result = $this->_affectedRows($connection, $result); - } else { - $result = $this->_wrapResult($result, $types, true, true, $limit, $offset); - } - } - - @pg_close($connection); - return $result; - } - - // }}} - // {{{ _doQuery() - - /** - * Execute a query - * @param string $query query - * @param boolean $is_manip if the query is a manipulation query - * @param resource $connection - * @param string $database_name - * @return result or error object - * @access protected - */ - function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) - { - $this->last_query = $query; - $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre')); - if ($result) { - if (MDB2::isError($result)) { - return $result; - } - $query = $result; - } - if ($this->options['disable_query']) { - $result = $is_manip ? 0 : null; - return $result; - } - - if (null === $connection) { - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - } - - $function = $this->options['multi_query'] ? 'pg_send_query' : 'pg_query'; - $result = @$function($connection, $query); - if (!$result) { - $err = $this->raiseError(null, null, null, - 'Could not execute statement', __FUNCTION__); - return $err; - } elseif ($this->options['multi_query']) { - if (!($result = @pg_get_result($connection))) { - $err = $this->raiseError(null, null, null, - 'Could not get the first result from a multi query', __FUNCTION__); - return $err; - } - } - - $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'post', 'result' => $result)); - return $result; - } - - // }}} - // {{{ _affectedRows() - - /** - * Returns the number of rows affected - * - * @param resource $result - * @param resource $connection - * @return mixed MDB2 Error Object or the number of rows affected - * @access private - */ - function _affectedRows($connection, $result = null) - { - if (null === $connection) { - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - } - return @pg_affected_rows($result); - } - - // }}} - // {{{ _modifyQuery() - - /** - * Changes a query string for various DBMS specific reasons - * - * @param string $query query to modify - * @param boolean $is_manip if it is a DML query - * @param integer $limit limit the number of rows - * @param integer $offset start reading from given offset - * @return string modified query - * @access protected - */ - function _modifyQuery($query, $is_manip, $limit, $offset) - { - if ($limit > 0 - && !preg_match('/LIMIT\s*\d(?:\s*(?:,|OFFSET)\s*\d+)?(?:[^\)]*)?$/i', $query) - ) { - $query = rtrim($query); - if (substr($query, -1) == ';') { - $query = substr($query, 0, -1); - } - if ($is_manip) { - $query = $this->_modifyManipQuery($query, $limit); - } else { - $query.= " LIMIT $limit OFFSET $offset"; - } - } - return $query; - } - - // }}} - // {{{ _modifyManipQuery() - - /** - * Changes a manip query string for various DBMS specific reasons - * - * @param string $query query to modify - * @param integer $limit limit the number of rows - * @return string modified query - * @access protected - */ - function _modifyManipQuery($query, $limit) - { - $pos = strpos(strtolower($query), 'where'); - $where = $pos ? substr($query, $pos) : ''; - - $manip_clause = '(\bDELETE\b\s+(?:\*\s+)?\bFROM\b|\bUPDATE\b)'; - $from_clause = '([\w\.]+)'; - $where_clause = '(?:(.*)\bWHERE\b\s+(.*))|(.*)'; - $pattern = '/^'. $manip_clause . '\s+' . $from_clause .'(?:\s)*(?:'. $where_clause .')?$/i'; - $matches = preg_match($pattern, $query, $match); - if ($matches) { - $manip = $match[1]; - $from = $match[2]; - $what = (count($matches) == 6) ? $match[5] : $match[3]; - return $manip.' '.$from.' '.$what.' WHERE ctid=(SELECT ctid FROM '.$from.' '.$where.' LIMIT '.$limit.')'; - } - //return error? - return $query; - } - - // }}} - // {{{ getServerVersion() - - /** - * return version information about the server - * - * @param bool $native determines if the raw version string should be returned - * @return mixed array/string with version information or MDB2 error object - * @access public - */ - function getServerVersion($native = false) - { - $query = 'SHOW SERVER_VERSION'; - if ($this->connected_server_info) { - $server_info = $this->connected_server_info; - } else { - $server_info = $this->queryOne($query, 'text'); - if (MDB2::isError($server_info)) { - return $server_info; - } - } - // cache server_info - $this->connected_server_info = $server_info; - if (!$native && !MDB2::isError($server_info)) { - $tmp = explode('.', $server_info, 3); - if (empty($tmp[2]) - && isset($tmp[1]) - && preg_match('/(\d+)(.*)/', $tmp[1], $tmp2) - ) { - $server_info = array( - 'major' => $tmp[0], - 'minor' => $tmp2[1], - 'patch' => null, - 'extra' => $tmp2[2], - 'native' => $server_info, - ); - } else { - $server_info = array( - 'major' => isset($tmp[0]) ? $tmp[0] : null, - 'minor' => isset($tmp[1]) ? $tmp[1] : null, - 'patch' => isset($tmp[2]) ? $tmp[2] : null, - 'extra' => null, - 'native' => $server_info, - ); - } - } - return $server_info; - } - - // }}} - // {{{ prepare() - - /** - * Prepares a query for multiple execution with execute(). - * With some database backends, this is emulated. - * prepare() requires a generic query as string like - * 'INSERT INTO numbers VALUES(?,?)' or - * 'INSERT INTO numbers VALUES(:foo,:bar)'. - * The ? and :name and are placeholders which can be set using - * bindParam() and the query can be sent off using the execute() method. - * The allowed format for :name can be set with the 'bindname_format' option. - * - * @param string $query the query to prepare - * @param mixed $types array that contains the types of the placeholders - * @param mixed $result_types array that contains the types of the columns in - * the result set or MDB2_PREPARE_RESULT, if set to - * MDB2_PREPARE_MANIP the query is handled as a manipulation query - * @param mixed $lobs key (field) value (parameter) pair for all lob placeholders - * @return mixed resource handle for the prepared query on success, a MDB2 - * error on failure - * @access public - * @see bindParam, execute - */ - function prepare($query, $types = null, $result_types = null, $lobs = array()) - { - if ($this->options['emulate_prepared']) { - return parent::prepare($query, $types, $result_types, $lobs); - } - $is_manip = ($result_types === MDB2_PREPARE_MANIP); - $offset = $this->offset; - $limit = $this->limit; - $this->offset = $this->limit = 0; - $result = $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'pre')); - if ($result) { - if (MDB2::isError($result)) { - return $result; - } - $query = $result; - } - $pgtypes = function_exists('pg_prepare') ? false : array(); - if ($pgtypes !== false && !empty($types)) { - $this->loadModule('Datatype', null, true); - } - $query = $this->_modifyQuery($query, $is_manip, $limit, $offset); - $placeholder_type_guess = $placeholder_type = null; - $question = '?'; - $colon = ':'; - $positions = array(); - $position = $parameter = 0; - while ($position < strlen($query)) { - $q_position = strpos($query, $question, $position); - $c_position = strpos($query, $colon, $position); - //skip "::type" cast ("select id::varchar(20) from sometable where name=?") - $doublecolon_position = strpos($query, '::', $position); - if ($doublecolon_position !== false && $doublecolon_position == $c_position) { - $c_position = strpos($query, $colon, $position+2); - } - if ($q_position && $c_position) { - $p_position = min($q_position, $c_position); - } elseif ($q_position) { - $p_position = $q_position; - } elseif ($c_position) { - $p_position = $c_position; - } else { - break; - } - if (null === $placeholder_type) { - $placeholder_type_guess = $query[$p_position]; - } - - $new_pos = $this->_skipDelimitedStrings($query, $position, $p_position); - if (MDB2::isError($new_pos)) { - return $new_pos; - } - if ($new_pos != $position) { - $position = $new_pos; - continue; //evaluate again starting from the new position - } - - if ($query[$position] == $placeholder_type_guess) { - if (null === $placeholder_type) { - $placeholder_type = $query[$p_position]; - $question = $colon = $placeholder_type; - if (!empty($types) && is_array($types)) { - if ($placeholder_type == ':') { - } else { - $types = array_values($types); - } - } - } - if ($placeholder_type_guess == '?') { - $length = 1; - $name = $parameter; - } else { - $regexp = '/^.{'.($position+1).'}('.$this->options['bindname_format'].').*$/s'; - $param = preg_replace($regexp, '\\1', $query); - if ($param === '') { - $err = $this->raiseError(MDB2_ERROR_SYNTAX, null, null, - 'named parameter name must match "bindname_format" option', __FUNCTION__); - return $err; - } - $length = strlen($param) + 1; - $name = $param; - } - if ($pgtypes !== false) { - if (is_array($types) && array_key_exists($name, $types)) { - $pgtypes[] = $this->datatype->mapPrepareDatatype($types[$name]); - } elseif (is_array($types) && array_key_exists($parameter, $types)) { - $pgtypes[] = $this->datatype->mapPrepareDatatype($types[$parameter]); - } else { - $pgtypes[] = 'text'; - } - } - if (($key_parameter = array_search($name, $positions)) !== false) { - //$next_parameter = 1; - $parameter = $key_parameter + 1; - //foreach ($positions as $key => $value) { - // if ($key_parameter == $key) { - // break; - // } - // ++$next_parameter; - //} - } else { - ++$parameter; - //$next_parameter = $parameter; - $positions[] = $name; - } - $query = substr_replace($query, '$'.$parameter, $position, $length); - $position = $p_position + strlen($parameter); - } else { - $position = $p_position; - } - } - $connection = $this->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - static $prep_statement_counter = 1; - $statement_name = sprintf($this->options['statement_format'], $this->phptype, $prep_statement_counter++ . sha1(microtime() + mt_rand())); - $statement_name = substr(strtolower($statement_name), 0, $this->options['max_identifiers_length']); - if (false === $pgtypes) { - $result = @pg_prepare($connection, $statement_name, $query); - if (!$result) { - $err = $this->raiseError(null, null, null, - 'Unable to create prepared statement handle', __FUNCTION__); - return $err; - } - } else { - $types_string = ''; - if ($pgtypes) { - $types_string = ' ('.implode(', ', $pgtypes).') '; - } - $query = 'PREPARE '.$statement_name.$types_string.' AS '.$query; - $statement = $this->_doQuery($query, true, $connection); - if (MDB2::isError($statement)) { - return $statement; - } - } - - $class_name = 'MDB2_Statement_'.$this->phptype; - $obj = new $class_name($this, $statement_name, $positions, $query, $types, $result_types, $is_manip, $limit, $offset); - $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'post', 'result' => $obj)); - return $obj; - } - - // }}} - // {{{ function getSequenceName($sqn) - - /** - * adds sequence name formatting to a sequence name - * - * @param string name of the sequence - * - * @return string formatted sequence name - * - * @access public - */ - function getSequenceName($sqn) - { - if (false === $this->options['disable_smart_seqname']) { - if (strpos($sqn, '_') !== false) { - list($table, $field) = explode('_', $sqn, 2); - } - $schema_list = $this->queryOne("SELECT array_to_string(current_schemas(false), ',')"); - if (MDB2::isError($schema_list) || empty($schema_list) || count($schema_list) < 2) { - $order_by = ' a.attnum'; - $schema_clause = ' AND n.nspname=current_schema()'; - } else { - $schemas = explode(',', $schema_list); - $schema_clause = ' AND n.nspname IN ('.$schema_list.')'; - $counter = 1; - $order_by = ' CASE '; - foreach ($schemas as $schema) { - $order_by .= ' WHEN n.nspname='.$schema.' THEN '.$counter++; - } - $order_by .= ' ELSE '.$counter.' END, a.attnum'; - } - - $query = "SELECT substring((SELECT substring(pg_get_expr(d.adbin, d.adrelid) for 128) - FROM pg_attrdef d - WHERE d.adrelid = a.attrelid - AND d.adnum = a.attnum - AND a.atthasdef - ) FROM 'nextval[^'']*''([^'']*)') - FROM pg_attribute a - LEFT JOIN pg_class c ON c.oid = a.attrelid - LEFT JOIN pg_attrdef d ON d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef - LEFT JOIN pg_namespace n ON c.relnamespace = n.oid - WHERE (c.relname = ".$this->quote($sqn, 'text'); - if (!empty($field)) { - $query .= " OR (c.relname = ".$this->quote($table, 'text')." AND a.attname = ".$this->quote($field, 'text').")"; - } - $query .= " )" - .$schema_clause." - AND NOT a.attisdropped - AND a.attnum > 0 - AND pg_get_expr(d.adbin, d.adrelid) LIKE 'nextval%' - ORDER BY ".$order_by; - $seqname = $this->queryOne($query); - if (!MDB2::isError($seqname) && !empty($seqname) && is_string($seqname)) { - return $seqname; - } - } - - return parent::getSequenceName($sqn); - } - - // }}} - // {{{ nextID() - - /** - * Returns the next free id of a sequence - * - * @param string $seq_name name of the sequence - * @param boolean $ondemand when true the sequence is - * automatic created, if it - * not exists - * @return mixed MDB2 Error Object or id - * @access public - */ - function nextID($seq_name, $ondemand = true) - { - $sequence_name = $this->quoteIdentifier($this->getSequenceName($seq_name), true); - $query = "SELECT NEXTVAL('$sequence_name')"; - $this->pushErrorHandling(PEAR_ERROR_RETURN); - $this->expectError(MDB2_ERROR_NOSUCHTABLE); - $result = $this->queryOne($query, 'integer'); - $this->popExpect(); - $this->popErrorHandling(); - if (MDB2::isError($result)) { - if ($ondemand && $result->getCode() == MDB2_ERROR_NOSUCHTABLE) { - $this->loadModule('Manager', null, true); - $result = $this->manager->createSequence($seq_name); - if (MDB2::isError($result)) { - return $this->raiseError($result, null, null, - 'on demand sequence could not be created', __FUNCTION__); - } - return $this->nextId($seq_name, false); - } - } - return $result; - } - - // }}} - // {{{ lastInsertID() - - /** - * Returns the autoincrement ID if supported or $id or fetches the current - * ID in a sequence called: $table.(empty($field) ? '' : '_'.$field) - * - * @param string $table name of the table into which a new row was inserted - * @param string $field name of the field into which a new row was inserted - * @return mixed MDB2 Error Object or id - * @access public - */ - function lastInsertID($table = null, $field = null) - { - if (empty($table) && empty($field)) { - return $this->queryOne('SELECT lastval()', 'integer'); - } - $seq = $table.(empty($field) ? '' : '_'.$field); - $sequence_name = $this->quoteIdentifier($this->getSequenceName($seq), true); - return $this->queryOne("SELECT currval('$sequence_name')", 'integer'); - } - - // }}} - // {{{ currID() - - /** - * Returns the current id of a sequence - * - * @param string $seq_name name of the sequence - * @return mixed MDB2 Error Object or id - * @access public - */ - function currID($seq_name) - { - $sequence_name = $this->quoteIdentifier($this->getSequenceName($seq_name), true); - return $this->queryOne("SELECT last_value FROM $sequence_name", 'integer'); - } -} - -/** - * MDB2 PostGreSQL result driver - * - * @package MDB2 - * @category Database - * @author Paul Cooper - */ -class MDB2_Result_pgsql extends MDB2_Result_Common -{ - // }}} - // {{{ fetchRow() - - /** - * Fetch a row and insert the data into an existing array. - * - * @param int $fetchmode how the array data should be indexed - * @param int $rownum number of the row where the data can be found - * @return int data array on success, a MDB2 error on failure - * @access public - */ - function fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) - { - if (null !== $rownum) { - $seek = $this->seek($rownum); - if (MDB2::isError($seek)) { - return $seek; - } - } - if ($fetchmode == MDB2_FETCHMODE_DEFAULT) { - $fetchmode = $this->db->fetchmode; - } - if ( $fetchmode == MDB2_FETCHMODE_ASSOC - || $fetchmode == MDB2_FETCHMODE_OBJECT - ) { - $row = @pg_fetch_array($this->result, null, PGSQL_ASSOC); - if (is_array($row) - && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE - ) { - $row = array_change_key_case($row, $this->db->options['field_case']); - } - } else { - $row = @pg_fetch_row($this->result); - } - if (!$row) { - if (false === $this->result) { - $err = $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'resultset has already been freed', __FUNCTION__); - return $err; - } - return null; - } - $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; - $rtrim = false; - if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) { - if (empty($this->types)) { - $mode += MDB2_PORTABILITY_RTRIM; - } else { - $rtrim = true; - } - } - if ($mode) { - $this->db->_fixResultArrayValues($row, $mode); - } - if ( ( $fetchmode != MDB2_FETCHMODE_ASSOC - && $fetchmode != MDB2_FETCHMODE_OBJECT) - && !empty($this->types) - ) { - $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); - } elseif (($fetchmode == MDB2_FETCHMODE_ASSOC - || $fetchmode == MDB2_FETCHMODE_OBJECT) - && !empty($this->types_assoc) - ) { - $row = $this->db->datatype->convertResultRow($this->types_assoc, $row, $rtrim); - } - if (!empty($this->values)) { - $this->_assignBindColumns($row); - } - if ($fetchmode === MDB2_FETCHMODE_OBJECT) { - $object_class = $this->db->options['fetch_class']; - if ($object_class == 'stdClass') { - $row = (object) $row; - } else { - $rowObj = new $object_class($row); - $row = $rowObj; - } - } - ++$this->rownum; - return $row; - } - - // }}} - // {{{ _getColumnNames() - - /** - * Retrieve the names of columns returned by the DBMS in a query result. - * - * @return mixed Array variable that holds the names of columns as keys - * or an MDB2 error on failure. - * Some DBMS may not return any columns when the result set - * does not contain any rows. - * @access private - */ - function _getColumnNames() - { - $columns = array(); - $numcols = $this->numCols(); - if (MDB2::isError($numcols)) { - return $numcols; - } - for ($column = 0; $column < $numcols; $column++) { - $column_name = @pg_field_name($this->result, $column); - $columns[$column_name] = $column; - } - if ($this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - $columns = array_change_key_case($columns, $this->db->options['field_case']); - } - return $columns; - } - - // }}} - // {{{ numCols() - - /** - * Count the number of columns returned by the DBMS in a query result. - * - * @access public - * @return mixed integer value with the number of columns, a MDB2 error - * on failure - */ - function numCols() - { - $cols = @pg_num_fields($this->result); - if (null === $cols) { - if (false === $this->result) { - return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'resultset has already been freed', __FUNCTION__); - } - if (null === $this->result) { - return count($this->types); - } - return $this->db->raiseError(null, null, null, - 'Could not get column count', __FUNCTION__); - } - return $cols; - } - - // }}} - // {{{ nextResult() - - /** - * Move the internal result pointer to the next available result - * - * @return true on success, false if there is no more result set or an error object on failure - * @access public - */ - function nextResult() - { - $connection = $this->db->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - - if (!($this->result = @pg_get_result($connection))) { - return false; - } - return MDB2_OK; - } - - // }}} - // {{{ free() - - /** - * Free the internal resources associated with result. - * - * @return boolean true on success, false if result is invalid - * @access public - */ - function free() - { - if (is_resource($this->result) && $this->db->connection) { - $free = @pg_free_result($this->result); - if (false === $free) { - return $this->db->raiseError(null, null, null, - 'Could not free result', __FUNCTION__); - } - } - $this->result = false; - return MDB2_OK; - } -} - -/** - * MDB2 PostGreSQL buffered result driver - * - * @package MDB2 - * @category Database - * @author Paul Cooper - */ -class MDB2_BufferedResult_pgsql extends MDB2_Result_pgsql -{ - // {{{ seek() - - /** - * Seek to a specific row in a result set - * - * @param int $rownum number of the row where the data can be found - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function seek($rownum = 0) - { - if ($this->rownum != ($rownum - 1) && !@pg_result_seek($this->result, $rownum)) { - if (false === $this->result) { - return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'resultset has already been freed', __FUNCTION__); - } - if (null === $this->result) { - return MDB2_OK; - } - return $this->db->raiseError(MDB2_ERROR_INVALID, null, null, - 'tried to seek to an invalid row number ('.$rownum.')', __FUNCTION__); - } - $this->rownum = $rownum - 1; - return MDB2_OK; - } - - // }}} - // {{{ valid() - - /** - * Check if the end of the result set has been reached - * - * @return mixed true or false on sucess, a MDB2 error on failure - * @access public - */ - function valid() - { - $numrows = $this->numRows(); - if (MDB2::isError($numrows)) { - return $numrows; - } - return $this->rownum < ($numrows - 1); - } - - // }}} - // {{{ numRows() - - /** - * Returns the number of rows in a result object - * - * @return mixed MDB2 Error Object or the number of rows - * @access public - */ - function numRows() - { - $rows = @pg_num_rows($this->result); - if (null === $rows) { - if (false === $this->result) { - return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'resultset has already been freed', __FUNCTION__); - } - if (null === $this->result) { - return 0; - } - return $this->db->raiseError(null, null, null, - 'Could not get row count', __FUNCTION__); - } - return $rows; - } -} - -/** - * MDB2 PostGreSQL statement driver - * - * @package MDB2 - * @category Database - * @author Paul Cooper - */ -class MDB2_Statement_pgsql extends MDB2_Statement_Common -{ - // {{{ _execute() - - /** - * Execute a prepared query statement helper method. - * - * @param mixed $result_class string which specifies which result class to use - * @param mixed $result_wrap_class string which specifies which class to wrap results in - * - * @return mixed MDB2_Result or integer (affected rows) on success, - * a MDB2 error on failure - * @access private - */ - function _execute($result_class = true, $result_wrap_class = true) - { - if (null === $this->statement) { - return parent::_execute($result_class, $result_wrap_class); - } - $this->db->last_query = $this->query; - $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'pre', 'parameters' => $this->values)); - if ($this->db->getOption('disable_query')) { - $result = $this->is_manip ? 0 : null; - return $result; - } - - $connection = $this->db->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - - $query = false; - $parameters = array(); - // todo: disabled until pg_execute() bytea issues are cleared up - if (true || !function_exists('pg_execute')) { - $query = 'EXECUTE '.$this->statement; - } - if (!empty($this->positions)) { - foreach ($this->positions as $parameter) { - if (!array_key_exists($parameter, $this->values)) { - return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, - 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__); - } - $value = $this->values[$parameter]; - $type = array_key_exists($parameter, $this->types) ? $this->types[$parameter] : null; - if (is_resource($value) || $type == 'clob' || $type == 'blob' || $this->db->options['lob_allow_url_include']) { - if (!is_resource($value) && preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) { - if ($match[1] == 'file://') { - $value = $match[2]; - } - $value = @fopen($value, 'r'); - $close = true; - } - if (is_resource($value)) { - $data = ''; - while (!@feof($value)) { - $data.= @fread($value, $this->db->options['lob_buffer_length']); - } - if ($close) { - @fclose($value); - } - $value = $data; - } - } - $quoted = $this->db->quote($value, $type, $query); - if (MDB2::isError($quoted)) { - return $quoted; - } - $parameters[] = $quoted; - } - if ($query) { - $query.= ' ('.implode(', ', $parameters).')'; - } - } - - if (!$query) { - $result = @pg_execute($connection, $this->statement, $parameters); - if (!$result) { - $err = $this->db->raiseError(null, null, null, - 'Unable to execute statement', __FUNCTION__); - return $err; - } - } else { - $result = $this->db->_doQuery($query, $this->is_manip, $connection); - if (MDB2::isError($result)) { - return $result; - } - } - - if ($this->is_manip) { - $affected_rows = $this->db->_affectedRows($connection, $result); - return $affected_rows; - } - - $result = $this->db->_wrapResult($result, $this->result_types, - $result_class, $result_wrap_class, $this->limit, $this->offset); - $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'post', 'result' => $result)); - return $result; - } - - // }}} - // {{{ free() - - /** - * Release resources allocated for the specified prepared query. - * - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function free() - { - if (null === $this->positions) { - return $this->db->raiseError(MDB2_ERROR, null, null, - 'Prepared statement has already been freed', __FUNCTION__); - } - $result = MDB2_OK; - - if (null !== $this->statement) { - $connection = $this->db->getConnection(); - if (MDB2::isError($connection)) { - return $connection; - } - $query = 'DEALLOCATE PREPARE '.$this->statement; - $result = $this->db->_doQuery($query, true, $connection); - } - - parent::free(); - return $result; - } - - /** - * drop an existing table - * - * @param string $name name of the table that should be dropped - * @return mixed MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function dropTable($name) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $name = $db->quoteIdentifier($name, true); - $result = $db->exec("DROP TABLE $name"); - - if (MDB2::isError($result)) { - $result = $db->exec("DROP TABLE $name CASCADE"); - } - - return $result; - } -} -?> diff --git a/data/module/MDB2/Extended.php b/data/module/MDB2/Extended.php deleted file mode 100644 index ed47ab9192e..00000000000 --- a/data/module/MDB2/Extended.php +++ /dev/null @@ -1,723 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Extended.php 327310 2012-08-27 15:16:18Z danielc $ - -/** - * @package MDB2 - * @category Database - * @author Lukas Smith - */ - -/** - * Used by autoPrepare() - */ -define('MDB2_AUTOQUERY_INSERT', 1); -define('MDB2_AUTOQUERY_UPDATE', 2); -define('MDB2_AUTOQUERY_DELETE', 3); -define('MDB2_AUTOQUERY_SELECT', 4); - -/** - * MDB2_Extended: class which adds several high level methods to MDB2 - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Extended extends MDB2_Module_Common -{ - // {{{ autoPrepare() - - /** - * Generate an insert, update or delete query and call prepare() on it - * - * @param string table - * @param array the fields names - * @param int type of query to build - * MDB2_AUTOQUERY_INSERT - * MDB2_AUTOQUERY_UPDATE - * MDB2_AUTOQUERY_DELETE - * MDB2_AUTOQUERY_SELECT - * @param string (in case of update and delete queries, this string will be put after the sql WHERE statement) - * @param array that contains the types of the placeholders - * @param mixed array that contains the types of the columns in - * the result set or MDB2_PREPARE_RESULT, if set to - * MDB2_PREPARE_MANIP the query is handled as a manipulation query - * - * @return resource handle for the query - * @see buildManipSQL - * @access public - */ - function autoPrepare($table, $table_fields, $mode = MDB2_AUTOQUERY_INSERT, - $where = false, $types = null, $result_types = MDB2_PREPARE_MANIP) - { - $query = $this->buildManipSQL($table, $table_fields, $mode, $where); - if (MDB2::isError($query)) { - return $query; - } - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - $lobs = array(); - foreach ((array)$types as $param => $type) { - if (($type == 'clob') || ($type == 'blob')) { - $lobs[$param] = $table_fields[$param]; - } - } - return $db->prepare($query, $types, $result_types, $lobs); - } - - // }}} - // {{{ autoExecute() - - /** - * Generate an insert, update or delete query and call prepare() and execute() on it - * - * @param string name of the table - * @param array assoc ($key=>$value) where $key is a field name and $value its value - * @param int type of query to build - * MDB2_AUTOQUERY_INSERT - * MDB2_AUTOQUERY_UPDATE - * MDB2_AUTOQUERY_DELETE - * MDB2_AUTOQUERY_SELECT - * @param string (in case of update and delete queries, this string will be put after the sql WHERE statement) - * @param array that contains the types of the placeholders - * @param string which specifies which result class to use - * @param mixed array that contains the types of the columns in - * the result set or MDB2_PREPARE_RESULT, if set to - * MDB2_PREPARE_MANIP the query is handled as a manipulation query - * - * @return bool|MDB2_Error true on success, a MDB2 error on failure - * @see buildManipSQL - * @see autoPrepare - * @access public - */ - function autoExecute($table, $fields_values, $mode = MDB2_AUTOQUERY_INSERT, - $where = false, $types = null, $result_class = true, $result_types = MDB2_PREPARE_MANIP) - { - $fields_values = (array)$fields_values; - if ($mode == MDB2_AUTOQUERY_SELECT) { - if (is_array($result_types)) { - $keys = array_keys($result_types); - } elseif (!empty($fields_values)) { - $keys = $fields_values; - } else { - $keys = array(); - } - } else { - $keys = array_keys($fields_values); - } - $params = array_values($fields_values); - if (empty($params)) { - $query = $this->buildManipSQL($table, $keys, $mode, $where); - - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - if ($mode == MDB2_AUTOQUERY_SELECT) { - $result = $db->query($query, $result_types, $result_class); - } else { - $result = $db->exec($query); - } - } else { - $stmt = $this->autoPrepare($table, $keys, $mode, $where, $types, $result_types); - if (MDB2::isError($stmt)) { - return $stmt; - } - $result = $stmt->execute($params, $result_class); - $stmt->free(); - } - return $result; - } - - // }}} - // {{{ buildManipSQL() - - /** - * Make automaticaly an sql query for prepare() - * - * Example : buildManipSQL('table_sql', array('field1', 'field2', 'field3'), MDB2_AUTOQUERY_INSERT) - * will return the string : INSERT INTO table_sql (field1,field2,field3) VALUES (?,?,?) - * NB : - This belongs more to a SQL Builder class, but this is a simple facility - * - Be carefull ! If you don't give a $where param with an UPDATE/DELETE query, all - * the records of the table will be updated/deleted ! - * - * @param string name of the table - * @param ordered array containing the fields names - * @param int type of query to build - * MDB2_AUTOQUERY_INSERT - * MDB2_AUTOQUERY_UPDATE - * MDB2_AUTOQUERY_DELETE - * MDB2_AUTOQUERY_SELECT - * @param string (in case of update and delete queries, this string will be put after the sql WHERE statement) - * - * @return string sql query for prepare() - * @access public - */ - function buildManipSQL($table, $table_fields, $mode, $where = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if ($db->options['quote_identifier']) { - $table = $db->quoteIdentifier($table); - } - - if (!empty($table_fields) && $db->options['quote_identifier']) { - foreach ($table_fields as $key => $field) { - $table_fields[$key] = $db->quoteIdentifier($field); - } - } - - if ((false !== $where) && (null !== $where)) { - if (is_array($where)) { - $where = implode(' AND ', $where); - } - $where = ' WHERE '.$where; - } - - switch ($mode) { - case MDB2_AUTOQUERY_INSERT: - if (empty($table_fields)) { - return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'Insert requires table fields', __FUNCTION__); - } - $cols = implode(', ', $table_fields); - $values = '?'.str_repeat(', ?', (count($table_fields) - 1)); - return 'INSERT INTO '.$table.' ('.$cols.') VALUES ('.$values.')'; - break; - case MDB2_AUTOQUERY_UPDATE: - if (empty($table_fields)) { - return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, - 'Update requires table fields', __FUNCTION__); - } - $set = implode(' = ?, ', $table_fields).' = ?'; - $sql = 'UPDATE '.$table.' SET '.$set.$where; - return $sql; - break; - case MDB2_AUTOQUERY_DELETE: - $sql = 'DELETE FROM '.$table.$where; - return $sql; - break; - case MDB2_AUTOQUERY_SELECT: - $cols = !empty($table_fields) ? implode(', ', $table_fields) : '*'; - $sql = 'SELECT '.$cols.' FROM '.$table.$where; - return $sql; - break; - } - return $db->raiseError(MDB2_ERROR_SYNTAX, null, null, - 'Non existant mode', __FUNCTION__); - } - - // }}} - // {{{ limitQuery() - - /** - * Generates a limited query - * - * @param string query - * @param array that contains the types of the columns in the result set - * @param integer the numbers of rows to fetch - * @param integer the row to start to fetching - * @param string which specifies which result class to use - * @param mixed string which specifies which class to wrap results in - * - * @return MDB2_Result|MDB2_Error result set on success, a MDB2 error on failure - * @access public - */ - function limitQuery($query, $types, $limit, $offset = 0, $result_class = true, - $result_wrap_class = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - $result = $db->setLimit($limit, $offset); - if (MDB2::isError($result)) { - return $result; - } - return $db->query($query, $types, $result_class, $result_wrap_class); - } - - // }}} - // {{{ execParam() - - /** - * Execute a parameterized DML statement. - * - * @param string the SQL query - * @param array if supplied, prepare/execute will be used - * with this array as execute parameters - * @param array that contains the types of the values defined in $params - * - * @return int|MDB2_Error affected rows on success, a MDB2 error on failure - * @access public - */ - function execParam($query, $params = array(), $param_types = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - settype($params, 'array'); - if (empty($params)) { - return $db->exec($query); - } - - $stmt = $db->prepare($query, $param_types, MDB2_PREPARE_MANIP); - if (MDB2::isError($stmt)) { - return $stmt; - } - - $result = $stmt->execute($params); - if (MDB2::isError($result)) { - return $result; - } - - $stmt->free(); - return $result; - } - - // }}} - // {{{ getOne() - - /** - * Fetch the first column of the first row of data returned from a query. - * Takes care of doing the query and freeing the results when finished. - * - * @param string the SQL query - * @param string that contains the type of the column in the result set - * @param array if supplied, prepare/execute will be used - * with this array as execute parameters - * @param array that contains the types of the values defined in $params - * @param int|string which column to return - * - * @return scalar|MDB2_Error data on success, a MDB2 error on failure - * @access public - */ - function getOne($query, $type = null, $params = array(), - $param_types = null, $colnum = 0) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - settype($params, 'array'); - settype($type, 'array'); - if (empty($params)) { - return $db->queryOne($query, $type, $colnum); - } - - $stmt = $db->prepare($query, $param_types, $type); - if (MDB2::isError($stmt)) { - return $stmt; - } - - $result = $stmt->execute($params); - if (!MDB2::isResultCommon($result)) { - return $result; - } - - $one = $result->fetchOne($colnum); - $stmt->free(); - $result->free(); - return $one; - } - - // }}} - // {{{ getRow() - - /** - * Fetch the first row of data returned from a query. Takes care - * of doing the query and freeing the results when finished. - * - * @param string the SQL query - * @param array that contains the types of the columns in the result set - * @param array if supplied, prepare/execute will be used - * with this array as execute parameters - * @param array that contains the types of the values defined in $params - * @param int the fetch mode to use - * - * @return array|MDB2_Error data on success, a MDB2 error on failure - * @access public - */ - function getRow($query, $types = null, $params = array(), - $param_types = null, $fetchmode = MDB2_FETCHMODE_DEFAULT) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - settype($params, 'array'); - if (empty($params)) { - return $db->queryRow($query, $types, $fetchmode); - } - - $stmt = $db->prepare($query, $param_types, $types); - if (MDB2::isError($stmt)) { - return $stmt; - } - - $result = $stmt->execute($params); - if (!MDB2::isResultCommon($result)) { - return $result; - } - - $row = $result->fetchRow($fetchmode); - $stmt->free(); - $result->free(); - return $row; - } - - // }}} - // {{{ getCol() - - /** - * Fetch a single column from a result set and return it as an - * indexed array. - * - * @param string the SQL query - * @param string that contains the type of the column in the result set - * @param array if supplied, prepare/execute will be used - * with this array as execute parameters - * @param array that contains the types of the values defined in $params - * @param int|string which column to return - * - * @return array|MDB2_Error data on success, a MDB2 error on failure - * @access public - */ - function getCol($query, $type = null, $params = array(), - $param_types = null, $colnum = 0) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - settype($params, 'array'); - settype($type, 'array'); - if (empty($params)) { - return $db->queryCol($query, $type, $colnum); - } - - $stmt = $db->prepare($query, $param_types, $type); - if (MDB2::isError($stmt)) { - return $stmt; - } - - $result = $stmt->execute($params); - if (!MDB2::isResultCommon($result)) { - return $result; - } - - $col = $result->fetchCol($colnum); - $stmt->free(); - $result->free(); - return $col; - } - - // }}} - // {{{ getAll() - - /** - * Fetch all the rows returned from a query. - * - * @param string the SQL query - * @param array that contains the types of the columns in the result set - * @param array if supplied, prepare/execute will be used - * with this array as execute parameters - * @param array that contains the types of the values defined in $params - * @param int the fetch mode to use - * @param bool if set to true, the $all will have the first - * column as its first dimension - * @param bool $force_array used only when the query returns exactly - * two columns. If true, the values of the returned array will be - * one-element arrays instead of scalars. - * @param bool $group if true, the values of the returned array is - * wrapped in another array. If the same key value (in the first - * column) repeats itself, the values will be appended to this array - * instead of overwriting the existing values. - * - * @return array|MDB2_Error data on success, a MDB2 error on failure - * @access public - */ - function getAll($query, $types = null, $params = array(), - $param_types = null, $fetchmode = MDB2_FETCHMODE_DEFAULT, - $rekey = false, $force_array = false, $group = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - settype($params, 'array'); - if (empty($params)) { - return $db->queryAll($query, $types, $fetchmode, $rekey, $force_array, $group); - } - - $stmt = $db->prepare($query, $param_types, $types); - if (MDB2::isError($stmt)) { - return $stmt; - } - - $result = $stmt->execute($params); - if (!MDB2::isResultCommon($result)) { - return $result; - } - - $all = $result->fetchAll($fetchmode, $rekey, $force_array, $group); - $stmt->free(); - $result->free(); - return $all; - } - - // }}} - // {{{ getAssoc() - - /** - * Fetch the entire result set of a query and return it as an - * associative array using the first column as the key. - * - * If the result set contains more than two columns, the value - * will be an array of the values from column 2-n. If the result - * set contains only two columns, the returned value will be a - * scalar with the value of the second column (unless forced to an - * array with the $force_array parameter). A MDB2 error code is - * returned on errors. If the result set contains fewer than two - * columns, a MDB2_ERROR_TRUNCATED error is returned. - * - * For example, if the table 'mytable' contains: - *
-     *   ID      TEXT       DATE
-     * --------------------------------
-     *   1       'one'      944679408
-     *   2       'two'      944679408
-     *   3       'three'    944679408
-     * 
- * Then the call getAssoc('SELECT id,text FROM mytable') returns: - *
-     *    array(
-     *      '1' => 'one',
-     *      '2' => 'two',
-     *      '3' => 'three',
-     *    )
-     * 
- * ...while the call getAssoc('SELECT id,text,date FROM mytable') returns: - *
-     *    array(
-     *      '1' => array('one', '944679408'),
-     *      '2' => array('two', '944679408'),
-     *      '3' => array('three', '944679408')
-     *    )
-     * 
- * - * If the more than one row occurs with the same value in the - * first column, the last row overwrites all previous ones by - * default. Use the $group parameter if you don't want to - * overwrite like this. Example: - *
-     * getAssoc('SELECT category,id,name FROM mytable', null, null
-     *           MDB2_FETCHMODE_ASSOC, false, true) returns:
-     *    array(
-     *      '1' => array(array('id' => '4', 'name' => 'number four'),
-     *                   array('id' => '6', 'name' => 'number six')
-     *             ),
-     *      '9' => array(array('id' => '4', 'name' => 'number four'),
-     *                   array('id' => '6', 'name' => 'number six')
-     *             )
-     *    )
-     * 
- * - * Keep in mind that database functions in PHP usually return string - * values for results regardless of the database's internal type. - * - * @param string the SQL query - * @param array that contains the types of the columns in the result set - * @param array if supplied, prepare/execute will be used - * with this array as execute parameters - * @param array that contains the types of the values defined in $params - * @param bool $force_array used only when the query returns - * exactly two columns. If TRUE, the values of the returned array - * will be one-element arrays instead of scalars. - * @param bool $group if TRUE, the values of the returned array - * is wrapped in another array. If the same key value (in the first - * column) repeats itself, the values will be appended to this array - * instead of overwriting the existing values. - * - * @return array|MDB2_Error data on success, a MDB2 error on failure - * @access public - */ - function getAssoc($query, $types = null, $params = array(), $param_types = null, - $fetchmode = MDB2_FETCHMODE_DEFAULT, $force_array = false, $group = false) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - settype($params, 'array'); - if (empty($params)) { - return $db->queryAll($query, $types, $fetchmode, true, $force_array, $group); - } - - $stmt = $db->prepare($query, $param_types, $types); - if (MDB2::isError($stmt)) { - return $stmt; - } - - $result = $stmt->execute($params); - if (!MDB2::isResultCommon($result)) { - return $result; - } - - $all = $result->fetchAll($fetchmode, true, $force_array, $group); - $stmt->free(); - $result->free(); - return $all; - } - - // }}} - // {{{ executeMultiple() - - /** - * This function does several execute() calls on the same statement handle. - * $params must be an array indexed numerically from 0, one execute call is - * done for every 'row' in the array. - * - * If an error occurs during execute(), executeMultiple() does not execute - * the unfinished rows, but rather returns that error. - * - * @param resource query handle from prepare() - * @param array numeric array containing the data to insert into the query - * - * @return bool|MDB2_Error true on success, a MDB2 error on failure - * @access public - * @see prepare(), execute() - */ - function executeMultiple($stmt, $params = null) - { - if (MDB2::isError($stmt)) { - return $stmt; - } - for ($i = 0, $j = count($params); $i < $j; $i++) { - $result = $stmt->execute($params[$i]); - if (MDB2::isError($result)) { - return $result; - } - } - return MDB2_OK; - } - - // }}} - // {{{ getBeforeID() - - /** - * Returns the next free id of a sequence if the RDBMS - * does not support auto increment - * - * @param string name of the table into which a new row was inserted - * @param string name of the field into which a new row was inserted - * @param bool when true the sequence is automatic created, if it not exists - * @param bool if the returned value should be quoted - * - * @return int|MDB2_Error id on success, a MDB2 error on failure - * @access public - */ - function getBeforeID($table, $field = null, $ondemand = true, $quote = true) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if ($db->supports('auto_increment') !== true) { - $seq = $table.(empty($field) ? '' : '_'.$field); - $id = $db->nextID($seq, $ondemand); - if (!$quote || MDB2::isError($id)) { - return $id; - } - return $db->quote($id, 'integer'); - } elseif (!$quote) { - return null; - } - return 'NULL'; - } - - // }}} - // {{{ getAfterID() - - /** - * Returns the autoincrement ID if supported or $id - * - * @param mixed value as returned by getBeforeId() - * @param string name of the table into which a new row was inserted - * @param string name of the field into which a new row was inserted - * - * @return int|MDB2_Error id on success, a MDB2 error on failure - * @access public - */ - function getAfterID($id, $table, $field = null) - { - $db = $this->getDBInstance(); - if (MDB2::isError($db)) { - return $db; - } - - if ($db->supports('auto_increment') !== true) { - return $id; - } - return $db->lastInsertID($table, $field); - } - - // }}} -} -?> diff --git a/data/module/MDB2/Iterator.php b/data/module/MDB2/Iterator.php deleted file mode 100644 index 17a3ac29ad2..00000000000 --- a/data/module/MDB2/Iterator.php +++ /dev/null @@ -1,262 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Iterator.php 327310 2012-08-27 15:16:18Z danielc $ - -/** - * PHP5 Iterator - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Iterator implements Iterator -{ - protected $fetchmode; - /** - * @var MDB2_Result_Common - */ - protected $result; - protected $row; - - // {{{ constructor - - /** - * Constructor - */ - public function __construct(MDB2_Result_Common $result, $fetchmode = MDB2_FETCHMODE_DEFAULT) - { - $this->result = $result; - $this->fetchmode = $fetchmode; - } - // }}} - - // {{{ seek() - - /** - * Seek forward to a specific row in a result set - * - * @param int number of the row where the data can be found - * - * @return void - * @access public - */ - public function seek($rownum) - { - $this->row = null; - if ($this->result) { - $this->result->seek($rownum); - } - } - // }}} - - // {{{ next() - - /** - * Fetch next row of data - * - * @return void - * @access public - */ - public function next() - { - $this->row = null; - } - // }}} - - // {{{ current() - - /** - * return a row of data - * - * @return void - * @access public - */ - public function current() - { - if (null === $this->row) { - $row = $this->result->fetchRow($this->fetchmode); - if (MDB2::isError($row)) { - $row = false; - } - $this->row = $row; - } - return $this->row; - } - // }}} - - // {{{ valid() - - /** - * Check if the end of the result set has been reached - * - * @return bool true/false, false is also returned on failure - * @access public - */ - public function valid() - { - return (bool)$this->current(); - } - // }}} - - // {{{ free() - - /** - * Free the internal resources associated with result. - * - * @return bool|MDB2_Error true on success, false|MDB2_Error if result is invalid - * @access public - */ - public function free() - { - if ($this->result) { - return $this->result->free(); - } - $this->result = false; - $this->row = null; - return false; - } - // }}} - - // {{{ key() - - /** - * Returns the row number - * - * @return int|bool|MDB2_Error true on success, false|MDB2_Error if result is invalid - * @access public - */ - public function key() - { - if ($this->result) { - return $this->result->rowCount(); - } - return false; - } - // }}} - - // {{{ rewind() - - /** - * Seek to the first row in a result set - * - * @return void - * @access public - */ - public function rewind() - { - } - // }}} - - // {{{ destructor - - /** - * Destructor - */ - public function __destruct() - { - $this->free(); - } - // }}} -} - -/** - * PHP5 buffered Iterator - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_BufferedIterator extends MDB2_Iterator implements SeekableIterator -{ - // {{{ valid() - - /** - * Check if the end of the result set has been reached - * - * @return bool|MDB2_Error true on success, false|MDB2_Error if result is invalid - * @access public - */ - public function valid() - { - if ($this->result) { - return $this->result->valid(); - } - return false; - } - // }}} - - // {{{count() - - /** - * Returns the number of rows in a result object - * - * @return int|MDB2_Error number of rows, false|MDB2_Error if result is invalid - * @access public - */ - public function count() - { - if ($this->result) { - return $this->result->numRows(); - } - return false; - } - // }}} - - // {{{ rewind() - - /** - * Seek to the first row in a result set - * - * @return void - * @access public - */ - public function rewind() - { - $this->seek(0); - } - // }}} -} - -?> diff --git a/data/module/MDB2/LOB.php b/data/module/MDB2/LOB.php deleted file mode 100644 index ff2342dbb9a..00000000000 --- a/data/module/MDB2/LOB.php +++ /dev/null @@ -1,264 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: LOB.php 222350 2006-10-25 11:52:21Z lsmith $ - -/** - * @package MDB2 - * @category Database - * @author Lukas Smith - */ - -require_once 'MDB2.php'; - -/** - * MDB2_LOB: user land stream wrapper implementation for LOB support - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_LOB -{ - /** - * contains the key to the global MDB2 instance array of the associated - * MDB2 instance - * - * @var integer - * @access protected - */ - var $db_index; - - /** - * contains the key to the global MDB2_LOB instance array of the associated - * MDB2_LOB instance - * - * @var integer - * @access protected - */ - var $lob_index; - - // {{{ stream_open() - - /** - * open stream - * - * @param string specifies the URL that was passed to fopen() - * @param string the mode used to open the file - * @param int holds additional flags set by the streams API - * @param string not used - * - * @return bool - * @access public - */ - function stream_open($path, $mode, $options, &$opened_path) - { - if (!preg_match('/^rb?\+?$/', $mode)) { - return false; - } - $url = parse_url($path); - if (empty($url['host'])) { - return false; - } - $this->db_index = (int)$url['host']; - if (!isset($GLOBALS['_MDB2_databases'][$this->db_index])) { - return false; - } - $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; - $this->lob_index = (int)$url['user']; - if (!isset($db->datatype->lobs[$this->lob_index])) { - return false; - } - return true; - } - // }}} - - // {{{ stream_read() - - /** - * read stream - * - * @param int number of bytes to read - * - * @return string - * @access public - */ - function stream_read($count) - { - if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) { - $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; - $db->datatype->_retrieveLOB($db->datatype->lobs[$this->lob_index]); - - $data = $db->datatype->_readLOB($db->datatype->lobs[$this->lob_index], $count); - $length = strlen($data); - if ($length == 0) { - $db->datatype->lobs[$this->lob_index]['endOfLOB'] = true; - } - $db->datatype->lobs[$this->lob_index]['position'] += $length; - return $data; - } - } - // }}} - - // {{{ stream_write() - - /** - * write stream, note implemented - * - * @param string data - * - * @return int - * @access public - */ - function stream_write($data) - { - return 0; - } - // }}} - - // {{{ stream_tell() - - /** - * return the current position - * - * @return int current position - * @access public - */ - function stream_tell() - { - if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) { - $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; - return $db->datatype->lobs[$this->lob_index]['position']; - } - } - // }}} - - // {{{ stream_eof() - - /** - * Check if stream reaches EOF - * - * @return bool - * @access public - */ - function stream_eof() - { - if (!isset($GLOBALS['_MDB2_databases'][$this->db_index])) { - return true; - } - - $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; - $result = $db->datatype->_endOfLOB($db->datatype->lobs[$this->lob_index]); - if (version_compare(phpversion(), "5.0", ">=") - && version_compare(phpversion(), "5.1", "<") - ) { - return !$result; - } - return $result; - } - // }}} - - // {{{ stream_seek() - - /** - * Seek stream, not implemented - * - * @param int offset - * @param int whence - * - * @return bool - * @access public - */ - function stream_seek($offset, $whence) - { - return false; - } - // }}} - - // {{{ stream_stat() - - /** - * return information about stream - * - * @access public - */ - function stream_stat() - { - if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) { - $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; - return array( - 'db_index' => $this->db_index, - 'lob_index' => $this->lob_index, - ); - } - } - // }}} - - // {{{ stream_close() - - /** - * close stream - * - * @access public - */ - function stream_close() - { - if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) { - $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; - if (isset($db->datatype->lobs[$this->lob_index])) { - $db->datatype->_destroyLOB($db->datatype->lobs[$this->lob_index]); - unset($db->datatype->lobs[$this->lob_index]); - } - } - } - // }}} -} - -// register streams wrapper -if (!stream_wrapper_register("MDB2LOB", "MDB2_LOB")) { - MDB2::raiseError(); - return false; -} - -?> diff --git a/data/module/Mail.php b/data/module/Mail.php deleted file mode 100644 index 75132ac2a6c..00000000000 --- a/data/module/Mail.php +++ /dev/null @@ -1,270 +0,0 @@ - - * @copyright 1997-2010 Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Mail.php 294747 2010-02-08 08:18:33Z clockwerx $ - * @link http://pear.php.net/package/Mail/ - */ - -require_once 'PEAR.php'; - -/** - * PEAR's Mail:: interface. Defines the interface for implementing - * mailers under the PEAR hierarchy, and provides supporting functions - * useful in multiple mailer backends. - * - * @access public - * @version $Revision: 294747 $ - * @package Mail - */ -class Mail -{ - /** - * Line terminator used for separating header lines. - * @var string - */ - var $sep = "\r\n"; - - /** - * Provides an interface for generating Mail:: objects of various - * types - * - * @param string $driver The kind of Mail:: object to instantiate. - * @param array $params The parameters to pass to the Mail:: object. - * @return object Mail a instance of the driver class or if fails a PEAR Error - * @access public - */ - function &factory($driver, $params = array()) - { - $driver = strtolower($driver); - @include_once 'Mail/' . $driver . '.php'; - $class = 'Mail_' . $driver; - if (class_exists($class)) { - $mailer = new $class($params); - return $mailer; - } else { - return PEAR::raiseError('Unable to find class for driver ' . $driver); - } - } - - /** - * Implements Mail::send() function using php's built-in mail() - * command. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (ie, 'Subject'), and the array value - * is the header value (ie, 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * - * @access public - * @deprecated use Mail_mail::send instead - */ - function send($recipients, $headers, $body) - { - if (!is_array($headers)) { - return PEAR::raiseError('$headers must be an array'); - } - - $result = $this->_sanitizeHeaders($headers); - if (is_a($result, 'PEAR_Error')) { - return $result; - } - - // if we're passed an array of recipients, implode it. - if (is_array($recipients)) { - $recipients = implode(', ', $recipients); - } - - // get the Subject out of the headers array so that we can - // pass it as a seperate argument to mail(). - $subject = ''; - if (isset($headers['Subject'])) { - $subject = $headers['Subject']; - unset($headers['Subject']); - } - - // flatten the headers out. - list(, $text_headers) = Mail::prepareHeaders($headers); - - return mail($recipients, $subject, $body, $text_headers); - } - - /** - * Sanitize an array of mail headers by removing any additional header - * strings present in a legitimate header's value. The goal of this - * filter is to prevent mail injection attacks. - * - * @param array $headers The associative array of headers to sanitize. - * - * @access private - */ - function _sanitizeHeaders(&$headers) - { - foreach ($headers as $key => $value) { - $headers[$key] = - preg_replace('=((||0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i', - null, $value); - } - } - - /** - * Take an array of mail headers and return a string containing - * text usable in sending a message. - * - * @param array $headers The array of headers to prepare, in an associative - * array, where the array key is the header name (ie, - * 'Subject'), and the array value is the header - * value (ie, 'test'). The header produced from those - * values would be 'Subject: test'. - * - * @return mixed Returns false if it encounters a bad address, - * otherwise returns an array containing two - * elements: Any From: address found in the headers, - * and the plain text version of the headers. - * @access private - */ - function prepareHeaders($headers) - { - $lines = array(); - $from = null; - - foreach ($headers as $key => $value) { - if (strcasecmp($key, 'From') === 0) { - include_once 'Mail/RFC822.php'; - $parser = new Mail_RFC822(); - $addresses = $parser->parseAddressList($value, 'localhost', false); - if (is_a($addresses, 'PEAR_Error')) { - return $addresses; - } - - $from = $addresses[0]->mailbox . '@' . $addresses[0]->host; - - // Reject envelope From: addresses with spaces. - if (strstr($from, ' ')) { - return false; - } - - $lines[] = $key . ': ' . $value; - } elseif (strcasecmp($key, 'Received') === 0) { - $received = array(); - if (is_array($value)) { - foreach ($value as $line) { - $received[] = $key . ': ' . $line; - } - } - else { - $received[] = $key . ': ' . $value; - } - // Put Received: headers at the top. Spam detectors often - // flag messages with Received: headers after the Subject: - // as spam. - $lines = array_merge($received, $lines); - } else { - // If $value is an array (i.e., a list of addresses), convert - // it to a comma-delimited string of its elements (addresses). - if (is_array($value)) { - $value = implode(', ', $value); - } - $lines[] = $key . ': ' . $value; - } - } - - return array($from, join($this->sep, $lines)); - } - - /** - * Take a set of recipients and parse them, returning an array of - * bare addresses (forward paths) that can be passed to sendmail - * or an smtp server with the rcpt to: command. - * - * @param mixed Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. - * - * @return mixed An array of forward paths (bare addresses) or a PEAR_Error - * object if the address list could not be parsed. - * @access private - */ - function parseRecipients($recipients) - { - include_once 'Mail/RFC822.php'; - - // if we're passed an array, assume addresses are valid and - // implode them before parsing. - if (is_array($recipients)) { - $recipients = implode(', ', $recipients); - } - - // Parse recipients, leaving out all personal info. This is - // for smtp recipients, etc. All relevant personal information - // should already be in the headers. - $addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false); - - // If parseAddressList() returned a PEAR_Error object, just return it. - if (is_a($addresses, 'PEAR_Error')) { - return $addresses; - } - - $recipients = array(); - if (is_array($addresses)) { - foreach ($addresses as $ob) { - $recipients[] = $ob->mailbox . '@' . $ob->host; - } - } - - return $recipients; - } - -} diff --git a/data/module/Mail/RFC822.php b/data/module/Mail/RFC822.php deleted file mode 100644 index 58d36465cba..00000000000 --- a/data/module/Mail/RFC822.php +++ /dev/null @@ -1,951 +0,0 @@ - - * @author Chuck Hagenbuch - * @author Chuck Hagenbuch - * @version $Revision: 294749 $ - * @license BSD - * @package Mail - */ -class Mail_RFC822 { - - /** - * The address being parsed by the RFC822 object. - * @var string $address - */ - var $address = ''; - - /** - * The default domain to use for unqualified addresses. - * @var string $default_domain - */ - var $default_domain = 'localhost'; - - /** - * Should we return a nested array showing groups, or flatten everything? - * @var boolean $nestGroups - */ - var $nestGroups = true; - - /** - * Whether or not to validate atoms for non-ascii characters. - * @var boolean $validate - */ - var $validate = true; - - /** - * The array of raw addresses built up as we parse. - * @var array $addresses - */ - var $addresses = array(); - - /** - * The final array of parsed address information that we build up. - * @var array $structure - */ - var $structure = array(); - - /** - * The current error message, if any. - * @var string $error - */ - var $error = null; - - /** - * An internal counter/pointer. - * @var integer $index - */ - var $index = null; - - /** - * The number of groups that have been found in the address list. - * @var integer $num_groups - * @access public - */ - var $num_groups = 0; - - /** - * A variable so that we can tell whether or not we're inside a - * Mail_RFC822 object. - * @var boolean $mailRFC822 - */ - var $mailRFC822 = true; - - /** - * A limit after which processing stops - * @var int $limit - */ - var $limit = null; - - /** - * Sets up the object. The address must either be set here or when - * calling parseAddressList(). One or the other. - * - * @access public - * @param string $address The address(es) to validate. - * @param string $default_domain Default domain/host etc. If not supplied, will be set to localhost. - * @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing. - * @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance. - * - * @return object Mail_RFC822 A new Mail_RFC822 object. - */ - function Mail_RFC822($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null) - { - if (isset($address)) $this->address = $address; - if (isset($default_domain)) $this->default_domain = $default_domain; - if (isset($nest_groups)) $this->nestGroups = $nest_groups; - if (isset($validate)) $this->validate = $validate; - if (isset($limit)) $this->limit = $limit; - } - - /** - * Starts the whole process. The address must either be set here - * or when creating the object. One or the other. - * - * @access public - * @param string $address The address(es) to validate. - * @param string $default_domain Default domain/host etc. - * @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing. - * @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance. - * - * @return array A structured array of addresses. - */ - function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null) - { - if (!isset($this) || !isset($this->mailRFC822)) { - $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit); - return $obj->parseAddressList(); - } - - if (isset($address)) $this->address = $address; - if (isset($default_domain)) $this->default_domain = $default_domain; - if (isset($nest_groups)) $this->nestGroups = $nest_groups; - if (isset($validate)) $this->validate = $validate; - if (isset($limit)) $this->limit = $limit; - - $this->structure = array(); - $this->addresses = array(); - $this->error = null; - $this->index = null; - - // Unfold any long lines in $this->address. - $this->address = preg_replace('/\r?\n/', "\r\n", $this->address); - $this->address = preg_replace('/\r\n(\t| )+/', ' ', $this->address); - - while ($this->address = $this->_splitAddresses($this->address)); - - if ($this->address === false || isset($this->error)) { - require_once 'PEAR.php'; - return PEAR::raiseError($this->error); - } - - // Validate each address individually. If we encounter an invalid - // address, stop iterating and return an error immediately. - foreach ($this->addresses as $address) { - $valid = $this->_validateAddress($address); - - if ($valid === false || isset($this->error)) { - require_once 'PEAR.php'; - return PEAR::raiseError($this->error); - } - - if (!$this->nestGroups) { - $this->structure = array_merge($this->structure, $valid); - } else { - $this->structure[] = $valid; - } - } - - return $this->structure; - } - - /** - * Splits an address into separate addresses. - * - * @access private - * @param string $address The addresses to split. - * @return boolean Success or failure. - */ - function _splitAddresses($address) - { - if (!empty($this->limit) && count($this->addresses) == $this->limit) { - return ''; - } - - if ($this->_isGroup($address) && !isset($this->error)) { - $split_char = ';'; - $is_group = true; - } elseif (!isset($this->error)) { - $split_char = ','; - $is_group = false; - } elseif (isset($this->error)) { - return false; - } - - // Split the string based on the above ten or so lines. - $parts = explode($split_char, $address); - $string = $this->_splitCheck($parts, $split_char); - - // If a group... - if ($is_group) { - // If $string does not contain a colon outside of - // brackets/quotes etc then something's fubar. - - // First check there's a colon at all: - if (strpos($string, ':') === false) { - $this->error = 'Invalid address: ' . $string; - return false; - } - - // Now check it's outside of brackets/quotes: - if (!$this->_splitCheck(explode(':', $string), ':')) { - return false; - } - - // We must have a group at this point, so increase the counter: - $this->num_groups++; - } - - // $string now contains the first full address/group. - // Add to the addresses array. - $this->addresses[] = array( - 'address' => trim($string), - 'group' => $is_group - ); - - // Remove the now stored address from the initial line, the +1 - // is to account for the explode character. - $address = trim(substr($address, strlen($string) + 1)); - - // If the next char is a comma and this was a group, then - // there are more addresses, otherwise, if there are any more - // chars, then there is another address. - if ($is_group && substr($address, 0, 1) == ','){ - $address = trim(substr($address, 1)); - return $address; - - } elseif (strlen($address) > 0) { - return $address; - - } else { - return ''; - } - - // If you got here then something's off - return false; - } - - /** - * Checks for a group at the start of the string. - * - * @access private - * @param string $address The address to check. - * @return boolean Whether or not there is a group at the start of the string. - */ - function _isGroup($address) - { - // First comma not in quotes, angles or escaped: - $parts = explode(',', $address); - $string = $this->_splitCheck($parts, ','); - - // Now we have the first address, we can reliably check for a - // group by searching for a colon that's not escaped or in - // quotes or angle brackets. - if (count($parts = explode(':', $string)) > 1) { - $string2 = $this->_splitCheck($parts, ':'); - return ($string2 !== $string); - } else { - return false; - } - } - - /** - * A common function that will check an exploded string. - * - * @access private - * @param array $parts The exloded string. - * @param string $char The char that was exploded on. - * @return mixed False if the string contains unclosed quotes/brackets, or the string on success. - */ - function _splitCheck($parts, $char) - { - $string = $parts[0]; - - for ($i = 0; $i < count($parts); $i++) { - if ($this->_hasUnclosedQuotes($string) - || $this->_hasUnclosedBrackets($string, '<>') - || $this->_hasUnclosedBrackets($string, '[]') - || $this->_hasUnclosedBrackets($string, '()') - || substr($string, -1) == '\\') { - if (isset($parts[$i + 1])) { - $string = $string . $char . $parts[$i + 1]; - } else { - $this->error = 'Invalid address spec. Unclosed bracket or quotes'; - return false; - } - } else { - $this->index = $i; - break; - } - } - - return $string; - } - - /** - * Checks if a string has unclosed quotes or not. - * - * @access private - * @param string $string The string to check. - * @return boolean True if there are unclosed quotes inside the string, - * false otherwise. - */ - function _hasUnclosedQuotes($string) - { - $string = trim($string); - $iMax = strlen($string); - $in_quote = false; - $i = $slashes = 0; - - for (; $i < $iMax; ++$i) { - switch ($string[$i]) { - case '\\': - ++$slashes; - break; - - case '"': - if ($slashes % 2 == 0) { - $in_quote = !$in_quote; - } - // Fall through to default action below. - - default: - $slashes = 0; - break; - } - } - - return $in_quote; - } - - /** - * Checks if a string has an unclosed brackets or not. IMPORTANT: - * This function handles both angle brackets and square brackets; - * - * @access private - * @param string $string The string to check. - * @param string $chars The characters to check for. - * @return boolean True if there are unclosed brackets inside the string, false otherwise. - */ - function _hasUnclosedBrackets($string, $chars) - { - $num_angle_start = substr_count($string, $chars[0]); - $num_angle_end = substr_count($string, $chars[1]); - - $this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]); - $this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]); - - if ($num_angle_start < $num_angle_end) { - $this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')'; - return false; - } else { - return ($num_angle_start > $num_angle_end); - } - } - - /** - * Sub function that is used only by hasUnclosedBrackets(). - * - * @access private - * @param string $string The string to check. - * @param integer &$num The number of occurences. - * @param string $char The character to count. - * @return integer The number of occurences of $char in $string, adjusted for backslashes. - */ - function _hasUnclosedBracketsSub($string, &$num, $char) - { - $parts = explode($char, $string); - for ($i = 0; $i < count($parts); $i++){ - if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i])) - $num--; - if (isset($parts[$i + 1])) - $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1]; - } - - return $num; - } - - /** - * Function to begin checking the address. - * - * @access private - * @param string $address The address to validate. - * @return mixed False on failure, or a structured array of address information on success. - */ - function _validateAddress($address) - { - $is_group = false; - $addresses = array(); - - if ($address['group']) { - $is_group = true; - - // Get the group part of the name - $parts = explode(':', $address['address']); - $groupname = $this->_splitCheck($parts, ':'); - $structure = array(); - - // And validate the group part of the name. - if (!$this->_validatePhrase($groupname)){ - $this->error = 'Group name did not validate.'; - return false; - } else { - // Don't include groups if we are not nesting - // them. This avoids returning invalid addresses. - if ($this->nestGroups) { - $structure = new stdClass; - $structure->groupname = $groupname; - } - } - - $address['address'] = ltrim(substr($address['address'], strlen($groupname . ':'))); - } - - // If a group then split on comma and put into an array. - // Otherwise, Just put the whole address in an array. - if ($is_group) { - while (strlen($address['address']) > 0) { - $parts = explode(',', $address['address']); - $addresses[] = $this->_splitCheck($parts, ','); - $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ','))); - } - } else { - $addresses[] = $address['address']; - } - - // Check that $addresses is set, if address like this: - // Groupname:; - // Then errors were appearing. - if (!count($addresses)){ - $this->error = 'Empty group.'; - return false; - } - - // Trim the whitespace from all of the address strings. - array_map('trim', $addresses); - - // Validate each mailbox. - // Format could be one of: name - // geezer@domain.com - // geezer - // ... or any other format valid by RFC 822. - for ($i = 0; $i < count($addresses); $i++) { - if (!$this->validateMailbox($addresses[$i])) { - if (empty($this->error)) { - $this->error = 'Validation failed for: ' . $addresses[$i]; - } - return false; - } - } - - // Nested format - if ($this->nestGroups) { - if ($is_group) { - $structure->addresses = $addresses; - } else { - $structure = $addresses[0]; - } - - // Flat format - } else { - if ($is_group) { - $structure = array_merge($structure, $addresses); - } else { - $structure = $addresses; - } - } - - return $structure; - } - - /** - * Function to validate a phrase. - * - * @access private - * @param string $phrase The phrase to check. - * @return boolean Success or failure. - */ - function _validatePhrase($phrase) - { - // Splits on one or more Tab or space. - $parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY); - - $phrase_parts = array(); - while (count($parts) > 0){ - $phrase_parts[] = $this->_splitCheck($parts, ' '); - for ($i = 0; $i < $this->index + 1; $i++) - array_shift($parts); - } - - foreach ($phrase_parts as $part) { - // If quoted string: - if (substr($part, 0, 1) == '"') { - if (!$this->_validateQuotedString($part)) { - return false; - } - continue; - } - - // Otherwise it's an atom: - if (!$this->_validateAtom($part)) return false; - } - - return true; - } - - /** - * Function to validate an atom which from rfc822 is: - * atom = 1* - * - * If validation ($this->validate) has been turned off, then - * validateAtom() doesn't actually check anything. This is so that you - * can split a list of addresses up before encoding personal names - * (umlauts, etc.), for example. - * - * @access private - * @param string $atom The string to check. - * @return boolean Success or failure. - */ - function _validateAtom($atom) - { - if (!$this->validate) { - // Validation has been turned off; assume the atom is okay. - return true; - } - - // Check for any char from ASCII 0 - ASCII 127 - if (!preg_match('/^[\\x00-\\x7E]+$/i', $atom, $matches)) { - return false; - } - - // Check for specials: - if (preg_match('/[][()<>@,;\\:". ]/', $atom)) { - return false; - } - - // Check for control characters (ASCII 0-31): - if (preg_match('/[\\x00-\\x1F]+/', $atom)) { - return false; - } - - return true; - } - - /** - * Function to validate quoted string, which is: - * quoted-string = <"> *(qtext/quoted-pair) <"> - * - * @access private - * @param string $qstring The string to check - * @return boolean Success or failure. - */ - function _validateQuotedString($qstring) - { - // Leading and trailing " - $qstring = substr($qstring, 1, -1); - - // Perform check, removing quoted characters first. - return !preg_match('/[\x0D\\\\"]/', preg_replace('/\\\\./', '', $qstring)); - } - - /** - * Function to validate a mailbox, which is: - * mailbox = addr-spec ; simple address - * / phrase route-addr ; name and route-addr - * - * @access public - * @param string &$mailbox The string to check. - * @return boolean Success or failure. - */ - function validateMailbox(&$mailbox) - { - // A couple of defaults. - $phrase = ''; - $comment = ''; - $comments = array(); - - // Catch any RFC822 comments and store them separately. - $_mailbox = $mailbox; - while (strlen(trim($_mailbox)) > 0) { - $parts = explode('(', $_mailbox); - $before_comment = $this->_splitCheck($parts, '('); - if ($before_comment != $_mailbox) { - // First char should be a (. - $comment = substr(str_replace($before_comment, '', $_mailbox), 1); - $parts = explode(')', $comment); - $comment = $this->_splitCheck($parts, ')'); - $comments[] = $comment; - - // +2 is for the brackets - $_mailbox = substr($_mailbox, strpos($_mailbox, '('.$comment)+strlen($comment)+2); - } else { - break; - } - } - - foreach ($comments as $comment) { - $mailbox = str_replace("($comment)", '', $mailbox); - } - - $mailbox = trim($mailbox); - - // Check for name + route-addr - if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') { - $parts = explode('<', $mailbox); - $name = $this->_splitCheck($parts, '<'); - - $phrase = trim($name); - $route_addr = trim(substr($mailbox, strlen($name.'<'), -1)); - - if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false) { - return false; - } - - // Only got addr-spec - } else { - // First snip angle brackets if present. - if (substr($mailbox, 0, 1) == '<' && substr($mailbox, -1) == '>') { - $addr_spec = substr($mailbox, 1, -1); - } else { - $addr_spec = $mailbox; - } - - if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { - return false; - } - } - - // Construct the object that will be returned. - $mbox = new stdClass(); - - // Add the phrase (even if empty) and comments - $mbox->personal = $phrase; - $mbox->comment = isset($comments) ? $comments : array(); - - if (isset($route_addr)) { - $mbox->mailbox = $route_addr['local_part']; - $mbox->host = $route_addr['domain']; - $route_addr['adl'] !== '' ? $mbox->adl = $route_addr['adl'] : ''; - } else { - $mbox->mailbox = $addr_spec['local_part']; - $mbox->host = $addr_spec['domain']; - } - - $mailbox = $mbox; - return true; - } - - /** - * This function validates a route-addr which is: - * route-addr = "<" [route] addr-spec ">" - * - * Angle brackets have already been removed at the point of - * getting to this function. - * - * @access private - * @param string $route_addr The string to check. - * @return mixed False on failure, or an array containing validated address/route information on success. - */ - function _validateRouteAddr($route_addr) - { - // Check for colon. - if (strpos($route_addr, ':') !== false) { - $parts = explode(':', $route_addr); - $route = $this->_splitCheck($parts, ':'); - } else { - $route = $route_addr; - } - - // If $route is same as $route_addr then the colon was in - // quotes or brackets or, of course, non existent. - if ($route === $route_addr){ - unset($route); - $addr_spec = $route_addr; - if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { - return false; - } - } else { - // Validate route part. - if (($route = $this->_validateRoute($route)) === false) { - return false; - } - - $addr_spec = substr($route_addr, strlen($route . ':')); - - // Validate addr-spec part. - if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { - return false; - } - } - - if (isset($route)) { - $return['adl'] = $route; - } else { - $return['adl'] = ''; - } - - $return = array_merge($return, $addr_spec); - return $return; - } - - /** - * Function to validate a route, which is: - * route = 1#("@" domain) ":" - * - * @access private - * @param string $route The string to check. - * @return mixed False on failure, or the validated $route on success. - */ - function _validateRoute($route) - { - // Split on comma. - $domains = explode(',', trim($route)); - - foreach ($domains as $domain) { - $domain = str_replace('@', '', trim($domain)); - if (!$this->_validateDomain($domain)) return false; - } - - return $route; - } - - /** - * Function to validate a domain, though this is not quite what - * you expect of a strict internet domain. - * - * domain = sub-domain *("." sub-domain) - * - * @access private - * @param string $domain The string to check. - * @return mixed False on failure, or the validated domain on success. - */ - function _validateDomain($domain) - { - // Note the different use of $subdomains and $sub_domains - $subdomains = explode('.', $domain); - - while (count($subdomains) > 0) { - $sub_domains[] = $this->_splitCheck($subdomains, '.'); - for ($i = 0; $i < $this->index + 1; $i++) - array_shift($subdomains); - } - - foreach ($sub_domains as $sub_domain) { - if (!$this->_validateSubdomain(trim($sub_domain))) - return false; - } - - // Managed to get here, so return input. - return $domain; - } - - /** - * Function to validate a subdomain: - * subdomain = domain-ref / domain-literal - * - * @access private - * @param string $subdomain The string to check. - * @return boolean Success or failure. - */ - function _validateSubdomain($subdomain) - { - if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){ - if (!$this->_validateDliteral($arr[1])) return false; - } else { - if (!$this->_validateAtom($subdomain)) return false; - } - - // Got here, so return successful. - return true; - } - - /** - * Function to validate a domain literal: - * domain-literal = "[" *(dtext / quoted-pair) "]" - * - * @access private - * @param string $dliteral The string to check. - * @return boolean Success or failure. - */ - function _validateDliteral($dliteral) - { - return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\'; - } - - /** - * Function to validate an addr-spec. - * - * addr-spec = local-part "@" domain - * - * @access private - * @param string $addr_spec The string to check. - * @return mixed False on failure, or the validated addr-spec on success. - */ - function _validateAddrSpec($addr_spec) - { - $addr_spec = trim($addr_spec); - - // Split on @ sign if there is one. - if (strpos($addr_spec, '@') !== false) { - $parts = explode('@', $addr_spec); - $local_part = $this->_splitCheck($parts, '@'); - $domain = substr($addr_spec, strlen($local_part . '@')); - - // No @ sign so assume the default domain. - } else { - $local_part = $addr_spec; - $domain = $this->default_domain; - } - - if (($local_part = $this->_validateLocalPart($local_part)) === false) return false; - if (($domain = $this->_validateDomain($domain)) === false) return false; - - // Got here so return successful. - return array('local_part' => $local_part, 'domain' => $domain); - } - - /** - * Function to validate the local part of an address: - * local-part = word *("." word) - * - * @access private - * @param string $local_part - * @return mixed False on failure, or the validated local part on success. - */ - function _validateLocalPart($local_part) - { - $parts = explode('.', $local_part); - $words = array(); - - // Split the local_part into words. - while (count($parts) > 0){ - $words[] = $this->_splitCheck($parts, '.'); - for ($i = 0; $i < $this->index + 1; $i++) { - array_shift($parts); - } - } - - // Validate each word. - foreach ($words as $word) { - // If this word contains an unquoted space, it is invalid. (6.2.4) - if (strpos($word, ' ') && $word[0] !== '"') - { - return false; - } - - if ($this->_validatePhrase(trim($word)) === false) return false; - } - - // Managed to get here, so return the input. - return $local_part; - } - - /** - * Returns an approximate count of how many addresses are in the - * given string. This is APPROXIMATE as it only splits based on a - * comma which has no preceding backslash. Could be useful as - * large amounts of addresses will end up producing *large* - * structures when used with parseAddressList(). - * - * @param string $data Addresses to count - * @return int Approximate count - */ - function approximateCount($data) - { - return count(preg_split('/(?@. This can be sufficient for most - * people. Optional stricter mode can be utilised which restricts - * mailbox characters allowed to alphanumeric, full stop, hyphen - * and underscore. - * - * @param string $data Address to check - * @param boolean $strict Optional stricter mode - * @return mixed False if it fails, an indexed array - * username/domain if it matches - */ - function isValidInetAddress($data, $strict = false) - { - $regex = $strict ? '/^([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i'; - if (preg_match($regex, trim($data), $matches)) { - return array($matches[1], $matches[2]); - } else { - return false; - } - } - -} diff --git a/data/module/Mail/mail.php b/data/module/Mail/mail.php deleted file mode 100644 index 17547064259..00000000000 --- a/data/module/Mail/mail.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @copyright 2010 Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/Mail/ - */ - -/** - * internal PHP-mail() implementation of the PEAR Mail:: interface. - * @package Mail - * @version $Revision$ - */ -class Mail_mail extends Mail { - - /** - * Any arguments to pass to the mail() function. - * @var string - */ - var $_params = ''; - - /** - * Constructor. - * - * Instantiates a new Mail_mail:: object based on the parameters - * passed in. - * - * @param array $params Extra arguments for the mail() function. - */ - function Mail_mail($params = null) - { - // The other mail implementations accept parameters as arrays. - // In the interest of being consistent, explode an array into - // a string of parameter arguments. - if (is_array($params)) { - $this->_params = join(' ', $params); - } else { - $this->_params = $params; - } - - /* Because the mail() function may pass headers as command - * line arguments, we can't guarantee the use of the standard - * "\r\n" separator. Instead, we use the system's native line - * separator. */ - if (defined('PHP_EOL')) { - $this->sep = PHP_EOL; - } else { - $this->sep = (strpos(PHP_OS, 'WIN') === false) ? "\n" : "\r\n"; - } - } - - /** - * Implements Mail_mail::send() function using php's built-in mail() - * command. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (ie, 'Subject'), and the array value - * is the header value (ie, 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * - * @access public - */ - function send($recipients, $headers, $body) - { - if (!is_array($headers)) { - return PEAR::raiseError('$headers must be an array'); - } - - $result = $this->_sanitizeHeaders($headers); - if (is_a($result, 'PEAR_Error')) { - return $result; - } - - // If we're passed an array of recipients, implode it. - if (is_array($recipients)) { - $recipients = implode(', ', $recipients); - } - - // Get the Subject out of the headers array so that we can - // pass it as a seperate argument to mail(). - $subject = ''; - if (isset($headers['Subject'])) { - $subject = $headers['Subject']; - unset($headers['Subject']); - } - - // Also remove the To: header. The mail() function will add its own - // To: header based on the contents of $recipients. - unset($headers['To']); - - // Flatten the headers out. - $headerElements = $this->prepareHeaders($headers); - if (is_a($headerElements, 'PEAR_Error')) { - return $headerElements; - } - list(, $text_headers) = $headerElements; - - // We only use mail()'s optional fifth parameter if the additional - // parameters have been provided and we're not running in safe mode. - if (empty($this->_params) || ini_get('safe_mode')) { - $result = mail($recipients, $subject, $body, $text_headers); - } else { - $result = mail($recipients, $subject, $body, $text_headers, - $this->_params); - } - - // If the mail() function returned failure, we need to create a - // PEAR_Error object and return it instead of the boolean result. - if ($result === false) { - $result = PEAR::raiseError('mail() returned failure'); - } - - return $result; - } - -} diff --git a/data/module/Mail/mime.php b/data/module/Mail/mime.php deleted file mode 100644 index c5dd305fab8..00000000000 --- a/data/module/Mail/mime.php +++ /dev/null @@ -1,1468 +0,0 @@ - - * Copyright (c) 2003-2006, PEAR - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - Neither the name of the authors, nor the names of its contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - * @category Mail - * @package Mail_Mime - * @author Richard Heyes - * @author Tomas V.V. Cox - * @author Cipriano Groenendal - * @author Sean Coates - * @author Aleksander Machniak - * @copyright 2003-2006 PEAR - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/Mail_mime - * - * This class is based on HTML Mime Mail class from - * Richard Heyes which was based also - * in the mime_mail.class by Tobias Ratschiller - * and Sascha Schumann - */ - - -/** - * require PEAR - * - * This package depends on PEAR to raise errors. - */ -require_once 'PEAR.php'; - -/** - * require Mail_mimePart - * - * Mail_mimePart contains the code required to - * create all the different parts a mail can - * consist of. - */ -require_once 'Mail/mimePart.php'; - - -/** - * The Mail_Mime class provides an OO interface to create MIME - * enabled email messages. This way you can create emails that - * contain plain-text bodies, HTML bodies, attachments, inline - * images and specific headers. - * - * @category Mail - * @package Mail_Mime - * @author Richard Heyes - * @author Tomas V.V. Cox - * @author Cipriano Groenendal - * @author Sean Coates - * @copyright 2003-2006 PEAR - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/Mail_mime - */ -class Mail_mime -{ - /** - * Contains the plain text part of the email - * - * @var string - * @access private - */ - var $_txtbody; - - /** - * Contains the html part of the email - * - * @var string - * @access private - */ - var $_htmlbody; - - /** - * list of the attached images - * - * @var array - * @access private - */ - var $_html_images = array(); - - /** - * list of the attachements - * - * @var array - * @access private - */ - var $_parts = array(); - - /** - * Headers for the mail - * - * @var array - * @access private - */ - var $_headers = array(); - - /** - * Build parameters - * - * @var array - * @access private - */ - var $_build_params = array( - // What encoding to use for the headers - // Options: quoted-printable or base64 - 'head_encoding' => 'quoted-printable', - // What encoding to use for plain text - // Options: 7bit, 8bit, base64, or quoted-printable - 'text_encoding' => 'quoted-printable', - // What encoding to use for html - // Options: 7bit, 8bit, base64, or quoted-printable - 'html_encoding' => 'quoted-printable', - // The character set to use for html - 'html_charset' => 'ISO-8859-1', - // The character set to use for text - 'text_charset' => 'ISO-8859-1', - // The character set to use for headers - 'head_charset' => 'ISO-8859-1', - // End-of-line sequence - 'eol' => "\r\n", - // Delay attachment files IO until building the message - 'delay_file_io' => false - ); - - /** - * Constructor function - * - * @param mixed $params Build parameters that change the way the email - * is built. Should be an associative array. - * See $_build_params. - * - * @return void - * @access public - */ - function Mail_mime($params = array()) - { - // Backward-compatible EOL setting - if (is_string($params)) { - $this->_build_params['eol'] = $params; - } else if (defined('MAIL_MIME_CRLF') && !isset($params['eol'])) { - $this->_build_params['eol'] = MAIL_MIME_CRLF; - } - - // Update build parameters - if (!empty($params) && is_array($params)) { - while (list($key, $value) = each($params)) { - $this->_build_params[$key] = $value; - } - } - } - - /** - * Set build parameter value - * - * @param string $name Parameter name - * @param string $value Parameter value - * - * @return void - * @access public - * @since 1.6.0 - */ - function setParam($name, $value) - { - $this->_build_params[$name] = $value; - } - - /** - * Get build parameter value - * - * @param string $name Parameter name - * - * @return mixed Parameter value - * @access public - * @since 1.6.0 - */ - function getParam($name) - { - return isset($this->_build_params[$name]) ? $this->_build_params[$name] : null; - } - - /** - * Accessor function to set the body text. Body text is used if - * it's not an html mail being sent or else is used to fill the - * text/plain part that emails clients who don't support - * html should show. - * - * @param string $data Either a string or - * the file name with the contents - * @param bool $isfile If true the first param should be treated - * as a file name, else as a string (default) - * @param bool $append If true the text or file is appended to - * the existing body, else the old body is - * overwritten - * - * @return mixed True on success or PEAR_Error object - * @access public - */ - function setTXTBody($data, $isfile = false, $append = false) - { - if (!$isfile) { - if (!$append) { - $this->_txtbody = $data; - } else { - $this->_txtbody .= $data; - } - } else { - $cont = $this->_file2str($data); - if (PEAR::isError($cont)) { - return $cont; - } - if (!$append) { - $this->_txtbody = $cont; - } else { - $this->_txtbody .= $cont; - } - } - return true; - } - - /** - * Get message text body - * - * @return string Text body - * @access public - * @since 1.6.0 - */ - function getTXTBody() - { - return $this->_txtbody; - } - - /** - * Adds a html part to the mail. - * - * @param string $data Either a string or the file name with the - * contents - * @param bool $isfile A flag that determines whether $data is a - * filename, or a string(false, default) - * - * @return bool True on success - * @access public - */ - function setHTMLBody($data, $isfile = false) - { - if (!$isfile) { - $this->_htmlbody = $data; - } else { - $cont = $this->_file2str($data); - if (PEAR::isError($cont)) { - return $cont; - } - $this->_htmlbody = $cont; - } - - return true; - } - - /** - * Get message HTML body - * - * @return string HTML body - * @access public - * @since 1.6.0 - */ - function getHTMLBody() - { - return $this->_htmlbody; - } - - /** - * Adds an image to the list of embedded images. - * - * @param string $file The image file name OR image data itself - * @param string $c_type The content type - * @param string $name The filename of the image. - * Only used if $file is the image data. - * @param bool $isfile Whether $file is a filename or not. - * Defaults to true - * @param string $content_id Desired Content-ID of MIME part - * Defaults to generated unique ID - * - * @return bool True on success - * @access public - */ - function addHTMLImage($file, - $c_type='application/octet-stream', - $name = '', - $isfile = true, - $content_id = null - ) { - $bodyfile = null; - - if ($isfile) { - // Don't load file into memory - if ($this->_build_params['delay_file_io']) { - $filedata = null; - $bodyfile = $file; - } else { - if (PEAR::isError($filedata = $this->_file2str($file))) { - return $filedata; - } - } - $filename = ($name ? $name : $file); - } else { - $filedata = $file; - $filename = $name; - } - - if (!$content_id) { - $content_id = md5(uniqid(time())); - } - - $this->_html_images[] = array( - 'body' => $filedata, - 'body_file' => $bodyfile, - 'name' => $filename, - 'c_type' => $c_type, - 'cid' => $content_id - ); - - return true; - } - - /** - * Adds a file to the list of attachments. - * - * @param string $file The file name of the file to attach - * or the file contents itself - * @param string $c_type The content type - * @param string $name The filename of the attachment - * Only use if $file is the contents - * @param bool $isfile Whether $file is a filename or not. Defaults to true - * @param string $encoding The type of encoding to use. Defaults to base64. - * Possible values: 7bit, 8bit, base64 or quoted-printable. - * @param string $disposition The content-disposition of this file - * Defaults to attachment. - * Possible values: attachment, inline. - * @param string $charset The character set of attachment's content. - * @param string $language The language of the attachment - * @param string $location The RFC 2557.4 location of the attachment - * @param string $n_encoding Encoding of the attachment's name in Content-Type - * By default filenames are encoded using RFC2231 method - * Here you can set RFC2047 encoding (quoted-printable - * or base64) instead - * @param string $f_encoding Encoding of the attachment's filename - * in Content-Disposition header. - * @param string $description Content-Description header - * @param string $h_charset The character set of the headers e.g. filename - * If not specified, $charset will be used - * - * @return mixed True on success or PEAR_Error object - * @access public - */ - function addAttachment($file, - $c_type = 'application/octet-stream', - $name = '', - $isfile = true, - $encoding = 'base64', - $disposition = 'attachment', - $charset = '', - $language = '', - $location = '', - $n_encoding = null, - $f_encoding = null, - $description = '', - $h_charset = null - ) { - $bodyfile = null; - - if ($isfile) { - // Don't load file into memory - if ($this->_build_params['delay_file_io']) { - $filedata = null; - $bodyfile = $file; - } else { - if (PEAR::isError($filedata = $this->_file2str($file))) { - return $filedata; - } - } - // Force the name the user supplied, otherwise use $file - $filename = ($name ? $name : $file); - } else { - $filedata = $file; - $filename = $name; - } - - if (!strlen($filename)) { - $msg = "The supplied filename for the attachment can't be empty"; - $err = PEAR::raiseError($msg); - return $err; - } - $filename = $this->_basename($filename); - - $this->_parts[] = array( - 'body' => $filedata, - 'body_file' => $bodyfile, - 'name' => $filename, - 'c_type' => $c_type, - 'charset' => $charset, - 'encoding' => $encoding, - 'language' => $language, - 'location' => $location, - 'disposition' => $disposition, - 'description' => $description, - 'name_encoding' => $n_encoding, - 'filename_encoding' => $f_encoding, - 'headers_charset' => $h_charset, - ); - - return true; - } - - /** - * Get the contents of the given file name as string - * - * @param string $file_name Path of file to process - * - * @return string Contents of $file_name - * @access private - */ - function &_file2str($file_name) - { - // Check state of file and raise an error properly - if (!file_exists($file_name)) { - $err = PEAR::raiseError('File not found: ' . $file_name); - return $err; - } - if (!is_file($file_name)) { - $err = PEAR::raiseError('Not a regular file: ' . $file_name); - return $err; - } - if (!is_readable($file_name)) { - $err = PEAR::raiseError('File is not readable: ' . $file_name); - return $err; - } - - // Temporarily reset magic_quotes_runtime and read file contents - if ($magic_quote_setting = get_magic_quotes_runtime()) { - @ini_set('magic_quotes_runtime', 0); - } - $cont = file_get_contents($file_name); - if ($magic_quote_setting) { - @ini_set('magic_quotes_runtime', $magic_quote_setting); - } - - return $cont; - } - - /** - * Adds a text subpart to the mimePart object and - * returns it during the build process. - * - * @param mixed &$obj The object to add the part to, or - * null if a new object is to be created. - * @param string $text The text to add. - * - * @return object The text mimePart object - * @access private - */ - function &_addTextPart(&$obj, $text) - { - $params['content_type'] = 'text/plain'; - $params['encoding'] = $this->_build_params['text_encoding']; - $params['charset'] = $this->_build_params['text_charset']; - $params['eol'] = $this->_build_params['eol']; - - if (is_object($obj)) { - $ret = $obj->addSubpart($text, $params); - return $ret; - } else { - $ret = new Mail_mimePart($text, $params); - return $ret; - } - } - - /** - * Adds a html subpart to the mimePart object and - * returns it during the build process. - * - * @param mixed &$obj The object to add the part to, or - * null if a new object is to be created. - * - * @return object The html mimePart object - * @access private - */ - function &_addHtmlPart(&$obj) - { - $params['content_type'] = 'text/html'; - $params['encoding'] = $this->_build_params['html_encoding']; - $params['charset'] = $this->_build_params['html_charset']; - $params['eol'] = $this->_build_params['eol']; - - if (is_object($obj)) { - $ret = $obj->addSubpart($this->_htmlbody, $params); - return $ret; - } else { - $ret = new Mail_mimePart($this->_htmlbody, $params); - return $ret; - } - } - - /** - * Creates a new mimePart object, using multipart/mixed as - * the initial content-type and returns it during the - * build process. - * - * @return object The multipart/mixed mimePart object - * @access private - */ - function &_addMixedPart() - { - $params = array(); - $params['content_type'] = 'multipart/mixed'; - $params['eol'] = $this->_build_params['eol']; - - // Create empty multipart/mixed Mail_mimePart object to return - $ret = new Mail_mimePart('', $params); - return $ret; - } - - /** - * Adds a multipart/alternative part to a mimePart - * object (or creates one), and returns it during - * the build process. - * - * @param mixed &$obj The object to add the part to, or - * null if a new object is to be created. - * - * @return object The multipart/mixed mimePart object - * @access private - */ - function &_addAlternativePart(&$obj) - { - $params['content_type'] = 'multipart/alternative'; - $params['eol'] = $this->_build_params['eol']; - - if (is_object($obj)) { - return $obj->addSubpart('', $params); - } else { - $ret = new Mail_mimePart('', $params); - return $ret; - } - } - - /** - * Adds a multipart/related part to a mimePart - * object (or creates one), and returns it during - * the build process. - * - * @param mixed &$obj The object to add the part to, or - * null if a new object is to be created - * - * @return object The multipart/mixed mimePart object - * @access private - */ - function &_addRelatedPart(&$obj) - { - $params['content_type'] = 'multipart/related'; - $params['eol'] = $this->_build_params['eol']; - - if (is_object($obj)) { - return $obj->addSubpart('', $params); - } else { - $ret = new Mail_mimePart('', $params); - return $ret; - } - } - - /** - * Adds an html image subpart to a mimePart object - * and returns it during the build process. - * - * @param object &$obj The mimePart to add the image to - * @param array $value The image information - * - * @return object The image mimePart object - * @access private - */ - function &_addHtmlImagePart(&$obj, $value) - { - $params['content_type'] = $value['c_type']; - $params['encoding'] = 'base64'; - $params['disposition'] = 'inline'; - $params['filename'] = $value['name']; - $params['cid'] = $value['cid']; - $params['body_file'] = $value['body_file']; - $params['eol'] = $this->_build_params['eol']; - - if (!empty($value['name_encoding'])) { - $params['name_encoding'] = $value['name_encoding']; - } - if (!empty($value['filename_encoding'])) { - $params['filename_encoding'] = $value['filename_encoding']; - } - - $ret = $obj->addSubpart($value['body'], $params); - return $ret; - } - - /** - * Adds an attachment subpart to a mimePart object - * and returns it during the build process. - * - * @param object &$obj The mimePart to add the image to - * @param array $value The attachment information - * - * @return object The image mimePart object - * @access private - */ - function &_addAttachmentPart(&$obj, $value) - { - $params['eol'] = $this->_build_params['eol']; - $params['filename'] = $value['name']; - $params['encoding'] = $value['encoding']; - $params['content_type'] = $value['c_type']; - $params['body_file'] = $value['body_file']; - $params['disposition'] = isset($value['disposition']) ? - $value['disposition'] : 'attachment'; - - // content charset - if (!empty($value['charset'])) { - $params['charset'] = $value['charset']; - } - // headers charset (filename, description) - if (!empty($value['headers_charset'])) { - $params['headers_charset'] = $value['headers_charset']; - } - if (!empty($value['language'])) { - $params['language'] = $value['language']; - } - if (!empty($value['location'])) { - $params['location'] = $value['location']; - } - if (!empty($value['name_encoding'])) { - $params['name_encoding'] = $value['name_encoding']; - } - if (!empty($value['filename_encoding'])) { - $params['filename_encoding'] = $value['filename_encoding']; - } - if (!empty($value['description'])) { - $params['description'] = $value['description']; - } - - $ret = $obj->addSubpart($value['body'], $params); - return $ret; - } - - /** - * Returns the complete e-mail, ready to send using an alternative - * mail delivery method. Note that only the mailpart that is made - * with Mail_Mime is created. This means that, - * YOU WILL HAVE NO TO: HEADERS UNLESS YOU SET IT YOURSELF - * using the $headers parameter! - * - * @param string $separation The separation between these two parts. - * @param array $params The Build parameters passed to the - * &get() function. See &get for more info. - * @param array $headers The extra headers that should be passed - * to the &headers() function. - * See that function for more info. - * @param bool $overwrite Overwrite the existing headers with new. - * - * @return mixed The complete e-mail or PEAR error object - * @access public - */ - function getMessage($separation = null, $params = null, $headers = null, - $overwrite = false - ) { - if ($separation === null) { - $separation = $this->_build_params['eol']; - } - - $body = $this->get($params); - - if (PEAR::isError($body)) { - return $body; - } - - $head = $this->txtHeaders($headers, $overwrite); - $mail = $head . $separation . $body; - return $mail; - } - - /** - * Returns the complete e-mail body, ready to send using an alternative - * mail delivery method. - * - * @param array $params The Build parameters passed to the - * &get() function. See &get for more info. - * - * @return mixed The e-mail body or PEAR error object - * @access public - * @since 1.6.0 - */ - function getMessageBody($params = null) - { - return $this->get($params, null, true); - } - - /** - * Writes (appends) the complete e-mail into file. - * - * @param string $filename Output file location - * @param array $params The Build parameters passed to the - * &get() function. See &get for more info. - * @param array $headers The extra headers that should be passed - * to the &headers() function. - * See that function for more info. - * @param bool $overwrite Overwrite the existing headers with new. - * - * @return mixed True or PEAR error object - * @access public - * @since 1.6.0 - */ - function saveMessage($filename, $params = null, $headers = null, $overwrite = false) - { - // Check state of file and raise an error properly - if (file_exists($filename) && !is_writable($filename)) { - $err = PEAR::raiseError('File is not writable: ' . $filename); - return $err; - } - - // Temporarily reset magic_quotes_runtime and read file contents - if ($magic_quote_setting = get_magic_quotes_runtime()) { - @ini_set('magic_quotes_runtime', 0); - } - - if (!($fh = fopen($filename, 'ab'))) { - $err = PEAR::raiseError('Unable to open file: ' . $filename); - return $err; - } - - // Write message headers into file (skipping Content-* headers) - $head = $this->txtHeaders($headers, $overwrite, true); - if (fwrite($fh, $head) === false) { - $err = PEAR::raiseError('Error writing to file: ' . $filename); - return $err; - } - - fclose($fh); - - if ($magic_quote_setting) { - @ini_set('magic_quotes_runtime', $magic_quote_setting); - } - - // Write the rest of the message into file - $res = $this->get($params, $filename); - - return $res ? $res : true; - } - - /** - * Writes (appends) the complete e-mail body into file. - * - * @param string $filename Output file location - * @param array $params The Build parameters passed to the - * &get() function. See &get for more info. - * - * @return mixed True or PEAR error object - * @access public - * @since 1.6.0 - */ - function saveMessageBody($filename, $params = null) - { - // Check state of file and raise an error properly - if (file_exists($filename) && !is_writable($filename)) { - $err = PEAR::raiseError('File is not writable: ' . $filename); - return $err; - } - - // Temporarily reset magic_quotes_runtime and read file contents - if ($magic_quote_setting = get_magic_quotes_runtime()) { - @ini_set('magic_quotes_runtime', 0); - } - - if (!($fh = fopen($filename, 'ab'))) { - $err = PEAR::raiseError('Unable to open file: ' . $filename); - return $err; - } - - // Write the rest of the message into file - $res = $this->get($params, $filename, true); - - return $res ? $res : true; - } - - /** - * Builds the multipart message from the list ($this->_parts) and - * returns the mime content. - * - * @param array $params Build parameters that change the way the email - * is built. Should be associative. See $_build_params. - * @param resource $filename Output file where to save the message instead of - * returning it - * @param boolean $skip_head True if you want to return/save only the message - * without headers - * - * @return mixed The MIME message content string, null or PEAR error object - * @access public - */ - function &get($params = null, $filename = null, $skip_head = false) - { - if (isset($params)) { - while (list($key, $value) = each($params)) { - $this->_build_params[$key] = $value; - } - } - - if (isset($this->_headers['From'])) { - // Bug #11381: Illegal characters in domain ID - if (preg_match('#(@[0-9a-zA-Z\-\.]+)#', $this->_headers['From'], $matches)) { - $domainID = $matches[1]; - } else { - $domainID = '@localhost'; - } - foreach ($this->_html_images as $i => $img) { - $cid = $this->_html_images[$i]['cid']; - if (!preg_match('#'.preg_quote($domainID).'$#', $cid)) { - $this->_html_images[$i]['cid'] = $cid . $domainID; - } - } - } - - if (count($this->_html_images) && isset($this->_htmlbody)) { - foreach ($this->_html_images as $key => $value) { - $regex = array(); - $regex[] = '#(\s)((?i)src|background|href(?-i))\s*=\s*(["\']?)' . - preg_quote($value['name'], '#') . '\3#'; - $regex[] = '#(?i)url(?-i)\(\s*(["\']?)' . - preg_quote($value['name'], '#') . '\1\s*\)#'; - - $rep = array(); - $rep[] = '\1\2=\3cid:' . $value['cid'] .'\3'; - $rep[] = 'url(\1cid:' . $value['cid'] . '\1)'; - - $this->_htmlbody = preg_replace($regex, $rep, $this->_htmlbody); - $this->_html_images[$key]['name'] - = $this->_basename($this->_html_images[$key]['name']); - } - } - - $this->_checkParams(); - - $null = null; - $attachments = count($this->_parts) ? true : false; - $html_images = count($this->_html_images) ? true : false; - $html = strlen($this->_htmlbody) ? true : false; - $text = (!$html && strlen($this->_txtbody)) ? true : false; - - switch (true) { - case $text && !$attachments: - $message =& $this->_addTextPart($null, $this->_txtbody); - break; - - case !$text && !$html && $attachments: - $message =& $this->_addMixedPart(); - for ($i = 0; $i < count($this->_parts); $i++) { - $this->_addAttachmentPart($message, $this->_parts[$i]); - } - break; - - case $text && $attachments: - $message =& $this->_addMixedPart(); - $this->_addTextPart($message, $this->_txtbody); - for ($i = 0; $i < count($this->_parts); $i++) { - $this->_addAttachmentPart($message, $this->_parts[$i]); - } - break; - - case $html && !$attachments && !$html_images: - if (isset($this->_txtbody)) { - $message =& $this->_addAlternativePart($null); - $this->_addTextPart($message, $this->_txtbody); - $this->_addHtmlPart($message); - } else { - $message =& $this->_addHtmlPart($null); - } - break; - - case $html && !$attachments && $html_images: - // * Content-Type: multipart/alternative; - // * text - // * Content-Type: multipart/related; - // * html - // * image... - if (isset($this->_txtbody)) { - $message =& $this->_addAlternativePart($null); - $this->_addTextPart($message, $this->_txtbody); - - $ht =& $this->_addRelatedPart($message); - $this->_addHtmlPart($ht); - for ($i = 0; $i < count($this->_html_images); $i++) { - $this->_addHtmlImagePart($ht, $this->_html_images[$i]); - } - } else { - // * Content-Type: multipart/related; - // * html - // * image... - $message =& $this->_addRelatedPart($null); - $this->_addHtmlPart($message); - for ($i = 0; $i < count($this->_html_images); $i++) { - $this->_addHtmlImagePart($message, $this->_html_images[$i]); - } - } - /* - // #13444, #9725: the code below was a non-RFC compliant hack - // * Content-Type: multipart/related; - // * Content-Type: multipart/alternative; - // * text - // * html - // * image... - $message =& $this->_addRelatedPart($null); - if (isset($this->_txtbody)) { - $alt =& $this->_addAlternativePart($message); - $this->_addTextPart($alt, $this->_txtbody); - $this->_addHtmlPart($alt); - } else { - $this->_addHtmlPart($message); - } - for ($i = 0; $i < count($this->_html_images); $i++) { - $this->_addHtmlImagePart($message, $this->_html_images[$i]); - } - */ - break; - - case $html && $attachments && !$html_images: - $message =& $this->_addMixedPart(); - if (isset($this->_txtbody)) { - $alt =& $this->_addAlternativePart($message); - $this->_addTextPart($alt, $this->_txtbody); - $this->_addHtmlPart($alt); - } else { - $this->_addHtmlPart($message); - } - for ($i = 0; $i < count($this->_parts); $i++) { - $this->_addAttachmentPart($message, $this->_parts[$i]); - } - break; - - case $html && $attachments && $html_images: - $message =& $this->_addMixedPart(); - if (isset($this->_txtbody)) { - $alt =& $this->_addAlternativePart($message); - $this->_addTextPart($alt, $this->_txtbody); - $rel =& $this->_addRelatedPart($alt); - } else { - $rel =& $this->_addRelatedPart($message); - } - $this->_addHtmlPart($rel); - for ($i = 0; $i < count($this->_html_images); $i++) { - $this->_addHtmlImagePart($rel, $this->_html_images[$i]); - } - for ($i = 0; $i < count($this->_parts); $i++) { - $this->_addAttachmentPart($message, $this->_parts[$i]); - } - break; - - } - - if (!isset($message)) { - $ret = null; - return $ret; - } - - // Use saved boundary - if (!empty($this->_build_params['boundary'])) { - $boundary = $this->_build_params['boundary']; - } else { - $boundary = null; - } - - // Write output to file - if ($filename) { - // Append mimePart message headers and body into file - $headers = $message->encodeToFile($filename, $boundary, $skip_head); - if (PEAR::isError($headers)) { - return $headers; - } - $this->_headers = array_merge($this->_headers, $headers); - $ret = null; - return $ret; - } else { - $output = $message->encode($boundary, $skip_head); - if (PEAR::isError($output)) { - return $output; - } - $this->_headers = array_merge($this->_headers, $output['headers']); - $body = $output['body']; - return $body; - } - } - - /** - * Returns an array with the headers needed to prepend to the email - * (MIME-Version and Content-Type). Format of argument is: - * $array['header-name'] = 'header-value'; - * - * @param array $xtra_headers Assoc array with any extra headers (optional) - * (Don't set Content-Type for multipart messages here!) - * @param bool $overwrite Overwrite already existing headers. - * @param bool $skip_content Don't return content headers: Content-Type, - * Content-Disposition and Content-Transfer-Encoding - * - * @return array Assoc array with the mime headers - * @access public - */ - function &headers($xtra_headers = null, $overwrite = false, $skip_content = false) - { - // Add mime version header - $headers['MIME-Version'] = '1.0'; - - // Content-Type and Content-Transfer-Encoding headers should already - // be present if get() was called, but we'll re-set them to make sure - // we got them when called before get() or something in the message - // has been changed after get() [#14780] - if (!$skip_content) { - $headers += $this->_contentHeaders(); - } - - if (!empty($xtra_headers)) { - $headers = array_merge($headers, $xtra_headers); - } - - if ($overwrite) { - $this->_headers = array_merge($this->_headers, $headers); - } else { - $this->_headers = array_merge($headers, $this->_headers); - } - - $headers = $this->_headers; - - if ($skip_content) { - unset($headers['Content-Type']); - unset($headers['Content-Transfer-Encoding']); - unset($headers['Content-Disposition']); - } else if (!empty($this->_build_params['ctype'])) { - $headers['Content-Type'] = $this->_build_params['ctype']; - } - - $encodedHeaders = $this->_encodeHeaders($headers); - return $encodedHeaders; - } - - /** - * Get the text version of the headers - * (usefull if you want to use the PHP mail() function) - * - * @param array $xtra_headers Assoc array with any extra headers (optional) - * (Don't set Content-Type for multipart messages here!) - * @param bool $overwrite Overwrite the existing headers with new. - * @param bool $skip_content Don't return content headers: Content-Type, - * Content-Disposition and Content-Transfer-Encoding - * - * @return string Plain text headers - * @access public - */ - function txtHeaders($xtra_headers = null, $overwrite = false, $skip_content = false) - { - $headers = $this->headers($xtra_headers, $overwrite, $skip_content); - - // Place Received: headers at the beginning of the message - // Spam detectors often flag messages with it after the Subject: as spam - if (isset($headers['Received'])) { - $received = $headers['Received']; - unset($headers['Received']); - $headers = array('Received' => $received) + $headers; - } - - $ret = ''; - $eol = $this->_build_params['eol']; - - foreach ($headers as $key => $val) { - if (is_array($val)) { - foreach ($val as $value) { - $ret .= "$key: $value" . $eol; - } - } else { - $ret .= "$key: $val" . $eol; - } - } - - return $ret; - } - - /** - * Sets message Content-Type header. - * Use it to build messages with various content-types e.g. miltipart/raport - * not supported by _contentHeaders() function. - * - * @param string $type Type name - * @param array $params Hash array of header parameters - * - * @return void - * @access public - * @since 1.7.0 - */ - function setContentType($type, $params = array()) - { - $header = $type; - - $eol = !empty($this->_build_params['eol']) - ? $this->_build_params['eol'] : "\r\n"; - - // add parameters - $token_regexp = '#([^\x21,\x23-\x27,\x2A,\x2B,\x2D' - . ',\x2E,\x30-\x39,\x41-\x5A,\x5E-\x7E])#'; - if (is_array($params)) { - foreach ($params as $name => $value) { - if ($name == 'boundary') { - $this->_build_params['boundary'] = $value; - } - if (!preg_match($token_regexp, $value)) { - $header .= ";$eol $name=$value"; - } else { - $value = addcslashes($value, '\\"'); - $header .= ";$eol $name=\"$value\""; - } - } - } - - // add required boundary parameter if not defined - if (preg_match('/^multipart\//i', $type)) { - if (empty($this->_build_params['boundary'])) { - $this->_build_params['boundary'] = '=_' . md5(rand() . microtime()); - } - - $header .= ";$eol boundary=\"".$this->_build_params['boundary']."\""; - } - - $this->_build_params['ctype'] = $header; - } - - /** - * Sets the Subject header - * - * @param string $subject String to set the subject to. - * - * @return void - * @access public - */ - function setSubject($subject) - { - $this->_headers['Subject'] = $subject; - } - - /** - * Set an email to the From (the sender) header - * - * @param string $email The email address to use - * - * @return void - * @access public - */ - function setFrom($email) - { - $this->_headers['From'] = $email; - } - - /** - * Add an email to the To header - * (multiple calls to this method are allowed) - * - * @param string $email The email direction to add - * - * @return void - * @access public - */ - function addTo($email) - { - if (isset($this->_headers['To'])) { - $this->_headers['To'] .= ", $email"; - } else { - $this->_headers['To'] = $email; - } - } - - /** - * Add an email to the Cc (carbon copy) header - * (multiple calls to this method are allowed) - * - * @param string $email The email direction to add - * - * @return void - * @access public - */ - function addCc($email) - { - if (isset($this->_headers['Cc'])) { - $this->_headers['Cc'] .= ", $email"; - } else { - $this->_headers['Cc'] = $email; - } - } - - /** - * Add an email to the Bcc (blank carbon copy) header - * (multiple calls to this method are allowed) - * - * @param string $email The email direction to add - * - * @return void - * @access public - */ - function addBcc($email) - { - if (isset($this->_headers['Bcc'])) { - $this->_headers['Bcc'] .= ", $email"; - } else { - $this->_headers['Bcc'] = $email; - } - } - - /** - * Since the PHP send function requires you to specify - * recipients (To: header) separately from the other - * headers, the To: header is not properly encoded. - * To fix this, you can use this public method to - * encode your recipients before sending to the send - * function - * - * @param string $recipients A comma-delimited list of recipients - * - * @return string Encoded data - * @access public - */ - function encodeRecipients($recipients) - { - $input = array("To" => $recipients); - $retval = $this->_encodeHeaders($input); - return $retval["To"] ; - } - - /** - * Encodes headers as per RFC2047 - * - * @param array $input The header data to encode - * @param array $params Extra build parameters - * - * @return array Encoded data - * @access private - */ - function _encodeHeaders($input, $params = array()) - { - $build_params = $this->_build_params; - while (list($key, $value) = each($params)) { - $build_params[$key] = $value; - } - - foreach ($input as $hdr_name => $hdr_value) { - if (is_array($hdr_value)) { - foreach ($hdr_value as $idx => $value) { - $input[$hdr_name][$idx] = $this->encodeHeader( - $hdr_name, $value, - $build_params['head_charset'], $build_params['head_encoding'] - ); - } - } else { - $input[$hdr_name] = $this->encodeHeader( - $hdr_name, $hdr_value, - $build_params['head_charset'], $build_params['head_encoding'] - ); - } - } - - return $input; - } - - /** - * Encodes a header as per RFC2047 - * - * @param string $name The header name - * @param string $value The header data to encode - * @param string $charset Character set name - * @param string $encoding Encoding name (base64 or quoted-printable) - * - * @return string Encoded header data (without a name) - * @access public - * @since 1.5.3 - */ - function encodeHeader($name, $value, $charset, $encoding) - { - return Mail_mimePart::encodeHeader( - $name, $value, $charset, $encoding, $this->_build_params['eol'] - ); - } - - /** - * Get file's basename (locale independent) - * - * @param string $filename Filename - * - * @return string Basename - * @access private - */ - function _basename($filename) - { - // basename() is not unicode safe and locale dependent - if (stristr(PHP_OS, 'win') || stristr(PHP_OS, 'netware')) { - return preg_replace('/^.*[\\\\\\/]/', '', $filename); - } else { - return preg_replace('/^.*[\/]/', '', $filename); - } - } - - /** - * Get Content-Type and Content-Transfer-Encoding headers of the message - * - * @return array Headers array - * @access private - */ - function _contentHeaders() - { - $attachments = count($this->_parts) ? true : false; - $html_images = count($this->_html_images) ? true : false; - $html = strlen($this->_htmlbody) ? true : false; - $text = (!$html && strlen($this->_txtbody)) ? true : false; - $headers = array(); - - // See get() - switch (true) { - case $text && !$attachments: - $headers['Content-Type'] = 'text/plain'; - break; - - case !$text && !$html && $attachments: - case $text && $attachments: - case $html && $attachments && !$html_images: - case $html && $attachments && $html_images: - $headers['Content-Type'] = 'multipart/mixed'; - break; - - case $html && !$attachments && !$html_images && isset($this->_txtbody): - case $html && !$attachments && $html_images && isset($this->_txtbody): - $headers['Content-Type'] = 'multipart/alternative'; - break; - - case $html && !$attachments && !$html_images && !isset($this->_txtbody): - $headers['Content-Type'] = 'text/html'; - break; - - case $html && !$attachments && $html_images && !isset($this->_txtbody): - $headers['Content-Type'] = 'multipart/related'; - break; - - default: - return $headers; - } - - $this->_checkParams(); - - $eol = !empty($this->_build_params['eol']) - ? $this->_build_params['eol'] : "\r\n"; - - if ($headers['Content-Type'] == 'text/plain') { - // single-part message: add charset and encoding - $charset = 'charset=' . $this->_build_params['text_charset']; - // place charset parameter in the same line, if possible - // 26 = strlen("Content-Type: text/plain; ") - $headers['Content-Type'] - .= (strlen($charset) + 26 <= 76) ? "; $charset" : ";$eol $charset"; - $headers['Content-Transfer-Encoding'] - = $this->_build_params['text_encoding']; - } else if ($headers['Content-Type'] == 'text/html') { - // single-part message: add charset and encoding - $charset = 'charset=' . $this->_build_params['html_charset']; - // place charset parameter in the same line, if possible - $headers['Content-Type'] - .= (strlen($charset) + 25 <= 76) ? "; $charset" : ";$eol $charset"; - $headers['Content-Transfer-Encoding'] - = $this->_build_params['html_encoding']; - } else { - // multipart message: and boundary - if (!empty($this->_build_params['boundary'])) { - $boundary = $this->_build_params['boundary']; - } else if (!empty($this->_headers['Content-Type']) - && preg_match('/boundary="([^"]+)"/', $this->_headers['Content-Type'], $m) - ) { - $boundary = $m[1]; - } else { - $boundary = '=_' . md5(rand() . microtime()); - } - - $this->_build_params['boundary'] = $boundary; - $headers['Content-Type'] .= ";$eol boundary=\"$boundary\""; - } - - return $headers; - } - - /** - * Validate and set build parameters - * - * @return void - * @access private - */ - function _checkParams() - { - $encodings = array('7bit', '8bit', 'base64', 'quoted-printable'); - - $this->_build_params['text_encoding'] - = strtolower($this->_build_params['text_encoding']); - $this->_build_params['html_encoding'] - = strtolower($this->_build_params['html_encoding']); - - if (!in_array($this->_build_params['text_encoding'], $encodings)) { - $this->_build_params['text_encoding'] = '7bit'; - } - if (!in_array($this->_build_params['html_encoding'], $encodings)) { - $this->_build_params['html_encoding'] = '7bit'; - } - - // text body - if ($this->_build_params['text_encoding'] == '7bit' - && !preg_match('/ascii/i', $this->_build_params['text_charset']) - && preg_match('/[^\x00-\x7F]/', $this->_txtbody) - ) { - $this->_build_params['text_encoding'] = 'quoted-printable'; - } - // html body - if ($this->_build_params['html_encoding'] == '7bit' - && !preg_match('/ascii/i', $this->_build_params['html_charset']) - && preg_match('/[^\x00-\x7F]/', $this->_htmlbody) - ) { - $this->_build_params['html_encoding'] = 'quoted-printable'; - } - } - -} // End of class diff --git a/data/module/Mail/mimeDecode.php b/data/module/Mail/mimeDecode.php deleted file mode 100644 index 677d245e341..00000000000 --- a/data/module/Mail/mimeDecode.php +++ /dev/null @@ -1,1003 +0,0 @@ - - * Copyright (c) 2003-2006, PEAR - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - Neither the name of the authors, nor the names of its contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - * @category Mail - * @package Mail_Mime - * @author Richard Heyes - * @author George Schlossnagle - * @author Cipriano Groenendal - * @author Sean Coates - * @copyright 2003-2006 PEAR - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/Mail_mime - */ - - -/** - * require PEAR - * - * This package depends on PEAR to raise errors. - */ -require_once 'PEAR.php'; - - -/** - * The Mail_mimeDecode class is used to decode mail/mime messages - * - * This class will parse a raw mime email and return the structure. - * Returned structure is similar to that returned by imap_fetchstructure(). - * - * +----------------------------- IMPORTANT ------------------------------+ - * | Usage of this class compared to native php extensions such as | - * | mailparse or imap, is slow and may be feature deficient. If available| - * | you are STRONGLY recommended to use the php extensions. | - * +----------------------------------------------------------------------+ - * - * @category Mail - * @package Mail_Mime - * @author Richard Heyes - * @author George Schlossnagle - * @author Cipriano Groenendal - * @author Sean Coates - * @copyright 2003-2006 PEAR - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/Mail_mime - */ -class Mail_mimeDecode extends PEAR -{ - /** - * The raw email to decode - * - * @var string - * @access private - */ - var $_input; - - /** - * The header part of the input - * - * @var string - * @access private - */ - var $_header; - - /** - * The body part of the input - * - * @var string - * @access private - */ - var $_body; - - /** - * If an error occurs, this is used to store the message - * - * @var string - * @access private - */ - var $_error; - - /** - * Flag to determine whether to include bodies in the - * returned object. - * - * @var boolean - * @access private - */ - var $_include_bodies; - - /** - * Flag to determine whether to decode bodies - * - * @var boolean - * @access private - */ - var $_decode_bodies; - - /** - * Flag to determine whether to decode headers - * - * @var boolean - * @access private - */ - var $_decode_headers; - - /** - * Flag to determine whether to include attached messages - * as body in the returned object. Depends on $_include_bodies - * - * @var boolean - * @access private - */ - var $_rfc822_bodies; - - /** - * Constructor. - * - * Sets up the object, initialise the variables, and splits and - * stores the header and body of the input. - * - * @param string The input to decode - * @access public - */ - function Mail_mimeDecode($input) - { - list($header, $body) = $this->_splitBodyHeader($input); - - $this->_input = $input; - $this->_header = $header; - $this->_body = $body; - $this->_decode_bodies = false; - $this->_include_bodies = true; - $this->_rfc822_bodies = false; - } - - /** - * Begins the decoding process. If called statically - * it will create an object and call the decode() method - * of it. - * - * @param array An array of various parameters that determine - * various things: - * include_bodies - Whether to include the body in the returned - * object. - * decode_bodies - Whether to decode the bodies - * of the parts. (Transfer encoding) - * decode_headers - Whether to decode headers - * input - If called statically, this will be treated - * as the input - * @return object Decoded results - * @access public - */ - function decode($params = null) - { - // determine if this method has been called statically - $isStatic = empty($this) || !is_a($this, __CLASS__); - - // Have we been called statically? - // If so, create an object and pass details to that. - if ($isStatic AND isset($params['input'])) { - - $obj = new Mail_mimeDecode($params['input']); - $structure = $obj->decode($params); - - // Called statically but no input - } elseif ($isStatic) { - return PEAR::raiseError('Called statically and no input given'); - - // Called via an object - } else { - $this->_include_bodies = isset($params['include_bodies']) ? - $params['include_bodies'] : false; - $this->_decode_bodies = isset($params['decode_bodies']) ? - $params['decode_bodies'] : false; - $this->_decode_headers = isset($params['decode_headers']) ? - $params['decode_headers'] : false; - $this->_rfc822_bodies = isset($params['rfc_822bodies']) ? - $params['rfc_822bodies'] : false; - - $structure = $this->_decode($this->_header, $this->_body); - if ($structure === false) { - $structure = $this->raiseError($this->_error); - } - } - - return $structure; - } - - /** - * Performs the decoding. Decodes the body string passed to it - * If it finds certain content-types it will call itself in a - * recursive fashion - * - * @param string Header section - * @param string Body section - * @return object Results of decoding process - * @access private - */ - function _decode($headers, $body, $default_ctype = 'text/plain') - { - $return = new stdClass; - $return->headers = array(); - $headers = $this->_parseHeaders($headers); - - foreach ($headers as $value) { - $value['value'] = $this->_decode_headers ? $this->_decodeHeader($value['value']) : $value['value']; - if (isset($return->headers[strtolower($value['name'])]) AND !is_array($return->headers[strtolower($value['name'])])) { - $return->headers[strtolower($value['name'])] = array($return->headers[strtolower($value['name'])]); - $return->headers[strtolower($value['name'])][] = $value['value']; - - } elseif (isset($return->headers[strtolower($value['name'])])) { - $return->headers[strtolower($value['name'])][] = $value['value']; - - } else { - $return->headers[strtolower($value['name'])] = $value['value']; - } - } - - - foreach ($headers as $key => $value) { - $headers[$key]['name'] = strtolower($headers[$key]['name']); - switch ($headers[$key]['name']) { - - case 'content-type': - $content_type = $this->_parseHeaderValue($headers[$key]['value']); - - if (preg_match('/([0-9a-z+.-]+)\/([0-9a-z+.-]+)/i', $content_type['value'], $regs)) { - $return->ctype_primary = $regs[1]; - $return->ctype_secondary = $regs[2]; - } - - if (isset($content_type['other'])) { - foreach($content_type['other'] as $p_name => $p_value) { - $return->ctype_parameters[$p_name] = $p_value; - } - } - break; - - case 'content-disposition': - $content_disposition = $this->_parseHeaderValue($headers[$key]['value']); - $return->disposition = $content_disposition['value']; - if (isset($content_disposition['other'])) { - foreach($content_disposition['other'] as $p_name => $p_value) { - $return->d_parameters[$p_name] = $p_value; - } - } - break; - - case 'content-transfer-encoding': - $content_transfer_encoding = $this->_parseHeaderValue($headers[$key]['value']); - break; - } - } - - if (isset($content_type)) { - switch (strtolower($content_type['value'])) { - case 'text/plain': - $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit'; - $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body) : null; - break; - - case 'text/html': - $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit'; - $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body) : null; - break; - - case 'multipart/parallel': - case 'multipart/appledouble': // Appledouble mail - case 'multipart/report': // RFC1892 - case 'multipart/signed': // PGP - case 'multipart/digest': - case 'multipart/alternative': - case 'multipart/related': - case 'multipart/mixed': - case 'application/vnd.wap.multipart.related': - if(!isset($content_type['other']['boundary'])){ - $this->_error = 'No boundary found for ' . $content_type['value'] . ' part'; - return false; - } - - $default_ctype = (strtolower($content_type['value']) === 'multipart/digest') ? 'message/rfc822' : 'text/plain'; - - $parts = $this->_boundarySplit($body, $content_type['other']['boundary']); - for ($i = 0; $i < count($parts); $i++) { - list($part_header, $part_body) = $this->_splitBodyHeader($parts[$i]); - $part = $this->_decode($part_header, $part_body, $default_ctype); - if($part === false) - $part = $this->raiseError($this->_error); - $return->parts[] = $part; - } - break; - - case 'message/rfc822': - if ($this->_rfc822_bodies) { - $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit'; - $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body); - } - $obj = new Mail_mimeDecode($body); - $return->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies, - 'decode_bodies' => $this->_decode_bodies, - 'decode_headers' => $this->_decode_headers)); - unset($obj); - break; - - default: - if(!isset($content_transfer_encoding['value'])) - $content_transfer_encoding['value'] = '7bit'; - $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $content_transfer_encoding['value']) : $body) : null; - break; - } - - } else { - $ctype = explode('/', $default_ctype); - $return->ctype_primary = $ctype[0]; - $return->ctype_secondary = $ctype[1]; - $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body) : $body) : null; - } - - return $return; - } - - /** - * Given the output of the above function, this will return an - * array of references to the parts, indexed by mime number. - * - * @param object $structure The structure to go through - * @param string $mime_number Internal use only. - * @return array Mime numbers - */ - function &getMimeNumbers(&$structure, $no_refs = false, $mime_number = '', $prepend = '') - { - $return = array(); - if (!empty($structure->parts)) { - if ($mime_number != '') { - $structure->mime_id = $prepend . $mime_number; - $return[$prepend . $mime_number] = &$structure; - } - for ($i = 0; $i < count($structure->parts); $i++) { - - - if (!empty($structure->headers['content-type']) AND substr(strtolower($structure->headers['content-type']), 0, 8) == 'message/') { - $prepend = $prepend . $mime_number . '.'; - $_mime_number = ''; - } else { - $_mime_number = ($mime_number == '' ? $i + 1 : sprintf('%s.%s', $mime_number, $i + 1)); - } - - $arr = &Mail_mimeDecode::getMimeNumbers($structure->parts[$i], $no_refs, $_mime_number, $prepend); - foreach ($arr as $key => $val) { - $no_refs ? $return[$key] = '' : $return[$key] = &$arr[$key]; - } - } - } else { - if ($mime_number == '') { - $mime_number = '1'; - } - $structure->mime_id = $prepend . $mime_number; - $no_refs ? $return[$prepend . $mime_number] = '' : $return[$prepend . $mime_number] = &$structure; - } - - return $return; - } - - /** - * Given a string containing a header and body - * section, this function will split them (at the first - * blank line) and return them. - * - * @param string Input to split apart - * @return array Contains header and body section - * @access private - */ - function _splitBodyHeader($input) - { - if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $input, $match)) { - return array($match[1], $match[2]); - } - // bug #17325 - empty bodies are allowed. - we just check that at least one line - // of headers exist.. - if (count(explode("\n",$input))) { - return array($input, ''); - } - $this->_error = 'Could not split header and body'; - return false; - } - - /** - * Parse headers given in $input and return - * as assoc array. - * - * @param string Headers to parse - * @return array Contains parsed headers - * @access private - */ - function _parseHeaders($input) - { - - if ($input !== '') { - // Unfold the input - $input = preg_replace("/\r?\n/", "\r\n", $input); - //#7065 - wrapping.. with encoded stuff.. - probably not needed, - // wrapping space should only get removed if the trailing item on previous line is a - // encoded character - $input = preg_replace("/=\r\n(\t| )+/", '=', $input); - $input = preg_replace("/\r\n(\t| )+/", ' ', $input); - - $headers = explode("\r\n", trim($input)); - - foreach ($headers as $value) { - $hdr_name = substr($value, 0, $pos = strpos($value, ':')); - $hdr_value = substr($value, $pos+1); - if($hdr_value[0] == ' ') - $hdr_value = substr($hdr_value, 1); - - $return[] = array( - 'name' => $hdr_name, - 'value' => $hdr_value - ); - } - } else { - $return = array(); - } - - return $return; - } - - /** - * Function to parse a header value, - * extract first part, and any secondary - * parts (after ;) This function is not as - * robust as it could be. Eg. header comments - * in the wrong place will probably break it. - * - * @param string Header value to parse - * @return array Contains parsed result - * @access private - */ - function _parseHeaderValue($input) - { - - if (($pos = strpos($input, ';')) === false) { - $input = $this->_decode_headers ? $this->_decodeHeader($input) : $input; - $return['value'] = trim($input); - return $return; - } - - - - $value = substr($input, 0, $pos); - $value = $this->_decode_headers ? $this->_decodeHeader($value) : $value; - $return['value'] = trim($value); - $input = trim(substr($input, $pos+1)); - - if (!strlen($input) > 0) { - return $return; - } - // at this point input contains xxxx=".....";zzzz="...." - // since we are dealing with quoted strings, we need to handle this properly.. - $i = 0; - $l = strlen($input); - $key = ''; - $val = false; // our string - including quotes.. - $q = false; // in quote.. - $lq = ''; // last quote.. - - while ($i < $l) { - - $c = $input[$i]; - //var_dump(array('i'=>$i,'c'=>$c,'q'=>$q, 'lq'=>$lq, 'key'=>$key, 'val' =>$val)); - - $escaped = false; - if ($c == '\\') { - $i++; - if ($i == $l-1) { // end of string. - break; - } - $escaped = true; - $c = $input[$i]; - } - - - // state - in key.. - if ($val === false) { - if (!$escaped && $c == '=') { - $val = ''; - $key = trim($key); - $i++; - continue; - } - if (!$escaped && $c == ';') { - if ($key) { // a key without a value.. - $key= trim($key); - $return['other'][$key] = ''; - $return['other'][strtolower($key)] = ''; - } - $key = ''; - } - $key .= $c; - $i++; - continue; - } - - // state - in value.. (as $val is set..) - - if ($q === false) { - // not in quote yet. - if ((!strlen($val) || $lq !== false) && $c == ' ' || $c == "\t") { - $i++; - continue; // skip leading spaces after '=' or after '"' - } - if (!$escaped && ($c == '"' || $c == "'")) { - // start quoted area.. - $q = $c; - // in theory should not happen raw text in value part.. - // but we will handle it as a merged part of the string.. - $val = !strlen(trim($val)) ? '' : trim($val); - $i++; - continue; - } - // got end.... - if (!$escaped && $c == ';') { - - $val = trim($val); - $added = false; - if (preg_match('/\*[0-9]+$/', $key)) { - // this is the extended aaa*0=...;aaa*1=.... code - // it assumes the pieces arrive in order, and are valid... - $key = preg_replace('/\*[0-9]+$/', '', $key); - if (isset($return['other'][$key])) { - $return['other'][$key] .= $val; - if (strtolower($key) != $key) { - $return['other'][strtolower($key)] .= $val; - } - $added = true; - } - // continue and use standard setters.. - } - if (!$added) { - $return['other'][$key] = $val; - $return['other'][strtolower($key)] = $val; - } - $val = false; - $key = ''; - $lq = false; - $i++; - continue; - } - - $val .= $c; - $i++; - continue; - } - - // state - in quote.. - if (!$escaped && $c == $q) { // potential exit state.. - - // end of quoted string.. - $lq = $q; - $q = false; - $i++; - continue; - } - - // normal char inside of quoted string.. - $val.= $c; - $i++; - } - - // do we have anything left.. - if (strlen(trim($key)) || $val !== false) { - - $val = trim($val); - $added = false; - if ($val !== false && preg_match('/\*[0-9]+$/', $key)) { - // no dupes due to our crazy regexp. - $key = preg_replace('/\*[0-9]+$/', '', $key); - if (isset($return['other'][$key])) { - $return['other'][$key] .= $val; - if (strtolower($key) != $key) { - $return['other'][strtolower($key)] .= $val; - } - $added = true; - } - // continue and use standard setters.. - } - if (!$added) { - $return['other'][$key] = $val; - $return['other'][strtolower($key)] = $val; - } - } - // decode values. - foreach($return['other'] as $key =>$val) { - $return['other'][$key] = $this->_decode_headers ? $this->_decodeHeader($val) : $val; - } - //print_r($return); - return $return; - } - - /** - * This function splits the input based - * on the given boundary - * - * @param string Input to parse - * @return array Contains array of resulting mime parts - * @access private - */ - function _boundarySplit($input, $boundary) - { - $parts = array(); - - $bs_possible = substr($boundary, 2, -2); - $bs_check = '\"' . $bs_possible . '\"'; - - if ($boundary == $bs_check) { - $boundary = $bs_possible; - } - $tmp = preg_split("/--".preg_quote($boundary, '/')."((?=\s)|--)/", $input); - - $len = count($tmp) -1; - for ($i = 1; $i < $len; $i++) { - if (strlen(trim($tmp[$i]))) { - $parts[] = $tmp[$i]; - } - } - - // add the last part on if it does not end with the 'closing indicator' - if (!empty($tmp[$len]) && strlen(trim($tmp[$len])) && $tmp[$len][0] != '-') { - $parts[] = $tmp[$len]; - } - return $parts; - } - - /** - * Given a header, this function will decode it - * according to RFC2047. Probably not *exactly* - * conformant, but it does pass all the given - * examples (in RFC2047). - * - * @param string Input header value to decode - * @return string Decoded header value - * @access private - */ - function _decodeHeader($input) - { - // Remove white space between encoded-words - $input = preg_replace('/(=\?[^?]+\?(q|b)\?[^?]*\?=)(\s)+=\?/i', '\1=?', $input); - - // For each encoded-word... - while (preg_match('/(=\?([^?]+)\?(q|b)\?([^?]*)\?=)/i', $input, $matches)) { - - $encoded = $matches[1]; - $charset = $matches[2]; - $encoding = $matches[3]; - $text = $matches[4]; - - switch (strtolower($encoding)) { - case 'b': - $text = base64_decode($text); - break; - - case 'q': - $text = str_replace('_', ' ', $text); - preg_match_all('/=([a-f0-9]{2})/i', $text, $matches); - foreach($matches[1] as $value) - $text = str_replace('='.$value, chr(hexdec($value)), $text); - break; - } - - $input = str_replace($encoded, $text, $input); - } - - return $input; - } - - /** - * Given a body string and an encoding type, - * this function will decode and return it. - * - * @param string Input body to decode - * @param string Encoding type to use. - * @return string Decoded body - * @access private - */ - function _decodeBody($input, $encoding = '7bit') - { - switch (strtolower($encoding)) { - case '7bit': - return $input; - break; - - case 'quoted-printable': - return $this->_quotedPrintableDecode($input); - break; - - case 'base64': - return base64_decode($input); - break; - - default: - return $input; - } - } - - /** - * Given a quoted-printable string, this - * function will decode and return it. - * - * @param string Input body to decode - * @return string Decoded body - * @access private - */ - function _quotedPrintableDecode($input) - { - // Remove soft line breaks - $input = preg_replace("/=\r?\n/", '', $input); - - // Replace encoded characters - $input = preg_replace('/=([a-f0-9]{2})/ie', "chr(hexdec('\\1'))", $input); - - return $input; - } - - /** - * Checks the input for uuencoded files and returns - * an array of them. Can be called statically, eg: - * - * $files =& Mail_mimeDecode::uudecode($some_text); - * - * It will check for the begin 666 ... end syntax - * however and won't just blindly decode whatever you - * pass it. - * - * @param string Input body to look for attahcments in - * @return array Decoded bodies, filenames and permissions - * @access public - * @author Unknown - */ - function &uudecode($input) - { - // Find all uuencoded sections - preg_match_all("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", $input, $matches); - - for ($j = 0; $j < count($matches[3]); $j++) { - - $str = $matches[3][$j]; - $filename = $matches[2][$j]; - $fileperm = $matches[1][$j]; - - $file = ''; - $str = preg_split("/\r?\n/", trim($str)); - $strlen = count($str); - - for ($i = 0; $i < $strlen; $i++) { - $pos = 1; - $d = 0; - $len=(int)(((ord(substr($str[$i],0,1)) -32) - ' ') & 077); - - while (($d + 3 <= $len) AND ($pos + 4 <= strlen($str[$i]))) { - $c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20); - $c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20); - $c2 = (ord(substr($str[$i],$pos+2,1)) ^ 0x20); - $c3 = (ord(substr($str[$i],$pos+3,1)) ^ 0x20); - $file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4)); - - $file .= chr(((($c1 - ' ') & 077) << 4) | ((($c2 - ' ') & 077) >> 2)); - - $file .= chr(((($c2 - ' ') & 077) << 6) | (($c3 - ' ') & 077)); - - $pos += 4; - $d += 3; - } - - if (($d + 2 <= $len) && ($pos + 3 <= strlen($str[$i]))) { - $c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20); - $c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20); - $c2 = (ord(substr($str[$i],$pos+2,1)) ^ 0x20); - $file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4)); - - $file .= chr(((($c1 - ' ') & 077) << 4) | ((($c2 - ' ') & 077) >> 2)); - - $pos += 3; - $d += 2; - } - - if (($d + 1 <= $len) && ($pos + 2 <= strlen($str[$i]))) { - $c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20); - $c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20); - $file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4)); - - } - } - $files[] = array('filename' => $filename, 'fileperm' => $fileperm, 'filedata' => $file); - } - - return $files; - } - - /** - * getSendArray() returns the arguments required for Mail::send() - * used to build the arguments for a mail::send() call - * - * Usage: - * $mailtext = Full email (for example generated by a template) - * $decoder = new Mail_mimeDecode($mailtext); - * $parts = $decoder->getSendArray(); - * if (!PEAR::isError($parts) { - * list($recipents,$headers,$body) = $parts; - * $mail = Mail::factory('smtp'); - * $mail->send($recipents,$headers,$body); - * } else { - * echo $parts->message; - * } - * @return mixed array of recipeint, headers,body or Pear_Error - * @access public - * @author Alan Knowles - */ - function getSendArray() - { - // prevent warning if this is not set - $this->_decode_headers = FALSE; - $headerlist =$this->_parseHeaders($this->_header); - $to = ""; - if (!$headerlist) { - return $this->raiseError("Message did not contain headers"); - } - foreach($headerlist as $item) { - $header[$item['name']] = $item['value']; - switch (strtolower($item['name'])) { - case "to": - case "cc": - case "bcc": - $to .= ",".$item['value']; - default: - break; - } - } - if ($to == "") { - return $this->raiseError("Message did not contain any recipents"); - } - $to = substr($to,1); - return array($to,$header,$this->_body); - } - - /** - * Returns a xml copy of the output of - * Mail_mimeDecode::decode. Pass the output in as the - * argument. This function can be called statically. Eg: - * - * $output = $obj->decode(); - * $xml = Mail_mimeDecode::getXML($output); - * - * The DTD used for this should have been in the package. Or - * alternatively you can get it from cvs, or here: - * http://www.phpguru.org/xmail/xmail.dtd. - * - * @param object Input to convert to xml. This should be the - * output of the Mail_mimeDecode::decode function - * @return string XML version of input - * @access public - */ - function getXML($input) - { - $crlf = "\r\n"; - $output = '' . $crlf . - '' . $crlf . - '' . $crlf . - Mail_mimeDecode::_getXML($input) . - ''; - - return $output; - } - - /** - * Function that does the actual conversion to xml. Does a single - * mimepart at a time. - * - * @param object Input to convert to xml. This is a mimepart object. - * It may or may not contain subparts. - * @param integer Number of tabs to indent - * @return string XML version of input - * @access private - */ - function _getXML($input, $indent = 1) - { - $htab = "\t"; - $crlf = "\r\n"; - $output = ''; - $headers = @(array)$input->headers; - - foreach ($headers as $hdr_name => $hdr_value) { - - // Multiple headers with this name - if (is_array($headers[$hdr_name])) { - for ($i = 0; $i < count($hdr_value); $i++) { - $output .= Mail_mimeDecode::_getXML_helper($hdr_name, $hdr_value[$i], $indent); - } - - // Only one header of this sort - } else { - $output .= Mail_mimeDecode::_getXML_helper($hdr_name, $hdr_value, $indent); - } - } - - if (!empty($input->parts)) { - for ($i = 0; $i < count($input->parts); $i++) { - $output .= $crlf . str_repeat($htab, $indent) . '' . $crlf . - Mail_mimeDecode::_getXML($input->parts[$i], $indent+1) . - str_repeat($htab, $indent) . '' . $crlf; - } - } elseif (isset($input->body)) { - $output .= $crlf . str_repeat($htab, $indent) . 'body . ']]>' . $crlf; - } - - return $output; - } - - /** - * Helper function to _getXML(). Returns xml of a header. - * - * @param string Name of header - * @param string Value of header - * @param integer Number of tabs to indent - * @return string XML version of input - * @access private - */ - function _getXML_helper($hdr_name, $hdr_value, $indent) - { - $htab = "\t"; - $crlf = "\r\n"; - $return = ''; - - $new_hdr_value = ($hdr_name != 'received') ? Mail_mimeDecode::_parseHeaderValue($hdr_value) : array('value' => $hdr_value); - $new_hdr_name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $hdr_name))); - - // Sort out any parameters - if (!empty($new_hdr_value['other'])) { - foreach ($new_hdr_value['other'] as $paramname => $paramvalue) { - $params[] = str_repeat($htab, $indent) . $htab . '' . $crlf . - str_repeat($htab, $indent) . $htab . $htab . '' . htmlspecialchars($paramname) . '' . $crlf . - str_repeat($htab, $indent) . $htab . $htab . '' . htmlspecialchars($paramvalue) . '' . $crlf . - str_repeat($htab, $indent) . $htab . '' . $crlf; - } - - $params = implode('', $params); - } else { - $params = ''; - } - - $return = str_repeat($htab, $indent) . '
' . $crlf . - str_repeat($htab, $indent) . $htab . '' . htmlspecialchars($new_hdr_name) . '' . $crlf . - str_repeat($htab, $indent) . $htab . '' . htmlspecialchars($new_hdr_value['value']) . '' . $crlf . - $params . - str_repeat($htab, $indent) . '
' . $crlf; - - return $return; - } - -} // End of class diff --git a/data/module/Mail/mimePart.php b/data/module/Mail/mimePart.php deleted file mode 100644 index 60b3601e064..00000000000 --- a/data/module/Mail/mimePart.php +++ /dev/null @@ -1,1190 +0,0 @@ - - * Copyright (c) 2003-2006, PEAR - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - Neither the name of the authors, nor the names of its contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - * @category Mail - * @package Mail_Mime - * @author Richard Heyes - * @author Cipriano Groenendal - * @author Sean Coates - * @author Aleksander Machniak - * @copyright 2003-2006 PEAR - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/Mail_mime - */ - - -/** - * The Mail_mimePart class is used to create MIME E-mail messages - * - * This class enables you to manipulate and build a mime email - * from the ground up. The Mail_Mime class is a userfriendly api - * to this class for people who aren't interested in the internals - * of mime mail. - * This class however allows full control over the email. - * - * @category Mail - * @package Mail_Mime - * @author Richard Heyes - * @author Cipriano Groenendal - * @author Sean Coates - * @author Aleksander Machniak - * @copyright 2003-2006 PEAR - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/Mail_mime - */ -class Mail_mimePart -{ - /** - * The encoding type of this part - * - * @var string - * @access private - */ - var $_encoding; - - /** - * An array of subparts - * - * @var array - * @access private - */ - var $_subparts; - - /** - * The output of this part after being built - * - * @var string - * @access private - */ - var $_encoded; - - /** - * Headers for this part - * - * @var array - * @access private - */ - var $_headers; - - /** - * The body of this part (not encoded) - * - * @var string - * @access private - */ - var $_body; - - /** - * The location of file with body of this part (not encoded) - * - * @var string - * @access private - */ - var $_body_file; - - /** - * The end-of-line sequence - * - * @var string - * @access private - */ - var $_eol = "\r\n"; - - /** - * Constructor. - * - * Sets up the object. - * - * @param string $body The body of the mime part if any. - * @param array $params An associative array of optional parameters: - * content_type - The content type for this part eg multipart/mixed - * encoding - The encoding to use, 7bit, 8bit, - * base64, or quoted-printable - * charset - Content character set - * cid - Content ID to apply - * disposition - Content disposition, inline or attachment - * dfilename - Filename parameter for content disposition - * description - Content description - * name_encoding - Encoding of the attachment name (Content-Type) - * By default filenames are encoded using RFC2231 - * Here you can set RFC2047 encoding (quoted-printable - * or base64) instead - * filename_encoding - Encoding of the attachment filename (Content-Disposition) - * See 'name_encoding' - * headers_charset - Charset of the headers e.g. filename, description. - * If not set, 'charset' will be used - * eol - End of line sequence. Default: "\r\n" - * body_file - Location of file with part's body (instead of $body) - * - * @access public - */ - function Mail_mimePart($body = '', $params = array()) - { - if (!empty($params['eol'])) { - $this->_eol = $params['eol']; - } else if (defined('MAIL_MIMEPART_CRLF')) { // backward-copat. - $this->_eol = MAIL_MIMEPART_CRLF; - } - - foreach ($params as $key => $value) { - switch ($key) { - case 'encoding': - $this->_encoding = $value; - $headers['Content-Transfer-Encoding'] = $value; - break; - - case 'cid': - $headers['Content-ID'] = '<' . $value . '>'; - break; - - case 'location': - $headers['Content-Location'] = $value; - break; - - case 'body_file': - $this->_body_file = $value; - break; - } - } - - // Default content-type - if (empty($params['content_type'])) { - $params['content_type'] = 'text/plain'; - } - - // Content-Type - $headers['Content-Type'] = $params['content_type']; - if (!empty($params['charset'])) { - $charset = "charset={$params['charset']}"; - // place charset parameter in the same line, if possible - if ((strlen($headers['Content-Type']) + strlen($charset) + 16) <= 76) { - $headers['Content-Type'] .= '; '; - } else { - $headers['Content-Type'] .= ';' . $this->_eol . ' '; - } - $headers['Content-Type'] .= $charset; - - // Default headers charset - if (!isset($params['headers_charset'])) { - $params['headers_charset'] = $params['charset']; - } - } - if (!empty($params['filename'])) { - $headers['Content-Type'] .= ';' . $this->_eol; - $headers['Content-Type'] .= $this->_buildHeaderParam( - 'name', $params['filename'], - !empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII', - !empty($params['language']) ? $params['language'] : null, - !empty($params['name_encoding']) ? $params['name_encoding'] : null - ); - } - - // Content-Disposition - if (!empty($params['disposition'])) { - $headers['Content-Disposition'] = $params['disposition']; - if (!empty($params['filename'])) { - $headers['Content-Disposition'] .= ';' . $this->_eol; - $headers['Content-Disposition'] .= $this->_buildHeaderParam( - 'filename', $params['filename'], - !empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII', - !empty($params['language']) ? $params['language'] : null, - !empty($params['filename_encoding']) ? $params['filename_encoding'] : null - ); - } - } - - if (!empty($params['description'])) { - $headers['Content-Description'] = $this->encodeHeader( - 'Content-Description', $params['description'], - !empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII', - !empty($params['name_encoding']) ? $params['name_encoding'] : 'quoted-printable', - $this->_eol - ); - } - - // Default encoding - if (!isset($this->_encoding)) { - $this->_encoding = '7bit'; - } - - // Assign stuff to member variables - $this->_encoded = array(); - $this->_headers = $headers; - $this->_body = $body; - } - - /** - * Encodes and returns the email. Also stores - * it in the encoded member variable - * - * @param string $boundary Pre-defined boundary string - * - * @return An associative array containing two elements, - * body and headers. The headers element is itself - * an indexed array. On error returns PEAR error object. - * @access public - */ - function encode($boundary=null) - { - $encoded =& $this->_encoded; - - if (count($this->_subparts)) { - $boundary = $boundary ? $boundary : '=_' . md5(rand() . microtime()); - $eol = $this->_eol; - - $this->_headers['Content-Type'] .= ";$eol boundary=\"$boundary\""; - - $encoded['body'] = ''; - - for ($i = 0; $i < count($this->_subparts); $i++) { - $encoded['body'] .= '--' . $boundary . $eol; - $tmp = $this->_subparts[$i]->encode(); - if (PEAR::isError($tmp)) { - return $tmp; - } - foreach ($tmp['headers'] as $key => $value) { - $encoded['body'] .= $key . ': ' . $value . $eol; - } - $encoded['body'] .= $eol . $tmp['body'] . $eol; - } - - $encoded['body'] .= '--' . $boundary . '--' . $eol; - - } else if ($this->_body) { - $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding); - } else if ($this->_body_file) { - // Temporarily reset magic_quotes_runtime for file reads and writes - if ($magic_quote_setting = get_magic_quotes_runtime()) { - @ini_set('magic_quotes_runtime', 0); - } - $body = $this->_getEncodedDataFromFile($this->_body_file, $this->_encoding); - if ($magic_quote_setting) { - @ini_set('magic_quotes_runtime', $magic_quote_setting); - } - - if (PEAR::isError($body)) { - return $body; - } - $encoded['body'] = $body; - } else { - $encoded['body'] = ''; - } - - // Add headers to $encoded - $encoded['headers'] =& $this->_headers; - - return $encoded; - } - - /** - * Encodes and saves the email into file. File must exist. - * Data will be appended to the file. - * - * @param string $filename Output file location - * @param string $boundary Pre-defined boundary string - * @param boolean $skip_head True if you don't want to save headers - * - * @return array An associative array containing message headers - * or PEAR error object - * @access public - * @since 1.6.0 - */ - function encodeToFile($filename, $boundary=null, $skip_head=false) - { - if (file_exists($filename) && !is_writable($filename)) { - $err = PEAR::raiseError('File is not writeable: ' . $filename); - return $err; - } - - if (!($fh = fopen($filename, 'ab'))) { - $err = PEAR::raiseError('Unable to open file: ' . $filename); - return $err; - } - - // Temporarily reset magic_quotes_runtime for file reads and writes - if ($magic_quote_setting = get_magic_quotes_runtime()) { - @ini_set('magic_quotes_runtime', 0); - } - - $res = $this->_encodePartToFile($fh, $boundary, $skip_head); - - fclose($fh); - - if ($magic_quote_setting) { - @ini_set('magic_quotes_runtime', $magic_quote_setting); - } - - return PEAR::isError($res) ? $res : $this->_headers; - } - - /** - * Encodes given email part into file - * - * @param string $fh Output file handle - * @param string $boundary Pre-defined boundary string - * @param boolean $skip_head True if you don't want to save headers - * - * @return array True on sucess or PEAR error object - * @access private - */ - function _encodePartToFile($fh, $boundary=null, $skip_head=false) - { - $eol = $this->_eol; - - if (count($this->_subparts)) { - $boundary = $boundary ? $boundary : '=_' . md5(rand() . microtime()); - $this->_headers['Content-Type'] .= ";$eol boundary=\"$boundary\""; - } - - if (!$skip_head) { - foreach ($this->_headers as $key => $value) { - fwrite($fh, $key . ': ' . $value . $eol); - } - $f_eol = $eol; - } else { - $f_eol = ''; - } - - if (count($this->_subparts)) { - for ($i = 0; $i < count($this->_subparts); $i++) { - fwrite($fh, $f_eol . '--' . $boundary . $eol); - $res = $this->_subparts[$i]->_encodePartToFile($fh); - if (PEAR::isError($res)) { - return $res; - } - $f_eol = $eol; - } - - fwrite($fh, $eol . '--' . $boundary . '--' . $eol); - - } else if ($this->_body) { - fwrite($fh, $f_eol . $this->_getEncodedData($this->_body, $this->_encoding)); - } else if ($this->_body_file) { - fwrite($fh, $f_eol); - $res = $this->_getEncodedDataFromFile( - $this->_body_file, $this->_encoding, $fh - ); - if (PEAR::isError($res)) { - return $res; - } - } - - return true; - } - - /** - * Adds a subpart to current mime part and returns - * a reference to it - * - * @param string $body The body of the subpart, if any. - * @param array $params The parameters for the subpart, same - * as the $params argument for constructor. - * - * @return Mail_mimePart A reference to the part you just added. It is - * crucial if using multipart/* in your subparts that - * you use =& in your script when calling this function, - * otherwise you will not be able to add further subparts. - * @access public - */ - function &addSubpart($body, $params) - { - $this->_subparts[] = new Mail_mimePart($body, $params); - return $this->_subparts[count($this->_subparts) - 1]; - } - - /** - * Returns encoded data based upon encoding passed to it - * - * @param string $data The data to encode. - * @param string $encoding The encoding type to use, 7bit, base64, - * or quoted-printable. - * - * @return string - * @access private - */ - function _getEncodedData($data, $encoding) - { - switch ($encoding) { - case 'quoted-printable': - return $this->_quotedPrintableEncode($data); - break; - - case 'base64': - return rtrim(chunk_split(base64_encode($data), 76, $this->_eol)); - break; - - case '8bit': - case '7bit': - default: - return $data; - } - } - - /** - * Returns encoded data based upon encoding passed to it - * - * @param string $filename Data file location - * @param string $encoding The encoding type to use, 7bit, base64, - * or quoted-printable. - * @param resource $fh Output file handle. If set, data will be - * stored into it instead of returning it - * - * @return string Encoded data or PEAR error object - * @access private - */ - function _getEncodedDataFromFile($filename, $encoding, $fh=null) - { - if (!is_readable($filename)) { - $err = PEAR::raiseError('Unable to read file: ' . $filename); - return $err; - } - - if (!($fd = fopen($filename, 'rb'))) { - $err = PEAR::raiseError('Could not open file: ' . $filename); - return $err; - } - - $data = ''; - - switch ($encoding) { - case 'quoted-printable': - while (!feof($fd)) { - $buffer = $this->_quotedPrintableEncode(fgets($fd)); - if ($fh) { - fwrite($fh, $buffer); - } else { - $data .= $buffer; - } - } - break; - - case 'base64': - while (!feof($fd)) { - // Should read in a multiple of 57 bytes so that - // the output is 76 bytes per line. Don't use big chunks - // because base64 encoding is memory expensive - $buffer = fread($fd, 57 * 9198); // ca. 0.5 MB - $buffer = base64_encode($buffer); - $buffer = chunk_split($buffer, 76, $this->_eol); - if (feof($fd)) { - $buffer = rtrim($buffer); - } - - if ($fh) { - fwrite($fh, $buffer); - } else { - $data .= $buffer; - } - } - break; - - case '8bit': - case '7bit': - default: - while (!feof($fd)) { - $buffer = fread($fd, 1048576); // 1 MB - if ($fh) { - fwrite($fh, $buffer); - } else { - $data .= $buffer; - } - } - } - - fclose($fd); - - if (!$fh) { - return $data; - } - } - - /** - * Encodes data to quoted-printable standard. - * - * @param string $input The data to encode - * @param int $line_max Optional max line length. Should - * not be more than 76 chars - * - * @return string Encoded data - * - * @access private - */ - function _quotedPrintableEncode($input , $line_max = 76) - { - $eol = $this->_eol; - /* - // imap_8bit() is extremely fast, but doesn't handle properly some characters - if (function_exists('imap_8bit') && $line_max == 76) { - $input = preg_replace('/\r?\n/', "\r\n", $input); - $input = imap_8bit($input); - if ($eol != "\r\n") { - $input = str_replace("\r\n", $eol, $input); - } - return $input; - } - */ - $lines = preg_split("/\r?\n/", $input); - $escape = '='; - $output = ''; - - while (list($idx, $line) = each($lines)) { - $newline = ''; - $i = 0; - - while (isset($line[$i])) { - $char = $line[$i]; - $dec = ord($char); - $i++; - - if (($dec == 32) && (!isset($line[$i]))) { - // convert space at eol only - $char = '=20'; - } elseif ($dec == 9 && isset($line[$i])) { - ; // Do nothing if a TAB is not on eol - } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { - $char = $escape . sprintf('%02X', $dec); - } elseif (($dec == 46) && (($newline == '') - || ((strlen($newline) + strlen("=2E")) >= $line_max)) - ) { - // Bug #9722: convert full-stop at bol, - // some Windows servers need this, won't break anything (cipri) - // Bug #11731: full-stop at bol also needs to be encoded - // if this line would push us over the line_max limit. - $char = '=2E'; - } - - // Note, when changing this line, also change the ($dec == 46) - // check line, as it mimics this line due to Bug #11731 - // EOL is not counted - if ((strlen($newline) + strlen($char)) >= $line_max) { - // soft line break; " =\r\n" is okay - $output .= $newline . $escape . $eol; - $newline = ''; - } - $newline .= $char; - } // end of for - $output .= $newline . $eol; - unset($lines[$idx]); - } - // Don't want last crlf - $output = substr($output, 0, -1 * strlen($eol)); - return $output; - } - - /** - * Encodes the paramater of a header. - * - * @param string $name The name of the header-parameter - * @param string $value The value of the paramter - * @param string $charset The characterset of $value - * @param string $language The language used in $value - * @param string $encoding Parameter encoding. If not set, parameter value - * is encoded according to RFC2231 - * @param int $maxLength The maximum length of a line. Defauls to 75 - * - * @return string - * - * @access private - */ - function _buildHeaderParam($name, $value, $charset=null, $language=null, - $encoding=null, $maxLength=75 - ) { - // RFC 2045: - // value needs encoding if contains non-ASCII chars or is longer than 78 chars - if (!preg_match('#[^\x20-\x7E]#', $value)) { - $token_regexp = '#([^\x21,\x23-\x27,\x2A,\x2B,\x2D' - . ',\x2E,\x30-\x39,\x41-\x5A,\x5E-\x7E])#'; - if (!preg_match($token_regexp, $value)) { - // token - if (strlen($name) + strlen($value) + 3 <= $maxLength) { - return " {$name}={$value}"; - } - } else { - // quoted-string - $quoted = addcslashes($value, '\\"'); - if (strlen($name) + strlen($quoted) + 5 <= $maxLength) { - return " {$name}=\"{$quoted}\""; - } - } - } - - // RFC2047: use quoted-printable/base64 encoding - if ($encoding == 'quoted-printable' || $encoding == 'base64') { - return $this->_buildRFC2047Param($name, $value, $charset, $encoding); - } - - // RFC2231: - $encValue = preg_replace_callback( - '/([^\x21,\x23,\x24,\x26,\x2B,\x2D,\x2E,\x30-\x39,\x41-\x5A,\x5E-\x7E])/', - array($this, '_encodeReplaceCallback'), $value - ); - $value = "$charset'$language'$encValue"; - - $header = " {$name}*={$value}"; - if (strlen($header) <= $maxLength) { - return $header; - } - - $preLength = strlen(" {$name}*0*="); - $maxLength = max(16, $maxLength - $preLength - 3); - $maxLengthReg = "|(.{0,$maxLength}[^\%][^\%])|"; - - $headers = array(); - $headCount = 0; - while ($value) { - $matches = array(); - $found = preg_match($maxLengthReg, $value, $matches); - if ($found) { - $headers[] = " {$name}*{$headCount}*={$matches[0]}"; - $value = substr($value, strlen($matches[0])); - } else { - $headers[] = " {$name}*{$headCount}*={$value}"; - $value = ''; - } - $headCount++; - } - - $headers = implode(';' . $this->_eol, $headers); - return $headers; - } - - /** - * Encodes header parameter as per RFC2047 if needed - * - * @param string $name The parameter name - * @param string $value The parameter value - * @param string $charset The parameter charset - * @param string $encoding Encoding type (quoted-printable or base64) - * @param int $maxLength Encoded parameter max length. Default: 76 - * - * @return string Parameter line - * @access private - */ - function _buildRFC2047Param($name, $value, $charset, - $encoding='quoted-printable', $maxLength=76 - ) { - // WARNING: RFC 2047 says: "An 'encoded-word' MUST NOT be used in - // parameter of a MIME Content-Type or Content-Disposition field", - // but... it's supported by many clients/servers - $quoted = ''; - - if ($encoding == 'base64') { - $value = base64_encode($value); - $prefix = '=?' . $charset . '?B?'; - $suffix = '?='; - - // 2 x SPACE, 2 x '"', '=', ';' - $add_len = strlen($prefix . $suffix) + strlen($name) + 6; - $len = $add_len + strlen($value); - - while ($len > $maxLength) { - // We can cut base64-encoded string every 4 characters - $real_len = floor(($maxLength - $add_len) / 4) * 4; - $_quote = substr($value, 0, $real_len); - $value = substr($value, $real_len); - - $quoted .= $prefix . $_quote . $suffix . $this->_eol . ' '; - $add_len = strlen($prefix . $suffix) + 4; // 2 x SPACE, '"', ';' - $len = strlen($value) + $add_len; - } - $quoted .= $prefix . $value . $suffix; - - } else { - // quoted-printable - $value = $this->encodeQP($value); - $prefix = '=?' . $charset . '?Q?'; - $suffix = '?='; - - // 2 x SPACE, 2 x '"', '=', ';' - $add_len = strlen($prefix . $suffix) + strlen($name) + 6; - $len = $add_len + strlen($value); - - while ($len > $maxLength) { - $length = $maxLength - $add_len; - // don't break any encoded letters - if (preg_match("/^(.{0,$length}[^\=][^\=])/", $value, $matches)) { - $_quote = $matches[1]; - } - - $quoted .= $prefix . $_quote . $suffix . $this->_eol . ' '; - $value = substr($value, strlen($_quote)); - $add_len = strlen($prefix . $suffix) + 4; // 2 x SPACE, '"', ';' - $len = strlen($value) + $add_len; - } - - $quoted .= $prefix . $value . $suffix; - } - - return " {$name}=\"{$quoted}\""; - } - - /** - * Encodes a header as per RFC2047 - * - * @param string $name The header name - * @param string $value The header data to encode - * @param string $charset Character set name - * @param string $encoding Encoding name (base64 or quoted-printable) - * @param string $eol End-of-line sequence. Default: "\r\n" - * - * @return string Encoded header data (without a name) - * @access public - * @since 1.6.1 - */ - function encodeHeader($name, $value, $charset='ISO-8859-1', - $encoding='quoted-printable', $eol="\r\n" - ) { - // Structured headers - $comma_headers = array( - 'from', 'to', 'cc', 'bcc', 'sender', 'reply-to', - 'resent-from', 'resent-to', 'resent-cc', 'resent-bcc', - 'resent-sender', 'resent-reply-to', - 'return-receipt-to', 'disposition-notification-to', - ); - $other_headers = array( - 'references', 'in-reply-to', 'message-id', 'resent-message-id', - ); - - $name = strtolower($name); - - if (in_array($name, $comma_headers)) { - $separator = ','; - } else if (in_array($name, $other_headers)) { - $separator = ' '; - } - - if (!$charset) { - $charset = 'ISO-8859-1'; - } - - // Structured header (make sure addr-spec inside is not encoded) - if (!empty($separator)) { - $parts = Mail_mimePart::_explodeQuotedString($separator, $value); - $value = ''; - - foreach ($parts as $part) { - $part = preg_replace('/\r?\n[\s\t]*/', $eol . ' ', $part); - $part = trim($part); - - if (!$part) { - continue; - } - if ($value) { - $value .= $separator==',' ? $separator.' ' : ' '; - } else { - $value = $name . ': '; - } - - // let's find phrase (name) and/or addr-spec - if (preg_match('/^<\S+@\S+>$/', $part)) { - $value .= $part; - } else if (preg_match('/^\S+@\S+$/', $part)) { - // address without brackets and without name - $value .= $part; - } else if (preg_match('/<*\S+@\S+>*$/', $part, $matches)) { - // address with name (handle name) - $address = $matches[0]; - $word = str_replace($address, '', $part); - $word = trim($word); - // check if phrase requires quoting - if ($word) { - // non-ASCII: require encoding - if (preg_match('#([\x80-\xFF]){1}#', $word)) { - if ($word[0] == '"' && $word[strlen($word)-1] == '"') { - // de-quote quoted-string, encoding changes - // string to atom - $search = array("\\\"", "\\\\"); - $replace = array("\"", "\\"); - $word = str_replace($search, $replace, $word); - $word = substr($word, 1, -1); - } - // find length of last line - if (($pos = strrpos($value, $eol)) !== false) { - $last_len = strlen($value) - $pos; - } else { - $last_len = strlen($value); - } - $word = Mail_mimePart::encodeHeaderValue( - $word, $charset, $encoding, $last_len, $eol - ); - } else if (($word[0] != '"' || $word[strlen($word)-1] != '"') - && preg_match('/[\(\)\<\>\\\.\[\]@,;:"]/', $word) - ) { - // ASCII: quote string if needed - $word = '"'.addcslashes($word, '\\"').'"'; - } - } - $value .= $word.' '.$address; - } else { - // addr-spec not found, don't encode (?) - $value .= $part; - } - - // RFC2822 recommends 78 characters limit, use 76 from RFC2047 - $value = wordwrap($value, 76, $eol . ' '); - } - - // remove header name prefix (there could be EOL too) - $value = preg_replace( - '/^'.$name.':('.preg_quote($eol, '/').')* /', '', $value - ); - - } else { - // Unstructured header - // non-ASCII: require encoding - if (preg_match('#([\x80-\xFF]){1}#', $value)) { - if ($value[0] == '"' && $value[strlen($value)-1] == '"') { - // de-quote quoted-string, encoding changes - // string to atom - $search = array("\\\"", "\\\\"); - $replace = array("\"", "\\"); - $value = str_replace($search, $replace, $value); - $value = substr($value, 1, -1); - } - $value = Mail_mimePart::encodeHeaderValue( - $value, $charset, $encoding, strlen($name) + 2, $eol - ); - } else if (strlen($name.': '.$value) > 78) { - // ASCII: check if header line isn't too long and use folding - $value = preg_replace('/\r?\n[\s\t]*/', $eol . ' ', $value); - $tmp = wordwrap($name.': '.$value, 78, $eol . ' '); - $value = preg_replace('/^'.$name.':\s*/', '', $tmp); - // hard limit 998 (RFC2822) - $value = wordwrap($value, 998, $eol . ' ', true); - } - } - - return $value; - } - - /** - * Explode quoted string - * - * @param string $delimiter Delimiter expression string for preg_match() - * @param string $string Input string - * - * @return array String tokens array - * @access private - */ - function _explodeQuotedString($delimiter, $string) - { - $result = array(); - $strlen = strlen($string); - - for ($q=$p=$i=0; $i < $strlen; $i++) { - if ($string[$i] == "\"" - && (empty($string[$i-1]) || $string[$i-1] != "\\") - ) { - $q = $q ? false : true; - } else if (!$q && preg_match("/$delimiter/", $string[$i])) { - $result[] = substr($string, $p, $i - $p); - $p = $i + 1; - } - } - - $result[] = substr($string, $p); - return $result; - } - - /** - * Encodes a header value as per RFC2047 - * - * @param string $value The header data to encode - * @param string $charset Character set name - * @param string $encoding Encoding name (base64 or quoted-printable) - * @param int $prefix_len Prefix length. Default: 0 - * @param string $eol End-of-line sequence. Default: "\r\n" - * - * @return string Encoded header data - * @access public - * @since 1.6.1 - */ - function encodeHeaderValue($value, $charset, $encoding, $prefix_len=0, $eol="\r\n") - { - // #17311: Use multibyte aware method (requires mbstring extension) - if ($result = Mail_mimePart::encodeMB($value, $charset, $encoding, $prefix_len, $eol)) { - return $result; - } - - // Generate the header using the specified params and dynamicly - // determine the maximum length of such strings. - // 75 is the value specified in the RFC. - $encoding = $encoding == 'base64' ? 'B' : 'Q'; - $prefix = '=?' . $charset . '?' . $encoding .'?'; - $suffix = '?='; - $maxLength = 75 - strlen($prefix . $suffix); - $maxLength1stLine = $maxLength - $prefix_len; - - if ($encoding == 'B') { - // Base64 encode the entire string - $value = base64_encode($value); - - // We can cut base64 every 4 characters, so the real max - // we can get must be rounded down. - $maxLength = $maxLength - ($maxLength % 4); - $maxLength1stLine = $maxLength1stLine - ($maxLength1stLine % 4); - - $cutpoint = $maxLength1stLine; - $output = ''; - - while ($value) { - // Split translated string at every $maxLength - $part = substr($value, 0, $cutpoint); - $value = substr($value, $cutpoint); - $cutpoint = $maxLength; - // RFC 2047 specifies that any split header should - // be seperated by a CRLF SPACE. - if ($output) { - $output .= $eol . ' '; - } - $output .= $prefix . $part . $suffix; - } - $value = $output; - } else { - // quoted-printable encoding has been selected - $value = Mail_mimePart::encodeQP($value); - - // This regexp will break QP-encoded text at every $maxLength - // but will not break any encoded letters. - $reg1st = "|(.{0,$maxLength1stLine}[^\=][^\=])|"; - $reg2nd = "|(.{0,$maxLength}[^\=][^\=])|"; - - if (strlen($value) > $maxLength1stLine) { - // Begin with the regexp for the first line. - $reg = $reg1st; - $output = ''; - while ($value) { - // Split translated string at every $maxLength - // But make sure not to break any translated chars. - $found = preg_match($reg, $value, $matches); - - // After this first line, we need to use a different - // regexp for the first line. - $reg = $reg2nd; - - // Save the found part and encapsulate it in the - // prefix & suffix. Then remove the part from the - // $value_out variable. - if ($found) { - $part = $matches[0]; - $len = strlen($matches[0]); - $value = substr($value, $len); - } else { - $part = $value; - $value = ''; - } - - // RFC 2047 specifies that any split header should - // be seperated by a CRLF SPACE - if ($output) { - $output .= $eol . ' '; - } - $output .= $prefix . $part . $suffix; - } - $value = $output; - } else { - $value = $prefix . $value . $suffix; - } - } - - return $value; - } - - /** - * Encodes the given string using quoted-printable - * - * @param string $str String to encode - * - * @return string Encoded string - * @access public - * @since 1.6.0 - */ - function encodeQP($str) - { - // Bug #17226 RFC 2047 restricts some characters - // if the word is inside a phrase, permitted chars are only: - // ASCII letters, decimal digits, "!", "*", "+", "-", "/", "=", and "_" - - // "=", "_", "?" must be encoded - $regexp = '/([\x22-\x29\x2C\x2E\x3A-\x40\x5B-\x60\x7B-\x7E\x80-\xFF])/'; - $str = preg_replace_callback( - $regexp, array('Mail_mimePart', '_qpReplaceCallback'), $str - ); - - return str_replace(' ', '_', $str); - } - - /** - * Encodes the given string using base64 or quoted-printable. - * This method makes sure that encoded-word represents an integral - * number of characters as per RFC2047. - * - * @param string $str String to encode - * @param string $charset Character set name - * @param string $encoding Encoding name (base64 or quoted-printable) - * @param int $prefix_len Prefix length. Default: 0 - * @param string $eol End-of-line sequence. Default: "\r\n" - * - * @return string Encoded string - * @access public - * @since 1.8.0 - */ - function encodeMB($str, $charset, $encoding, $prefix_len=0, $eol="\r\n") - { - if (!function_exists('mb_substr') || !function_exists('mb_strlen')) { - return; - } - - $encoding = $encoding == 'base64' ? 'B' : 'Q'; - // 75 is the value specified in the RFC - $prefix = '=?' . $charset . '?'.$encoding.'?'; - $suffix = '?='; - $maxLength = 75 - strlen($prefix . $suffix); - - // A multi-octet character may not be split across adjacent encoded-words - // So, we'll loop over each character - // mb_stlen() with wrong charset will generate a warning here and return null - $length = mb_strlen($str, $charset); - $result = ''; - $line_length = $prefix_len; - - if ($encoding == 'B') { - // base64 - $start = 0; - $prev = ''; - - for ($i=1; $i<=$length; $i++) { - // See #17311 - $chunk = mb_substr($str, $start, $i-$start, $charset); - $chunk = base64_encode($chunk); - $chunk_len = strlen($chunk); - - if ($line_length + $chunk_len == $maxLength || $i == $length) { - if ($result) { - $result .= "\n"; - } - $result .= $chunk; - $line_length = 0; - $start = $i; - } else if ($line_length + $chunk_len > $maxLength) { - if ($result) { - $result .= "\n"; - } - if ($prev) { - $result .= $prev; - } - $line_length = 0; - $start = $i - 1; - } else { - $prev = $chunk; - } - } - } else { - // quoted-printable - // see encodeQP() - $regexp = '/([\x22-\x29\x2C\x2E\x3A-\x40\x5B-\x60\x7B-\x7E\x80-\xFF])/'; - - for ($i=0; $i<=$length; $i++) { - $char = mb_substr($str, $i, 1, $charset); - // RFC recommends underline (instead of =20) in place of the space - // that's one of the reasons why we're not using iconv_mime_encode() - if ($char == ' ') { - $char = '_'; - $char_len = 1; - } else { - $char = preg_replace_callback( - $regexp, array('Mail_mimePart', '_qpReplaceCallback'), $char - ); - $char_len = strlen($char); - } - - if ($line_length + $char_len > $maxLength) { - if ($result) { - $result .= "\n"; - } - $line_length = 0; - } - - $result .= $char; - $line_length += $char_len; - } - } - - if ($result) { - $result = $prefix - .str_replace("\n", $suffix.$eol.' '.$prefix, $result).$suffix; - } - - return $result; - } - - /** - * Callback function to replace extended characters (\x80-xFF) with their - * ASCII values (RFC2047: quoted-printable) - * - * @param array $matches Preg_replace's matches array - * - * @return string Encoded character string - * @access private - */ - function _qpReplaceCallback($matches) - { - return sprintf('=%02X', ord($matches[1])); - } - - /** - * Callback function to replace extended characters (\x80-xFF) with their - * ASCII values (RFC2231) - * - * @param array $matches Preg_replace's matches array - * - * @return string Encoded character string - * @access private - */ - function _encodeReplaceCallback($matches) - { - return sprintf('%%%02X', ord($matches[1])); - } - -} // End of class diff --git a/data/module/Mail/mock.php b/data/module/Mail/mock.php deleted file mode 100644 index 61570ba408c..00000000000 --- a/data/module/Mail/mock.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @copyright 2010 Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: mock.php 294747 2010-02-08 08:18:33Z clockwerx $ - * @link http://pear.php.net/package/Mail/ - */ - -/** - * Mock implementation of the PEAR Mail:: interface for testing. - * @access public - * @package Mail - * @version $Revision: 294747 $ - */ -class Mail_mock extends Mail { - - /** - * Array of messages that have been sent with the mock. - * - * @var array - * @access public - */ - var $sentMessages = array(); - - /** - * Callback before sending mail. - * - * @var callback - */ - var $_preSendCallback; - - /** - * Callback after sending mai. - * - * @var callback - */ - var $_postSendCallback; - - /** - * Constructor. - * - * Instantiates a new Mail_mock:: object based on the parameters - * passed in. It looks for the following parameters, both optional: - * preSendCallback Called before an email would be sent. - * postSendCallback Called after an email would have been sent. - * - * @param array Hash containing any parameters. - * @access public - */ - function Mail_mock($params) - { - if (isset($params['preSendCallback']) && - is_callable($params['preSendCallback'])) { - $this->_preSendCallback = $params['preSendCallback']; - } - - if (isset($params['postSendCallback']) && - is_callable($params['postSendCallback'])) { - $this->_postSendCallback = $params['postSendCallback']; - } - } - - /** - * Implements Mail_mock::send() function. Silently discards all - * mail. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (ie, 'Subject'), and the array value - * is the header value (ie, 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * @access public - */ - function send($recipients, $headers, $body) - { - if ($this->_preSendCallback) { - call_user_func_array($this->_preSendCallback, - array(&$this, $recipients, $headers, $body)); - } - - $entry = array('recipients' => $recipients, 'headers' => $headers, 'body' => $body); - $this->sentMessages[] = $entry; - - if ($this->_postSendCallback) { - call_user_func_array($this->_postSendCallback, - array(&$this, $recipients, $headers, $body)); - } - - return true; - } - -} diff --git a/data/module/Mail/null.php b/data/module/Mail/null.php deleted file mode 100644 index c8d9fbc16c9..00000000000 --- a/data/module/Mail/null.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright 2010 Phil Kernick - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/Mail/ - */ - -/** - * Null implementation of the PEAR Mail:: interface. - * @access public - * @package Mail - * @version $Revision$ - */ -class Mail_null extends Mail { - - /** - * Implements Mail_null::send() function. Silently discards all - * mail. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (ie, 'Subject'), and the array value - * is the header value (ie, 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * @access public - */ - function send($recipients, $headers, $body) - { - return true; - } - -} diff --git a/data/module/Mail/sendmail.php b/data/module/Mail/sendmail.php deleted file mode 100644 index 627b0e8f6a3..00000000000 --- a/data/module/Mail/sendmail.php +++ /dev/null @@ -1,171 +0,0 @@ - | -// +----------------------------------------------------------------------+ - -/** - * Sendmail implementation of the PEAR Mail:: interface. - * @access public - * @package Mail - * @version $Revision$ - */ -class Mail_sendmail extends Mail { - - /** - * The location of the sendmail or sendmail wrapper binary on the - * filesystem. - * @var string - */ - var $sendmail_path = '/usr/sbin/sendmail'; - - /** - * Any extra command-line parameters to pass to the sendmail or - * sendmail wrapper binary. - * @var string - */ - var $sendmail_args = '-i'; - - /** - * Constructor. - * - * Instantiates a new Mail_sendmail:: object based on the parameters - * passed in. It looks for the following parameters: - * sendmail_path The location of the sendmail binary on the - * filesystem. Defaults to '/usr/sbin/sendmail'. - * - * sendmail_args Any extra parameters to pass to the sendmail - * or sendmail wrapper binary. - * - * If a parameter is present in the $params array, it replaces the - * default. - * - * @param array $params Hash containing any parameters different from the - * defaults. - * @access public - */ - function Mail_sendmail($params) - { - if (isset($params['sendmail_path'])) { - $this->sendmail_path = $params['sendmail_path']; - } - if (isset($params['sendmail_args'])) { - $this->sendmail_args = $params['sendmail_args']; - } - - /* - * Because we need to pass message headers to the sendmail program on - * the commandline, we can't guarantee the use of the standard "\r\n" - * separator. Instead, we use the system's native line separator. - */ - if (defined('PHP_EOL')) { - $this->sep = PHP_EOL; - } else { - $this->sep = (strpos(PHP_OS, 'WIN') === false) ? "\n" : "\r\n"; - } - } - - /** - * Implements Mail::send() function using the sendmail - * command-line binary. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (ie, 'Subject'), and the array value - * is the header value (ie, 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * @access public - */ - function send($recipients, $headers, $body) - { - if (!is_array($headers)) { - return PEAR::raiseError('$headers must be an array'); - } - - $result = $this->_sanitizeHeaders($headers); - if (is_a($result, 'PEAR_Error')) { - return $result; - } - - $recipients = $this->parseRecipients($recipients); - if (is_a($recipients, 'PEAR_Error')) { - return $recipients; - } - $recipients = implode(' ', array_map('escapeshellarg', $recipients)); - - $headerElements = $this->prepareHeaders($headers); - if (is_a($headerElements, 'PEAR_Error')) { - return $headerElements; - } - list($from, $text_headers) = $headerElements; - - /* Since few MTAs are going to allow this header to be forged - * unless it's in the MAIL FROM: exchange, we'll use - * Return-Path instead of From: if it's set. */ - if (!empty($headers['Return-Path'])) { - $from = $headers['Return-Path']; - } - - if (!isset($from)) { - return PEAR::raiseError('No from address given.'); - } elseif (strpos($from, ' ') !== false || - strpos($from, ';') !== false || - strpos($from, '&') !== false || - strpos($from, '`') !== false) { - return PEAR::raiseError('From address specified with dangerous characters.'); - } - - $from = escapeshellarg($from); // Security bug #16200 - - $mail = @popen($this->sendmail_path . (!empty($this->sendmail_args) ? ' ' . $this->sendmail_args : '') . " -f$from -- $recipients", 'w'); - if (!$mail) { - return PEAR::raiseError('Failed to open sendmail [' . $this->sendmail_path . '] for execution.'); - } - - // Write the headers following by two newlines: one to end the headers - // section and a second to separate the headers block from the body. - fputs($mail, $text_headers . $this->sep . $this->sep); - - fputs($mail, $body); - $result = pclose($mail); - if (version_compare(phpversion(), '4.2.3') == -1) { - // With older php versions, we need to shift the pclose - // result to get the exit code. - $result = $result >> 8 & 0xFF; - } - - if ($result != 0) { - return PEAR::raiseError('sendmail returned error code ' . $result, - $result); - } - - return true; - } - -} diff --git a/data/module/Mail/smtp.php b/data/module/Mail/smtp.php deleted file mode 100644 index 52ea6020865..00000000000 --- a/data/module/Mail/smtp.php +++ /dev/null @@ -1,444 +0,0 @@ - - * @author Chuck Hagenbuch - * @copyright 2010 Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: smtp.php 294747 2010-02-08 08:18:33Z clockwerx $ - * @link http://pear.php.net/package/Mail/ - */ - -/** Error: Failed to create a Net_SMTP object */ -define('PEAR_MAIL_SMTP_ERROR_CREATE', 10000); - -/** Error: Failed to connect to SMTP server */ -define('PEAR_MAIL_SMTP_ERROR_CONNECT', 10001); - -/** Error: SMTP authentication failure */ -define('PEAR_MAIL_SMTP_ERROR_AUTH', 10002); - -/** Error: No From: address has been provided */ -define('PEAR_MAIL_SMTP_ERROR_FROM', 10003); - -/** Error: Failed to set sender */ -define('PEAR_MAIL_SMTP_ERROR_SENDER', 10004); - -/** Error: Failed to add recipient */ -define('PEAR_MAIL_SMTP_ERROR_RECIPIENT', 10005); - -/** Error: Failed to send data */ -define('PEAR_MAIL_SMTP_ERROR_DATA', 10006); - -/** - * SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class. - * @access public - * @package Mail - * @version $Revision: 294747 $ - */ -class Mail_smtp extends Mail { - - /** - * SMTP connection object. - * - * @var object - * @access private - */ - var $_smtp = null; - - /** - * The list of service extension parameters to pass to the Net_SMTP - * mailFrom() command. - * @var array - */ - var $_extparams = array(); - - /** - * The SMTP host to connect to. - * @var string - */ - var $host = 'localhost'; - - /** - * The port the SMTP server is on. - * @var integer - */ - var $port = 25; - - /** - * Should SMTP authentication be used? - * - * This value may be set to true, false or the name of a specific - * authentication method. - * - * If the value is set to true, the Net_SMTP package will attempt to use - * the best authentication method advertised by the remote SMTP server. - * - * @var mixed - */ - var $auth = false; - - /** - * The username to use if the SMTP server requires authentication. - * @var string - */ - var $username = ''; - - /** - * The password to use if the SMTP server requires authentication. - * @var string - */ - var $password = ''; - - /** - * Hostname or domain that will be sent to the remote SMTP server in the - * HELO / EHLO message. - * - * @var string - */ - var $localhost = 'localhost'; - - /** - * SMTP connection timeout value. NULL indicates no timeout. - * - * @var integer - */ - var $timeout = null; - - /** - * Turn on Net_SMTP debugging? - * - * @var boolean $debug - */ - var $debug = false; - - /** - * Indicates whether or not the SMTP connection should persist over - * multiple calls to the send() method. - * - * @var boolean - */ - var $persist = false; - - /** - * Use SMTP command pipelining (specified in RFC 2920) if the SMTP server - * supports it. This speeds up delivery over high-latency connections. By - * default, use the default value supplied by Net_SMTP. - * @var bool - */ - var $pipelining; - - /** - * Constructor. - * - * Instantiates a new Mail_smtp:: object based on the parameters - * passed in. It looks for the following parameters: - * host The server to connect to. Defaults to localhost. - * port The port to connect to. Defaults to 25. - * auth SMTP authentication. Defaults to none. - * username The username to use for SMTP auth. No default. - * password The password to use for SMTP auth. No default. - * localhost The local hostname / domain. Defaults to localhost. - * timeout The SMTP connection timeout. Defaults to none. - * verp Whether to use VERP or not. Defaults to false. - * DEPRECATED as of 1.2.0 (use setMailParams()). - * debug Activate SMTP debug mode? Defaults to false. - * persist Should the SMTP connection persist? - * pipelining Use SMTP command pipelining - * - * If a parameter is present in the $params array, it replaces the - * default. - * - * @param array Hash containing any parameters different from the - * defaults. - * @access public - */ - function Mail_smtp($params) - { - if (isset($params['host'])) $this->host = $params['host']; - if (isset($params['port'])) $this->port = $params['port']; - if (isset($params['auth'])) $this->auth = $params['auth']; - if (isset($params['username'])) $this->username = $params['username']; - if (isset($params['password'])) $this->password = $params['password']; - if (isset($params['localhost'])) $this->localhost = $params['localhost']; - if (isset($params['timeout'])) $this->timeout = $params['timeout']; - if (isset($params['debug'])) $this->debug = (bool)$params['debug']; - if (isset($params['persist'])) $this->persist = (bool)$params['persist']; - if (isset($params['pipelining'])) $this->pipelining = (bool)$params['pipelining']; - - // Deprecated options - if (isset($params['verp'])) { - $this->addServiceExtensionParameter('XVERP', is_bool($params['verp']) ? null : $params['verp']); - } - - register_shutdown_function(array(&$this, '_Mail_smtp')); - } - - /** - * Destructor implementation to ensure that we disconnect from any - * potentially-alive persistent SMTP connections. - */ - function _Mail_smtp() - { - $this->disconnect(); - } - - /** - * Implements Mail::send() function using SMTP. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (e.g., 'Subject'), and the array value - * is the header value (e.g., 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * MIME parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * @access public - */ - function send($recipients, $headers, $body) - { - /* If we don't already have an SMTP object, create one. */ - $result = &$this->getSMTPObject(); - if (PEAR::isError($result)) { - return $result; - } - - if (!is_array($headers)) { - return PEAR::raiseError('$headers must be an array'); - } - - $this->_sanitizeHeaders($headers); - - $headerElements = $this->prepareHeaders($headers); - if (is_a($headerElements, 'PEAR_Error')) { - $this->_smtp->rset(); - return $headerElements; - } - list($from, $textHeaders) = $headerElements; - - /* Since few MTAs are going to allow this header to be forged - * unless it's in the MAIL FROM: exchange, we'll use - * Return-Path instead of From: if it's set. */ - if (!empty($headers['Return-Path'])) { - $from = $headers['Return-Path']; - } - - if (!isset($from)) { - $this->_smtp->rset(); - return PEAR::raiseError('No From: address has been provided', - PEAR_MAIL_SMTP_ERROR_FROM); - } - - $params = null; - if (!empty($this->_extparams)) { - foreach ($this->_extparams as $key => $val) { - $params .= ' ' . $key . (is_null($val) ? '' : '=' . $val); - } - } - if (PEAR::isError($res = $this->_smtp->mailFrom($from, ltrim($params)))) { - $error = $this->_error("Failed to set sender: $from", $res); - $this->_smtp->rset(); - return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_SENDER); - } - - $recipients = $this->parseRecipients($recipients); - if (is_a($recipients, 'PEAR_Error')) { - $this->_smtp->rset(); - return $recipients; - } - - foreach ($recipients as $recipient) { - $res = $this->_smtp->rcptTo($recipient); - if (is_a($res, 'PEAR_Error')) { - $error = $this->_error("Failed to add recipient: $recipient", $res); - $this->_smtp->rset(); - return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_RECIPIENT); - } - } - - /* Send the message's headers and the body as SMTP data. */ - $res = $this->_smtp->data($textHeaders . "\r\n\r\n" . $body); - list(,$args) = $this->_smtp->getResponse(); - - if (preg_match("/Ok: queued as (.*)/", $args, $queued)) { - $this->queued_as = $queued[1]; - } - - /* we need the greeting; from it we can extract the authorative name of the mail server we've really connected to. - * ideal if we're connecting to a round-robin of relay servers and need to track which exact one took the email */ - $this->greeting = $this->_smtp->getGreeting(); - - if (is_a($res, 'PEAR_Error')) { - $error = $this->_error('Failed to send data', $res); - $this->_smtp->rset(); - return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_DATA); - } - - /* If persistent connections are disabled, destroy our SMTP object. */ - if ($this->persist === false) { - $this->disconnect(); - } - - return true; - } - - /** - * Connect to the SMTP server by instantiating a Net_SMTP object. - * - * @return mixed Returns a reference to the Net_SMTP object on success, or - * a PEAR_Error containing a descriptive error message on - * failure. - * - * @since 1.2.0 - * @access public - */ - function &getSMTPObject() - { - if (is_object($this->_smtp) !== false) { - return $this->_smtp; - } - - include_once 'Net/SMTP.php'; - $this->_smtp = &new Net_SMTP($this->host, - $this->port, - $this->localhost); - - /* If we still don't have an SMTP object at this point, fail. */ - if (is_object($this->_smtp) === false) { - return PEAR::raiseError('Failed to create a Net_SMTP object', - PEAR_MAIL_SMTP_ERROR_CREATE); - } - - /* Configure the SMTP connection. */ - if ($this->debug) { - $this->_smtp->setDebug(true); - } - - /* Attempt to connect to the configured SMTP server. */ - if (PEAR::isError($res = $this->_smtp->connect($this->timeout))) { - $error = $this->_error('Failed to connect to ' . - $this->host . ':' . $this->port, - $res); - return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_CONNECT); - } - - /* Attempt to authenticate if authentication has been enabled. */ - if ($this->auth) { - $method = is_string($this->auth) ? $this->auth : ''; - - if (PEAR::isError($res = $this->_smtp->auth($this->username, - $this->password, - $method))) { - $error = $this->_error("$method authentication failure", - $res); - $this->_smtp->rset(); - return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_AUTH); - } - } - - return $this->_smtp; - } - - /** - * Add parameter associated with a SMTP service extension. - * - * @param string Extension keyword. - * @param string Any value the keyword needs. - * - * @since 1.2.0 - * @access public - */ - function addServiceExtensionParameter($keyword, $value = null) - { - $this->_extparams[$keyword] = $value; - } - - /** - * Disconnect and destroy the current SMTP connection. - * - * @return boolean True if the SMTP connection no longer exists. - * - * @since 1.1.9 - * @access public - */ - function disconnect() - { - /* If we have an SMTP object, disconnect and destroy it. */ - if (is_object($this->_smtp) && $this->_smtp->disconnect()) { - $this->_smtp = null; - } - - /* We are disconnected if we no longer have an SMTP object. */ - return ($this->_smtp === null); - } - - /** - * Build a standardized string describing the current SMTP error. - * - * @param string $text Custom string describing the error context. - * @param object $error Reference to the current PEAR_Error object. - * - * @return string A string describing the current SMTP error. - * - * @since 1.1.7 - * @access private - */ - function _error($text, &$error) - { - /* Split the SMTP response into a code and a response string. */ - list($code, $response) = $this->_smtp->getResponse(); - - /* Build our standardized error string. */ - return $text - . ' [SMTP: ' . $error->getMessage() - . " (code: $code, response: $response)]"; - } - -} diff --git a/data/module/Mail/smtpmx.php b/data/module/Mail/smtpmx.php deleted file mode 100644 index f0b69408681..00000000000 --- a/data/module/Mail/smtpmx.php +++ /dev/null @@ -1,502 +0,0 @@ - - * @copyright 2010 gERD Schaufelberger - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: smtpmx.php 294747 2010-02-08 08:18:33Z clockwerx $ - * @link http://pear.php.net/package/Mail/ - */ - -require_once 'Net/SMTP.php'; - -/** - * SMTP MX implementation of the PEAR Mail interface. Requires the Net_SMTP class. - * - * - * @access public - * @author gERD Schaufelberger - * @package Mail - * @version $Revision: 294747 $ - */ -class Mail_smtpmx extends Mail { - - /** - * SMTP connection object. - * - * @var object - * @access private - */ - var $_smtp = null; - - /** - * The port the SMTP server is on. - * @var integer - * @see getservicebyname() - */ - var $port = 25; - - /** - * Hostname or domain that will be sent to the remote SMTP server in the - * HELO / EHLO message. - * - * @var string - * @see posix_uname() - */ - var $mailname = 'localhost'; - - /** - * SMTP connection timeout value. NULL indicates no timeout. - * - * @var integer - */ - var $timeout = 10; - - /** - * use either PEAR:Net_DNS or getmxrr - * - * @var boolean - */ - var $withNetDns = true; - - /** - * PEAR:Net_DNS_Resolver - * - * @var object - */ - var $resolver; - - /** - * Whether to use VERP or not. If not a boolean, the string value - * will be used as the VERP separators. - * - * @var mixed boolean or string - */ - var $verp = false; - - /** - * Whether to use VRFY or not. - * - * @var boolean $vrfy - */ - var $vrfy = false; - - /** - * Switch to test mode - don't send emails for real - * - * @var boolean $debug - */ - var $test = false; - - /** - * Turn on Net_SMTP debugging? - * - * @var boolean $peardebug - */ - var $debug = false; - - /** - * internal error codes - * - * translate internal error identifier to PEAR-Error codes and human - * readable messages. - * - * @var boolean $debug - * @todo as I need unique error-codes to identify what exactly went wrond - * I did not use intergers as it should be. Instead I added a "namespace" - * for each code. This avoids conflicts with error codes from different - * classes. How can I use unique error codes and stay conform with PEAR? - */ - var $errorCode = array( - 'not_connected' => array( - 'code' => 1, - 'msg' => 'Could not connect to any mail server ({HOST}) at port {PORT} to send mail to {RCPT}.' - ), - 'failed_vrfy_rcpt' => array( - 'code' => 2, - 'msg' => 'Recipient "{RCPT}" could not be veryfied.' - ), - 'failed_set_from' => array( - 'code' => 3, - 'msg' => 'Failed to set sender: {FROM}.' - ), - 'failed_set_rcpt' => array( - 'code' => 4, - 'msg' => 'Failed to set recipient: {RCPT}.' - ), - 'failed_send_data' => array( - 'code' => 5, - 'msg' => 'Failed to send mail to: {RCPT}.' - ), - 'no_from' => array( - 'code' => 5, - 'msg' => 'No from address has be provided.' - ), - 'send_data' => array( - 'code' => 7, - 'msg' => 'Failed to create Net_SMTP object.' - ), - 'no_mx' => array( - 'code' => 8, - 'msg' => 'No MX-record for {RCPT} found.' - ), - 'no_resolver' => array( - 'code' => 9, - 'msg' => 'Could not start resolver! Install PEAR:Net_DNS or switch off "netdns"' - ), - 'failed_rset' => array( - 'code' => 10, - 'msg' => 'RSET command failed, SMTP-connection corrupt.' - ), - ); - - /** - * Constructor. - * - * Instantiates a new Mail_smtp:: object based on the parameters - * passed in. It looks for the following parameters: - * mailname The name of the local mail system (a valid hostname which matches the reverse lookup) - * port smtp-port - the default comes from getservicebyname() and should work fine - * timeout The SMTP connection timeout. Defaults to 30 seconds. - * vrfy Whether to use VRFY or not. Defaults to false. - * verp Whether to use VERP or not. Defaults to false. - * test Activate test mode? Defaults to false. - * debug Activate SMTP and Net_DNS debug mode? Defaults to false. - * netdns whether to use PEAR:Net_DNS or the PHP build in function getmxrr, default is true - * - * If a parameter is present in the $params array, it replaces the - * default. - * - * @access public - * @param array Hash containing any parameters different from the - * defaults. - * @see _Mail_smtpmx() - */ - function __construct($params) - { - if (isset($params['mailname'])) { - $this->mailname = $params['mailname']; - } else { - // try to find a valid mailname - if (function_exists('posix_uname')) { - $uname = posix_uname(); - $this->mailname = $uname['nodename']; - } - } - - // port number - if (isset($params['port'])) { - $this->_port = $params['port']; - } else { - $this->_port = getservbyname('smtp', 'tcp'); - } - - if (isset($params['timeout'])) $this->timeout = $params['timeout']; - if (isset($params['verp'])) $this->verp = $params['verp']; - if (isset($params['test'])) $this->test = $params['test']; - if (isset($params['peardebug'])) $this->test = $params['peardebug']; - if (isset($params['netdns'])) $this->withNetDns = $params['netdns']; - } - - /** - * Constructor wrapper for PHP4 - * - * @access public - * @param array Hash containing any parameters different from the defaults - * @see __construct() - */ - function Mail_smtpmx($params) - { - $this->__construct($params); - register_shutdown_function(array(&$this, '__destruct')); - } - - /** - * Destructor implementation to ensure that we disconnect from any - * potentially-alive persistent SMTP connections. - */ - function __destruct() - { - if (is_object($this->_smtp)) { - $this->_smtp->disconnect(); - $this->_smtp = null; - } - } - - /** - * Implements Mail::send() function using SMTP direct delivery - * - * @access public - * @param mixed $recipients in RFC822 style or array - * @param array $headers The array of headers to send with the mail. - * @param string $body The full text of the message body, - * @return mixed Returns true on success, or a PEAR_Error - */ - function send($recipients, $headers, $body) - { - if (!is_array($headers)) { - return PEAR::raiseError('$headers must be an array'); - } - - $result = $this->_sanitizeHeaders($headers); - if (is_a($result, 'PEAR_Error')) { - return $result; - } - - // Prepare headers - $headerElements = $this->prepareHeaders($headers); - if (is_a($headerElements, 'PEAR_Error')) { - return $headerElements; - } - list($from, $textHeaders) = $headerElements; - - // use 'Return-Path' if possible - if (!empty($headers['Return-Path'])) { - $from = $headers['Return-Path']; - } - if (!isset($from)) { - return $this->_raiseError('no_from'); - } - - // Prepare recipients - $recipients = $this->parseRecipients($recipients); - if (is_a($recipients, 'PEAR_Error')) { - return $recipients; - } - - foreach ($recipients as $rcpt) { - list($user, $host) = explode('@', $rcpt); - - $mx = $this->_getMx($host); - if (is_a($mx, 'PEAR_Error')) { - return $mx; - } - - if (empty($mx)) { - $info = array('rcpt' => $rcpt); - return $this->_raiseError('no_mx', $info); - } - - $connected = false; - foreach ($mx as $mserver => $mpriority) { - $this->_smtp = new Net_SMTP($mserver, $this->port, $this->mailname); - - // configure the SMTP connection. - if ($this->debug) { - $this->_smtp->setDebug(true); - } - - // attempt to connect to the configured SMTP server. - $res = $this->_smtp->connect($this->timeout); - if (is_a($res, 'PEAR_Error')) { - $this->_smtp = null; - continue; - } - - // connection established - if ($res) { - $connected = true; - break; - } - } - - if (!$connected) { - $info = array( - 'host' => implode(', ', array_keys($mx)), - 'port' => $this->port, - 'rcpt' => $rcpt, - ); - return $this->_raiseError('not_connected', $info); - } - - // Verify recipient - if ($this->vrfy) { - $res = $this->_smtp->vrfy($rcpt); - if (is_a($res, 'PEAR_Error')) { - $info = array('rcpt' => $rcpt); - return $this->_raiseError('failed_vrfy_rcpt', $info); - } - } - - // mail from: - $args['verp'] = $this->verp; - $res = $this->_smtp->mailFrom($from, $args); - if (is_a($res, 'PEAR_Error')) { - $info = array('from' => $from); - return $this->_raiseError('failed_set_from', $info); - } - - // rcpt to: - $res = $this->_smtp->rcptTo($rcpt); - if (is_a($res, 'PEAR_Error')) { - $info = array('rcpt' => $rcpt); - return $this->_raiseError('failed_set_rcpt', $info); - } - - // Don't send anything in test mode - if ($this->test) { - $result = $this->_smtp->rset(); - $res = $this->_smtp->rset(); - if (is_a($res, 'PEAR_Error')) { - return $this->_raiseError('failed_rset'); - } - - $this->_smtp->disconnect(); - $this->_smtp = null; - return true; - } - - // Send data - $res = $this->_smtp->data("$textHeaders\r\n$body"); - if (is_a($res, 'PEAR_Error')) { - $info = array('rcpt' => $rcpt); - return $this->_raiseError('failed_send_data', $info); - } - - $this->_smtp->disconnect(); - $this->_smtp = null; - } - - return true; - } - - /** - * Recieve mx rexords for a spciefied host - * - * The MX records - * - * @access private - * @param string $host mail host - * @return mixed sorted - */ - function _getMx($host) - { - $mx = array(); - - if ($this->withNetDns) { - $res = $this->_loadNetDns(); - if (is_a($res, 'PEAR_Error')) { - return $res; - } - - $response = $this->resolver->query($host, 'MX'); - if (!$response) { - return false; - } - - foreach ($response->answer as $rr) { - if ($rr->type == 'MX') { - $mx[$rr->exchange] = $rr->preference; - } - } - } else { - $mxHost = array(); - $mxWeight = array(); - - if (!getmxrr($host, $mxHost, $mxWeight)) { - return false; - } - for ($i = 0; $i < count($mxHost); ++$i) { - $mx[$mxHost[$i]] = $mxWeight[$i]; - } - } - - asort($mx); - return $mx; - } - - /** - * initialize PEAR:Net_DNS_Resolver - * - * @access private - * @return boolean true on success - */ - function _loadNetDns() - { - if (is_object($this->resolver)) { - return true; - } - - if (!include_once 'Net/DNS.php') { - return $this->_raiseError('no_resolver'); - } - - $this->resolver = new Net_DNS_Resolver(); - if ($this->debug) { - $this->resolver->test = 1; - } - - return true; - } - - /** - * raise standardized error - * - * include additional information in error message - * - * @access private - * @param string $id maps error ids to codes and message - * @param array $info optional information in associative array - * @see _errorCode - */ - function _raiseError($id, $info = array()) - { - $code = $this->errorCode[$id]['code']; - $msg = $this->errorCode[$id]['msg']; - - // include info to messages - if (!empty($info)) { - $search = array(); - $replace = array(); - - foreach ($info as $key => $value) { - array_push($search, '{' . strtoupper($key) . '}'); - array_push($replace, $value); - } - - $msg = str_replace($search, $replace, $msg); - } - - return PEAR::raiseError($msg, $code); - } - -} diff --git a/data/module/Mobile/Detect.php b/data/module/Mobile/Detect.php deleted file mode 100755 index b6eb0da21b3..00000000000 --- a/data/module/Mobile/Detect.php +++ /dev/null @@ -1,1248 +0,0 @@ -, Nick Ilyin - * Original author: Victor Stanciu - * - * @license Code and contributions have 'MIT License' - * More details: https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt - * - * @link Homepage: http://mobiledetect.net - * GitHub Repo: https://github.com/serbanghita/Mobile-Detect - * Google Code: http://code.google.com/p/php-mobile-detect/ - * README: https://github.com/serbanghita/Mobile-Detect/blob/master/README.md - * HOWTO: https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples - * - * @version 2.8.3 - */ - -class Mobile_Detect -{ - /** - * Mobile detection type. - * - * @deprecated since version 2.6.9 - */ - const DETECTION_TYPE_MOBILE = 'mobile'; - - /** - * Extended detection type. - * - * @deprecated since version 2.6.9 - */ - const DETECTION_TYPE_EXTENDED = 'extended'; - - /** - * A frequently used regular expression to extract version #s. - * - * @deprecated since version 2.6.9 - */ - const VER = '([\w._\+]+)'; - - /** - * Top-level device. - */ - const MOBILE_GRADE_A = 'A'; - - /** - * Mid-level device. - */ - const MOBILE_GRADE_B = 'B'; - - /** - * Low-level device. - */ - const MOBILE_GRADE_C = 'C'; - - /** - * Stores the version number of the current release. - */ - const VERSION = '2.8.3'; - - /** - * A type for the version() method indicating a string return value. - */ - const VERSION_TYPE_STRING = 'text'; - - /** - * A type for the version() method indicating a float return value. - */ - const VERSION_TYPE_FLOAT = 'float'; - - /** - * The User-Agent HTTP header is stored in here. - * @var string - */ - protected $userAgent = null; - - /** - * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE. - * @var array - */ - protected $httpHeaders = array(); - - /** - * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED. - * - * @deprecated since version 2.6.9 - * - * @var string - */ - protected $detectionType = self::DETECTION_TYPE_MOBILE; - - /** - * HTTP headers that trigger the 'isMobile' detection - * to be true. - * - * @var array - */ - protected static $mobileHeaders = array( - - 'HTTP_ACCEPT' => array('matches' => array( - // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/ - 'application/x-obml2d', - // BlackBerry devices. - 'application/vnd.rim.html', - 'text/vnd.wap.wml', - 'application/vnd.wap.xhtml+xml' - )), - 'HTTP_X_WAP_PROFILE' => null, - 'HTTP_X_WAP_CLIENTID' => null, - 'HTTP_WAP_CONNECTION' => null, - 'HTTP_PROFILE' => null, - // Reported by Opera on Nokia devices (eg. C3). - 'HTTP_X_OPERAMINI_PHONE_UA' => null, - 'HTTP_X_NOKIA_GATEWAY_ID' => null, - 'HTTP_X_ORANGE_ID' => null, - 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null, - 'HTTP_X_HUAWEI_USERID' => null, - // Reported by Windows Smartphones. - 'HTTP_UA_OS' => null, - // Reported by Verizon, Vodafone proxy system. - 'HTTP_X_MOBILE_GATEWAY' => null, - // Seend this on HTC Sensation. @ref: SensationXE_Beats_Z715e. - 'HTTP_X_ATT_DEVICEID' => null, - // Seen this on a HTC. - 'HTTP_UA_CPU' => array('matches' => array('ARM')), - ); - - /** - * List of mobile devices (phones). - * - * @var array - */ - protected static $phoneDevices = array( - 'iPhone' => '\biPhone.*(Mobile|PhoneGap)|\biPod', // |\biTunes - 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+', - 'HTC' => 'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\bEVO\b|T-Mobile G1|Z520m', - 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile', - // @todo: Is 'Dell Streak' a tablet or a phone? ;) - 'Dell' => 'Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b', - 'Motorola' => 'Motorola|DROIDX|DROID BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925', - 'Samsung' => 'Samsung|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E', - 'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802)', - 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i', - 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile', - // @ref: http://www.micromaxinfo.com/mobiles/smartphones - // Added because the codes might conflict with Acer Tablets. - 'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b', - 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ; @todo - complete the regex. - 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;) - // @ref: http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH) - // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android. - 'Pantech' => 'PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790', - // @ref: http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones. - 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250', - 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)', - // Added simvalley mobile just for fun. They have some interesting devices. - // @ref: http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html - 'SimValley' => '\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\b', - // @Tapatalk is a mobile app; @ref: http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039 - 'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser' - ); - - /** - * List of tablet devices. - * - * @var array - */ - protected static $tabletDevices = array( - 'iPad' => 'iPad|iPad.*Mobile', // @todo: check for mobile friendly emails topic. - 'NexusTablet' => 'Android.*Nexus[\s]+(7|10)|^.*Android.*Nexus(?:(?!Mobile).)*$', - 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-I9205|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705C|SM-T535|SM-T331', // SCH-P709|SCH-P729|SM-T2558 - Samsung Mega - treat them like a regular phone. - // @reference: http://www.labnol.org/software/kindle-user-agent-string/20378/ - 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE)\b', - // Only the Surface tablets with Windows RT are considered mobile. - // @ref: http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx - 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;', - // @ref: http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT - 'HPTablet' => 'HP Slate 7|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8', - // @note: watch out for PadFone, see #132 - 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|TX201LA', - 'BlackBerryTablet' => 'PlayBook|RIM Tablet', - 'HTCtablet' => 'HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200', - 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617', - 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2', - // @ref: http://www.acer.ro/ac/ro/RO/content/drivers - // @ref: http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer) - // @ref: http://us.acer.com/ac/en/US/content/group/tablets - // @note: Can conflict with Micromax and Motorola phones codes. - 'AcerTablet' => 'Android.*; \b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-830)\b|W3-810|\bA3-A10\b', - // @ref: http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/ - // @ref: http://us.toshiba.com/tablets/tablet-finder - // @ref: http://www.toshiba.co.jp/regza/tablet/ - 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO', - // @ref: http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html - // @ref: http://www.lg.com/us/tablets - 'LGTablet' => '\bL-06C|LG-V900|LG-V500|LG-V909|LG-V500|LG-V510|LG-VK810\b', - 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b', - // Prestigio Tablets http://www.prestigio.com/support - 'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD', - // @ref: http://support.lenovo.com/en_GB/downloads/default.page?# - 'LenovoTablet' => 'IdeaTab|ThinkPad([ ]+)?Tablet|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A1000|A2107|A2109|A1107|B6000|B8000|B8080-F)', - // @ref: http://www.yarvik.com/en/matrix/tablets/ - 'YarvikTablet' => 'Android.*\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\b', - 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB', - 'ArnovaTablet' => 'AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT', - // http://www.intenso.de/kategorie_en.php?kategorie=33 - // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate - 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab', - // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/ - 'IRUTablet' => 'M702pro', - 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b', - // @ref: http://www.e-boda.ro/tablete-pc.html - 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)', - // @ref: http://www.allview.ro/produse/droseries/lista-tablete-pc/ - 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)', - // @reference: http://wiki.archosfans.com/index.php?title=Main_Page - 'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive 97R|ARCHOS 101G10|Archos 101 Neon', - // @ref: http://www.ainol.com/plugin.php?identifier=ainol&module=product - 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark', - // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER - // @ref: Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser - // @ref: http://www.sony.jp/support/tablet/ - 'SonyTablet' => 'Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551', - // @ref: db + http://www.cube-tablet.com/buy-products.html - 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT', - // @ref: http://www.cobyusa.com/?p=pcat&pcat_id=3001 - 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010', - // @ref: http://www.match.net.cn/products.asp - 'MIDTablet' => 'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733', - // @ref: http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets) - // @ref: http://www.imp3.net/14/show.php?itemid=20454 - 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)', - // @ref: http://www.rock-chips.com/index.php?do=prod&pid=2 - 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A', - // @ref: http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/ - 'FlyTablet' => 'IQ310|Fly Vision', - // @ref: http://www.bqreaders.com/gb/tablets-prices-sale.html - 'bqTablet' => 'bq.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant)|Maxwell.*Lite|Maxwell.*Plus', - // @ref: http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290 - // @ref: http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets) - 'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim', - // Nec or Medias Tab - 'NecTablet' => '\bN-06D|\bN-08D', - // Pantech Tablets: http://www.pantechusa.com/phones/ - 'PantechTablet' => 'Pantech.*P4100', - // Broncho Tablets: http://www.broncho.cn/ (hard to find) - 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)', - // @ref: http://versusuk.com/support.html - 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b', - // @ref: http://www.zync.in/index.php/our-products/tablet-phablets - 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900', - // @ref: http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/ - 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA', - // @ref: https://www.nabitablet.com/ - 'NabiTablet' => 'Android.*\bNabi', - 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build', - // French Danew Tablets http://www.danew.com/produits-tablette.php - 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b', - // Texet Tablets and Readers http://www.texet.ru/tablet/ - 'TexetTablet' => 'NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE', - // @note: Avoid detecting 'PLAYSTATION 3' as mobile. - 'PlaystationTablet' => 'Playstation.*(Portable|Vita)', - // @ref: http://www.trekstor.de/surftabs.html - 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A', - // @ref: http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets - 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b', - // @ref: http://www.advandigital.com/index.php?link=content-product&jns=JP001 - // @Note: because of the short codenames we have to include whitespaces to reduce the possible conflicts. - 'AdvanTablet' => 'Android.* \b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\b ', - // @ref: http://www.danytech.com/category/tablet-pc - 'DanyTechTablet' => 'Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1', - // @ref: http://www.galapad.net/product.html - 'GalapadTablet' => 'Android.*\bG1\b', - // @ref: http://www.micromaxinfo.com/tablet/funbook - 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b', - // http://www.karbonnmobiles.com/products_tablet.php - 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b', - // @ref: http://www.myallfine.com/Products.asp - 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide', - // @ref: http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr= - 'PROSCANTablet' => '\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\b', - // @ref: http://www.yonesnav.com/products/products.php - 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026', - // @ref: http://www.cjshowroom.com/eproducts.aspx?classcode=004001001 - // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html) - 'ChangJiaTablet' => 'TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503', - // @ref: http://www.gloryunion.cn/products.asp - // @ref: http://www.allwinnertech.com/en/apply/mobile.html - // @ref: http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB) - // @todo: Softwiner tablets? - // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions. - 'GUTablet' => 'TX-A1301|TX-M9002|Q702|kf026', // A12R|D75A|D77|D79|R83|A95|A106C|R15|A75|A76|D71|D72|R71|R73|R77|D82|R85|D92|A97|D92|R91|A10F|A77F|W71F|A78F|W78F|W81F|A97F|W91F|W97F|R16G|C72|C73E|K72|K73|R96G - // @ref: http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118 - 'PointOfViewTablet' => 'TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10', - // @ref: http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/ - // @todo: add more tests. - 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)', - // @ref: http://hclmetablet.com/India/index.php - 'HCLTablet' => 'HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync', - // @ref: http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html - 'DPSTablet' => 'DPS Dream 9|DPS Dual 7', - // @ref: http://www.visture.com/index.asp - 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10', - // @ref: http://www.mijncresta.nl/tablet - 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989', - // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309 - 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b', - // Concorde tab - 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan', - // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/ - 'GoCleverTablet' => 'GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042', - // Modecom Tablets - http://www.modecom.eu/tablets/portal/ - 'ModecomTablet' => 'FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003', - // Vonino Tablets - http://www.vonino.eu/tablets - 'VoninoTablet' => '\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\bQ8\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\b', - // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0 - 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1', - // Storex Tablets - http://storex.fr/espace_client/support.html - // @note: no need to add all the tablet codes since they are guided by the first regex. - 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab', - // Generic Vodafone tablets. - 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10', - // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb - // Aka: http://www.essentielb.fr/ - 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2', - // Ross & Moor - http://ross-moor.ru/ - 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711', - // i-mobile http://product.i-mobilephone.com/Mobile_Device - 'iMobileTablet' => 'i-mobile i-note', - // @ref: http://www.tolino.de/de/vergleichen/ - 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine', - // AudioSonic - a Kmart brand - // http://www.kmart.com.au/webapp/wcs/stores/servlet/Search?langId=-1&storeId=10701&catalogId=10001&categoryId=193001&pageSize=72¤tPage=1&searchCategory=193001%2b4294965664&sortBy=p_MaxPrice%7c1 - 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b', - // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/ - // @todo: add them gradually to avoid conflicts. - 'AMPETablet' => 'Android.* A78 ', - // Skk Mobile - http://skkmobile.com.ph/product_tablets.php - 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)', - // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1 - 'TecnoTablet' => 'TECNO P9', - // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3 - 'JXDTablet' => 'Android.*\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\b', - // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/ - 'iJoyTablet' => 'Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)', - // http://www.intracon.eu/tablet - 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10', - // http://www.xoro.de/produkte/ - // @note: Might be the same brand with 'Simply tablets' - 'XoroTablet' => 'KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151', - // http://www1.viewsonic.com/products/computing/tablets/ - 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a', - // http://www.odys.de/web/internet-tablet_en.html - 'OdysTablet' => 'LOOX|XENO10|ODYS Space', - // http://www.captiva-power.de/products.html#tablets-en - 'CaptivaTablet' => 'CAPTIVA PAD', - // IconBIT - http://www.iconbit.com/products/tablets/ - 'IconbitTablet' => 'NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S', - // @ref: http://www.tesco.com/direct/hudl/ - 'Hudl' => 'Hudl HT7S3', - // @ref: http://www.telstra.com.au/home-phone/thub-2/ - 'TelstraTablet' => 'T-Hub2', - 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4', - ); - - /** - * List of mobile Operating Systems. - * - * @var array - */ - protected static $operatingSystems = array( - 'AndroidOS' => 'Android', - 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os', - 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino', - 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b', - // @reference: http://en.wikipedia.org/wiki/Windows_Mobile - 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;', - // @reference: http://en.wikipedia.org/wiki/Windows_Phone - // http://wifeng.cn/?r=blog&a=view&id=106 - // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx - 'WindowsPhoneOS' => 'Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7', - 'iOS' => '\biPhone.*Mobile|\biPod|\biPad', - // http://en.wikipedia.org/wiki/MeeGo - // @todo: research MeeGo in UAs - 'MeeGoOS' => 'MeeGo', - // http://en.wikipedia.org/wiki/Maemo - // @todo: research Maemo in UAs - 'MaemoOS' => 'Maemo', - 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135 - 'webOS' => 'webOS|hpwOS', - 'badaOS' => '\bBada\b', - 'BREWOS' => 'BREW', - ); - - /** - * List of mobile User Agents. - * - * @var array - */ - protected static $browsers = array( - // @reference: https://developers.google.com/chrome/mobile/docs/user-agent - 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?', - 'Dolfin' => '\bDolfin\b', - 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+', - 'Skyfire' => 'Skyfire', - 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+ - 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile', - 'Bolt' => 'bolt', - 'TeaShark' => 'teashark', - 'Blazer' => 'Blazer', - // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3 - 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile', - // @ref: http://en.wikipedia.org/wiki/Midori_(web_browser) - //'Midori' => 'midori', - 'Tizen' => 'Tizen', - 'UCBrowser' => 'UC.*Browser|UCWEB', - // @ref: https://github.com/serbanghita/Mobile-Detect/issues/7 - 'DiigoBrowser' => 'DiigoBrowser', - // http://www.puffinbrowser.com/index.php - 'Puffin' => 'Puffin', - // @ref: http://mercury-browser.com/index.html - 'Mercury' => '\bMercury\b', - // @reference: http://en.wikipedia.org/wiki/Minimo - // http://en.wikipedia.org/wiki/Vision_Mobile_Browser - 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger' - ); - - /** - * Utilities. - * - * @var array - */ - protected static $utilities = array( - // Experimental. When a mobile device wants to switch to 'Desktop Mode'. - // @ref: http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/ - // @ref: https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011 - 'DesktopMode' => 'WPDesktop', - 'TV' => 'SonyDTV|HbbTV', // experimental - 'WebKit' => '(webkit)[ /]([\w.]+)', - 'Bot' => 'Googlebot|DoCoMo|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|facebookexternalhit', - 'MobileBot' => 'Googlebot-Mobile|DoCoMo|YahooSeeker/M1A1-R2D2', - // @todo: Include JXD consoles. - 'Console' => '\b(Nintendo|Nintendo WiiU|PLAYSTATION|Xbox)\b', - 'Watch' => 'SM-V700', - ); - - /** - * All possible HTTP headers that represent the - * User-Agent string. - * - * @var array - */ - protected static $uaHttpHeaders = array( - // The default User-Agent string. - 'HTTP_USER_AGENT', - // Header can occur on devices using Opera Mini. - 'HTTP_X_OPERAMINI_PHONE_UA', - // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/ - 'HTTP_X_DEVICE_USER_AGENT', - 'HTTP_X_ORIGINAL_USER_AGENT', - 'HTTP_X_SKYFIRE_PHONE', - 'HTTP_X_BOLT_PHONE_UA', - 'HTTP_DEVICE_STOCK_UA', - 'HTTP_X_UCBROWSER_DEVICE_UA' - ); - - /** - * The individual segments that could exist in a User-Agent string. VER refers to the regular - * expression defined in the constant self::VER. - * - * @var array - */ - protected static $properties = array( - - // Build - 'Mobile' => 'Mobile/[VER]', - 'Build' => 'Build/[VER]', - 'Version' => 'Version/[VER]', - 'VendorID' => 'VendorID/[VER]', - - // Devices - 'iPad' => 'iPad.*CPU[a-z ]+[VER]', - 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]', - 'iPod' => 'iPod.*CPU[a-z ]+[VER]', - //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'), - 'Kindle' => 'Kindle/[VER]', - - // Browser - 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'), - 'Coast' => array('Coast/[VER]'), - 'Dolfin' => 'Dolfin/[VER]', - // @reference: https://developer.mozilla.org/en-US/docs/User_Agent_Strings_Reference - 'Firefox' => 'Firefox/[VER]', - 'Fennec' => 'Fennec/[VER]', - // @reference: http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx - 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];'), - // http://en.wikipedia.org/wiki/NetFront - 'NetFront' => 'NetFront/[VER]', - 'NokiaBrowser' => 'NokiaBrowser/[VER]', - 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ), - 'Opera Mini' => 'Opera Mini/[VER]', - 'Opera Mobi' => 'Version/[VER]', - 'UC Browser' => 'UC Browser[VER]', - 'MQQBrowser' => 'MQQBrowser/[VER]', - 'MicroMessenger' => 'MicroMessenger/[VER]', - // @note: Safari 7534.48.3 is actually Version 5.1. - // @note: On BlackBerry the Version is overwriten by the OS. - 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ), - 'Skyfire' => 'Skyfire/[VER]', - 'Tizen' => 'Tizen/[VER]', - 'Webkit' => 'webkit[ /][VER]', - - // Engine - 'Gecko' => 'Gecko/[VER]', - 'Trident' => 'Trident/[VER]', - 'Presto' => 'Presto/[VER]', - - // OS - 'iOS' => ' \bOS\b [VER] ', - 'Android' => 'Android [VER]', - 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'), - 'BREW' => 'BREW [VER]', - 'Java' => 'Java/[VER]', - // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx - // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases - 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'), - 'Windows Phone' => 'Windows Phone [VER]', - 'Windows CE' => 'Windows CE/[VER]', - // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd - 'Windows NT' => 'Windows NT [VER]', - 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'), - 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'), - ); - - /** - * Construct an instance of this class. - * - * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored. - * If left empty, will use the global _SERVER['HTTP_*'] vars instead. - * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT - * from the $headers array instead. - */ - public function __construct( - array $headers = null, - $userAgent = null - ){ - $this->setHttpHeaders($headers); - $this->setUserAgent($userAgent); - } - - /** - * Get the current script version. - * This is useful for the demo.php file, - * so people can check on what version they are testing - * for mobile devices. - * - * @return string The version number in semantic version format. - */ - public static function getScriptVersion() - { - return self::VERSION; - } - - /** - * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers. - * - * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract - * the headers. The default null is left for backwards compatibilty. - */ - public function setHttpHeaders($httpHeaders = null) - { - //use global _SERVER if $httpHeaders aren't defined - if (!is_array($httpHeaders) || !count($httpHeaders)) { - $httpHeaders = $_SERVER; - } - - //clear existing headers - $this->httpHeaders = array(); - - //Only save HTTP headers. In PHP land, that means only _SERVER vars that - //start with HTTP_. - foreach ($httpHeaders as $key => $value) { - if (substr($key,0,5) == 'HTTP_') { - $this->httpHeaders[$key] = $value; - } - } - } - - /** - * Retrieves the HTTP headers. - * - * @return array - */ - public function getHttpHeaders() - { - return $this->httpHeaders; - } - - /** - * Retrieves a particular header. If it doesn't exist, no exception/error is caused. - * Simply null is returned. - * - * @param string $header The name of the header to retrieve. Can be HTTP compliant such as - * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the - * all-caps, HTTP_ prefixed, underscore seperated awesomeness. - * - * @return string|null The value of the header. - */ - public function getHttpHeader($header) - { - //are we using PHP-flavored headers? - if (strpos($header, '_') === false) { - $header = str_replace('-', '_', $header); - $header = strtoupper($header); - } - - //test the alternate, too - $altHeader = 'HTTP_' . $header; - - //Test both the regular and the HTTP_ prefix - if (isset($this->httpHeaders[$header])) { - return $this->httpHeaders[$header]; - } elseif (isset($this->httpHeaders[$altHeader])) { - return $this->httpHeaders[$altHeader]; - } - - return null; - } - - public function getMobileHeaders() - { - return self::$mobileHeaders; - } - - /** - * Get all possible HTTP headers that - * can contain the User-Agent string. - * - * @return array List of HTTP headers. - */ - public function getUaHttpHeaders() - { - return self::$uaHttpHeaders; - } - - /** - * Set the User-Agent to be used. - * - * @param string $userAgent The user agent string to set. - * - * @return string|null - */ - public function setUserAgent($userAgent = null) - { - if (!empty($userAgent)) { - return $this->userAgent = $userAgent; - } else { - - $this->userAgent = null; - - foreach($this->getUaHttpHeaders() as $altHeader){ - if(!empty($this->httpHeaders[$altHeader])){ // @todo: should use getHttpHeader(), but it would be slow. (Serban) - $this->userAgent .= $this->httpHeaders[$altHeader] . " "; - } - } - - return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null); - - } - } - - /** - * Retrieve the User-Agent. - * - * @return string|null The user agent if it's set. - */ - public function getUserAgent() - { - return $this->userAgent; - } - - /** - * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or - * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set. - * - * @deprecated since version 2.6.9 - * - * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default - * parameter is null which will default to self::DETECTION_TYPE_MOBILE. - */ - public function setDetectionType($type = null) - { - if ($type === null) { - $type = self::DETECTION_TYPE_MOBILE; - } - - if ($type != self::DETECTION_TYPE_MOBILE && $type != self::DETECTION_TYPE_EXTENDED) { - return; - } - - $this->detectionType = $type; - } - - /** - * Retrieve the list of known phone devices. - * - * @return array List of phone devices. - */ - public static function getPhoneDevices() - { - return self::$phoneDevices; - } - - /** - * Retrieve the list of known tablet devices. - * - * @return array List of tablet devices. - */ - public static function getTabletDevices() - { - return self::$tabletDevices; - } - - /** - * Alias for getBrowsers() method. - * - * @return array List of user agents. - */ - public static function getUserAgents() - { - return self::getBrowsers(); - } - - /** - * Retrieve the list of known browsers. Specifically, the user agents. - * - * @return array List of browsers / user agents. - */ - public static function getBrowsers() - { - return self::$browsers; - } - - /** - * Retrieve the list of known utilities. - * - * @return array List of utilities. - */ - public static function getUtilities() - { - return self::$utilities; - } - - /** - * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*(). - * - * @deprecated since version 2.6.9 - * - * @return array All the rules (but not extended). - */ - public static function getMobileDetectionRules() - { - static $rules; - - if (!$rules) { - $rules = array_merge( - self::$phoneDevices, - self::$tabletDevices, - self::$operatingSystems, - self::$browsers - ); - } - - return $rules; - - } - - /** - * Method gets the mobile detection rules + utilities. - * The reason this is separate is because utilities rules - * don't necessary imply mobile. This method is used inside - * the new $detect->is('stuff') method. - * - * @deprecated since version 2.6.9 - * - * @return array All the rules + extended. - */ - public function getMobileDetectionRulesExtended() - { - static $rules; - - if (!$rules) { - // Merge all rules together. - $rules = array_merge( - self::$phoneDevices, - self::$tabletDevices, - self::$operatingSystems, - self::$browsers, - self::$utilities - ); - } - - return $rules; - } - - /** - * Retrieve the current set of rules. - * - * @deprecated since version 2.6.9 - * - * @return array - */ - public function getRules() - { - if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) { - return self::getMobileDetectionRulesExtended(); - } else { - return self::getMobileDetectionRules(); - } - } - - /** - * Retrieve the list of mobile operating systems. - * - * @return array The list of mobile operating systems. - */ - public static function getOperatingSystems() - { - return self::$operatingSystems; - } - - /** - * Check the HTTP headers for signs of mobile. - * This is the fastest mobile check possible; it's used - * inside isMobile() method. - * - * @return bool - */ - public function checkHttpHeadersForMobile() - { - - foreach($this->getMobileHeaders() as $mobileHeader => $matchType){ - if( isset($this->httpHeaders[$mobileHeader]) ){ - if( is_array($matchType['matches']) ){ - foreach($matchType['matches'] as $_match){ - if( strpos($this->httpHeaders[$mobileHeader], $_match) !== false ){ - return true; - } - } - return false; - } else { - return true; - } - } - } - - return false; - - } - - /** - * Magic overloading method. - * - * @method boolean is[...]() - * @param string $name - * @param array $arguments - * @return mixed - * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is' - */ - public function __call($name, $arguments) - { - //make sure the name starts with 'is', otherwise - if (substr($name, 0, 2) != 'is') { - throw new BadMethodCallException("No such method exists: $name"); - } - - $this->setDetectionType(self::DETECTION_TYPE_MOBILE); - - $key = substr($name, 2); - - return $this->matchUAAgainstKey($key); - } - - /** - * Find a detection rule that matches the current User-agent. - * - * @param null $userAgent deprecated - * @return boolean - */ - protected function matchDetectionRulesAgainstUA($userAgent = null) - { - // Begin general search. - foreach ($this->getRules() as $_regex) { - if (empty($_regex)) { - continue; - } - if ($this->match($_regex, $userAgent)) { - return true; - } - } - - return false; - } - - /** - * Search for a certain key in the rules array. - * If the key is found the try to match the corresponding - * regex agains the User-Agent. - * - * @param string $key - * @param null $userAgent deprecated - * @return mixed - */ - protected function matchUAAgainstKey($key, $userAgent = null) - { - // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc. - $key = strtolower($key); - - //change the keys to lower case - $_rules = array_change_key_case($this->getRules()); - - if (array_key_exists($key, $_rules)) { - if (empty($_rules[$key])) { - return null; - } - - return $this->match($_rules[$key], $userAgent); - } - - return false; - } - - /** - * Check if the device is mobile. - * Returns true if any type of mobile device detected, including special ones - * @param null $userAgent deprecated - * @param null $httpHeaders deprecated - * @return bool - */ - public function isMobile($userAgent = null, $httpHeaders = null) - { - - if ($httpHeaders) { - $this->setHttpHeaders($httpHeaders); - } - - if ($userAgent) { - $this->setUserAgent($userAgent); - } - - $this->setDetectionType(self::DETECTION_TYPE_MOBILE); - - if ($this->checkHttpHeadersForMobile()) { - return true; - } else { - return $this->matchDetectionRulesAgainstUA(); - } - - } - - /** - * Check if the device is a tablet. - * Return true if any type of tablet device is detected. - * - * @param string $userAgent deprecated - * @param array $httpHeaders deprecated - * @return bool - */ - public function isTablet($userAgent = null, $httpHeaders = null) - { - $this->setDetectionType(self::DETECTION_TYPE_MOBILE); - - foreach (self::$tabletDevices as $_regex) { - if ($this->match($_regex, $userAgent)) { - return true; - } - } - - return false; - } - - /** - * This method checks for a certain property in the - * userAgent. - * @todo: The httpHeaders part is not yet used. - * - * @param string $key - * @param string $userAgent deprecated - * @param string $httpHeaders deprecated - * @return bool|int|null - */ - public function is($key, $userAgent = null, $httpHeaders = null) - { - // Set the UA and HTTP headers only if needed (eg. batch mode). - if ($httpHeaders) { - $this->setHttpHeaders($httpHeaders); - } - - if ($userAgent) { - $this->setUserAgent($userAgent); - } - - $this->setDetectionType(self::DETECTION_TYPE_EXTENDED); - - return $this->matchUAAgainstKey($key); - } - - /** - * Some detection rules are relative (not standard), - * because of the diversity of devices, vendors and - * their conventions in representing the User-Agent or - * the HTTP headers. - * - * This method will be used to check custom regexes against - * the User-Agent string. - * - * @param $regex - * @param string $userAgent - * @return bool - * - * @todo: search in the HTTP headers too. - */ - public function match($regex, $userAgent = null) - { - // Escape the special character which is the delimiter. - $regex = str_replace('/', '\/', $regex); - - return (bool) preg_match('/'.$regex.'/is', (!empty($userAgent) ? $userAgent : $this->userAgent)); - } - - /** - * Get the properties array. - * - * @return array - */ - public static function getProperties() - { - return self::$properties; - } - - /** - * Prepare the version number. - * - * @todo Remove the error supression from str_replace() call. - * - * @param string $ver The string version, like "2.6.21.2152"; - * - * @return float - */ - public function prepareVersionNo($ver) - { - $ver = str_replace(array('_', ' ', '/'), '.', $ver); - $arrVer = explode('.', $ver, 2); - - if (isset($arrVer[1])) { - $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions. - } - - return (float) implode('.', $arrVer); - } - - /** - * Check the version of the given property in the User-Agent. - * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31) - * - * @param string $propertyName The name of the property. See self::getProperties() array - * keys for all possible properties. - * @param string $type Either self::VERSION_TYPE_STRING to get a string value or - * self::VERSION_TYPE_FLOAT indicating a float value. This parameter - * is optional and defaults to self::VERSION_TYPE_STRING. Passing an - * invalid parameter will default to the this type as well. - * - * @return string|float The version of the property we are trying to extract. - */ - public function version($propertyName, $type = self::VERSION_TYPE_STRING) - { - if (empty($propertyName)) { - return false; - } - - //set the $type to the default if we don't recognize the type - if ($type != self::VERSION_TYPE_STRING && $type != self::VERSION_TYPE_FLOAT) { - $type = self::VERSION_TYPE_STRING; - } - - $properties = self::getProperties(); - - // Check if the property exists in the properties array. - if (array_key_exists($propertyName, $properties)) { - - // Prepare the pattern to be matched. - // Make sure we always deal with an array (string is converted). - $properties[$propertyName] = (array) $properties[$propertyName]; - - foreach ($properties[$propertyName] as $propertyMatchString) { - - $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString); - - // Escape the special character which is the delimiter. - $propertyPattern = str_replace('/', '\/', $propertyPattern); - - // Identify and extract the version. - preg_match('/'.$propertyPattern.'/is', $this->userAgent, $match); - - if (!empty($match[1])) { - $version = ( $type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1] ); - - return $version; - } - - } - - } - - return false; - } - - /** - * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants. - * - * @return string One of the self::MOBILE_GRADE_* constants. - */ - public function mobileGrade() - { - $isMobile = $this->isMobile(); - - if ( - // Apple iOS 3.2-5.1 - Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3), iPad 3 (5.1), original iPhone (3.1), iPhone 3 (3.2), 3GS (4.3), 4 (4.3 / 5.0), and 4S (5.1) - $this->isIOS() && $this->version('iPad', self::VERSION_TYPE_FLOAT)>=4.3 || - $this->isIOS() && $this->version('iPhone', self::VERSION_TYPE_FLOAT)>=3.1 || - $this->isIOS() && $this->version('iPod', self::VERSION_TYPE_FLOAT)>=3.1 || - - // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5) - // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM - // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices - // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7 - ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) || - - // Windows Phone 7-7.5 - Tested on the HTC Surround (7.0) HTC Trophy (7.5), LG-E900 (7.5), Nokia Lumia 800 - $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT)>=7.0 || - - // Blackberry 7 - Tested on BlackBerry Torch 9810 - // Blackberry 6.0 - Tested on the Torch 9800 and Style 9670 - $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)>=6.0 || - // Blackberry Playbook (1.0-2.0) - Tested on PlayBook - $this->match('Playbook.*Tablet') || - - // Palm WebOS (1.4-2.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0) - ( $this->version('webOS', self::VERSION_TYPE_FLOAT)>=1.4 && $this->match('Palm|Pre|Pixi') ) || - // Palm WebOS 3.0 - Tested on HP TouchPad - $this->match('hp.*TouchPad') || - - // Firefox Mobile (12 Beta) - Tested on Android 2.3 device - ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT)>=12 ) || - - // Chrome for Android - Tested on Android 4.0, 4.1 device - ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT)>=4.0 ) || - - // Skyfire 4.1 - Tested on Android 2.3 device - ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT)>=4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 ) || - - // Opera Mobile 11.5-12: Tested on Android 2.3 - ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT)>11 && $this->is('AndroidOS') ) || - - // Meego 1.2 - Tested on Nokia 950 and N9 - $this->is('MeeGoOS') || - - // Tizen (pre-release) - Tested on early hardware - $this->is('Tizen') || - - // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser - // @todo: more tests here! - $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT)>=2.0 || - - // UC Browser - Tested on Android 2.3 device - ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 ) || - - // Kindle 3 and Fire - Tested on the built-in WebKit browser for each - ( $this->match('Kindle Fire') || - $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT)>=3.0 ) || - - // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet - $this->is('AndroidOS') && $this->is('NookTablet') || - - // Chrome Desktop 11-21 - Tested on OS X 10.7 and Windows 7 - $this->version('Chrome', self::VERSION_TYPE_FLOAT)>=11 && !$isMobile || - - // Safari Desktop 4-5 - Tested on OS X 10.7 and Windows 7 - $this->version('Safari', self::VERSION_TYPE_FLOAT)>=5.0 && !$isMobile || - - // Firefox Desktop 4-13 - Tested on OS X 10.7 and Windows 7 - $this->version('Firefox', self::VERSION_TYPE_FLOAT)>=4.0 && !$isMobile || - - // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7 - $this->version('MSIE', self::VERSION_TYPE_FLOAT)>=7.0 && !$isMobile || - - // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7 - // @reference: http://my.opera.com/community/openweb/idopera/ - $this->version('Opera', self::VERSION_TYPE_FLOAT)>=10 && !$isMobile - - ){ - return self::MOBILE_GRADE_A; - } - - if ( - $this->isIOS() && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 || - $this->isIOS() && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<3.1 || - $this->isIOS() && $this->version('iPod', self::VERSION_TYPE_FLOAT)<3.1 || - - // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770 - $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)>=5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 || - - //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3 - ( $this->version('Opera Mini', self::VERSION_TYPE_FLOAT)>=5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT)<=6.5 && - ($this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 || $this->is('iOS')) ) || - - // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1) - $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') || - - // @todo: report this (tested on Nokia N71) - $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT)>=11 && $this->is('SymbianOS') - ){ - return self::MOBILE_GRADE_B; - } - - if ( - // Blackberry 4.x - Tested on the Curve 8330 - $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<5.0 || - // Windows Mobile - Tested on the HTC Leo (WinMo 5.2) - $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT)<=5.2 - - ){ - return self::MOBILE_GRADE_C; - } - - //All older smartphone platforms and featurephones - Any device that doesn't support media queries - //will receive the basic, C grade experience. - return self::MOBILE_GRADE_C; - } -} diff --git a/data/module/Net/SMTP.php b/data/module/Net/SMTP.php deleted file mode 100644 index e9277ffb50a..00000000000 --- a/data/module/Net/SMTP.php +++ /dev/null @@ -1,1218 +0,0 @@ - | -// | Jon Parise | -// | Damian Alejandro Fernandez Sosa | -// +----------------------------------------------------------------------+ -// -// $Id: SMTP.php 304535 2010-10-20 06:48:06Z jon $ - -require_once 'PEAR.php'; -require_once 'Net/Socket.php'; - -/** - * Provides an implementation of the SMTP protocol using PEAR's - * Net_Socket:: class. - * - * @package Net_SMTP - * @author Chuck Hagenbuch - * @author Jon Parise - * @author Damian Alejandro Fernandez Sosa - * - * @example basic.php A basic implementation of the Net_SMTP package. - */ -class Net_SMTP -{ - /** - * The server to connect to. - * @var string - * @access public - */ - var $host = 'localhost'; - - /** - * The port to connect to. - * @var int - * @access public - */ - var $port = 25; - - /** - * The value to give when sending EHLO or HELO. - * @var string - * @access public - */ - var $localhost = 'localhost'; - - /** - * List of supported authentication methods, in preferential order. - * @var array - * @access public - */ - var $auth_methods = array('DIGEST-MD5', 'CRAM-MD5', 'LOGIN', 'PLAIN'); - - /** - * Use SMTP command pipelining (specified in RFC 2920) if the SMTP - * server supports it. - * - * When pipeling is enabled, rcptTo(), mailFrom(), sendFrom(), - * somlFrom() and samlFrom() do not wait for a response from the - * SMTP server but return immediately. - * - * @var bool - * @access public - */ - var $pipelining = false; - - /** - * Number of pipelined commands. - * @var int - * @access private - */ - var $_pipelined_commands = 0; - - /** - * Should debugging output be enabled? - * @var boolean - * @access private - */ - var $_debug = false; - - /** - * Debug output handler. - * @var callback - * @access private - */ - var $_debug_handler = null; - - /** - * The socket resource being used to connect to the SMTP server. - * @var resource - * @access private - */ - var $_socket = null; - - /** - * The most recent server response code. - * @var int - * @access private - */ - var $_code = -1; - - /** - * The most recent server response arguments. - * @var array - * @access private - */ - var $_arguments = array(); - - /** - * Stores the SMTP server's greeting string. - * @var string - * @access private - */ - var $_greeting = null; - - /** - * Stores detected features of the SMTP server. - * @var array - * @access private - */ - var $_esmtp = array(); - - /** - * Instantiates a new Net_SMTP object, overriding any defaults - * with parameters that are passed in. - * - * If you have SSL support in PHP, you can connect to a server - * over SSL using an 'ssl://' prefix: - * - * // 465 is a common smtps port. - * $smtp = new Net_SMTP('ssl://mail.host.com', 465); - * $smtp->connect(); - * - * @param string $host The server to connect to. - * @param integer $port The port to connect to. - * @param string $localhost The value to give when sending EHLO or HELO. - * @param boolean $pipeling Use SMTP command pipelining - * - * @access public - * @since 1.0 - */ - function Net_SMTP($host = null, $port = null, $localhost = null, $pipelining = false) - { - if (isset($host)) { - $this->host = $host; - } - if (isset($port)) { - $this->port = $port; - } - if (isset($localhost)) { - $this->localhost = $localhost; - } - $this->pipelining = $pipelining; - - $this->_socket = new Net_Socket(); - - /* Include the Auth_SASL package. If the package is not - * available, we disable the authentication methods that - * depend upon it. */ - if ((@include_once 'Auth/SASL.php') === false) { - $pos = array_search('DIGEST-MD5', $this->auth_methods); - unset($this->auth_methods[$pos]); - $pos = array_search('CRAM-MD5', $this->auth_methods); - unset($this->auth_methods[$pos]); - } - } - - /** - * Set the value of the debugging flag. - * - * @param boolean $debug New value for the debugging flag. - * - * @access public - * @since 1.1.0 - */ - function setDebug($debug, $handler = null) - { - $this->_debug = $debug; - $this->_debug_handler = $handler; - } - - /** - * Write the given debug text to the current debug output handler. - * - * @param string $message Debug mesage text. - * - * @access private - * @since 1.3.3 - */ - function _debug($message) - { - if ($this->_debug) { - if ($this->_debug_handler) { - call_user_func_array($this->_debug_handler, - array(&$this, $message)); - } else { - echo "DEBUG: $message\n"; - } - } - } - - /** - * Send the given string of data to the server. - * - * @param string $data The string of data to send. - * - * @return mixed True on success or a PEAR_Error object on failure. - * - * @access private - * @since 1.1.0 - */ - function _send($data) - { - $this->_debug("Send: $data"); - - $error = $this->_socket->write($data); - if ($error === false || PEAR::isError($error)) { - $msg = ($error) ? $error->getMessage() : "unknown error"; - return PEAR::raiseError("Failed to write to socket: $msg"); - } - - return true; - } - - /** - * Send a command to the server with an optional string of - * arguments. A carriage return / linefeed (CRLF) sequence will - * be appended to each command string before it is sent to the - * SMTP server - an error will be thrown if the command string - * already contains any newline characters. Use _send() for - * commands that must contain newlines. - * - * @param string $command The SMTP command to send to the server. - * @param string $args A string of optional arguments to append - * to the command. - * - * @return mixed The result of the _send() call. - * - * @access private - * @since 1.1.0 - */ - function _put($command, $args = '') - { - if (!empty($args)) { - $command .= ' ' . $args; - } - - if (strcspn($command, "\r\n") !== strlen($command)) { - return PEAR::raiseError('Commands cannot contain newlines'); - } - - return $this->_send($command . "\r\n"); - } - - /** - * Read a reply from the SMTP server. The reply consists of a response - * code and a response message. - * - * @param mixed $valid The set of valid response codes. These - * may be specified as an array of integer - * values or as a single integer value. - * @param bool $later Do not parse the response now, but wait - * until the last command in the pipelined - * command group - * - * @return mixed True if the server returned a valid response code or - * a PEAR_Error object is an error condition is reached. - * - * @access private - * @since 1.1.0 - * - * @see getResponse - */ - function _parseResponse($valid, $later = false) - { - $this->_code = -1; - $this->_arguments = array(); - - if ($later) { - $this->_pipelined_commands++; - return true; - } - - for ($i = 0; $i <= $this->_pipelined_commands; $i++) { - while ($line = $this->_socket->readLine()) { - $this->_debug("Recv: $line"); - - /* If we receive an empty line, the connection has been closed. */ - if (empty($line)) { - $this->disconnect(); - return PEAR::raiseError('Connection was unexpectedly closed'); - } - - /* Read the code and store the rest in the arguments array. */ - $code = substr($line, 0, 3); - $this->_arguments[] = trim(substr($line, 4)); - - /* Check the syntax of the response code. */ - if (is_numeric($code)) { - $this->_code = (int)$code; - } else { - $this->_code = -1; - break; - } - - /* If this is not a multiline response, we're done. */ - if (substr($line, 3, 1) != '-') { - break; - } - } - } - - $this->_pipelined_commands = 0; - - /* Compare the server's response code with the valid code/codes. */ - if (is_int($valid) && ($this->_code === $valid)) { - return true; - } elseif (is_array($valid) && in_array($this->_code, $valid, true)) { - return true; - } - - return PEAR::raiseError('Invalid response code received from server', - $this->_code); - } - - /** - * Return a 2-tuple containing the last response from the SMTP server. - * - * @return array A two-element array: the first element contains the - * response code as an integer and the second element - * contains the response's arguments as a string. - * - * @access public - * @since 1.1.0 - */ - function getResponse() - { - return array($this->_code, join("\n", $this->_arguments)); - } - - /** - * Return the SMTP server's greeting string. - * - * @return string A string containing the greeting string, or null if a - * greeting has not been received. - * - * @access public - * @since 1.3.3 - */ - function getGreeting() - { - return $this->_greeting; - } - - /** - * Attempt to connect to the SMTP server. - * - * @param int $timeout The timeout value (in seconds) for the - * socket connection. - * @param bool $persistent Should a persistent socket connection - * be used? - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function connect($timeout = null, $persistent = false) - { - $this->_greeting = null; - $result = $this->_socket->connect($this->host, $this->port, - $persistent, $timeout); - if (PEAR::isError($result)) { - return PEAR::raiseError('Failed to connect socket: ' . - $result->getMessage()); - } - - if (PEAR::isError($error = $this->_parseResponse(220))) { - return $error; - } - - /* Extract and store a copy of the server's greeting string. */ - list(, $this->_greeting) = $this->getResponse(); - - if (PEAR::isError($error = $this->_negotiate())) { - return $error; - } - - return true; - } - - /** - * Attempt to disconnect from the SMTP server. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function disconnect() - { - if (PEAR::isError($error = $this->_put('QUIT'))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(221))) { - return $error; - } - if (PEAR::isError($error = $this->_socket->disconnect())) { - return PEAR::raiseError('Failed to disconnect socket: ' . - $error->getMessage()); - } - - return true; - } - - /** - * Attempt to send the EHLO command and obtain a list of ESMTP - * extensions available, and failing that just send HELO. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * - * @access private - * @since 1.1.0 - */ - function _negotiate() - { - if (PEAR::isError($error = $this->_put('EHLO', $this->localhost))) { - return $error; - } - - if (PEAR::isError($this->_parseResponse(250))) { - /* If we receive a 503 response, we're already authenticated. */ - if ($this->_code === 503) { - return true; - } - - /* If the EHLO failed, try the simpler HELO command. */ - if (PEAR::isError($error = $this->_put('HELO', $this->localhost))) { - return $error; - } - if (PEAR::isError($this->_parseResponse(250))) { - return PEAR::raiseError('HELO was not accepted: ', $this->_code); - } - - return true; - } - - foreach ($this->_arguments as $argument) { - $verb = strtok($argument, ' '); - $arguments = substr($argument, strlen($verb) + 1, - strlen($argument) - strlen($verb) - 1); - $this->_esmtp[$verb] = $arguments; - } - - if (!isset($this->_esmtp['PIPELINING'])) { - $this->pipelining = false; - } - - return true; - } - - /** - * Returns the name of the best authentication method that the server - * has advertised. - * - * @return mixed Returns a string containing the name of the best - * supported authentication method or a PEAR_Error object - * if a failure condition is encountered. - * @access private - * @since 1.1.0 - */ - function _getBestAuthMethod() - { - $available_methods = explode(' ', $this->_esmtp['AUTH']); - - foreach ($this->auth_methods as $method) { - if (in_array($method, $available_methods)) { - return $method; - } - } - - return PEAR::raiseError('No supported authentication methods'); - } - - /** - * Attempt to do SMTP authentication. - * - * @param string The userid to authenticate as. - * @param string The password to authenticate with. - * @param string The requested authentication method. If none is - * specified, the best supported method will be used. - * @param bool Flag indicating whether or not TLS should be attempted. - * @param string An optional authorization identifier. If specified, this - * identifier will be used as the authorization proxy. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function auth($uid, $pwd , $method = '', $tls = true, $authz = '') - { - /* We can only attempt a TLS connection if one has been requested, - * we're running PHP 5.1.0 or later, have access to the OpenSSL - * extension, are connected to an SMTP server which supports the - * STARTTLS extension, and aren't already connected over a secure - * (SSL) socket connection. */ - if ($tls && version_compare(PHP_VERSION, '5.1.0', '>=') && - extension_loaded('openssl') && isset($this->_esmtp['STARTTLS']) && - strncasecmp($this->host, 'ssl://', 6) !== 0) { - /* Start the TLS connection attempt. */ - if (PEAR::isError($result = $this->_put('STARTTLS'))) { - return $result; - } - if (PEAR::isError($result = $this->_parseResponse(220))) { - return $result; - } - if (PEAR::isError($result = $this->_socket->enableCrypto(true, STREAM_CRYPTO_METHOD_TLS_CLIENT))) { - return $result; - } elseif ($result !== true) { - return PEAR::raiseError('STARTTLS failed'); - } - - /* Send EHLO again to recieve the AUTH string from the - * SMTP server. */ - $this->_negotiate(); - } - - if (empty($this->_esmtp['AUTH'])) { - return PEAR::raiseError('SMTP server does not support authentication'); - } - - /* If no method has been specified, get the name of the best - * supported method advertised by the SMTP server. */ - if (empty($method)) { - if (PEAR::isError($method = $this->_getBestAuthMethod())) { - /* Return the PEAR_Error object from _getBestAuthMethod(). */ - return $method; - } - } else { - $method = strtoupper($method); - if (!in_array($method, $this->auth_methods)) { - return PEAR::raiseError("$method is not a supported authentication method"); - } - } - - switch ($method) { - case 'DIGEST-MD5': - $result = $this->_authDigest_MD5($uid, $pwd, $authz); - break; - - case 'CRAM-MD5': - $result = $this->_authCRAM_MD5($uid, $pwd); - break; - - case 'LOGIN': - $result = $this->_authLogin($uid, $pwd); - break; - - case 'PLAIN': - $result = $this->_authPlain($uid, $pwd, $authz); - break; - - default: - $result = PEAR::raiseError("$method is not a supported authentication method"); - break; - } - - /* If an error was encountered, return the PEAR_Error object. */ - if (PEAR::isError($result)) { - return $result; - } - - return true; - } - - /** - * Authenticates the user using the DIGEST-MD5 method. - * - * @param string The userid to authenticate as. - * @param string The password to authenticate with. - * @param string The optional authorization proxy identifier. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access private - * @since 1.1.0 - */ - function _authDigest_MD5($uid, $pwd, $authz = '') - { - if (PEAR::isError($error = $this->_put('AUTH', 'DIGEST-MD5'))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - /* 503: Error: already authenticated */ - if ($this->_code === 503) { - return true; - } - return $error; - } - - $challenge = base64_decode($this->_arguments[0]); - $digest = &Auth_SASL::factory('digestmd5'); - $auth_str = base64_encode($digest->getResponse($uid, $pwd, $challenge, - $this->host, "smtp")); - - if (PEAR::isError($error = $this->_put($auth_str))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - return $error; - } - - /* We don't use the protocol's third step because SMTP doesn't - * allow subsequent authentication, so we just silently ignore - * it. */ - if (PEAR::isError($error = $this->_put(''))) { - return $error; - } - /* 235: Authentication successful */ - if (PEAR::isError($error = $this->_parseResponse(235))) { - return $error; - } - } - - /** - * Authenticates the user using the CRAM-MD5 method. - * - * @param string The userid to authenticate as. - * @param string The password to authenticate with. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access private - * @since 1.1.0 - */ - function _authCRAM_MD5($uid, $pwd) - { - if (PEAR::isError($error = $this->_put('AUTH', 'CRAM-MD5'))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - /* 503: Error: already authenticated */ - if ($this->_code === 503) { - return true; - } - return $error; - } - - $challenge = base64_decode($this->_arguments[0]); - $cram = &Auth_SASL::factory('crammd5'); - $auth_str = base64_encode($cram->getResponse($uid, $pwd, $challenge)); - - if (PEAR::isError($error = $this->_put($auth_str))) { - return $error; - } - - /* 235: Authentication successful */ - if (PEAR::isError($error = $this->_parseResponse(235))) { - return $error; - } - } - - /** - * Authenticates the user using the LOGIN method. - * - * @param string The userid to authenticate as. - * @param string The password to authenticate with. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access private - * @since 1.1.0 - */ - function _authLogin($uid, $pwd) - { - if (PEAR::isError($error = $this->_put('AUTH', 'LOGIN'))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - /* 503: Error: already authenticated */ - if ($this->_code === 503) { - return true; - } - return $error; - } - - if (PEAR::isError($error = $this->_put(base64_encode($uid)))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - return $error; - } - - if (PEAR::isError($error = $this->_put(base64_encode($pwd)))) { - return $error; - } - - /* 235: Authentication successful */ - if (PEAR::isError($error = $this->_parseResponse(235))) { - return $error; - } - - return true; - } - - /** - * Authenticates the user using the PLAIN method. - * - * @param string The userid to authenticate as. - * @param string The password to authenticate with. - * @param string The optional authorization proxy identifier. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access private - * @since 1.1.0 - */ - function _authPlain($uid, $pwd, $authz = '') - { - if (PEAR::isError($error = $this->_put('AUTH', 'PLAIN'))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - /* 503: Error: already authenticated */ - if ($this->_code === 503) { - return true; - } - return $error; - } - - $auth_str = base64_encode($authz . chr(0) . $uid . chr(0) . $pwd); - - if (PEAR::isError($error = $this->_put($auth_str))) { - return $error; - } - - /* 235: Authentication successful */ - if (PEAR::isError($error = $this->_parseResponse(235))) { - return $error; - } - - return true; - } - - /** - * Send the HELO command. - * - * @param string The domain name to say we are. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function helo($domain) - { - if (PEAR::isError($error = $this->_put('HELO', $domain))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Return the list of SMTP service extensions advertised by the server. - * - * @return array The list of SMTP service extensions. - * @access public - * @since 1.3 - */ - function getServiceExtensions() - { - return $this->_esmtp; - } - - /** - * Send the MAIL FROM: command. - * - * @param string $sender The sender (reverse path) to set. - * @param string $params String containing additional MAIL parameters, - * such as the NOTIFY flags defined by RFC 1891 - * or the VERP protocol. - * - * If $params is an array, only the 'verp' option - * is supported. If 'verp' is true, the XVERP - * parameter is appended to the MAIL command. If - * the 'verp' value is a string, the full - * XVERP=value parameter is appended. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function mailFrom($sender, $params = null) - { - $args = "FROM:<$sender>"; - - /* Support the deprecated array form of $params. */ - if (is_array($params) && isset($params['verp'])) { - /* XVERP */ - if ($params['verp'] === true) { - $args .= ' XVERP'; - - /* XVERP=something */ - } elseif (trim($params['verp'])) { - $args .= ' XVERP=' . $params['verp']; - } - } elseif (is_string($params)) { - $args .= ' ' . $params; - } - - if (PEAR::isError($error = $this->_put('MAIL', $args))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { - return $error; - } - - return true; - } - - /** - * Send the RCPT TO: command. - * - * @param string $recipient The recipient (forward path) to add. - * @param string $params String containing additional RCPT parameters, - * such as the NOTIFY flags defined by RFC 1891. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * - * @access public - * @since 1.0 - */ - function rcptTo($recipient, $params = null) - { - $args = "TO:<$recipient>"; - if (is_string($params)) { - $args .= ' ' . $params; - } - - if (PEAR::isError($error = $this->_put('RCPT', $args))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(array(250, 251), $this->pipelining))) { - return $error; - } - - return true; - } - - /** - * Quote the data so that it meets SMTP standards. - * - * This is provided as a separate public function to facilitate - * easier overloading for the cases where it is desirable to - * customize the quoting behavior. - * - * @param string $data The message text to quote. The string must be passed - * by reference, and the text will be modified in place. - * - * @access public - * @since 1.2 - */ - function quotedata(&$data) - { - /* Change Unix (\n) and Mac (\r) linefeeds into - * Internet-standard CRLF (\r\n) linefeeds. */ - $data = preg_replace(array('/(?_esmtp['SIZE'])) ? $this->_esmtp['SIZE'] : 0; - if ($limit > 0 && $size >= $limit) { - $this->disconnect(); - return PEAR::raiseError('Message size exceeds server limit'); - } - - /* Initiate the DATA command. */ - if (PEAR::isError($error = $this->_put('DATA'))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(354))) { - return $error; - } - - /* If we have a separate headers string, send it first. */ - if (!is_null($headers)) { - $this->quotedata($headers); - if (PEAR::isError($result = $this->_send($headers . "\r\n\r\n"))) { - return $result; - } - } - - /* Now we can send the message body data. */ - if (is_resource($data)) { - /* Stream the contents of the file resource out over our socket - * connection, line by line. Each line must be run through the - * quoting routine. */ - while ($line = fgets($data, 1024)) { - $this->quotedata($line); - if (PEAR::isError($result = $this->_send($line))) { - return $result; - } - } - } else { - /* - * Break up the data by sending one chunk (up to 512k) at a time. - * This approach reduces our peak memory usage. - */ - for ($offset = 0; $offset < $size;) { - $end = $offset + 512000; - - /* - * Ensure we don't read beyond our data size or span multiple - * lines. quotedata() can't properly handle character data - * that's split across two line break boundaries. - */ - if ($end >= $size) { - $end = $size; - } else { - for (; $end < $size; $end++) { - if ($data[$end] != "\n") { - break; - } - } - } - - /* Extract our chunk and run it through the quoting routine. */ - $chunk = substr($data, $offset, $end - $offset); - $this->quotedata($chunk); - - /* If we run into a problem along the way, abort. */ - if (PEAR::isError($result = $this->_send($chunk))) { - return $result; - } - - /* Advance the offset to the end of this chunk. */ - $offset = $end; - } - } - - /* Finally, send the DATA terminator sequence. */ - if (PEAR::isError($result = $this->_send("\r\n.\r\n"))) { - return $result; - } - - /* Verify that the data was successfully received by the server. */ - if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { - return $error; - } - - return true; - } - - /** - * Send the SEND FROM: command. - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.2.6 - */ - function sendFrom($path) - { - if (PEAR::isError($error = $this->_put('SEND', "FROM:<$path>"))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { - return $error; - } - - return true; - } - - /** - * Backwards-compatibility wrapper for sendFrom(). - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * - * @access public - * @since 1.0 - * @deprecated 1.2.6 - */ - function send_from($path) - { - return sendFrom($path); - } - - /** - * Send the SOML FROM: command. - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.2.6 - */ - function somlFrom($path) - { - if (PEAR::isError($error = $this->_put('SOML', "FROM:<$path>"))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { - return $error; - } - - return true; - } - - /** - * Backwards-compatibility wrapper for somlFrom(). - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * - * @access public - * @since 1.0 - * @deprecated 1.2.6 - */ - function soml_from($path) - { - return somlFrom($path); - } - - /** - * Send the SAML FROM: command. - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.2.6 - */ - function samlFrom($path) - { - if (PEAR::isError($error = $this->_put('SAML', "FROM:<$path>"))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { - return $error; - } - - return true; - } - - /** - * Backwards-compatibility wrapper for samlFrom(). - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * - * @access public - * @since 1.0 - * @deprecated 1.2.6 - */ - function saml_from($path) - { - return samlFrom($path); - } - - /** - * Send the RSET command. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function rset() - { - if (PEAR::isError($error = $this->_put('RSET'))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) { - return $error; - } - - return true; - } - - /** - * Send the VRFY command. - * - * @param string The string to verify - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function vrfy($string) - { - /* Note: 251 is also a valid response code */ - if (PEAR::isError($error = $this->_put('VRFY', $string))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(array(250, 252)))) { - return $error; - } - - return true; - } - - /** - * Send the NOOP command. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function noop() - { - if (PEAR::isError($error = $this->_put('NOOP'))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Backwards-compatibility method. identifySender()'s functionality is - * now handled internally. - * - * @return boolean This method always return true. - * - * @access public - * @since 1.0 - */ - function identifySender() - { - return true; - } - -} diff --git a/data/module/Net/Socket.php b/data/module/Net/Socket.php deleted file mode 100644 index dd1047c4310..00000000000 --- a/data/module/Net/Socket.php +++ /dev/null @@ -1,653 +0,0 @@ - - * Chuck Hagenbuch - * - * @category Net - * @package Net_Socket - * @author Stig Bakken - * @author Chuck Hagenbuch - * @copyright 1997-2003 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP 2.02 - * @version CVS: $Id$ - * @link http://pear.php.net/packages/Net_Socket - */ - -require_once 'PEAR.php'; - -define('NET_SOCKET_READ', 1); -define('NET_SOCKET_WRITE', 2); -define('NET_SOCKET_ERROR', 4); - -/** - * Generalized Socket class. - * - * @category Net - * @package Net_Socket - * @author Stig Bakken - * @author Chuck Hagenbuch - * @copyright 1997-2003 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP 2.02 - * @link http://pear.php.net/packages/Net_Socket - */ -class Net_Socket extends PEAR -{ - /** - * Socket file pointer. - * @var resource $fp - */ - var $fp = null; - - /** - * Whether the socket is blocking. Defaults to true. - * @var boolean $blocking - */ - var $blocking = true; - - /** - * Whether the socket is persistent. Defaults to false. - * @var boolean $persistent - */ - var $persistent = false; - - /** - * The IP address to connect to. - * @var string $addr - */ - var $addr = ''; - - /** - * The port number to connect to. - * @var integer $port - */ - var $port = 0; - - /** - * Number of seconds to wait on socket connections before assuming - * there's no more data. Defaults to no timeout. - * @var integer $timeout - */ - var $timeout = false; - - /** - * Number of bytes to read at a time in readLine() and - * readAll(). Defaults to 2048. - * @var integer $lineLength - */ - var $lineLength = 2048; - - /** - * The string to use as a newline terminator. Usually "\r\n" or "\n". - * @var string $newline - */ - var $newline = "\r\n"; - - /** - * Connect to the specified port. If called when the socket is - * already connected, it disconnects and connects again. - * - * @param string $addr IP address or host name. - * @param integer $port TCP port number. - * @param boolean $persistent (optional) Whether the connection is - * persistent (kept open between requests - * by the web server). - * @param integer $timeout (optional) How long to wait for data. - * @param array $options See options for stream_context_create. - * - * @access public - * - * @return boolean | PEAR_Error True on success or a PEAR_Error on failure. - */ - function connect($addr, $port = 0, $persistent = null, - $timeout = null, $options = null) - { - if (is_resource($this->fp)) { - @fclose($this->fp); - $this->fp = null; - } - - if (!$addr) { - return $this->raiseError('$addr cannot be empty'); - } elseif (strspn($addr, '.0123456789') == strlen($addr) || - strstr($addr, '/') !== false) { - $this->addr = $addr; - } else { - $this->addr = @gethostbyname($addr); - } - - $this->port = $port % 65536; - - if ($persistent !== null) { - $this->persistent = $persistent; - } - - if ($timeout !== null) { - $this->timeout = $timeout; - } - - $openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen'; - $errno = 0; - $errstr = ''; - - $old_track_errors = @ini_set('track_errors', 1); - - if ($options && function_exists('stream_context_create')) { - if ($this->timeout) { - $timeout = $this->timeout; - } else { - $timeout = 0; - } - $context = stream_context_create($options); - - // Since PHP 5 fsockopen doesn't allow context specification - if (function_exists('stream_socket_client')) { - $flags = STREAM_CLIENT_CONNECT; - - if ($this->persistent) { - $flags = STREAM_CLIENT_PERSISTENT; - } - - $addr = $this->addr . ':' . $this->port; - $fp = stream_socket_client($addr, $errno, $errstr, - $timeout, $flags, $context); - } else { - $fp = @$openfunc($this->addr, $this->port, $errno, - $errstr, $timeout, $context); - } - } else { - if ($this->timeout) { - $fp = @$openfunc($this->addr, $this->port, $errno, - $errstr, $this->timeout); - } else { - $fp = @$openfunc($this->addr, $this->port, $errno, $errstr); - } - } - - if (!$fp) { - if ($errno == 0 && !strlen($errstr) && isset($php_errormsg)) { - $errstr = $php_errormsg; - } - @ini_set('track_errors', $old_track_errors); - return $this->raiseError($errstr, $errno); - } - - @ini_set('track_errors', $old_track_errors); - $this->fp = $fp; - - return $this->setBlocking($this->blocking); - } - - /** - * Disconnects from the peer, closes the socket. - * - * @access public - * @return mixed true on success or a PEAR_Error instance otherwise - */ - function disconnect() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - @fclose($this->fp); - $this->fp = null; - return true; - } - - /** - * Set the newline character/sequence to use. - * - * @param string $newline Newline character(s) - * @return boolean True - */ - function setNewline($newline) - { - $this->newline = $newline; - return true; - } - - /** - * Find out if the socket is in blocking mode. - * - * @access public - * @return boolean The current blocking mode. - */ - function isBlocking() - { - return $this->blocking; - } - - /** - * Sets whether the socket connection should be blocking or - * not. A read call to a non-blocking socket will return immediately - * if there is no data available, whereas it will block until there - * is data for blocking sockets. - * - * @param boolean $mode True for blocking sockets, false for nonblocking. - * - * @access public - * @return mixed true on success or a PEAR_Error instance otherwise - */ - function setBlocking($mode) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $this->blocking = $mode; - stream_set_blocking($this->fp, (int)$this->blocking); - return true; - } - - /** - * Sets the timeout value on socket descriptor, - * expressed in the sum of seconds and microseconds - * - * @param integer $seconds Seconds. - * @param integer $microseconds Microseconds. - * - * @access public - * @return mixed true on success or a PEAR_Error instance otherwise - */ - function setTimeout($seconds, $microseconds) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return socket_set_timeout($this->fp, $seconds, $microseconds); - } - - /** - * Sets the file buffering size on the stream. - * See php's stream_set_write_buffer for more information. - * - * @param integer $size Write buffer size. - * - * @access public - * @return mixed on success or an PEAR_Error object otherwise - */ - function setWriteBuffer($size) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $returned = stream_set_write_buffer($this->fp, $size); - if ($returned == 0) { - return true; - } - return $this->raiseError('Cannot set write buffer.'); - } - - /** - * Returns information about an existing socket resource. - * Currently returns four entries in the result array: - * - *

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

- * - * @access public - * @return mixed Array containing information about existing socket - * resource or a PEAR_Error instance otherwise - */ - function getStatus() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return socket_get_status($this->fp); - } - - /** - * Get a specified line of data - * - * @param int $size ?? - * - * @access public - * @return $size bytes of data from the socket, or a PEAR_Error if - * not connected. - */ - function gets($size = null) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - if (is_null($size)) { - return @fgets($this->fp); - } else { - return @fgets($this->fp, $size); - } - } - - /** - * Read a specified amount of data. This is guaranteed to return, - * and has the added benefit of getting everything in one fread() - * chunk; if you know the size of the data you're getting - * beforehand, this is definitely the way to go. - * - * @param integer $size The number of bytes to read from the socket. - * - * @access public - * @return $size bytes of data from the socket, or a PEAR_Error if - * not connected. - */ - function read($size) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return @fread($this->fp, $size); - } - - /** - * Write a specified amount of data. - * - * @param string $data Data to write. - * @param integer $blocksize Amount of data to write at once. - * NULL means all at once. - * - * @access public - * @return mixed If the socket is not connected, returns an instance of - * PEAR_Error - * If the write succeeds, returns the number of bytes written - * If the write fails, returns false. - */ - function write($data, $blocksize = null) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - if (is_null($blocksize) && !OS_WINDOWS) { - return @fwrite($this->fp, $data); - } else { - if (is_null($blocksize)) { - $blocksize = 1024; - } - - $pos = 0; - $size = strlen($data); - while ($pos < $size) { - $written = @fwrite($this->fp, substr($data, $pos, $blocksize)); - if (!$written) { - return $written; - } - $pos += $written; - } - - return $pos; - } - } - - /** - * Write a line of data to the socket, followed by a trailing newline. - * - * @param string $data Data to write - * - * @access public - * @return mixed fputs result, or an error - */ - function writeLine($data) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return fwrite($this->fp, $data . $this->newline); - } - - /** - * Tests for end-of-file on a socket descriptor. - * - * Also returns true if the socket is disconnected. - * - * @access public - * @return bool - */ - function eof() - { - return (!is_resource($this->fp) || feof($this->fp)); - } - - /** - * Reads a byte of data - * - * @access public - * @return 1 byte of data from the socket, or a PEAR_Error if - * not connected. - */ - function readByte() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return ord(@fread($this->fp, 1)); - } - - /** - * Reads a word of data - * - * @access public - * @return 1 word of data from the socket, or a PEAR_Error if - * not connected. - */ - function readWord() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 2); - return (ord($buf[0]) + (ord($buf[1]) << 8)); - } - - /** - * Reads an int of data - * - * @access public - * @return integer 1 int of data from the socket, or a PEAR_Error if - * not connected. - */ - function readInt() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 4); - return (ord($buf[0]) + (ord($buf[1]) << 8) + - (ord($buf[2]) << 16) + (ord($buf[3]) << 24)); - } - - /** - * Reads a zero-terminated string of data - * - * @access public - * @return string, or a PEAR_Error if - * not connected. - */ - function readString() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $string = ''; - while (($char = @fread($this->fp, 1)) != "\x00") { - $string .= $char; - } - return $string; - } - - /** - * Reads an IP Address and returns it in a dot formatted string - * - * @access public - * @return Dot formatted string, or a PEAR_Error if - * not connected. - */ - function readIPAddress() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 4); - return sprintf('%d.%d.%d.%d', ord($buf[0]), ord($buf[1]), - ord($buf[2]), ord($buf[3])); - } - - /** - * Read until either the end of the socket or a newline, whichever - * comes first. Strips the trailing newline from the returned data. - * - * @access public - * @return All available data up to a newline, without that - * newline, or until the end of the socket, or a PEAR_Error if - * not connected. - */ - function readLine() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $line = ''; - - $timeout = time() + $this->timeout; - - while (!feof($this->fp) && (!$this->timeout || time() < $timeout)) { - $line .= @fgets($this->fp, $this->lineLength); - if (substr($line, -1) == "\n") { - return rtrim($line, $this->newline); - } - } - return $line; - } - - /** - * Read until the socket closes, or until there is no more data in - * the inner PHP buffer. If the inner buffer is empty, in blocking - * mode we wait for at least 1 byte of data. Therefore, in - * blocking mode, if there is no data at all to be read, this - * function will never exit (unless the socket is closed on the - * remote end). - * - * @access public - * - * @return string All data until the socket closes, or a PEAR_Error if - * not connected. - */ - function readAll() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $data = ''; - while (!feof($this->fp)) { - $data .= @fread($this->fp, $this->lineLength); - } - return $data; - } - - /** - * Runs the equivalent of the select() system call on the socket - * with a timeout specified by tv_sec and tv_usec. - * - * @param integer $state Which of read/write/error to check for. - * @param integer $tv_sec Number of seconds for timeout. - * @param integer $tv_usec Number of microseconds for timeout. - * - * @access public - * @return False if select fails, integer describing which of read/write/error - * are ready, or PEAR_Error if not connected. - */ - function select($state, $tv_sec, $tv_usec = 0) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $read = null; - $write = null; - $except = null; - if ($state & NET_SOCKET_READ) { - $read[] = $this->fp; - } - if ($state & NET_SOCKET_WRITE) { - $write[] = $this->fp; - } - if ($state & NET_SOCKET_ERROR) { - $except[] = $this->fp; - } - if (false === ($sr = stream_select($read, $write, $except, - $tv_sec, $tv_usec))) { - return false; - } - - $result = 0; - if (count($read)) { - $result |= NET_SOCKET_READ; - } - if (count($write)) { - $result |= NET_SOCKET_WRITE; - } - if (count($except)) { - $result |= NET_SOCKET_ERROR; - } - return $result; - } - - /** - * Turns encryption on/off on a connected socket. - * - * @param bool $enabled Set this parameter to true to enable encryption - * and false to disable encryption. - * @param integer $type Type of encryption. See stream_socket_enable_crypto() - * for values. - * - * @see http://se.php.net/manual/en/function.stream-socket-enable-crypto.php - * @access public - * @return false on error, true on success and 0 if there isn't enough data - * and the user should try again (non-blocking sockets only). - * A PEAR_Error object is returned if the socket is not - * connected - */ - function enableCrypto($enabled, $type) - { - if (version_compare(phpversion(), "5.1.0", ">=")) { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - return @stream_socket_enable_crypto($this->fp, $enabled, $type); - } else { - $msg = 'Net_Socket::enableCrypto() requires php version >= 5.1.0'; - return $this->raiseError($msg); - } - } - -} diff --git a/data/module/Net/URL.php b/data/module/Net/URL.php deleted file mode 100644 index 5064a12ea79..00000000000 --- a/data/module/Net/URL.php +++ /dev/null @@ -1,485 +0,0 @@ - | -// +-----------------------------------------------------------------------+ -// -// $Id$ -// -// Net_URL Class - - -class Net_URL -{ - var $options = array('encode_query_keys' => false); - /** - * Full url - * @var string - */ - var $url; - - /** - * Protocol - * @var string - */ - var $protocol; - - /** - * Username - * @var string - */ - var $username; - - /** - * Password - * @var string - */ - var $password; - - /** - * Host - * @var string - */ - var $host; - - /** - * Port - * @var integer - */ - var $port; - - /** - * Path - * @var string - */ - var $path; - - /** - * Query string - * @var array - */ - var $querystring; - - /** - * Anchor - * @var string - */ - var $anchor; - - /** - * Whether to use [] - * @var bool - */ - var $useBrackets; - - /** - * PHP4 Constructor - * - * @see __construct() - */ - function Net_URL($url = null, $useBrackets = true) - { - $this->__construct($url, $useBrackets); - } - - /** - * PHP5 Constructor - * - * Parses the given url and stores the various parts - * Defaults are used in certain cases - * - * @param string $url Optional URL - * @param bool $useBrackets Whether to use square brackets when - * multiple querystrings with the same name - * exist - */ - function __construct($url = null, $useBrackets = true) - { - $this->url = $url; - $this->useBrackets = $useBrackets; - - $this->initialize(); - } - - function initialize() - { - $HTTP_SERVER_VARS = !empty($_SERVER) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; - - $this->user = ''; - $this->pass = ''; - $this->host = ''; - $this->port = 80; - $this->path = ''; - $this->querystring = array(); - $this->anchor = ''; - - // Only use defaults if not an absolute URL given - if (!preg_match('/^[a-z0-9]+:\/\//i', $this->url)) { - $this->protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http'); - - /** - * Figure out host/port - */ - if (!empty($HTTP_SERVER_VARS['HTTP_HOST']) && - preg_match('/^(.*)(:([0-9]+))?$/U', $HTTP_SERVER_VARS['HTTP_HOST'], $matches)) - { - $host = $matches[1]; - if (!empty($matches[3])) { - $port = $matches[3]; - } else { - $port = $this->getStandardPort($this->protocol); - } - } - - $this->user = ''; - $this->pass = ''; - $this->host = !empty($host) ? $host : (isset($HTTP_SERVER_VARS['SERVER_NAME']) ? $HTTP_SERVER_VARS['SERVER_NAME'] : 'localhost'); - $this->port = !empty($port) ? $port : (isset($HTTP_SERVER_VARS['SERVER_PORT']) ? $HTTP_SERVER_VARS['SERVER_PORT'] : $this->getStandardPort($this->protocol)); - $this->path = !empty($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : '/'; - $this->querystring = isset($HTTP_SERVER_VARS['QUERY_STRING']) ? $this->_parseRawQuerystring($HTTP_SERVER_VARS['QUERY_STRING']) : null; - $this->anchor = ''; - } - - // Parse the url and store the various parts - if (!empty($this->url)) { - $urlinfo = parse_url($this->url); - - // Default querystring - $this->querystring = array(); - - foreach ($urlinfo as $key => $value) { - switch ($key) { - case 'scheme': - $this->protocol = $value; - $this->port = $this->getStandardPort($value); - break; - - case 'user': - case 'pass': - case 'host': - case 'port': - $this->$key = $value; - break; - - case 'path': - if ($value{0} == '/') { - $this->path = $value; - } else { - $path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path); - $this->path = sprintf('%s/%s', $path, $value); - } - break; - - case 'query': - $this->querystring = $this->_parseRawQueryString($value); - break; - - case 'fragment': - $this->anchor = $value; - break; - } - } - } - } - /** - * Returns full url - * - * @return string Full url - * @access public - */ - function getURL() - { - $querystring = $this->getQueryString(); - - $this->url = $this->protocol . '://' - . $this->user . (!empty($this->pass) ? ':' : '') - . $this->pass . (!empty($this->user) ? '@' : '') - . $this->host . ($this->port == $this->getStandardPort($this->protocol) ? '' : ':' . $this->port) - . $this->path - . (!empty($querystring) ? '?' . $querystring : '') - . (!empty($this->anchor) ? '#' . $this->anchor : ''); - - return $this->url; - } - - /** - * Adds or updates a querystring item (URL parameter). - * Automatically encodes parameters with rawurlencode() if $preencoded - * is false. - * You can pass an array to $value, it gets mapped via [] in the URL if - * $this->useBrackets is activated. - * - * @param string $name Name of item - * @param string $value Value of item - * @param bool $preencoded Whether value is urlencoded or not, default = not - * @access public - */ - function addQueryString($name, $value, $preencoded = false) - { - if ($this->getOption('encode_query_keys')) { - $name = rawurlencode($name); - } - - if ($preencoded) { - $this->querystring[$name] = $value; - } else { - $this->querystring[$name] = is_array($value) ? array_map('rawurlencode', $value): rawurlencode($value); - } - } - - /** - * Removes a querystring item - * - * @param string $name Name of item - * @access public - */ - function removeQueryString($name) - { - if ($this->getOption('encode_query_keys')) { - $name = rawurlencode($name); - } - - if (isset($this->querystring[$name])) { - unset($this->querystring[$name]); - } - } - - /** - * Sets the querystring to literally what you supply - * - * @param string $querystring The querystring data. Should be of the format foo=bar&x=y etc - * @access public - */ - function addRawQueryString($querystring) - { - $this->querystring = $this->_parseRawQueryString($querystring); - } - - /** - * Returns flat querystring - * - * @return string Querystring - * @access public - */ - function getQueryString() - { - if (!empty($this->querystring)) { - foreach ($this->querystring as $name => $value) { - // Encode var name - $name = rawurlencode($name); - - if (is_array($value)) { - foreach ($value as $k => $v) { - $querystring[] = $this->useBrackets ? sprintf('%s[%s]=%s', $name, $k, $v) : ($name . '=' . $v); - } - } elseif (!is_null($value)) { - $querystring[] = $name . '=' . $value; - } else { - $querystring[] = $name; - } - } - $querystring = implode(ini_get('arg_separator.output'), $querystring); - } else { - $querystring = ''; - } - - return $querystring; - } - - /** - * Parses raw querystring and returns an array of it - * - * @param string $querystring The querystring to parse - * @return array An array of the querystring data - * @access private - */ - function _parseRawQuerystring($querystring) - { - $parts = preg_split('/[' . preg_quote(ini_get('arg_separator.input'), '/') . ']/', $querystring, -1, PREG_SPLIT_NO_EMPTY); - $return = array(); - - foreach ($parts as $part) { - if (strpos($part, '=') !== false) { - $value = substr($part, strpos($part, '=') + 1); - $key = substr($part, 0, strpos($part, '=')); - } else { - $value = null; - $key = $part; - } - - if (!$this->getOption('encode_query_keys')) { - $key = rawurldecode($key); - } - - if (preg_match('#^(.*)\[([0-9a-z_-]*)\]#i', $key, $matches)) { - $key = $matches[1]; - $idx = $matches[2]; - - // Ensure is an array - if (empty($return[$key]) || !is_array($return[$key])) { - $return[$key] = array(); - } - - // Add data - if ($idx === '') { - $return[$key][] = $value; - } else { - $return[$key][$idx] = $value; - } - } elseif (!$this->useBrackets AND !empty($return[$key])) { - $return[$key] = (array)$return[$key]; - $return[$key][] = $value; - } else { - $return[$key] = $value; - } - } - - return $return; - } - - /** - * Resolves //, ../ and ./ from a path and returns - * the result. Eg: - * - * /foo/bar/../boo.php => /foo/boo.php - * /foo/bar/../../boo.php => /boo.php - * /foo/bar/.././/boo.php => /foo/boo.php - * - * This method can also be called statically. - * - * @param string $path URL path to resolve - * @return string The result - */ - function resolvePath($path) - { - $path = explode('/', str_replace('//', '/', $path)); - - for ($i=0; $i 1 OR ($i == 1 AND $path[0] != '') ) ) { - unset($path[$i]); - unset($path[$i-1]); - $path = array_values($path); - $i -= 2; - - } elseif ($path[$i] == '..' AND $i == 1 AND $path[0] == '') { - unset($path[$i]); - $path = array_values($path); - $i--; - - } else { - continue; - } - } - - return implode('/', $path); - } - - /** - * Returns the standard port number for a protocol - * - * @param string $scheme The protocol to lookup - * @return integer Port number or NULL if no scheme matches - * - * @author Philippe Jausions - */ - function getStandardPort($scheme) - { - switch (strtolower($scheme)) { - case 'http': return 80; - case 'https': return 443; - case 'ftp': return 21; - case 'imap': return 143; - case 'imaps': return 993; - case 'pop3': return 110; - case 'pop3s': return 995; - default: return null; - } - } - - /** - * Forces the URL to a particular protocol - * - * @param string $protocol Protocol to force the URL to - * @param integer $port Optional port (standard port is used by default) - */ - function setProtocol($protocol, $port = null) - { - $this->protocol = $protocol; - $this->port = is_null($port) ? $this->getStandardPort($protocol) : $port; - } - - /** - * Set an option - * - * This function set an option - * to be used thorough the script. - * - * @access public - * @param string $optionName The optionname to set - * @param string $value The value of this option. - */ - function setOption($optionName, $value) - { - if (!array_key_exists($optionName, $this->options)) { - return false; - } - - $this->options[$optionName] = $value; - $this->initialize(); - } - - /** - * Get an option - * - * This function gets an option - * from the $this->options array - * and return it's value. - * - * @access public - * @param string $opionName The name of the option to retrieve - * @see $this->options - */ - function getOption($optionName) - { - if (!isset($this->options[$optionName])) { - return false; - } - - return $this->options[$optionName]; - } - -} -?> diff --git a/data/module/Net/UserAgent/Mobile.php b/data/module/Net/UserAgent/Mobile.php deleted file mode 100644 index 2f5b2274125..00000000000 --- a/data/module/Net/UserAgent/Mobile.php +++ /dev/null @@ -1,457 +0,0 @@ -, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @since File available since Release 0.1 - */ - -require_once dirname(__FILE__) . '/../../PEAR.php'; -require_once dirname(__FILE__) . '/Mobile/Error.php'; - -// {{{ GLOBALS - -/** - * globals for fallback on no match - * - * @global boolean $GLOBALS['NET_USERAGENT_MOBILE_FallbackOnNomatch'] - */ -$GLOBALS['NET_USERAGENT_MOBILE_FallbackOnNomatch'] = false; - -// }}} -// {{{ Net_UserAgent_Mobile - -/** - * HTTP mobile user agent string parser - * - * Net_UserAgent_Mobile parses HTTP_USER_AGENT strings of (mainly Japanese) mobile - * HTTP user agents. It'll be useful in page dispatching by user agents. - * This package was ported from Perl's HTTP::MobileAgent. - * See {@link http://search.cpan.org/search?mode=module&query=HTTP-MobileAgent} - * - * SYNOPSIS: - * - * require_once 'Net/UserAgent/Mobile.php'; - * - * $agent = &Net_UserAgent_Mobile::factory($agent_string); - * // or $agent = &Net_UserAgent_Mobile::factory(); // to get from $_SERVER - * - * if ($agent->isDoCoMo()) { - * // or if ($agent->getName() == 'DoCoMo') - * // or if (strtolower(get_class($agent)) == 'http_mobileagent_docomo') - * // it's NTT DoCoMo i-mode - * // see what's available in Net_UserAgent_Mobile_DoCoMo - * } elseif ($agent->isSoftBank()) { - * // it's SoftBank - * // see what's available in Net_UserAgent_Mobile_SoftBank - * } elseif ($agent->isEZweb()) { - * // it's KDDI/EZWeb - * // see what's available in Net_UserAgent_Mobile_EZweb - * } else { - * // may be PC - * // $agent is Net_UserAgent_Mobile_NonMobile - * } - * - * $display = $agent->getDisplay(); // Net_UserAgent_Mobile_Display - * if ($display->isColor()) { - * ... - * } - * - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.0.0 - * @since Class available since Release 0.1 - */ -class Net_UserAgent_Mobile -{ - - // {{{ properties - - /**#@+ - * @access public - */ - - /**#@-*/ - - /**#@+ - * @access private - */ - - /**#@-*/ - - /**#@+ - * @access public - * @static - */ - - // }}} - // {{{ factory() - - /** - * create a new {@link Net_UserAgent_Mobile_Common} subclass instance - * - * parses HTTP headers and constructs {@link Net_UserAgent_Mobile_Common} - * subclass instance. - * If no argument is supplied, $_SERVER{'HTTP_*'} is used. - * - * @param string $userAgent User-Agent string - * @return Net_UserAgent_Mobile_Common a newly created or an existing - * Net_UserAgent_Mobile_Common object - * @throws Net_UserAgent_Mobile_Error - */ - function &factory($userAgent = null) - { - if (is_null($userAgent)) { - $userAgent = @$_SERVER['HTTP_USER_AGENT']; - } - - // parse User-Agent string - if (Net_UserAgent_Mobile::isDoCoMo($userAgent)) { - $driver = 'DoCoMo'; - } elseif (Net_UserAgent_Mobile::isEZweb($userAgent)) { - $driver = 'EZweb'; - } elseif (Net_UserAgent_Mobile::isSoftBank($userAgent)) { - $driver = 'SoftBank'; - } elseif (Net_UserAgent_Mobile::isWillcom($userAgent)) { - $driver = 'Willcom'; - } else { - $driver = 'NonMobile'; - } - - $class = "Net_UserAgent_Mobile_$driver"; - - if (!class_exists($class)) { - $file = dirname(__FILE__) . "/Mobile/{$driver}.php"; - if (!include_once $file) { - return PEAR::raiseError(null, - NET_USERAGENT_MOBILE_ERROR_NOT_FOUND, - null, null, - "Unable to include the $file file", - 'Net_UserAgent_Mobile_Error', true - ); - } - } - - PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - $instance = new $class($userAgent); - PEAR::staticPopErrorHandling(); - $error = &$instance->getError(); - if (Net_UserAgent_Mobile::isError($error)) { - if ($GLOBALS['NET_USERAGENT_MOBILE_FallbackOnNomatch'] - && $error->getCode() == NET_USERAGENT_MOBILE_ERROR_NOMATCH - ) { - $instance = &Net_UserAgent_Mobile::factory('Net_UserAgent_Mobile_Fallback_On_NoMatch'); - return $instance; - } - - return PEAR::raiseError($error); - } - - return $instance; - } - - // }}} - // {{{ singleton() - - /** - * creates a new {@link Net_UserAgent_Mobile_Common} subclass instance or returns - * a instance from existent ones - * - * @param string $userAgent User-Agent string - * @return Net_UserAgent_Mobile_Common a newly created or an existing - * Net_UserAgent_Mobile_Common object - * @throws Net_UserAgent_Mobile_Error - */ - function &singleton($userAgent = null) - { - static $instances; - - if (!isset($instances)) { - $instances = array(); - } - - if (is_null($userAgent)) { - $userAgent = @$_SERVER['HTTP_USER_AGENT']; - } - - if (!array_key_exists($userAgent, $instances)) { - $instances[$userAgent] = Net_UserAgent_Mobile::factory($userAgent); - } - - return $instances[$userAgent]; - } - - // }}} - // {{{ isError() - - /** - * tell whether a result code from a Net_UserAgent_Mobile method is an error - * - * @param integer $value result code - * @return boolean whether $value is an {@link Net_UserAgent_Mobile_Error} - */ - function isError($value) - { - return is_object($value) - && (strtolower(get_class($value)) == strtolower('Net_UserAgent_Mobile_Error') - || is_subclass_of($value, 'Net_UserAgent_Mobile_Error')); - } - - // }}} - // {{{ errorMessage() - - /** - * return a textual error message for a Net_UserAgent_Mobile error code - * - * @param integer $value error code - * @return string error message, or null if the error code was not recognized - */ - function errorMessage($value) - { - static $errorMessages; - if (!isset($errorMessages)) { - $errorMessages = array( - NET_USERAGENT_MOBILE_ERROR => 'unknown error', - NET_USERAGENT_MOBILE_ERROR_NOMATCH => 'no match', - NET_USERAGENT_MOBILE_ERROR_NOT_FOUND => 'not found', - NET_USERAGENT_MOBILE_OK => 'no error' - ); - } - - if (Net_UserAgent_Mobile::isError($value)) { - $value = $value->getCode(); - } - - return isset($errorMessages[$value]) ? - $errorMessages[$value] : - $errorMessages[NET_USERAGENT_MOBILE_ERROR]; - } - - // }}} - // {{{ isMobile() - - /** - * Checks whether or not the user agent is mobile by a given user agent string. - * - * @param string $userAgent - * @return boolean - * @since Method available since Release 0.31.0 - */ - function isMobile($userAgent = null) - { - if (Net_UserAgent_Mobile::isDoCoMo($userAgent)) { - return true; - } elseif (Net_UserAgent_Mobile::isEZweb($userAgent)) { - return true; - } elseif (Net_UserAgent_Mobile::isSoftBank($userAgent)) { - return true; - } elseif (Net_UserAgent_Mobile::isWillcom($userAgent)) { - return true; - } - - return false; - } - - // }}} - // {{{ isDoCoMo() - - /** - * Checks whether or not the user agent is DoCoMo by a given user agent string. - * - * @param string $userAgent - * @return boolean - * @since Method available since Release 0.31.0 - */ - function isDoCoMo($userAgent = null) - { - if (is_null($userAgent)) { - $userAgent = @$_SERVER['HTTP_USER_AGENT']; - } - - if (preg_match('!^DoCoMo!', $userAgent)) { - return true; - } - - return false; - } - - // }}} - // {{{ isEZweb() - - /** - * Checks whether or not the user agent is EZweb by a given user agent string. - * - * @param string $userAgent - * @return boolean - * @since Method available since Release 0.31.0 - */ - function isEZweb($userAgent = null) - { - if (is_null($userAgent)) { - $userAgent = @$_SERVER['HTTP_USER_AGENT']; - } - - if (preg_match('!^KDDI-!', $userAgent)) { - return true; - } elseif (preg_match('!^UP\.Browser!', $userAgent)) { - return true; - } - - return false; - } - - // }}} - // {{{ isSoftBank() - - /** - * Checks whether or not the user agent is SoftBank by a given user agent string. - * - * @param string $userAgent - * @return boolean - * @since Method available since Release 0.31.0 - */ - function isSoftBank($userAgent = null) - { - if (is_null($userAgent)) { - $userAgent = @$_SERVER['HTTP_USER_AGENT']; - } - - if (preg_match('!^SoftBank!', $userAgent)) { - return true; - } elseif (preg_match('!^Semulator!', $userAgent)) { - return true; - } elseif (preg_match('!^Vodafone!', $userAgent)) { - return true; - } elseif (preg_match('!^Vemulator!', $userAgent)) { - return true; - } elseif (preg_match('!^MOT-!', $userAgent)) { - return true; - } elseif (preg_match('!^MOTEMULATOR!', $userAgent)) { - return true; - } elseif (preg_match('!^J-PHONE!', $userAgent)) { - return true; - } elseif (preg_match('!^J-EMULATOR!', $userAgent)) { - return true; - } - - return false; - } - - // }}} - // {{{ isWillcom() - - /** - * Checks whether or not the user agent is Willcom by a given user agent string. - * - * @param string $userAgent - * @return boolean - * @since Method available since Release 0.31.0 - */ - function isWillcom($userAgent = null) - { - if (is_null($userAgent)) { - $userAgent = @$_SERVER['HTTP_USER_AGENT']; - } - - if (preg_match('!^Mozilla/3\.0\((?:DDIPOCKET|WILLCOM);!', $userAgent)) { - return true; - } - - return false; - } - - // }}} - // {{{ isSmartphone() - - /** - * Checks whether or not the user agent is Smartphone by a given user agent string. - * - * @param string $userAgent - * @return boolean - * @since Method available since Release 0.31.0 - */ - function isSmartphone($userAgent = null) - { - if (is_null($userAgent)) { - $userAgent = @$_SERVER['HTTP_USER_AGENT']; - } - - $useragents = array( - 'iPhone', // Apple iPhone - 'iPod', // Apple iPod touch - 'Android', // 1.5+ Android - 'dream', // Pre 1.5 Android - 'CUPCAKE', // 1.5+ Android - 'blackberry9500', // Storm - 'blackberry9530', // Storm - 'blackberry9520', // Storm v2 - 'blackberry9550', // Storm v2 - 'blackberry9800', // Torch - 'webOS', // Palm Pre Experimental - 'incognito', // Other iPhone browser - 'webmate', // Other iPhone browser - 'Windows Phone OS' // Windows Phone - ); - - $pattern = implode("|", $useragents); - return preg_match('/'.$pattern.'/', $userAgent); - } - - /**#@-*/ - - /**#@+ - * @access private - */ - - /**#@-*/ - - // }}} -} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: iso-8859-1 - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * indent-tabs-mode: nil - * End: - */ diff --git a/data/module/Net/UserAgent/Mobile/Common.php b/data/module/Net/UserAgent/Mobile/Common.php deleted file mode 100644 index dc8c8ee2611..00000000000 --- a/data/module/Net/UserAgent/Mobile/Common.php +++ /dev/null @@ -1,528 +0,0 @@ -, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @since File available since Release 0.1 - */ - -require_once dirname(__FILE__) . '/Error.php'; -require_once dirname(__FILE__) . '/../../../PEAR.php'; - -// {{{ Net_UserAgent_Mobile_Common - -/** - * Base class that is extended by each user agents implementor - * - * Net_UserAgent_Mobile_Common is a class for mobile user agent - * abstraction layer on Net_UserAgent_Mobile. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.0.0 - * @since Class available since Release 0.1 - */ -class Net_UserAgent_Mobile_Common -{ - - // {{{ properties - - /**#@+ - * @access public - */ - - /** - * User-Agent name like 'DoCoMo' - * @var string - */ - var $name; - - /** - * User-Agent version number like '1.0' - * @var string - */ - var $version; - - /**#@-*/ - - /**#@+ - * @access private - */ - - /** - * {@link Net_UserAgent_Mobile_Display} object - * @var object {@link Net_UserAgent_Mobile_Display} - */ - var $_display; - - /** - * {@link Net_UserAgent_Mobile_Error} object for error handling in the constructor - * @var object - **/ - var $_error; - - /** - * The User-Agent string. - * @var string - * @since Property available since Release 0.31.0 - **/ - var $_userAgent; - - /** - * The model name of the user agent. - * - * @var string - * @since Property available since Release 0.31.0 - */ - var $_model; - - /** - * The raw model name of the user agent. - * - * @var string - * @since Property available since Release 0.31.0 - */ - var $_rawModel; - - /**#@-*/ - - /**#@+ - * @access public - */ - - // }}} - // {{{ constructor - - /** - * constructor - * - * @param string $userAgent User-Agent string - */ - function Net_UserAgent_Mobile_Common($userAgent) - { - $this->_userAgent = $userAgent; - - $result = $this->parse($userAgent); - if (PEAR::isError($result)) { - $this->_error = &$result; - } - } - - // }}} - // {{{ getError - - /** - * Gets a Net_UserAgent_Mobile_Error object. - * - * @param object {@link Net_UserAgent_Mobile_Error} object when setting an error - * @return Net_UserAgent_Mobile_Error - * @since Method available since Release 1.0.0RC2 - */ - function &getError() - { - if (is_null($this->_error)) { - $return = null; - return $return; - } - - return $this->_error; - } - - // }}} - // {{{ getUserAgent() - - /** - * returns User-Agent string - * - * @return string - */ - function getUserAgent() - { - return $this->_userAgent; - } - - // }}} - // {{{ getHeader() - - /** - * returns a specified HTTP header - * - * @param string $header - * @return string - */ - function getHeader($header) - { - return @$_SERVER[ 'HTTP_' . str_replace('-', '_', $header) ]; - } - - // }}} - // {{{ getName() - - /** - * returns User-Agent name like 'DoCoMo' - * - * @return string - */ - function getName() - { - return $this->name; - } - - // }}} - // {{{ getDisplay() - - /** - * returns {@link Net_UserAgent_Mobile_Disply} object - * - * @return Net_UserAgent_Mobile_Display - */ - function getDisplay() - { - if (is_null($this->_display)) { - $this->_display = $this->makeDisplay(); - } - - return $this->_display; - } - - // }}} - // {{{ getVersion() - - /** - * returns User-Agent version number like '1.0' - * - * @return string - */ - function getVersion() - { - return $this->version; - } - - // }}} - // {{{ noMatch() - - /** - * generates a warning message for new variants - * - * @throws Net_UserAgent_Mobile_Error - */ - function noMatch() - { - return PEAR::raiseError($this->getUserAgent() . ': might be new variants. Please contact the author of Net_UserAgent_Mobile!', - NET_USERAGENT_MOBILE_ERROR_NOMATCH, - null, - null, - null, - 'Net_UserAgent_Mobile_Error' - ); - } - - // }}} - // {{{ parse() - - /** - * Parses HTTP_USER_AGENT string. - * - * @param string $userAgent User-Agent string - * @abstract - */ - function parse($userAgent) {} - - // }}} - // {{{ makeDisplay() - - /** - * create a new Net_UserAgent_Mobile_Display class instance (should be - * implemented in subclasses) - * - * @return Net_UserAgent_Mobile_Display - * @abstract - */ - function makeDisplay() {} - - // }}} - // {{{ isDoCoMo() - - /** - * returns true if the agent is DoCoMo - * - * @return boolean - */ - function isDoCoMo() - { - return false; - } - - // }}} - // {{{ isJPhone() - - /** - * returns true if the agent is J-PHONE - * - * @return boolean - */ - function isJPhone() - { - return false; - } - - // }}} - // {{{ isVodafone() - - /** - * returns true if the agent is Vodafone - * - * @return boolean - */ - function isVodafone() - { - return false; - } - - // }}} - // {{{ isEZweb() - - /** - * returns true if the agent is EZweb - * - * @return boolean - */ - function isEZweb() - { - return false; - } - - // }}} - // {{{ isAirHPhone() - - /** - * returns true if the agent is AirH"PHONE - * - * @return boolean - */ - function isAirHPhone() - { - return false; - } - - // }}} - // {{{ isNonMobile() - - /** - * returns true if the agent is NonMobile - * - * @return boolean - */ - function isNonMobile() - { - return false; - } - - // }}} - // {{{ isTUKa() - - /** - * returns true if the agent is TU-Ka - * - * @return boolean - */ - function isTUKa() - { - return false; - } - - // }}} - // {{{ isWAP1() - - /** - * returns true if the agent can speak WAP1 protocol - * - * @return boolean - */ - function isWAP1() - { - return $this->isEZweb() && !$this->isWAP2(); - } - - // }}} - // {{{ isWAP2() - - /** - * returns true if the agent can speak WAP2 protocol - * - * @return boolean - */ - function isWAP2() - { - return $this->isEZweb() && $this->isXHTMLCompliant(); - } - - // }}} - // {{{ getCarrierShortName() - - /** - * returns the short name of the carrier - * - * @abstract - */ - function getCarrierShortName() - { - die(); - } - - // }}} - // {{{ getCarrierLongName() - - /** - * returns the long name of the carrier - * - * @abstract - */ - function getCarrierLongName() - { - die(); - } - - // }}} - // {{{ isSoftBank() - - /** - * Returns whether the agent is SoftBank or not. - * - * @return boolean - * @since Method available since Release 0.31.0 - */ - function isSoftBank() - { - return false; - } - - // }}} - // {{{ isWillcom() - - /** - * Returns whether the agent is Willcom or not. - * - * @return boolean - * @since Method available since Release 0.31.0 - */ - function isWillcom() - { - return false; - } - - // }}} - // {{{ isSmartphone() - - /** - * Returns whether the agent is Smartphone or not. - * - * @return boolean - * @since Method available since Release 0.31.0 - */ - function isSmartphone() - { - return false; - } - - - // }}} - // {{{ getModel() - - /** - * Returns the model name of the user agent. - * - * @return string - * @since Method available since Release 0.31.0 - */ - function getModel() - { - if (is_null($this->_model)) { - return $this->_rawModel; - } else { - return $this->_model; - } - } - - // }}} - // {{{ getRawModel() - - /** - * Returns the raw model name of the user agent. - * - * @return string - * @since Method available since Release 0.31.0 - */ - function getRawModel() - { - return $this->_rawModel; - } - - // }}} - // {{{ getUID() - - /** - * Gets the UID of a subscriber. - * - * @return string - * @since Method available since Release 1.0.0RC1 - */ - function getUID() {} - - /**#@-*/ - - /**#@+ - * @access private - */ - - /**#@-*/ - - // }}} -} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: iso-8859-1 - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * indent-tabs-mode: nil - * End: - */ diff --git a/data/module/Net/UserAgent/Mobile/Display.php b/data/module/Net/UserAgent/Mobile/Display.php deleted file mode 100644 index 41c03b0a7be..00000000000 --- a/data/module/Net/UserAgent/Mobile/Display.php +++ /dev/null @@ -1,285 +0,0 @@ -, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @since File available since Release 0.1 - */ - -// {{{ Net_UserAgent_Mobile_Display - -/** - * Display information for Net_UserAgent_Mobile - * - * Net_UserAgent_Mobile_Display is a class for display information on - * {@link Net_UserAgent_Mobile}. Handy for image resizing or dispatching. - * - * SYNOPSIS: - * - * require_once 'Net/UserAgent/Mobile.php'; - * - * $agent = &Net_UserAgent_Mobile::factory(); - * $display = $agent->getDisplay(); - * - * $width = $display->getWidth(); - * $height = $display->getHeight(); - * list($width, $height) = $display->getSize(); - * - * if ($display->isColor()) { - * $depth = $display->getDepth(); - * } - * - * // only available in DoCoMo 505i - * $width_bytes = $display->getWidthBytes(); - * $height_bytes = $display->getHeightBytes(); - * - * - * USING EXTERNAL MAP FILE: - * If the environment variable DOCOMO_MAP exists, the specified XML data will be used - * for DoCoMo display information. - * - * ex) Please add the following code. - * $_SERVER['DOCOMO_MAP'] = '/path/to/DoCoMoMap.xml'; - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.0.0 - * @since Class available since Release 0.1 - */ -class Net_UserAgent_Mobile_Display -{ - - // {{{ properties - - /**#@+ - * @access public - */ - - /**#@-*/ - - /**#@+ - * @access private - */ - - /** - * width of the display - * @var integer - */ - var $_width; - - /** - * height of the display - * @var integer - */ - var $_height; - - /** - * depth of the display - * @var integer - */ - var $_depth; - - /** - * color capability of the display - * @var boolean - */ - var $_color; - - /** - * width (bytes) of the display - * @var integer - */ - var $_widthBytes; - - /** - * height (bytes) of the display - * @var integer - */ - var $_heightBytes; - - /**#@-*/ - - /**#@+ - * @access public - */ - - // }}} - // {{{ constructor - - /** - * constructor - * - * @param array $data display infomation - */ - function Net_UserAgent_Mobile_Display($data) - { - $this->_width = (integer)@$data['width']; - $this->_height = (integer)@$data['height']; - $this->_depth = (integer)@$data['depth']; - $this->_color = (boolean)@$data['color']; - - $this->_widthBytes = (integer)@$data['width_bytes']; - $this->_heightBytes = (integer)@$data['height_bytes']; - } - - // }}} - // {{{ calcSize() - - /** - * returns width * height of the display - * - * @return integer - */ - function calcSize() - { - return $this->_width * $this->_height; - } - - // }}} - // {{{ getSize() - - /** - * returns width with height of the display - * - * @return array - */ - function getSize() - { - return array($this->_width, $this->_height); - } - - // }}} - // {{{ getWidth() - - /** - * returns width of the display - * - * @return integer - */ - function getWidth() - { - return $this->_width; - } - - // }}} - // {{{ getHeight() - - /** - * returns height of the display - * - * @return integer - */ - function getHeight() - { - return $this->_height; - } - - // }}} - // {{{ getDepth() - - /** - * returns depth of the display - * - * @return integer - */ - function getDepth() - { - return $this->_depth; - } - - // }}} - // {{{ isColor() - - /** - * returns true if the display has color capability - * - * @return boolean - */ - function isColor() - { - return $this->_color; - } - - // }}} - // {{{ getWidthBytes() - - /** - * returns width (bytes) of the display - * - * @return integer - */ - function getWidthBytes() - { - return $this->_widthBytes; - } - - // }}} - // {{{ getHeightBytes() - - /** - * returns height (bytes) of the display - * - * @return integer - */ - function getHeightBytes() - { - return $this->_heightBytes; - } - - /**#@-*/ - - /**#@+ - * @access private - */ - - /**#@-*/ - - // }}} -} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: iso-8859-1 - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * indent-tabs-mode: nil - * End: - */ diff --git a/data/module/Net/UserAgent/Mobile/DoCoMo.php b/data/module/Net/UserAgent/Mobile/DoCoMo.php deleted file mode 100644 index ada57a5f366..00000000000 --- a/data/module/Net/UserAgent/Mobile/DoCoMo.php +++ /dev/null @@ -1,988 +0,0 @@ -, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://www.nttdocomo.co.jp/service/imode/make/content/spec/useragent/index.html - * @link http://www.nttdocomo.co.jp/service/imode/make/content/browser/browser2/useragent/index.html - * @since File available since Release 0.1 - */ - -require_once dirname(__FILE__) . '/Common.php'; -require_once dirname(__FILE__) . '/Display.php'; -require_once dirname(__FILE__) . '/../Mobile.php'; - -// {{{ Net_UserAgent_Mobile_DoCoMo - -/** - * NTT DoCoMo implementation - * - * Net_UserAgent_Mobile_DoCoMo is a subclass of {@link Net_UserAgent_Mobile_Common}, - * which implements NTT docomo i-mode user agents. - * - * SYNOPSIS: - * - * require_once 'Net/UserAgent/Mobile.php'; - * - * $_SERVER['HTTP_USER_AGENT'] = 'DoCoMo/1.0/P502i/c10'; - * $agent = &Net_UserAgent_Mobile::factory(); - * - * printf("Name: %s\n", $agent->getName()); // 'DoCoMo' - * printf("Version: %s\n", $agent->getVersion()); // 1.0 - * printf("HTML version: %s\n", $agent->getHTMLVersion()); // 2.0 - * printf("Model: %s\n", $agent->getModel()); // 'P502i' - * printf("Cache: %dk\n", $agent->getCacheSize()); // 10 - * if ($agent->isFOMA()) { - * print "FOMA\n"; // false - * } - * printf("Vendor: %s\n", $agent->getVendor()); // 'P' - * printf("Series: %s\n", $agent->getSeries()); // '502i' - * - * // only available with
- * // e.g.) 'DoCoMo/1.0/P503i/c10/serNMABH200331'; - * printf("Serial: %s\n", $agent->getSerialNumber()); // 'NMABH200331' - * - * // e.g.) 'DoCoMo/2.0 N2001(c10;ser0123456789abcde;icc01234567890123456789)'; - * printf("Serial: %s\n", $agent->getSerialNumber()); // '0123456789abcde' - * printf("Card ID: %s\n", $agent->getCardID()); // '01234567890123456789' - * - * // e.g.) 'DoCoMo/1.0/P502i (Google CHTML Proxy/1.0)' - * printf("Comment: %s\n", $agent->getComment()); // 'Google CHTML Proxy/1.0' - * - * // e.g.) 'DoCoMo/1.0/D505i/c20/TB/W20H10' - * printf("Status: %s\n", $agent->getStatus()); // 'TB' - * - * // only available in eggy/M-stage - * // e.g.) 'DoCoMo/1.0/eggy/c300/s32/kPHS-K' - * printf("Bandwidth: %dkbps\n", $agent->getBandwidth()); // 32 - * - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.0.0 - * @link http://www.nttdocomo.co.jp/service/imode/make/content/spec/useragent/index.html - * @link http://www.nttdocomo.co.jp/service/imode/make/content/browser/browser2/useragent/index.html - * @since Class available since Release 0.1 - */ -class Net_UserAgent_Mobile_DoCoMo extends Net_UserAgent_Mobile_Common -{ - - // {{{ properties - - /**#@+ - * @access public - */ - - /**#@-*/ - - /**#@+ - * @access private - */ - - /** - * status of the cache (TC, TB, TD, TJ) - * @var string - */ - var $_status; - - /** - * bandwidth like 32 as kilobytes unit - * @var integer - */ - var $_bandwidth; - - /** - * hardware unique serial number - * @var string - */ - var $_serialNumber; - - /** - * whether it's FOMA or not - * @var boolean - */ - var $_isFOMA = false; - - /** - * FOMA Card ID (20 digit alphanumeric) - * @var string - */ - var $_cardID; - - /** - * comment on user agent string like 'Google Proxy' - * @var string - */ - var $_comment; - - /** - * cache size as killobytes unit - * @var integer - */ - var $_cacheSize; - - /** - * width and height of the display - * @var string - */ - var $_displayBytes; - - /** - * The model names which have GPS capability. - * - * @var array - * @since Property available since Release 1.0.0RC1 - */ - var $_gpsModels = array('F884i', - 'F801i', - 'F905iBiz', - 'SO905iCS', - 'N905iBiz', - 'N905imyu', - 'SO905i', - 'F905i', - 'P905i', - 'N905i', - 'D905i', - 'SH905i', - 'P904i', - 'D904i', - 'F904i', - 'N904i', - 'SH904i', - 'F883iESS', - 'F883iES', - 'F903iBSC', - 'SO903i', - 'F903i', - 'D903i', - 'N903i', - 'P903i', - 'SH903i', - 'SA800i', - 'SA702i', - 'SA700iS', - 'F505iGPS', - 'F661i', - 'F884iES', - 'N906iL', - 'P906i', - 'SO906i', - 'SH906i', - 'N906imyu', - 'F906i', - 'N906i', - 'F01A', - 'F03A', - 'F06A', - 'F05A', - 'P01A', - 'P02A', - 'SH01A', - 'SH02A', - 'SH03A', - 'SH04A', - 'N01A', - 'N02A', - 'P07A3', - 'N06A3', - 'N08A3', - 'P08A3', - 'P09A3', - 'N09A3', - 'F09A3', - 'SH05A3', - 'SH06A3', - 'SH07A3' - ); - - /** - * The HTML versions which maps models to HTML versions. - * - * @var array - * @since Property available since Release 1.0.0RC1 - */ - var $_htmlVersions = array( - 'D501i' => '1.0', - 'F501i' => '1.0', - 'N501i' => '1.0', - 'P501i' => '1.0', - 'D502i' => '2.0', - 'F502i' => '2.0', - 'N502i' => '2.0', - 'P502i' => '2.0', - 'NM502i' => '2.0', - 'SO502i' => '2.0', - 'F502it' => '2.0', - 'N502it' => '2.0', - 'SO502iWM' => '2.0', - 'SH821i' => '2.0', - 'N821i' => '2.0', - 'P821i' => '2.0', - 'D209i' => '2.0', - 'ER209i' => '2.0', - 'F209i' => '2.0', - 'KO209i' => '2.0', - 'N209i' => '2.0', - 'P209i' => '2.0', - 'P209iS' => '2.0', - 'R209i' => '2.0', - 'P651ps' => '2.0', - 'R691i' => '2.0', - 'F210i' => '2.0', - 'N210i' => '2.0', - 'P210i' => '2.0', - 'KO210i' => '2.0', - 'F671i' => '2.0', - 'D210i' => '3.0', - 'SO210i' => '3.0', - 'F503i' => '3.0', - 'F503iS' => '3.0', - 'P503i' => '3.0', - 'P503iS' => '3.0', - 'N503i' => '3.0', - 'N503iS' => '3.0', - 'SO503i' => '3.0', - 'SO503iS' => '3.0', - 'D503i' => '3.0', - 'D503iS' => '3.0', - 'F211i' => '3.0', - 'D211i' => '3.0', - 'N211i' => '3.0', - 'N211iS' => '3.0', - 'P211i' => '3.0', - 'P211iS' => '3.0', - 'SO211i' => '3.0', - 'R211i' => '3.0', - 'SH251i' => '3.0', - 'SH251iS' => '3.0', - 'R692i' => '3.0', - 'N2001' => '3.0', - 'N2002' => '3.0', - 'P2002' => '3.0', - 'D2101V' => '3.0', - 'P2101V' => '3.0', - 'SH2101V' => '3.0', - 'T2101V' => '3.0', - 'D504i' => '4.0', - 'F504i' => '4.0', - 'F504iS' => '4.0', - 'N504i' => '4.0', - 'N504iS' => '4.0', - 'SO504i' => '4.0', - 'P504i' => '4.0', - 'P504iS' => '4.0', - 'D251i' => '4.0', - 'D251iS' => '4.0', - 'F251i' => '4.0', - 'N251i' => '4.0', - 'N251iS' => '4.0', - 'P251iS' => '4.0', - 'F671iS' => '4.0', - 'F212i' => '4.0', - 'SO212i' => '4.0', - 'F661i' => '4.0', - 'F672i' => '4.0', - 'SO213i' => '4.0', - 'SO213iS' => '4.0', - 'SO213iWR' => '4.0', - 'F2051' => '4.0', - 'N2051' => '4.0', - 'P2102V' => '4.0', - 'F2102V' => '4.0', - 'N2102V' => '4.0', - 'N2701' => '4.0', - 'NM850iG' => '4.0', - 'NM705i' => '4.0', - 'NM706i' => '4.0', - 'D505i' => '5.0', - 'SO505i' => '5.0', - 'SH505i' => '5.0', - 'N505i' => '5.0', - 'F505i' => '5.0', - 'P505i' => '5.0', - 'D505iS' => '5.0', - 'P505iS' => '5.0', - 'N505iS' => '5.0', - 'SO505iS' => '5.0', - 'SH505iS' => '5.0', - 'F505iGPS' => '5.0', - 'D252i' => '5.0', - 'SH252i' => '5.0', - 'P252i' => '5.0', - 'N252i' => '5.0', - 'P252iS' => '5.0', - 'D506i' => '5.0', - 'F506i' => '5.0', - 'N506i' => '5.0', - 'P506iC' => '5.0', - 'SH506iC' => '5.0', - 'SO506iC' => '5.0', - 'N506iS' => '5.0', - 'SO506i' => '5.0', - 'SO506iS' => '5.0', - 'N506iS2' => '5.0', - 'D253i' => '5.0', - 'N253i' => '5.0', - 'P253i' => '5.0', - 'D253iWM' => '5.0', - 'P253iS' => '5.0', - 'P213i' => '5.0', - 'F900i' => '5.0', - 'N900i' => '5.0', - 'P900i' => '5.0', - 'SH900i' => '5.0', - 'F900iT' => '5.0', - 'P900iV' => '5.0', - 'N900iS' => '5.0', - 'D900i' => '5.0', - 'F900iC' => '5.0', - 'N900iL' => '5.0', - 'N900iG' => '5.0', - 'F880iES' => '5.0', - 'SH901iC' => '5.0', - 'F901iC' => '5.0', - 'N901iC' => '5.0', - 'D901i' => '5.0', - 'P901i' => '5.0', - 'SH901iS' => '5.0', - 'F901iS' => '5.0', - 'D901iS' => '5.0', - 'P901iS' => '5.0', - 'N901iS' => '5.0', - 'P901iTV' => '5.0', - 'F700i' => '5.0', - 'SH700i' => '5.0', - 'N700i' => '5.0', - 'P700i' => '5.0', - 'F700iS' => '5.0', - 'SH700iS' => '5.0', - 'SA700iS' => '5.0', - 'SH851i' => '5.0', - 'P851i' => '5.0', - 'F881iES' => '5.0', - 'D701i' => '5.0', - 'N701i' => '5.0', - 'P701iD' => '5.0', - 'D701iWM' => '5.0', - 'N701iECO' => '5.0', - 'SA800i' => '5.0', - 'L600i' => '5.0', - 'N600i' => '5.0', - 'L601i' => '5.0', - 'M702iS' => '5.0', - 'M702iG' => '5.0', - 'L602i' => '5.0', - 'F902i' => '6.0', - 'D902i' => '6.0', - 'N902i' => '6.0', - 'P902i' => '6.0', - 'SH902i' => '6.0', - 'SO902i' => '6.0', - 'SH902iS' => '6.0', - 'P902iS' => '6.0', - 'N902iS' => '6.0', - 'D902iS' => '6.0', - 'F902iS' => '6.0', - 'SO902iWP+' => '6.0', - 'SH902iSL' => '6.0', - 'N902iX' => '6.0', - 'N902iL' => '6.0', - 'P702i' => '6.0', - 'N702iD' => '6.0', - 'F702iD' => '6.0', - 'SH702iD' => '6.0', - 'D702i' => '6.0', - 'SO702i' => '6.0', - 'D702iBCL' => '6.0', - 'SA702i' => '6.0', - 'SH702iS' => '6.0', - 'N702iS' => '6.0', - 'P702iD' => '6.0', - 'D702iF' => '6.0', - 'D851iWM' => '6.0', - 'F882iES' => '6.0', - 'N601i' => '6.0', - 'D800iDS' => '6.0', - 'P703imyu' => '6.0', - 'F883i' => '6.0', - 'F883iS' => '6.0', - 'P704imyu' => '6.0', - 'L704i' => '6.0', - 'L705i' => '6.0', - 'L705iX' => '6.0', - 'L852i' => '6.0', - 'L706ie' => '6.0', - 'L01A' => '6.0', - 'L03A' => '6.0', - 'SH903i' => '7.0', - 'P903i' => '7.0', - 'N903i' => '7.0', - 'D903i' => '7.0', - 'F903i' => '7.0', - 'SO903i' => '7.0', - 'D903iTV' => '7.0', - 'F903iX' => '7.0', - 'P903iTV' => '7.0', - 'SH903iTV' => '7.0', - 'F903iBSC' => '7.0', - 'P903iX' => '7.0', - 'SO903iTV' => '7.0', - 'N703iD' => '7.0', - 'F703i' => '7.0', - 'P703i' => '7.0', - 'D703i' => '7.0', - 'SH703i' => '7.0', - 'N703imyu' => '7.0', - 'SO703i' => '7.0', - 'SH904i' => '7.0', - 'N904i' => '7.0', - 'F904i' => '7.0', - 'D904i' => '7.0', - 'P904i' => '7.0', - 'SO704i' => '7.0', - 'F704i' => '7.0', - 'N704imyu' => '7.0', - 'SH704i' => '7.0', - 'D704i' => '7.0', - 'P704i' => '7.0', - 'F883iES' => '7.0', - 'F883iESS' => '7.0', - 'F801i' => '7.0', - 'F705i' => '7.0', - 'D705i' => '7.0', - 'D705imyu' => '7.0', - 'SH705i' => '7.0', - 'SH705i2' => '7.0', - 'SH706ie' => '7.0', - 'F05A' => '7.0', - 'SH905i' => '7.1', - 'D905i' => '7.1', - 'N905i' => '7.1', - 'P905i' => '7.1', - 'F905i' => '7.1', - 'SO905i' => '7.1', - 'N905imyu' => '7.1', - 'N905iBiz' => '7.1', - 'SH905iTV' => '7.1', - 'SO905iCS' => '7.1', - 'F905iBiz' => '7.1', - 'P905iTV' => '7.1', - 'P705i' => '7.1', - 'N705i' => '7.1', - 'N705imyu' => '7.1', - 'P705imyu' => '7.1', - 'SO705i' => '7.1', - 'P705iCL' => '7.1', - 'F884i' => '7.1', - 'F884iES' => '7.1', - 'N906iL' => '7.1', - 'N706i' => '7.1', - 'SO706i' => '7.1', - 'P706imyu' => '7.1', - 'N706ie' => '7.1', - 'N706i2' => '7.1', - 'N03A' => '7.1', - 'N05A' => '7.1', - 'F07A' => '7.1', - 'P906i' => '7.2', - 'SO906i' => '7.2', - 'SH906i' => '7.2', - 'N906imyu' => '7.2', - 'F906i' => '7.2', - 'N906i' => '7.2', - 'SH906iTV' => '7.2', - 'F706i' => '7.2', - 'SH706i' => '7.2', - 'P706ie' => '7.2', - 'SH706iw' => '7.2', - 'F01A' => '7.2', - 'F02A' => '7.2', - 'F03A' => '7.2', - 'F04A' => '7.2', - 'F06A' => '7.2', - 'P01A' => '7.2', - 'P02A' => '7.2', - 'P03A' => '7.2', - 'P04A' => '7.2', - 'P05A' => '7.2', - 'P06A' => '7.2', - 'SH01A' => '7.2', - 'SH02A' => '7.2', - 'SH03A' => '7.2', - 'SH04A' => '7.2', - 'N01A' => '7.2', - 'N02A' => '7.2', - 'N04A' => '7.2', - 'P10A' => '7.2', - ); - - /**#@-*/ - - /**#@+ - * @access public - */ - - // }}} - // {{{ isDoCoMo() - - /** - * returns true - * - * @return boolean - */ - function isDoCoMo() - { - return true; - } - - // }}} - // {{{ parse() - - /** - * Parses HTTP_USER_AGENT string. - * - * @param string $userAgent User-Agent string - * @throws Net_UserAgent_Mobile_Error - */ - function parse($userAgent) - { - @list($main, $foma_or_comment) = explode(' ', $userAgent, 2); - - if ($foma_or_comment - && preg_match('/^\((.*)\)$/', $foma_or_comment, $matches) - ) { - - // DoCoMo/1.0/P209is (Google CHTML Proxy/1.0) - $this->_comment = $matches[1]; - $result = $this->_parseMain($main); - } elseif ($foma_or_comment) { - - // DoCoMo/2.0 N2001(c10;ser0123456789abcde;icc01234567890123456789) - $this->_isFOMA = true; - @list($this->name, $this->version) = explode('/', $main); - $result = $this->_parseFOMA($foma_or_comment); - } else { - - // DoCoMo/1.0/R692i/c10 - $result = $this->_parseMain($main); - } - - if (Net_UserAgent_Mobile::isError($result)) { - return $result; - } - } - - // }}} - // {{{ makeDisplay() - - /** - * create a new {@link Net_UserAgent_Mobile_Display} class instance - * - * @return Net_UserAgent_Mobile_Display - */ - function makeDisplay() - { - include_once dirname(__FILE__) . '/DoCoMo/ScreenInfo.php'; - - $screenInfo = &Net_UserAgent_Mobile_DoCoMo_ScreenInfo::singleton(); - $display = $screenInfo->get($this->getModel()); - if (!is_null($this->_displayBytes)) { - @list($widthBytes, $heightBytes) = explode('*', $this->_displayBytes); - $display['width_bytes'] = $widthBytes; - $display['height_bytes'] = $heightBytes; - } - - return new Net_UserAgent_Mobile_Display($display); - } - - // }}} - // {{{ getHTMLVersion() - - /** - * Gets the HTML version like '3.0'. Returns null if unknown. - * - * @return string - */ - function getHTMLVersion() - { - return @$this->_htmlVersions[ $this->getModel() ]; - } - - // }}} - // {{{ getCacheSize() - - /** - * returns cache size as kilobytes unit. returns 5 if unknown. - * - * @return integer - */ - function getCacheSize() - { - if ($this->_cacheSize) { - return $this->_cacheSize; - } - - return 5; - } - - // }}} - // {{{ getSeries() - - /** - * returns series name like '502i'. returns null if unknown. - * - * @return string - */ - function getSeries() - { - if (preg_match('/(\d{4})/', $this->_rawModel)) { - return 'FOMA'; - } - - if (preg_match('/(\d{3}i)/', $this->_rawModel, $matches)) { - return $matches[1]; - } - - if ($this->_rawModel == 'P651ps') { - return '651'; - } - } - - // }}} - // {{{ getVendor() - - /** - * returns vender code like 'SO' for Sony. returns null if unknown. - * - * @return string - */ - function getVendor() - { - if (preg_match('/([A-Z]+)\d/', $this->_rawModel, $matches)) { - return $matches[1]; - } - } - - // }}} - // {{{ getStatus() - - /** - * returns status like "TB", "TC", "TD" or "TJ", which means: - * - * TB | Browsers - * TC | Browsers with image off (only Available in HTML 5.0) - * TD | Fetching JAR - * TJ | i-Appli - * - * @return string - */ - function getStatus() - { - return $this->_status; - } - - // }}} - // {{{ getBandwidth() - - /** - * returns bandwidth like 32 as killobytes unit. Only vailable in eggy, - * returns null otherwise. - * - * @return integer - */ - function getBandwidth() - { - return $this->_bandwidth; - } - - // }}} - // {{{ getSerialNumber() - - /** - * returns hardware unique serial number (15 digit in FOMA, 11 digit - * otherwise alphanumeric). Only available with form utn attribute. - * returns null otherwise. - * - * @return string - */ - function getSerialNumber() - { - return $this->_serialNumber; - } - - // }}} - // {{{ isFOMA() - - /** - * retuns whether it's FOMA or not - * - * @return boolean - */ - function isFOMA() - { - return $this->_isFOMA; - } - - // }}} - // {{{ getComment() - - /** - * returns comment on user agent string like 'Google Proxy'. returns null - * otherwise. - * - * @return string - */ - function getComment() - { - return $this->_comment; - } - - // }}} - // {{{ getCardID() - - /** - * returns FOMA Card ID (20 digit alphanumeric). Only available in FOMA - * with attribute. returns null otherwise. - * - * @return string - */ - function getCardID() - { - return $this->_cardID; - } - - // }}} - // {{{ isGPS() - - /** - * Returns whether a user agent is a GPS model or not. - * - * @return boolean - */ - function isGPS() - { - return in_array($this->_rawModel, $this->_gpsModels); - } - - // }}} - // {{{ getCarrierShortName() - - /** - * returns the short name of the carrier - * - * @return string - */ - function getCarrierShortName() - { - return 'I'; - } - - // }}} - // {{{ getCarrierLongName() - - /** - * returns the long name of the carrier - * - * @return string - */ - function getCarrierLongName() - { - return 'DoCoMo'; - } - - // }}} - // {{{ getUID() - - /** - * Gets the UID of a subscriber. - * - * @return string - * @since Method available since Release 1.0.0RC1 - */ - function getUID() - { - if (array_key_exists('HTTP_X_DCMGUID', $_SERVER)) { - return $_SERVER['HTTP_X_DCMGUID']; - } - } - - // }}} - // {{{ getBrowserVersion() - - /** - * Gets the i-mode browser version. - * - * @return string - * @since Method available since Release 1.0.0RC3 - */ - function getBrowserVersion() - { - return $this->getCacheSize() == 500 ? '2.0' : '1.0'; - } - - /**#@-*/ - - /**#@+ - * @access private - */ - - // }}} - // {{{ _parseMain() - - /** - * parse main part of HTTP_USER_AGENT string (not FOMA) - * - * @param string $main main part of HTTP_USER_AGENT string - * @throws Net_UserAgent_Mobile_Error - */ - function _parseMain($main) - { - @list($this->name, $this->version, $this->_rawModel, $cache, $rest) = - explode('/', $main, 5); - if ($this->_rawModel == 'SH505i2') { - $this->_model = 'SH505i'; - } - - if ($cache) { - if (!preg_match('/^c(\d+)$/', $cache, $matches)) { - return $this->noMatch(); - } - $this->_cacheSize = (integer)$matches[1]; - } - - if ($rest) { - $rest = explode('/', $rest); - foreach ($rest as $value) { - if (preg_match('/^ser(\w{11})$/', $value, $matches)) { - $this->_serialNumber = $matches[1]; - continue; - } - if (preg_match('/^(T[CDBJ])$/', $value, $matches)) { - $this->_status = $matches[1]; - continue; - } - if (preg_match('/^s(\d+)$/', $value, $matches)) { - $this->_bandwidth = (integer)$matches[1]; - continue; - } - if (preg_match('/^W(\d+)H(\d+)$/', $value, $matches)) { - $this->_displayBytes = "{$matches[1]}*{$matches[2]}"; - continue; - } - } - } - } - - // }}} - // {{{ _parseFOMA() - - /** - * parse main part of HTTP_USER_AGENT string (FOMA) - * - * @param string $foma main part of HTTP_USER_AGENT string - * @throws Net_UserAgent_Mobile_Error - */ - function _parseFOMA($foma) - { - if (!preg_match('/^([^(\s]+)/', $foma, $matches)) { - return $this->noMatch(); - } - - $this->_rawModel = $matches[1]; - if ($this->_rawModel == 'MST_v_SH2101V') { - $this->_model = 'SH2101V'; - } - - if (preg_match('/^[^(\s]+\s?\(([^)]+)\)(?:\(([^)]+)\))?$/', $foma, $matches)) { - if (preg_match('/^compatible/', $matches[1])) { // The user-agent is DoCoMo compatible. - $this->_comment = $matches[1]; - return; - } - - if (count($matches) == 3) { - if (preg_match('/^compatible/', $matches[2])) { // The user-agent is DoCoMo compatible. - $this->_comment = $matches[2]; - } - } - - $rest = explode(';', $matches[1]); - foreach ($rest as $value) { - if (preg_match('/^c(\d+)$/', $value, $matches)) { - $this->_cacheSize = (integer)$matches[1]; - continue; - } - if (preg_match('/^ser(\w{15})$/', $value, $matches)) { - $this->_serialNumber = $matches[1]; - continue; - } - if (preg_match('/^([A-Z]+)$/', $value, $matches)) { - $this->_status = $matches[1]; - continue; - } - if (preg_match('/^icc(\w{20})?$/', $value, $matches)) { - if (count($matches) == 2) { - $this->_cardID = $matches[1]; - } - continue; - } - if (preg_match('/^W(\d+)H(\d+)$/', $value, $matches)) { - $this->_displayBytes = "{$matches[1]}*{$matches[2]}"; - continue; - } - return $this->noMatch(); - } - } - } - - /**#@-*/ - - // }}} -} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: iso-8859-1 - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * indent-tabs-mode: nil - * End: - */ diff --git a/data/module/Net/UserAgent/Mobile/DoCoMo/ScreenInfo.php b/data/module/Net/UserAgent/Mobile/DoCoMo/ScreenInfo.php deleted file mode 100644 index e7a1b98a377..00000000000 --- a/data/module/Net/UserAgent/Mobile/DoCoMo/ScreenInfo.php +++ /dev/null @@ -1,2184 +0,0 @@ -, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2008-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: ScreenInfo.php,v 1.2 2009/06/23 08:06:58 kuboa Exp $ - * @link http://www.nttdocomo.co.jp/service/imode/make/content/spec/screen_area/index.html - * @since File available since Release 1.0.0RC1 - */ - -// {{{ GLOBALS - -$GLOBALS['NET_USERAGENT_MOBILE_DoCoMo_ScreenInfo_Instance'] = null; - -// }}} -// {{{ Net_UserAgent_Mobile_DoCoMo_ScreenInfo - -/** - * The screen information class for DoCoMo. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2008-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.0.0 - * @link http://www.nttdocomo.co.jp/service/imode/make/content/spec/screen_area/index.html - * @since Class available since Release 1.0.0RC1 - */ -class Net_UserAgent_Mobile_DoCoMo_ScreenInfo -{ - - // {{{ properties - - /**#@+ - * @access public - */ - - /**#@-*/ - - /**#@+ - * @access private - */ - - var $_data = array( - - // i-mode compliant HTML 1.0 - 'D501I' => array( - 'width' => 96, - 'height' => 72, - 'depth' => 2, - 'color' => 0 - ), - 'F501I' => array( - 'width' => 112, - 'height' => 84, - 'depth' => 2, - 'color' => 0 - ), - 'N501I' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 2, - 'color' => 0 - ), - 'P501I' => array( - 'width' => 96, - 'height' => 120, - 'depth' => 2, - 'color' => 0 - ), - - // i-mode compliant HTML 2.0 - 'D502I' => array( - 'width' => 96, - 'height' => 90, - 'depth' => 256, - 'color' => 1 - ), - 'F502I' => array( - 'width' => 96, - 'height' => 91, - 'depth' => 256, - 'color' => 1 - ), - 'N502I' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 4, - 'color' => 0 - ), - 'P502I' => array( - 'width' => 96, - 'height' => 117, - 'depth' => 4, - 'color' => 0 - ), - 'NM502I' => array( - 'width' => 111, - 'height' => 106, - 'depth' => 2, - 'color' => 0 - ), - 'SO502I' => array( - 'width' => 120, - 'height' => 120, - 'depth' => 4, - 'color' => 0 - ), - 'F502IT' => array( - 'width' => 96, - 'height' => 91, - 'depth' => 256, - 'color' => 1 - ), - 'N502IT' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 256, - 'color' => 1 - ), - 'SO502IWM' => array( - 'width' => 120, - 'height' => 113, - 'depth' => 256, - 'color' => 1 - ), - 'SH821I' => array( - 'width' => 96, - 'height' => 78, - 'depth' => 256, - 'color' => 1 - ), - 'N821I' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 4, - 'color' => 0 - ), - 'P821I' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 4, - 'color' => 0 - ), - 'D209I' => array( - 'width' => 96, - 'height' => 90, - 'depth' => 256, - 'color' => 1 - ), - 'ER209I' => array( - 'width' => 120, - 'height' => 72, - 'depth' => 2, - 'color' => 0 - ), - 'F209I' => array( - 'width' => 96, - 'height' => 91, - 'depth' => 256, - 'color' => 1 - ), - 'KO209I' => array( - 'width' => 96, - 'height' => 96, - 'depth' => 256, - 'color' => 1 - ), - 'N209I' => array( - 'width' => 108, - 'height' => 82, - 'depth' => 4, - 'color' => 0 - ), - 'P209I' => array( - 'width' => 96, - 'height' => 87, - 'depth' => 4, - 'color' => 0 - ), - 'P209IS' => array( - 'width' => 96, - 'height' => 87, - 'depth' => 256, - 'color' => 1 - ), - 'R209I' => array( - 'width' => 96, - 'height' => 72, - 'depth' => 4, - 'color' => 0 - ), - 'P651PS' => array( - 'width' => 96, - 'height' => 87, - 'depth' => 4, - 'color' => 0 - ), - 'R691I' => array( - 'width' => 96, - 'height' => 72, - 'depth' => 4, - 'color' => 0 - ), - 'F671I' => array( - 'width' => 120, - 'height' => 126, - 'depth' => 256, - 'color' => 1 - ), - 'F210I' => array( - 'width' => 96, - 'height' => 113, - 'depth' => 256, - 'color' => 1 - ), - 'N210I' => array( - 'width' => 118, - 'height' => 113, - 'depth' => 256, - 'color' => 1 - ), - 'P210I' => array( - 'width' => 96, - 'height' => 91, - 'depth' => 256, - 'color' => 1 - ), - 'KO210I' => array( - 'width' => 96, - 'height' => 96, - 'depth' => 256, - 'color' => 1 - ), - - // i-mode compliant HTML 3.0 - 'F503I' => array( - 'width' => 120, - 'height' => 130, - 'depth' => 256, - 'color' => 1 - ), - 'F503IS' => array( - 'width' => 120, - 'height' => 130, - 'depth' => 4096, - 'color' => 1 - ), - 'P503I' => array( - 'width' => 120, - 'height' => 130, - 'depth' => 256, - 'color' => 1 - ), - 'P503IS' => array( - 'width' => 120, - 'height' => 130, - 'depth' => 256, - 'color' => 1 - ), - 'N503I' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 4096, - 'color' => 1 - ), - 'N503IS' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 4096, - 'color' => 1 - ), - 'SO503I' => array( - 'width' => 120, - 'height' => 113, - 'depth' => 65536, - 'color' => 1 - ), - 'SO503IS' => array( - 'width' => 120, - 'height' => 113, - 'depth' => 65536, - 'color' => 1 - ), - 'D503I' => array( - 'width' => 132, - 'height' => 126, - 'depth' => 4096, - 'color' => 1 - ), - 'D503IS' => array( - 'width' => 132, - 'height' => 126, - 'depth' => 4096, - 'color' => 1 - ), - 'D210I' => array( - 'width' => 96, - 'height' => 91, - 'depth' => 256, - 'color' => 1 - ), - 'SO210I' => array( - 'width' => 120, - 'height' => 113, - 'depth' => 256, - 'color' => 1 - ), - 'F211I' => array( - 'width' => 96, - 'height' => 113, - 'depth' => 4096, - 'color' => 1 - ), - 'D211I' => array( - 'width' => 100, - 'height' => 91, - 'depth' => 4096, - 'color' => 1 - ), - 'N211I' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 4096, - 'color' => 1 - ), - 'N211IS' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 4096, - 'color' => 1 - ), - 'P211I' => array( - 'width' => 120, - 'height' => 130, - 'depth' => 65536, - 'color' => 1 - ), - 'P211IS' => array( - 'width' => 120, - 'height' => 130, - 'depth' => 65536, - 'color' => 1 - ), - 'SO211I' => array( - 'width' => 120, - 'height' => 112, - 'depth' => 4096, - 'color' => 1 - ), - 'R211I' => array( - 'width' => 96, - 'height' => 98, - 'depth' => 4096, - 'color' => 1 - ), - 'SH251I' => array( - 'width' => 120, - 'height' => 130, - 'depth' => 65536, - 'color' => 1 - ), - 'SH251IS' => array( - 'width' => 176, - 'height' => 187, - 'depth' => 65536, - 'color' => 1 - ), - 'R692I' => array( - 'width' => 96, - 'height' => 98, - 'depth' => 4096, - 'color' => 1 - ), - - // i-mode compliant HTML 3.0 - // (FOMA 2001/2002/2101V) - 'N2001' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 4096, - 'color' => 1 - ), - 'N2002' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 65536, - 'color' => 1 - ), - 'P2002' => array( - 'width' => 118, - 'height' => 128, - 'depth' => 65536, - 'color' => 1 - ), - 'D2101V' => array( - 'width' => 120, - 'height' => 130, - 'depth' => 262144, - 'color' => 1 - ), - 'P2101V' => array( - 'width' => 163, - 'height' => 182, - 'depth' => 262144, - 'color' => 1 - ), - 'SH2101V' => array( - 'width' => 800, - 'height' => 600, - 'depth' => 65536, - 'color' => 1 - ), - 'T2101V' => array( - 'width' => 176, - 'height' => 144, - 'depth' => 262144, - 'color' => 1 - ), - - // i-mode compliant HTML 4.0 - 'D504I' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 262144, - 'color' => 1 - ), - 'F504I' => array( - 'width' => 132, - 'height' => 136, - 'depth' => 65536, - 'color' => 1 - ), - 'F504IS' => array( - 'width' => 132, - 'height' => 136, - 'depth' => 65536, - 'color' => 1 - ), - 'N504I' => array( - 'width' => 160, - 'height' => 180, - 'depth' => 65536, - 'color' => 1 - ), - 'N504IS' => array( - 'width' => 160, - 'height' => 180, - 'depth' => 65536, - 'color' => 1 - ), - 'SO504I' => array( - 'width' => 120, - 'height' => 112, - 'depth' => 65536, - 'color' => 1 - ), - 'P504I' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 65536, - 'color' => 1 - ), - 'P504IS' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 65536, - 'color' => 1 - ), - 'D251I' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 262144, - 'color' => 1 - ), - 'D251IS' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 262144, - 'color' => 1 - ), - 'F251I' => array( - 'width' => 132, - 'height' => 140, - 'depth' => 65536, - 'color' => 1 - ), - 'N251I' => array( - 'width' => 132, - 'height' => 140, - 'depth' => 65536, - 'color' => 1 - ), - 'N251IS' => array( - 'width' => 132, - 'height' => 140, - 'depth' => 65536, - 'color' => 1 - ), - 'P251IS' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 65536, - 'color' => 1 - ), - 'F671IS' => array( - 'width' => 160, - 'height' => 120, - 'depth' => 65536, - 'color' => 1 - ), - 'F212I' => array( - 'width' => 132, - 'height' => 136, - 'depth' => 65536, - 'color' => 1 - ), - 'SO212I' => array( - 'width' => 120, - 'height' => 112, - 'depth' => 65536, - 'color' => 1 - ), - 'F661I' => array( - 'width' => 132, - 'height' => 136, - 'depth' => 65536, - 'color' => 1 - ), - 'F672I' => array( - 'width' => 160, - 'height' => 120, - 'depth' => 65536, - 'color' => 1 - ), - 'SO213I' => array( - 'width' => 120, - 'height' => 112, - 'depth' => 65536, - 'color' => 1 - ), - 'SO213IS' => array( - 'width' => 120, - 'height' => 112, - 'depth' => 65536, - 'color' => 1 - ), - 'SO213IWR' => array( - 'width' => 120, - 'height' => 112, - 'depth' => 65536, - 'color' => 1 - ), - - // i-mode compliant HTML 4.0 - // (FOMA 2051/2102V/2701 etc.) - 'F2051' => array( - 'width' => 176, - 'height' => 182, - 'depth' => 65536, - 'color' => 1 - ), - 'N2051' => array( - 'width' => 176, - 'height' => 198, - 'depth' => 65536, - 'color' => 1 - ), - 'P2102V' => array( - 'width' => 176, - 'height' => 198, - 'depth' => 262144, - 'color' => 1 - ), - 'P2102V' => array( - 'width' => 176, - 'height' => 198, - 'depth' => 262144, - 'color' => 1 - ), - 'F2102V' => array( - 'width' => 176, - 'height' => 182, - 'depth' => 65536, - 'color' => 1 - ), - 'N2102V' => array( - 'width' => 176, - 'height' => 198, - 'depth' => 65536, - 'color' => 1 - ), - 'N2701' => array( - 'width' => 176, - 'height' => 198, - 'depth' => 65536, - 'color' => 1 - ), - 'NM850IG' => array( - 'width' => 176, - 'height' => 144, - 'depth' => 65536, - 'color' => 1 - ), - 'NM705I' => array( - 'width' => 231, - 'height' => 235, - 'depth' => 16777216, - 'color' => 1 - ), - 'NM706I' => array( - 'width' => 231, - 'height' => 235, - 'depth' => 16777216, - 'color' => 1 - ), - - // i-mode compliant HTML 5.0 (505i etc.) - 'D505I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'SO505I' => array( - 'width' => 256, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SH505I' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 262144, - 'color' => 1 - ), - 'N505I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'F505I' => array( - 'width' => 240, - 'height' => 268, - 'depth' => 262144, - 'color' => 1 - ), - 'P505I' => array( - 'width' => 240, - 'height' => 266, - 'depth' => 65536, - 'color' => 1 - ), - 'D505IS' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'P505IS' => array( - 'width' => 240, - 'height' => 266, - 'depth' => 65536, - 'color' => 1 - ), - 'N505IS' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'SO505IS' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 262144, - 'color' => 1 - ), - 'SH505IS' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 262144, - 'color' => 1 - ), - 'F505IGPS' => array( - 'width' => 240, - 'height' => 268, - 'depth' => 262144, - 'color' => 1 - ), - 'D252I' => array( - 'width' => 176, - 'height' => 198, - 'depth' => 262144, - 'color' => 1 - ), - 'SH252I' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 262144, - 'color' => 1 - ), - 'P252I' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 65536, - 'color' => 1 - ), - 'N252I' => array( - 'width' => 132, - 'height' => 140, - 'depth' => 65536, - 'color' => 1 - ), - 'P252IS' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 65536, - 'color' => 1 - ), - 'D506I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'F506I' => array( - 'width' => 240, - 'height' => 268, - 'depth' => 262144, - 'color' => 1 - ), - 'N506I' => array( - 'width' => 240, - 'height' => 295, - 'depth' => 262144, - 'color' => 1 - ), - 'P506IC' => array( - 'width' => 240, - 'height' => 266, - 'depth' => 65536, - 'color' => 1 - ), - 'SH506IC' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 262144, - 'color' => 1 - ), - 'SO506IC' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 262144, - 'color' => 1 - ), - 'N506IS' => array( - 'width' => 240, - 'height' => 295, - 'depth' => 262144, - 'color' => 1 - ), - 'SO506I' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 262144, - 'color' => 1 - ), - 'SO506IS' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 262144, - 'color' => 1 - ), - 'N506IS2' => array( - 'width' => 240, - 'height' => 295, - 'depth' => 262144, - 'color' => 1 - ), - 'P506ICII' => array( - 'width' => 240, - 'height' => 266, - 'depth' => 65536, - 'color' => 1 - ), - 'D253I' => array( - 'width' => 176, - 'height' => 198, - 'depth' => 262144, - 'color' => 1 - ), - 'N253I' => array( - 'width' => 160, - 'height' => 180, - 'depth' => 65536, - 'color' => 1 - ), - 'P253I' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 65536, - 'color' => 1 - ), - 'D253IWM' => array( - 'width' => 220, - 'height' => 144, - 'depth' => 262144, - 'color' => 1 - ), - 'P253IS' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 65536, - 'color' => 1 - ), - 'P213I' => array( - 'width' => 132, - 'height' => 144, - 'depth' => 65536, - 'color' => 1 - ), - - // i-mode compliant HTML 5.0 - // (FOMA 900i etc.) - 'F900I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'N900I' => array( - 'width' => 240, - 'height' => 269, - 'depth' => 65536, - 'color' => 1 - ), - 'P900I' => array( - 'width' => 240, - 'height' => 266, - 'depth' => 65536, - 'color' => 1 - ), - 'SH900I' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 262144, - 'color' => 1 - ), - 'F900IT' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'P900IV' => array( - 'width' => 240, - 'height' => 266, - 'depth' => 262144, - 'color' => 1 - ), - 'N900IS' => array( - 'width' => 240, - 'height' => 269, - 'depth' => 65536, - 'color' => 1 - ), - 'D900I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'F900IC' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'F880IES' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 65536, - 'color' => 1 - ), - 'N900IL' => array( - 'width' => 240, - 'height' => 269, - 'depth' => 65536, - 'color' => 1 - ), - 'N900IG' => array( - 'width' => 240, - 'height' => 269, - 'depth' => 65536, - 'color' => 1 - ), - 'SH901IC' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 262144, - 'color' => 1 - ), - 'F901IC' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'N901IC' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'D901I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'P901I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'F700I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SH700I' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 262144, - 'color' => 1 - ), - 'N700I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'P700I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'F700IS' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SH700IS' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 262144, - 'color' => 1 - ), - 'SA700IS' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 65536, - 'color' => 1 - ), - - 'SH901IS' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 262144, - 'color' => 1 - ), - 'F901IS' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'D901IS' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'P901IS' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'N901IS' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'P901ITV' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'SH851I' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 262144, - 'color' => 1 - ), - 'P851I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'F881IES' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 65536, - 'color' => 1 - ), - 'D701I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 65536, - 'color' => 1 - ), - 'N701I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'P701ID' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'D701IWM' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 65536, - 'color' => 1 - ), - 'N701IECO' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'SA800I' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 65536, - 'color' => 1 - ), - 'L600I' => array( - 'width' => 170, - 'height' => 189, - 'depth' => 65536, - 'color' => 1 - ), - 'N600I' => array( - 'width' => 176, - 'height' => 180, - 'depth' => 65536, - 'color' => 1 - ), - 'L601I' => array( - 'width' => 170, - 'height' => 189, - 'depth' => 65536, - 'color' => 1 - ), - 'M702IS' => array( - 'width' => 240, - 'height' => 267, - 'depth' => 262144, - 'color' => 1 - ), - 'M702IG' => array( - 'width' => 240, - 'height' => 267, - 'depth' => 262144, - 'color' => 1 - ), - 'L602I' => array( - 'width' => 170, - 'height' => 189, - 'depth' => 65536, - 'color' => 1 - ), - - // i-mode compliant HTML 6.0 - // (FOMA 902i etc.) - 'F902I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'D902I' => array( - 'width' => 230, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'N902I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'P902I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'SH902I' => array( - 'width' => 240, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SO902I' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 262144, - 'color' => 1 - ), - 'SH902IS' => array( - 'width' => 240, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'P902IS' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'N902IS' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'D902IS' => array( - 'width' => 230, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'F902IS' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SO902IWP+' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 262144, - 'color' => 1 - ), - 'SH902ISL' => array( - 'width' => 240, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'N902IX' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'N902IL' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'P702I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'N702ID' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'F702ID' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SH702ID' => array( - 'width' => 240, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'D702I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SO702I' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 262144, - 'color' => 1 - ), - 'D702IBCL' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SA702I' => array( - 'width' => 240, - 'height' => 252, - 'depth' => 65536, - 'color' => 1 - ), - 'SH702IS' => array( - 'width' => 240, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'N702IS' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'P702ID' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'D702IF' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'D851IWM' => array( - 'width' => 230, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'F882IES' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 65536, - 'color' => 1 - ), - 'N601I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 65536, - 'color' => 1 - ), - 'D800IDS' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'P703IMYU' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'F883I' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 65536, - 'color' => 1 - ), - 'F883IS' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 65536, - 'color' => 1 - ), - 'P704IMYU' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'L704I' => array( - 'width' => 240, - 'height' => 280, - 'depth' => 262144, - 'color' => 1 - ), - 'L705I' => array( - 'width' => 240, - 'height' => 280, - 'depth' => 262144, - 'color' => 1 - ), - 'L705IX' => array( - 'width' => 240, - 'height' => 280, - 'depth' => 262144, - 'color' => 1 - ), - 'L852I' => array( - 'width' => 240, - 'height' => 298, - 'depth' => 65536, - 'color' => 1 - ), - 'L706IE' => array( - 'width' => 240, - 'height' => 280, - 'depth' => 262144, - 'color' => 1 - ), - 'L01A' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'L03A' => array( - 'width' => 240, - 'height' => 280, - 'depth' => 262144, - 'color' => 1 - ), - - // i-mode compliant HTML 7.0 - // (FOMA 903i etc.) - 'SH903I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'P903I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'N903I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'D903I' => array( - 'width' => 230, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'F903I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SO903I' => array( - 'width' => 240, - 'height' => 368, - 'depth' => 262144, - 'color' => 1 - ), - 'D903ITV' => array( - 'width' => 230, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'F903IX' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'P903ITV' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'SH903ITV' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'F903IBSC' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'P903IX' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'SO903ITV' => array( - 'width' => 240, - 'height' => 368, - 'depth' => 262144, - 'color' => 1 - ), - 'N703ID' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'F703I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'P703I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'D703I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SH703I' => array( - 'width' => 240, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SH703I' => array( - 'width' => 240, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'N703IMYU' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'SO703I' => array( - 'width' => 240, - 'height' => 368, - 'depth' => 262144, - 'color' => 1 - ), - 'P904I' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'D904I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'F904I' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 262144, - 'color' => 1 - ), - 'N904I' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 262144, - 'color' => 1 - ), - 'SH904I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'P704I' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'D704I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SH704I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'N704IMYU' => array( - 'width' => 240, - 'height' => 270, - 'depth' => 262144, - 'color' => 1 - ), - 'F704I' => array( - 'width' => 230, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SO704I' => array( - 'width' => 240, - 'height' => 368, - 'depth' => 262144, - 'color' => 1 - ), - 'F883IES' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 65536, - 'color' => 1 - ), - 'F883IESS' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 65536, - 'color' => 1 - ), - 'F801I' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 65536, - 'color' => 1 - ), - 'F705I' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 262144, - 'color' => 1 - ), - 'D705I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'D705IMYU' => array( - 'width' => 240, - 'height' => 240, - 'depth' => 262144, - 'color' => 1 - ), - 'SH705I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'SH705I2' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'SH706IE' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'F05A' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 65536, - 'color' => 1 - ), - - // i-mode compliant HTML 7.1 - // (FOMA 905i etc.) - 'SH905I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 16777216, - 'color' => 1 - ), - 'D905I' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 262144, - 'color' => 1 - ), - 'N905I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'P905I' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'F905I' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 16777216, - 'color' => 1 - ), - 'SO905I' => array( - 'width' => 240, - 'height' => 368, - 'depth' => 16777216, - 'color' => 1 - ), - 'N905IMYU' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'N905IBIZ' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'SH905ITV' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 16777216, - 'color' => 1 - ), - 'SO905ICS' => array( - 'width' => 240, - 'height' => 368, - 'depth' => 16777216, - 'color' => 1 - ), - 'F905IBIZ' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 16777216, - 'color' => 1 - ), - 'P905ITV' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'P705I' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'N705I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'N705IMYU' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'P705IMYU' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'SO705I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'P705ICL' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'F884I' => array( - 'width' => 240, - 'height' => 364, - 'depth' => 262144, - 'color' => 1 - ), - 'F884IES' => array( - 'width' => 240, - 'height' => 282, - 'depth' => 262144, - 'color' => 1 - ), - 'N906IL' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'N706I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'SO706I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'P706IMYU' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'N706IE' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'N706I2' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'N03A' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'N05A' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'F07A' => array( - 'width' => 240, - 'height' => 256, - 'depth' => 262144, - 'color' => 1 - ), - - // i-mode compliant HTML 7.2 - // (FOMA 906i etc.) - 'P906I' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'SO906I' => array( - 'width' => 240, - 'height' => 368, - 'depth' => 16777216, - 'color' => 1 - ), - 'SH906I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 16777216, - 'color' => 1 - ), - 'N906IMYU' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'F906I' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 16777216, - 'color' => 1 - ), - 'N906I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'SH906ITV' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 16777216, - 'color' => 1 - ), - 'F706I' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 262144, - 'color' => 1 - ), - 'SH706I' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 16777216, - 'color' => 1 - ), - 'P706IE' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'SH706IW' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 16777216, - 'color' => 1 - ), - 'F01A' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 16777216, - 'color' => 1 - ), - 'F02A' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 262144, - 'color' => 1 - ), - 'F03A' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 16777216, - 'color' => 1 - ), - 'F04A' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 262144, - 'color' => 1 - ), - 'F06A' => array( - 'width' => 240, - 'height' => 352, - 'depth' => 16777216, - 'color' => 1 - ), - 'P01A' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'P02A' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'P03A' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'P04A' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'P05A' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'P06A' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'P10A' => array( - 'width' => 240, - 'height' => 350, - 'depth' => 262144, - 'color' => 1 - ), - 'SH01A' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 16777216, - 'color' => 1 - ), - 'SH02A' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 16777216, - 'color' => 1 - ), - 'SH03A' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 16777216, - 'color' => 1 - ), - 'SH04A' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 16777216, - 'color' => 1 - ), - 'N01A' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'N02A' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - 'N04A' => array( - 'width' => 240, - 'height' => 320, - 'depth' => 262144, - 'color' => 1 - ), - - // i-mode browser 2.0 - 'P07A3' => array( - 'width' => 480, - 'height' => 662, - 'depth' => 262144, - 'color' => 1 - ), - 'P08A3' => array( - 'width' => 480, - 'height' => 662, - 'depth' => 262144, - 'color' => 1 - ), - 'P09A3' => array( - 'width' => 480, - 'height' => 662, - 'depth' => 262144, - 'color' => 1 - ), - 'N06A3' => array( - 'width' => 480, - 'height' => 640, - 'depth' => 262144, - 'color' => 1 - ), - 'N08A3' => array( - 'width' => 480, - 'height' => 640, - 'depth' => 262144, - 'color' => 1 - ), - 'N09A3' => array( - 'width' => 480, - 'height' => 640, - 'depth' => 262144, - 'color' => 1 - ), - 'F08A3' => array( - 'width' => 480, - 'height' => 648, - 'depth' => 262144, - 'color' => 1 - ), - 'F09A3' => array( - 'width' => 480, - 'height' => 648, - 'depth' => 16777216, - 'color' => 1 - ), - 'SH05A3' => array( - 'width' => 480, - 'height' => 592, - 'depth' => 16777216, - 'color' => 1 - ), - 'SH06A3' => array( - 'width' => 480, - 'height' => 592, - 'depth' => 16777216, - 'color' => 1 - ), - 'SH07A3' => array( - 'width' => 480, - 'height' => 592, - 'depth' => 16777216, - 'color' => 1 - ) - ); - - /**#@-*/ - - /**#@+ - * @access public - */ - - // }}} - // {{{ singleton() - - /** - * Returns the Net_UserAgent_Mobile_DoCoMo_Screen instance if it exists. If it - * not exists, a new instance of Net_UserAgent_Mobile_DoCoMo_Screen will be - * created and returned. - * - * @return Net_UserAgent_Mobile_DoCoMo_ScreenInfo - * @static - */ - function &singleton() - { - if (@is_null($GLOBALS['NET_USERAGENT_MOBILE_DoCoMo_ScreenInfo_Instance'])) { - $GLOBALS['NET_USERAGENT_MOBILE_DoCoMo_ScreenInfo_Instance'] = &new Net_UserAgent_Mobile_DoCoMo_ScreenInfo(); - } - - return $GLOBALS['NET_USERAGENT_MOBILE_DoCoMo_ScreenInfo_Instance']; - } - - // }}} - // {{{ get() - - /** - * Gets the screen information of a given model. - * - * @param string $model - * @return array - */ - function get($model) - { - return $this->_data[ strtoupper($model) ]; - } - - /**#@-*/ - - /**#@+ - * @access private - */ - - // }}} - // {{{ constructor - - /** - * Creates the screen information by a given XML file if DOCOMO_MAP environment - * variable exists. - */ - function Net_UserAgent_Mobile_DoCoMo_ScreenInfo() - { - if (!array_key_exists('DOCOMO_MAP', $_SERVER)) { - return; - } - - // using the specified XML data - do { - if (!function_exists('xml_parser_create') - || !is_readable($_SERVER['DOCOMO_MAP']) - ) { - break; - } - - $xml = file_get_contents($_SERVER['DOCOMO_MAP']); - if ($xml === false) { - break; - } - - $parser = xml_parser_create(); - if ($parser === false) { - break; - } - - xml_parse_into_struct($parser, $xml, $values, $indexes); - if (!xml_parser_free($parser)) { - break; - } - - if (array_key_exists('OPT', $indexes)) { - unset($indexes['OPT']); - } - - $data = array(); - foreach ($indexes as $modelName => $modelIndexes) { - $data[$modelName] = array(); - foreach ($values[ $modelIndexes[0] ]['attributes'] - as $attributeName => $attributeValue - ) { - $data[$modelName][ strtolower($attributeName) ] = $attributeValue; - } - } - - $this->_data = $data; - } while (false); - } - - /**#@-*/ - - // }}} -} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: iso-8859-1 - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * indent-tabs-mode: nil - * End: - */ diff --git a/data/module/Net/UserAgent/Mobile/EZweb.php b/data/module/Net/UserAgent/Mobile/EZweb.php deleted file mode 100644 index f8c1703cc17..00000000000 --- a/data/module/Net/UserAgent/Mobile/EZweb.php +++ /dev/null @@ -1,342 +0,0 @@ -, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://www.au.kddi.com/ezfactory/tec/spec/4_4.html - * @link http://www.au.kddi.com/ezfactory/tec/spec/new_win/ezkishu.html - * @since File available since Release 0.1.0 - */ - -require_once dirname(__FILE__) . '/Common.php'; -require_once dirname(__FILE__) . '/Display.php'; - -// {{{ Net_UserAgent_Mobile_EZweb - -/** - * EZweb implementation - * - * Net_UserAgent_Mobile_EZweb is a subclass of {@link Net_UserAgent_Mobile_Common}, - * which implements EZweb (WAP1.0/2.0) user agents. - * - * SYNOPSIS: - * - * require_once 'Net/UserAgent/Mobile.php'; - * - * $_SERVER['HTTP_USER_AGENT'] = 'UP.Browser/3.01-HI02 UP.Link/3.2.1.2'; - * $agent = &Net_UserAgent_Mobile::factory(); - * - * printf("Name: %s\n", $agent->getName()); // 'UP.Browser' - * printf("Version: %s\n", $agent->getVersion()); // 3.01 - * printf("DeviceID: %s\n", $agent->getDeviceID()); // 'HI02' - * printf("Server: %s\n", $agent->getServer()); // 'UP.Link/3.2.1.2' - * - * e.g.) 'UP.Browser/3.01-HI02 UP.Link/3.2.1.2 (Google WAP Proxy/1.0)' - * printf("Comment: %s\n", $agent->getComment()); // 'Google WAP Proxy/1.0' - * - * e.g.) 'KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1' - * if ($agent->isXHTMLCompliant()) { - * print "XHTML compliant!\n"; // true - * } - * - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.0.0 - * @link http://www.au.kddi.com/ezfactory/tec/spec/4_4.html - * @link http://www.au.kddi.com/ezfactory/tec/spec/new_win/ezkishu.html - * @since Class available since Release 0.1.0 - */ -class Net_UserAgent_Mobile_EZweb extends Net_UserAgent_Mobile_Common -{ - - // {{{ properties - - /**#@+ - * @access public - */ - - /**#@-*/ - - /**#@+ - * @access private - */ - - /** - * server string like 'UP.Link/3.2.1.2' - * @var string - */ - var $_serverName = ''; - - /** - * comment like 'Google WAP Proxy/1.0' - * @var string - */ - var $_comment = null; - - /** - * whether it's XHTML compliant or not - * @var boolean - */ - var $_xhtmlCompliant = false; - - /**#@-*/ - - /**#@+ - * @access public - */ - - // }}} - // {{{ isEZweb() - - /** - * returns true - * - * @return boolean - */ - function isEZweb() - { - return true; - } - - // }}} - // {{{ isTUKa() - - /** - * returns true if the agent is TU-Ka - * - * @return boolean - */ - function isTUKa() - { - $tuka = substr($this->_rawModel, 2, 1); - if ($this->isWAP2()) { - if ($tuka == 'U') { - return true; - } - } else { - if ($tuka == 'T') { - return true; - } - } - - return false; - } - - // }}} - // {{{ parse() - - /** - * Parses HTTP_USER_AGENT string. - * - * @param string $userAgent User-Agent string - */ - function parse($userAgent) - { - if (preg_match('/^KDDI-(.*)/', $userAgent, $matches)) { - - // KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1 - $this->_xhtmlCompliant = true; - @list($this->_rawModel, $browser, $opt, $this->_serverName) = - explode(' ', $matches[1], 4); - @list($this->name, $version) = explode('/', $browser); - $this->version = "$version $opt"; - } else { - - // UP.Browser/3.01-HI01 UP.Link/3.4.5.2 - @list($browser, $this->_serverName, $comment) = - explode(' ', $userAgent, 3); - @list($this->name, $software) = explode('/', $browser); - @list($this->version, $this->_rawModel) = explode('-', $software); - if ($comment) { - $this->_comment = preg_replace('/^\((.*)\)$/', '$1', $comment); - } - } - } - - // }}} - // {{{ makeDisplay() - - /** - * create a new {@link Net_UserAgent_Mobile_Display} class instance - * - * @return Net_UserAgent_Mobile_Display - */ - function makeDisplay() - { - @list($width, $height) = - explode(',', $this->getHeader('X-UP-DEVCAP-SCREENPIXELS')); - $screenDepth = explode(',', $this->getHeader('X-UP-DEVCAP-SCREENDEPTH')); - $depth = $screenDepth[0] ? pow(2, (integer)$screenDepth[0]) : 0; - $color = $this->getHeader('X-UP-DEVCAP-ISCOLOR') === '1' ? true : false; - return new Net_UserAgent_Mobile_Display(array('width' => $width, - 'height' => $height, - 'color' => $color, - 'depth' => $depth) - ); - } - - // }}} - // {{{ getDeviceID() - - /** - * Returns the device ID of the user agent. - * - * @return string - */ - function getDeviceID() - { - return $this->_rawModel; - } - - // }}} - // {{{ getServer() - - /** - * returns server string like 'UP.Link/3.2.1.2' - * - * @return string - */ - function getServer() - { - return $this->_serverName; - } - - // }}} - // {{{ getComment() - - /** - * returns comment like 'Google WAP Proxy/1.0'. returns null if nothinng. - * - * @return boolean - */ - function getComment() - { - return $this->_comment; - } - - // }}} - // {{{ isXHTMLCompliant() - - /** - * returns whether it's XHTML compliant or not - * - * @return boolean - */ - function isXHTMLCompliant() - { - return $this->_xhtmlCompliant; - } - - // }}} - // {{{ getCarrierShortName() - - /** - * returns the short name of the carrier - * - * @return string - */ - function getCarrierShortName() - { - return 'E'; - } - - // }}} - // {{{ getCarrierLongName() - - /** - * returns the long name of the carrier - * - * @return string - */ - function getCarrierLongName() - { - return 'EZweb'; - } - - // }}} - // {{{ isWIN() - - /** - * Returns whether the agent is CDMA 1X WIN or not. - * - * @return boolean - */ - function isWIN() - { - return substr($this->_rawModel, 2, 1) == 3 ? true : false; - } - - // }}} - // {{{ getUID() - - /** - * Gets the UID of a subscriber. - * - * @return string - * @since Method available since Release 1.0.0RC1 - */ - function getUID() - { - if (array_key_exists('HTTP_X_UP_SUBNO', $_SERVER)) { - return $_SERVER['HTTP_X_UP_SUBNO']; - } - } - - /**#@-*/ - - /**#@+ - * @access private - */ - - /**#@-*/ - - // }}} -} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: iso-8859-1 - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * indent-tabs-mode: nil - * End: - */ diff --git a/data/module/Net/UserAgent/Mobile/Error.php b/data/module/Net/UserAgent/Mobile/Error.php deleted file mode 100644 index 19056c816eb..00000000000 --- a/data/module/Net/UserAgent/Mobile/Error.php +++ /dev/null @@ -1,80 +0,0 @@ -, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Error.php,v 1.1 2009/05/26 08:48:16 kuboa Exp $ - * @since File available since Release 1.0.0RC3 - */ - -require_once dirname(__FILE__) . '/../../../PEAR.php'; - -// {{{ constants - -/** - * Constants for error handling. - */ -define('NET_USERAGENT_MOBILE_OK', 1); -define('NET_USERAGENT_MOBILE_ERROR', -1); -define('NET_USERAGENT_MOBILE_ERROR_NOMATCH', -2); -define('NET_USERAGENT_MOBILE_ERROR_NOT_FOUND', -3); - -// }}} -// {{{ Net_UserAgent_Mobile_Error - -/** - * Net_UserAgent_Mobile_Error implements a class for reporting user agent error - * messages - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.0.0 - * @since Class available since Release 0.1 - */ -class Net_UserAgent_Mobile_Error extends PEAR_Error {} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: iso-8859-1 - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * indent-tabs-mode: nil - * End: - */ diff --git a/data/module/Net/UserAgent/Mobile/NonMobile.php b/data/module/Net/UserAgent/Mobile/NonMobile.php deleted file mode 100644 index e2af4242fb8..00000000000 --- a/data/module/Net/UserAgent/Mobile/NonMobile.php +++ /dev/null @@ -1,176 +0,0 @@ -, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @since File available since Release 0.1.0 - */ - -require_once dirname(__FILE__) . '/Common.php'; -require_once dirname(__FILE__) . '/Display.php'; - -// {{{ Net_UserAgent_Mobile_NonMobile - -/** - * Non-Mobile Agent implementation - * - * Net_UserAgent_Mobile_NonMobile is a subclass of - * {@link Net_UserAgent_Mobile_Common}, which implements non-mobile or unimplemented - * user agents. - * - * SYNOPSIS: - * - * require_once 'Net/UserAgent/Mobile.php'; - * - * $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0'; - * $agent = &Net_UserAgent_Mobile::factory(); - * - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.0.0 - * @since Class available since Release 0.1.0 - */ -class Net_UserAgent_Mobile_NonMobile extends Net_UserAgent_Mobile_Common -{ - - // {{{ properties - - /**#@+ - * @access public - */ - - /**#@-*/ - - /**#@+ - * @access private - */ - - /**#@-*/ - - /**#@+ - * @access public - */ - - // }}} - // {{{ isNonMobile() - - /** - * returns true - * - * @return boolean - */ - function isNonMobile() - { - return true; - } - - // }}} - // {{{ parse() - - /** - * Parses HTTP_USER_AGENT string. - * - * @param string $userAgent User-Agent string - */ - function parse($userAgent) - { - @list($this->name, $this->version) = explode('/', $userAgent); - } - - // }}} - // {{{ makeDisplay() - - /** - * create a new {@link Net_UserAgent_Mobile_Display} class instance - * - * @return Net_UserAgent_Mobile_Display - */ - function makeDisplay() - { - return new Net_UserAgent_Mobile_Display(null); - } - - // }}} - // {{{ getCarrierShortName() - - /** - * returns the short name of the carrier - * - * @return string - */ - function getCarrierShortName() - { - return 'N'; - } - - // }}} - // {{{ getCarrierLongName() - - /** - * returns the long name of the carrier - * - * @return string - */ - function getCarrierLongName() - { - return 'NonMobile'; - } - - /**#@-*/ - - /**#@+ - * @access private - */ - - /**#@-*/ - - // }}} -} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: iso-8859-1 - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * indent-tabs-mode: nil - * End: - */ diff --git a/data/module/Net/UserAgent/Mobile/SoftBank.php b/data/module/Net/UserAgent/Mobile/SoftBank.php deleted file mode 100644 index e7e42369c0d..00000000000 --- a/data/module/Net/UserAgent/Mobile/SoftBank.php +++ /dev/null @@ -1,592 +0,0 @@ -, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://creation.mb.softbank.jp/ - * @since File available since Release 0.20.0 - */ - -require_once dirname(__FILE__) . '/Common.php'; -require_once dirname(__FILE__) . '/Display.php'; -require_once dirname(__FILE__) . '/../Mobile.php'; - -// {{{ Net_UserAgent_Mobile_SoftBank - -/** - * SoftBank implementation - * - * Net_UserAgent_Mobile_SoftBank is a subclass of {@link Net_UserAgent_Mobile_Common}, - * which implements SoftBank user agents. - * - * SYNOPSIS: - * - * require_once 'Net/UserAgent/Mobile.php'; - * - * $_SERVER['HTTP_USER_AGENT'] = 'J-PHONE/2.0/J-DN02'; - * $agent = &Net_UserAgent_Mobile::factory(); - * - * printf("Name: %s\n", $agent->getName()); // 'J-PHONE' - * printf("Version: %s\n", $agent->getVersion()); // 2.0 - * printf("Model: %s\n", $agent->getModel()); // 'J-DN02' - * if ($agent->isPacketCompliant()) { - * print "Packet is compliant.\n"; // false - * } - * - * // only availabe in Java compliant - * // e.g.) 'J-PHONE/4.0/J-SH51/SNXXXXXXXXX SH/0001a Profile/MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/JSCL-1.1.0' - * printf("Serial: %s\n", $agent->getSerialNumber()); // XXXXXXXXX - * printf("Vendor: %s\n", $agent->getVendor()); // 'SH' - * printf("Vendor Version: %s\n", $agent->getVendorVersion()); // '0001a' - * - * $info = $agent->getJavaInfo(); // array - * foreach ($info as $key => $value) { - * print "$key: $value\n"; - * } - * - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.0.0 - * @link http://creation.mb.softbank.jp/ - * @since Class available since Release 0.20.0 - */ -class Net_UserAgent_Mobile_SoftBank extends Net_UserAgent_Mobile_Common -{ - - // {{{ properties - - /**#@+ - * @access public - */ - - /**#@-*/ - - /**#@+ - * @access private - */ - - /** - * whether the agent is packet connection complicant or not - * @var boolean - */ - var $_packetCompliant = false; - - /** - * terminal unique serial number - * @var string - */ - var $_serialNumber; - - /** - * vendor code like 'SH' - * @var string - */ - var $_vendor = ''; - - /** - * vendor version like '0001a' - * @var string - */ - var $_vendorVersion; - - /** - * Java profiles - * @var array - */ - var $_javaInfo = array(); - - /** - * whether the agent is 3G - * @var boolean - */ - var $_is3G = true; - - /** - * the name of the mobile phone - * @var string - */ - var $_msname = ''; - - /**#@-*/ - - /**#@+ - * @access public - */ - - // }}} - // {{{ isJPhone() - - /** - * returns true - * - * @return boolean - */ - function isJPhone() - { - return $this->isSoftBank(); - } - - // }}} - // {{{ isVodafone() - - /** - * returns true - * - * @return boolean - */ - function isVodafone() - { - return $this->isSoftBank(); - } - - // }}} - // {{{ parse() - - /** - * Parses HTTP_USER_AGENT string. - * - * @param string $userAgent User-Agent string - * @throws Net_UserAgent_Mobile_Error - */ - function parse($userAgent) - { - $agent = explode(' ', $userAgent); - preg_match('!^(?:(SoftBank|Semulator|Vodafone|Vemulator|J-PHONE|J-EMULATOR)/\d\.\d|MOT-|MOTEMULATOR)!', - $agent[0], $matches - ); - if (count($matches) > 1) { - $carrier = $matches[1]; - } else { - $carrier = 'Motorola'; - } - - switch ($carrier) { - case 'SoftBank': - case 'Semulator': - case 'Vodafone': - case 'Vemulator': - $result = $this->_parseVodafone($agent); - break; - case 'J-PHONE': - case 'J-EMULATOR': - $result = $this->_parseJphone($agent); - break; - case 'Motorola': - case 'MOTEMULATOR': - $result = $this->_parseMotorola($agent); - break; - } - - if (Net_UserAgent_Mobile::isError($result)) { - return $result; - } - - $this->_msname = $this->getHeader('X-JPHONE-MSNAME'); - } - - // }}} - // {{{ makeDisplay() - - /** - * create a new {@link Net_UserAgent_Mobile_Display} class instance - * - * @return Net_UserAgent_Mobile_Display - */ - function makeDisplay() - { - @list($width, $height) = explode('*', $this->getHeader('X-JPHONE-DISPLAY')); - $color = false; - $depth = 0; - if ($color_string = $this->getHeader('X-JPHONE-COLOR')) { - preg_match('!^([CG])(\d+)$!', $color_string, $matches); - $color = $matches[1] === 'C' ? true : false; - $depth = $matches[2]; - } - - return new Net_UserAgent_Mobile_Display(array('width' => $width, - 'height' => $height, - 'depth' => $depth, - 'color' => $color) - ); - } - - // }}} - // {{{ isPacketCompliant() - - /** - * returns whether the agent is packet connection complicant or not - * - * @return boolean - */ - function isPacketCompliant() - { - return $this->_packetCompliant; - } - - // }}} - // {{{ getSerialNumber() - - /** - * return terminal unique serial number. returns null if user forbids to send - * his/her serial number. - * - * @return string - */ - function getSerialNumber() - { - return $this->_serialNumber; - } - - // }}} - // {{{ getVendor() - - /** - * returns vendor code like 'SH' - * - * @return string - */ - function getVendor() - { - return $this->_vendor; - } - - // }}} - // {{{ getVendorVersion() - - /** - * returns vendor version like '0001a'. returns null if unknown. - * - * @return string - */ - function getVendorVersion() - { - return $this->_vendorVersion; - } - - // }}} - // {{{ getJavaInfo() - - /** - * returns array of Java profiles - * - * Array structure is something like: - * - * - 'Profile' => 'MIDP-1.0', - * - 'Configuration' => 'CLDC-1.0', - * - 'Ext-Profile' => 'JSCL-1.1.0' - * - * @return array - */ - function getJavaInfo() - { - return $this->_javaInfo; - } - - // }}} - // {{{ getCarrierShortName() - - /** - * returns the short name of the carrier - * - * @return string - */ - function getCarrierShortName() - { - return 'S'; - } - - // }}} - // {{{ getCarrierLongName() - - /** - * returns the long name of the carrier - * - * @return string - */ - function getCarrierLongName() - { - return 'SoftBank'; - } - - // }}} - // {{{ isTypeC() - - /** - * returns true if the type is C - * - * @return boolean - */ - function isTypeC() - { - if ($this->_is3G || !preg_match('!^[32]\.!', $this->version)) { - return false; - } - - return true; - } - - // }}} - // {{{ isTypeP() - - /** - * returns true if the type is P - * - * @return boolean - */ - function isTypeP() - { - if ($this->_is3G || !preg_match('!^4\.!', $this->version)) { - return false; - } - - return true; - } - - // }}} - // {{{ isTypeW() - - /** - * returns true if the type is W - * - * @return boolean - */ - function isTypeW() - { - if ($this->_is3G || !preg_match('!^5\.!', $this->version)) { - return false; - } - - return true; - } - - // }}} - // {{{ isType3GC() - - /** - * returns true if the type is 3GC - * - * @return boolean - */ - function isType3GC() - { - return $this->_is3G; - } - - // }}} - // {{{ getMsname() - - /** - * returns the name of the mobile phone - * - * @return string the name of the mobile phone - */ - function getMsname() - { - return $this->_msname; - } - - // }}} - // {{{ isSoftBank() - - /** - * returns true if the agent is SoftBank. - * - * @return boolean - */ - function isSoftBank() - { - return true; - } - - // }}} - // {{{ getUID() - - /** - * Gets the UID of a subscriber. - * - * @return string - * @since Method available since Release 1.0.0RC1 - */ - function getUID() - { - if (array_key_exists('HTTP_X_JPHONE_UID', $_SERVER)) { - return $_SERVER['HTTP_X_JPHONE_UID']; - } - } - - /**#@-*/ - - /**#@+ - * @access private - */ - - // }}} - // {{{ _parseVodafone() - - /** - * parse HTTP_USER_AGENT string for the Vodafone 3G aegnt - * - * @param array $agent parts of the User-Agent string - * @throws Net_UserAgent_Mobile_Error - */ - function _parseVodafone($agent) - { - $this->_packetCompliant = true; - - // Vodafone/1.0/V702NK/NKJ001 Series60/2.6 Nokia6630/2.39.148 Profile/MIDP-2.0 Configuration/CLDC-1.1 - // Vodafone/1.0/V702NK/NKJ001/SN123456789012345 Series60/2.6 Nokia6630/2.39.148 Profile/MIDP-2.0 Configuration/CLDC-1.1 - // Vodafone/1.0/V802SE/SEJ001/SN123456789012345 Browser/SEMC-Browser/4.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 - @list($this->name, $this->version, $this->_rawModel, $modelVersion, - $serialNumber) = explode('/', $agent[0]); - if ($serialNumber) { - if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) { - return $this->noMatch(); - } - - $this->_serialNumber = $matches[1]; - } - - if (!preg_match('!^([a-z]+)((?:[a-z]|\d){4})$!i', $modelVersion, $matches)) { - return $this->noMatch(); - } - - $this->_vendor = $matches[1]; - $this->_vendorVersion = $matches[2]; - - for ($i = 2, $count = count($agent); $i < $count; ++$i) { - @list($key, $value) = explode('/', $agent[$i]); - $this->_javaInfo[$key] = $value; - } - } - - // }}} - // {{{ _parseJphone() - - /** - * parse HTTP_USER_AGENT string for the ancient agent - * - * @param array $agent parts of the User-Agent string - * @throws Net_UserAgent_Mobile_Error - */ - function _parseJphone($agent) - { - $count = count($agent); - $this->_is3G = false; - - if ($count > 1) { - - // J-PHONE/4.0/J-SH51/SNJSHA3029293 SH/0001aa Profile/MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/JSCL-1.1.0 - $this->_packetCompliant = true; - @list($this->name, $this->version, $this->_rawModel, $serialNumber) = - explode('/', $agent[0]); - if ($serialNumber) { - if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) { - return $this->noMatch(); - } - - $this->_serialNumber = $matches[1]; - } - - @list($this->_vendor, $this->_vendorVersion) = explode('/', $agent[1]); - for ($i = 2; $i < $count; ++$i) { - @list($key, $value) = explode('/', $agent[$i]); - $this->_javaInfo[$key] = $value; - } - } else { - - // J-PHONE/2.0/J-DN02 - @list($this->name, $this->version, $this->_rawModel, $serialNumber) = - explode('/', $agent[0]); - if ($serialNumber) { - if (!preg_match('!^SN(.+)!', $serialNumber, $matches)) { - return $this->noMatch(); - } - - $this->_serialNumber = $matches[1]; - } - - if ($this->_rawModel) { - if (preg_match('!V\d+([A-Z]+)!', $this->_rawModel, $matches)) { - $this->_vendor = $matches[1]; - } elseif (preg_match('!J-([A-Z]+)!', $this->_rawModel, $matches)) { - $this->_vendor = $matches[1]; - } - } - } - } - - // }}} - // {{{ _parseMotorola() - - /** - * parse HTTP_USER_AGENT string for the Motorola 3G aegnt - * - * @param array $agent parts of the User-Agent string - */ - function _parseMotorola($agent) - { - $this->_packetCompliant = true; - $this->_vendor = 'MOT'; - - // MOT-V980/80.2F.2E. MIB/2.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 - @list($this->_rawModel, $this->_vendorVersion) = explode('/', $agent[0]); - $this->_model = substr(strrchr($this->_rawModel, '-'), 1); - - for ($i = 2, $count = count($agent); $i < $count; ++$i) { - @list($key, $value) = explode('/', $agent[$i]); - $this->_javaInfo[$key] = $value; - } - } - - /**#@-*/ - - // }}} -} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: iso-8859-1 - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * indent-tabs-mode: nil - * End: - */ diff --git a/data/module/Net/UserAgent/Mobile/Willcom.php b/data/module/Net/UserAgent/Mobile/Willcom.php deleted file mode 100644 index 4c5119c802d..00000000000 --- a/data/module/Net/UserAgent/Mobile/Willcom.php +++ /dev/null @@ -1,293 +0,0 @@ -, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://www.willcom-inc.com/ja/service/contents_service/club_air_edge/for_phone/homepage/index.html - * @since File available since Release 0.5 - */ - -require_once dirname(__FILE__) . '/Common.php'; -require_once dirname(__FILE__) . '/Display.php'; - -// {{{ Net_UserAgent_Mobile_Willcom - -/** - * AirH"PHONE implementation - * - * Net_UserAgent_Mobile_Willcom is a subclass of {@link Net_UserAgent_Mobile_Common}, - * which implements Willcom's user agents. - * - * SYNOPSIS: - * - * require_once 'Net/UserAgent/Mobile.php'; - * - * $_SERVER['HTTP_USER_AGENT'] = - * 'Mozilla/3.0(DDIPOCKET;JRC/AH-J3001V,AH-J3002V/1.0/0100/c50)CNF/2.0'; - * $agent = &Net_UserAgent_Mobile::factory(); - * - * printf("Name: %s\n", $agent->getName()); // 'DDIPOCKET' - * printf("Verdor: %s\n", $agent->getVendor()); // 'JRC' - * printf("Model: %s\n", $agent->getModel()); // 'AH-J3001V,AH-J3002V' - * printf("Model Version: %s\n", $agent->getModelVersion()); // '1.0' - * printf("Browser Version: %s\n", $agent->getBrowserVersion()); // '0100' - * printf("Cache Size: %s\n", $agent->getCacheSize()); // 50 - * - * - * @category Networking - * @package Net_UserAgent_Mobile - * @author KUBO Atsuhiro - * @copyright 2003-2009 KUBO Atsuhiro - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.0.0 - * @link http://www.willcom-inc.com/ja/service/contents_service/club_air_edge/for_phone/homepage/index.html - * @since Class available since Release 0.5 - */ -class Net_UserAgent_Mobile_Willcom extends Net_UserAgent_Mobile_Common -{ - - // {{{ properties - - /**#@+ - * @access public - */ - - /** - * User-Agent name - * @var string - */ - var $name = 'WILLCOM'; - - /**#@-*/ - - /**#@+ - * @access private - */ - - /** - * vendor name - * @var string - */ - var $_vendor; - - /** - * version number of the model - * @var string - */ - var $_modelVersion; - - /** - * version number of the browser - * @var string - */ - var $_browserVersion; - - /** - * cache size as killobytes unit - * @var integer - */ - var $_cacheSize; - - /**#@-*/ - - /**#@+ - * @access public - */ - - // }}} - // {{{ isAirHPhone() - - /** - * returns true - * - * @return boolean - */ - function isAirHPhone() - { - return $this->isWillcom(); - } - - // }}} - // {{{ parse() - - /** - * Parses HTTP_USER_AGENT string. - * - * @param string $userAgent User-Agent string - */ - function parse($userAgent) - { - if (preg_match('!^Mozilla/3\.0\((?:DDIPOCKET|WILLCOM);(.*)\)!', - $userAgent, $matches) - ) { - list($this->_vendor, $this->_rawModel, $this->_modelVersion, - $this->_browserVersion, $cache) = - explode('/', $matches[1]); - if (!preg_match('/^[Cc](\d+)/', $cache, $matches)) { - return $this->noMatch(); - } - $this->_cacheSize = (integer)$matches[1]; - } else { - $this->noMatch(); - } - } - - // }}} - // {{{ makeDisplay() - - /** - * create a new {@link Net_UserAgent_Mobile_Display} class instance - * - * @return Net_UserAgent_Mobile_Display - */ - function makeDisplay() - { - return new Net_UserAgent_Mobile_Display(null); - } - - // }}} - // {{{ getVendor() - - /** - * returns vendor name - * - * @return string - */ - function getVendor() - { - return $this->_vendor; - } - - // }}} - // {{{ getModelVersion() - - /** - * returns version number of the model - * - * @return string - */ - function getModelVersion() - { - return $this->_modelVersion; - } - - // }}} - // {{{ getBrowserVersion() - - /** - * returns version number of the browser - * - * @return string - */ - function getBrowserVersion() - { - return $this->_browserVersion; - } - - // }}} - // {{{ getCacheSize() - - /** - * returns cache size as killobytes unit - * - * @return integer - */ - function getCacheSize() - { - return $this->_cacheSize; - } - - // }}} - // {{{ getCarrierShortName() - - /** - * returns the short name of the carrier - * - * @return string - */ - function getCarrierShortName() - { - return 'W'; - } - - // }}} - // {{{ getCarrierLongName() - - /** - * returns the long name of the carrier - * - * @return string - */ - function getCarrierLongName() - { - return 'WILLCOM'; - } - - // }}} - // {{{ isWillcom() - - /** - * Returns whether the agent is Willcom or not. - * - * @return boolean - * @since Method available since Release 0.31.0 - */ - function isWillcom() - { - return true; - } - - /**#@-*/ - - /**#@+ - * @access private - */ - - /**#@-*/ - - // }}} -} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: iso-8859-1 - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * indent-tabs-mode: nil - * End: - */ diff --git a/data/module/PEAR.php b/data/module/PEAR.php deleted file mode 100644 index b955a8ec082..00000000000 --- a/data/module/PEAR.php +++ /dev/null @@ -1,1072 +0,0 @@ - - * @author Stig Bakken - * @author Tomas V.V.Cox - * @author Greg Beaver - * @copyright 1997-2010 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: commit 01071ee7b71e4d38c4e96fdf0ae5e411841eaec7 - * @link http://pear.php.net/package/PEAR - * @since File available since Release 0.1 - */ - -/**#@+ - * ERROR constants - */ -define('PEAR_ERROR_RETURN', 1); -define('PEAR_ERROR_PRINT', 2); -define('PEAR_ERROR_TRIGGER', 4); -define('PEAR_ERROR_DIE', 8); -define('PEAR_ERROR_CALLBACK', 16); -/** - * WARNING: obsolete - * @deprecated - */ -define('PEAR_ERROR_EXCEPTION', 32); -/**#@-*/ -define('PEAR_ZE2', (function_exists('version_compare') && - version_compare(zend_version(), "2-dev", "ge"))); - -if (substr(PHP_OS, 0, 3) == 'WIN') { - define('OS_WINDOWS', true); - define('OS_UNIX', false); - define('PEAR_OS', 'Windows'); -} else { - define('OS_WINDOWS', false); - define('OS_UNIX', true); - define('PEAR_OS', 'Unix'); // blatant assumption -} - -$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; -$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; -$GLOBALS['_PEAR_destructor_object_list'] = array(); -$GLOBALS['_PEAR_shutdown_funcs'] = array(); -$GLOBALS['_PEAR_error_handler_stack'] = array(); - -@ini_set('track_errors', true); - -/** - * Base class for other PEAR classes. Provides rudimentary - * emulation of destructors. - * - * If you want a destructor in your class, inherit PEAR and make a - * destructor method called _yourclassname (same name as the - * constructor, but with a "_" prefix). Also, in your constructor you - * have to call the PEAR constructor: $this->PEAR();. - * The destructor method will be called without parameters. Note that - * at in some SAPI implementations (such as Apache), any output during - * the request shutdown (in which destructors are called) seems to be - * discarded. If you need to get any debug information from your - * destructor, use error_log(), syslog() or something similar. - * - * IMPORTANT! To use the emulated destructors you need to create the - * objects by reference: $obj =& new PEAR_child; - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Greg Beaver - * @copyright 1997-2006 The PHP Group - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PEAR - * @see PEAR_Error - * @since Class available since PHP 4.0.2 - * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear - */ -class PEAR -{ - /** - * Whether to enable internal debug messages. - * - * @var bool - * @access private - */ - var $_debug = false; - - /** - * Default error mode for this object. - * - * @var int - * @access private - */ - var $_default_error_mode = null; - - /** - * Default error options used for this object when error mode - * is PEAR_ERROR_TRIGGER. - * - * @var int - * @access private - */ - var $_default_error_options = null; - - /** - * Default error handler (callback) for this object, if error mode is - * PEAR_ERROR_CALLBACK. - * - * @var string - * @access private - */ - var $_default_error_handler = ''; - - /** - * Which class to use for error objects. - * - * @var string - * @access private - */ - var $_error_class = 'PEAR_Error'; - - /** - * An array of expected errors. - * - * @var array - * @access private - */ - var $_expected_errors = array(); - - /** - * Constructor. Registers this object in - * $_PEAR_destructor_object_list for destructor emulation if a - * destructor object exists. - * - * @param string $error_class (optional) which class to use for - * error objects, defaults to PEAR_Error. - * @access public - * @return void - */ - function PEAR($error_class = null) - { - $classname = strtolower(get_class($this)); - if ($this->_debug) { - print "PEAR constructor called, class=$classname\n"; - } - - if ($error_class !== null) { - $this->_error_class = $error_class; - } - - while ($classname && strcasecmp($classname, "pear")) { - $destructor = "_$classname"; - if (method_exists($this, $destructor)) { - global $_PEAR_destructor_object_list; - $_PEAR_destructor_object_list[] = &$this; - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - break; - } else { - $classname = get_parent_class($classname); - } - } - } - - /** - * Destructor (the emulated type of...). Does nothing right now, - * but is included for forward compatibility, so subclass - * destructors should always call it. - * - * See the note in the class desciption about output from - * destructors. - * - * @access public - * @return void - */ - function _PEAR() { - if ($this->_debug) { - printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); - } - } - - /** - * If you have a class that's mostly/entirely static, and you need static - * properties, you can use this method to simulate them. Eg. in your method(s) - * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); - * You MUST use a reference, or they will not persist! - * - * @access public - * @param string $class The calling classname, to prevent clashes - * @param string $var The variable to retrieve. - * @return mixed A reference to the variable. If not set it will be - * auto initialised to NULL. - */ - function &getStaticProperty($class, $var) - { - static $properties; - if (!isset($properties[$class])) { - $properties[$class] = array(); - } - - if (!array_key_exists($var, $properties[$class])) { - $properties[$class][$var] = null; - } - - return $properties[$class][$var]; - } - - /** - * Use this function to register a shutdown method for static - * classes. - * - * @access public - * @param mixed $func The function name (or array of class/method) to call - * @param mixed $args The arguments to pass to the function - * @return void - */ - function registerShutdownFunc($func, $args = array()) - { - // if we are called statically, there is a potential - // that no shutdown func is registered. Bug #6445 - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); - } - - /** - * Tell whether a value is a PEAR error. - * - * @param mixed $data the value to test - * @param int $code if $data is an error object, return true - * only if $code is a string and - * $obj->getMessage() == $code or - * $code is an integer and $obj->getCode() == $code - * @access public - * @return bool true if parameter is an error - */ - function isError($data, $code = null) - { - if (!is_object($data)) { - return false; - } - if (!is_a($data, 'PEAR_Error')) { - return false; - } - - if (is_null($code)) { - return true; - } elseif (is_string($code)) { - return $data->getMessage() == $code; - } - - return $data->getCode() == $code; - } - - /** - * Sets how errors generated by this object should be handled. - * Can be invoked both in objects and statically. If called - * statically, setErrorHandling sets the default behaviour for all - * PEAR objects. If called in an object, setErrorHandling sets - * the default behaviour for that object. - * - * @param int $mode - * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. - * - * @param mixed $options - * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one - * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * - * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected - * to be the callback function or method. A callback - * function is a string with the name of the function, a - * callback method is an array of two elements: the element - * at index 0 is the object, and the element at index 1 is - * the name of the method to call in the object. - * - * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is - * a printf format string used when printing the error - * message. - * - * @access public - * @return void - * @see PEAR_ERROR_RETURN - * @see PEAR_ERROR_PRINT - * @see PEAR_ERROR_TRIGGER - * @see PEAR_ERROR_DIE - * @see PEAR_ERROR_CALLBACK - * @see PEAR_ERROR_EXCEPTION - * - * @since PHP 4.0.5 - */ - function setErrorHandling($mode = null, $options = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $setmode = &$this->_default_error_mode; - $setoptions = &$this->_default_error_options; - } else { - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - } - - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - } - - /** - * This method is used to tell which errors you expect to get. - * Expected errors are always returned with error mode - * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, - * and this method pushes a new element onto it. The list of - * expected errors are in effect until they are popped off the - * stack with the popExpect() method. - * - * Note that this method can not be called statically - * - * @param mixed $code a single error code or an array of error codes to expect - * - * @return int the new depth of the "expected errors" stack - * @access public - */ - function expectError($code = '*') - { - if (is_array($code)) { - array_push($this->_expected_errors, $code); - } else { - array_push($this->_expected_errors, array($code)); - } - return count($this->_expected_errors); - } - - /** - * This method pops one element off the expected error codes - * stack. - * - * @return array the list of error codes that were popped - */ - function popExpect() - { - return array_pop($this->_expected_errors); - } - - /** - * This method checks unsets an error code if available - * - * @param mixed error code - * @return bool true if the error code was unset, false otherwise - * @access private - * @since PHP 4.3.0 - */ - function _checkDelExpect($error_code) - { - $deleted = false; - foreach ($this->_expected_errors as $key => $error_array) { - if (in_array($error_code, $error_array)) { - unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); - $deleted = true; - } - - // clean up empty arrays - if (0 == count($this->_expected_errors[$key])) { - unset($this->_expected_errors[$key]); - } - } - - return $deleted; - } - - /** - * This method deletes all occurences of the specified element from - * the expected error codes stack. - * - * @param mixed $error_code error code that should be deleted - * @return mixed list of error codes that were deleted or error - * @access public - * @since PHP 4.3.0 - */ - function delExpect($error_code) - { - $deleted = false; - if ((is_array($error_code) && (0 != count($error_code)))) { - // $error_code is a non-empty array here; we walk through it trying - // to unset all values - foreach ($error_code as $key => $error) { - $deleted = $this->_checkDelExpect($error) ? true : false; - } - - return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } elseif (!empty($error_code)) { - // $error_code comes alone, trying to unset it - if ($this->_checkDelExpect($error_code)) { - return true; - } - - return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } - - // $error_code is empty - return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME - } - - /** - * This method is a wrapper that returns an instance of the - * configured error class with this object's default error - * handling applied. If the $mode and $options parameters are not - * specified, the object's defaults are used. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. - * - * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter - * specifies the PHP-internal error level (one of - * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * If $mode is PEAR_ERROR_CALLBACK, this - * parameter specifies the callback function or - * method. In other error modes this parameter - * is ignored. - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @param string $error_class The returned error object will be - * instantiated from this class, if specified. - * - * @param bool $skipmsg If true, raiseError will only pass error codes, - * the error message parameter will be dropped. - * - * @access public - * @return object a PEAR error object - * @see PEAR::setErrorHandling - * @since PHP 4.0.5 - */ - function &raiseError($message = null, - $code = null, - $mode = null, - $options = null, - $userinfo = null, - $error_class = null, - $skipmsg = false) - { - // The error is yet a PEAR error object - if (is_object($message)) { - $code = $message->getCode(); - $userinfo = $message->getUserInfo(); - $error_class = $message->getType(); - $message->error_message_prefix = ''; - $message = $message->getMessage(); - - // Make sure right data gets passed. - $r = new ReflectionClass($error_class); - $c = $r->getConstructor(); - $p = array_shift($c->getParameters()); - $skipmsg = ($p->getName() != 'message'); - } - - if ( - isset($this) && - isset($this->_expected_errors) && - count($this->_expected_errors) > 0 && - count($exp = end($this->_expected_errors)) - ) { - if ($exp[0] == "*" || - (is_int(reset($exp)) && in_array($code, $exp)) || - (is_string(reset($exp)) && in_array($message, $exp)) - ) { - $mode = PEAR_ERROR_RETURN; - } - } - - // No mode given, try global ones - if ($mode === null) { - // Class error handler - if (isset($this) && isset($this->_default_error_mode)) { - $mode = $this->_default_error_mode; - $options = $this->_default_error_options; - // Global error handler - } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { - $mode = $GLOBALS['_PEAR_default_error_mode']; - $options = $GLOBALS['_PEAR_default_error_options']; - } - } - - if ($error_class !== null) { - $ec = $error_class; - } elseif (isset($this) && isset($this->_error_class)) { - $ec = $this->_error_class; - } else { - $ec = 'PEAR_Error'; - } - - if (intval(PHP_VERSION) < 5) { - // little non-eval hack to fix bug #12147 - include 'PEAR/FixPHP5PEARWarnings.php'; - return $a; - } - - if ($skipmsg) { - $a = new $ec($code, $mode, $options, $userinfo); - } else { - $a = new $ec($message, $code, $mode, $options, $userinfo); - } - - return $a; - } - - /** - * Simpler form of raiseError with fewer options. In most cases - * message, code and userinfo are enough. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @access public - * @return object a PEAR error object - * @see PEAR::raiseError - */ - function &throwError($message = null, $code = null, $userinfo = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $a = &$this->raiseError($message, $code, null, null, $userinfo); - return $a; - } - - $a = &PEAR::raiseError($message, $code, null, null, $userinfo); - return $a; - } - - function staticPushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - $stack[] = array($def_mode, $def_options); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $def_mode = $mode; - $def_options = $options; - break; - - case PEAR_ERROR_CALLBACK: - $def_mode = $mode; - // class/object method callback - if (is_callable($options)) { - $def_options = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - $stack[] = array($mode, $options); - return true; - } - - function staticPopErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - return true; - } - - /** - * Push a new error handler on top of the error handler options stack. With this - * you can easily override the actual error handler for some code and restore - * it later with popErrorHandling. - * - * @param mixed $mode (same as setErrorHandling) - * @param mixed $options (same as setErrorHandling) - * - * @return bool Always true - * - * @see PEAR::setErrorHandling - */ - function pushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - if (isset($this) && is_a($this, 'PEAR')) { - $def_mode = &$this->_default_error_mode; - $def_options = &$this->_default_error_options; - } else { - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - } - $stack[] = array($def_mode, $def_options); - - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - $stack[] = array($mode, $options); - return true; - } - - /** - * Pop the last error handler used - * - * @return bool Always true - * - * @see PEAR::pushErrorHandling - */ - function popErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - return true; - } - - /** - * OS independant PHP extension load. Remember to take care - * on the correct extension name for case sensitive OSes. - * - * @param string $ext The extension name - * @return bool Success or not on the dl() call - */ - function loadExtension($ext) - { - if (extension_loaded($ext)) { - return true; - } - - // if either returns true dl() will produce a FATAL error, stop that - if ( - function_exists('dl') === false || - ini_get('enable_dl') != 1 || - ini_get('safe_mode') == 1 - ) { - return false; - } - - if (OS_WINDOWS) { - $suffix = '.dll'; - } elseif (PHP_OS == 'HP-UX') { - $suffix = '.sl'; - } elseif (PHP_OS == 'AIX') { - $suffix = '.a'; - } elseif (PHP_OS == 'OSX') { - $suffix = '.bundle'; - } else { - $suffix = '.so'; - } - - return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); - } -} - -if (PEAR_ZE2) { - include_once 'PEAR5.php'; -} - -function _PEAR_call_destructors() -{ - global $_PEAR_destructor_object_list; - if (is_array($_PEAR_destructor_object_list) && - sizeof($_PEAR_destructor_object_list)) - { - reset($_PEAR_destructor_object_list); - if (PEAR_ZE2) { - $destructLifoExists = PEAR5::getStaticProperty('PEAR', 'destructlifo'); - } else { - $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo'); - } - - if ($destructLifoExists) { - $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); - } - - while (list($k, $objref) = each($_PEAR_destructor_object_list)) { - $classname = get_class($objref); - while ($classname) { - $destructor = "_$classname"; - if (method_exists($objref, $destructor)) { - $objref->$destructor(); - break; - } else { - $classname = get_parent_class($classname); - } - } - } - // Empty the object list to ensure that destructors are - // not called more than once. - $_PEAR_destructor_object_list = array(); - } - - // Now call the shutdown functions - if ( - isset($GLOBALS['_PEAR_shutdown_funcs']) && - is_array($GLOBALS['_PEAR_shutdown_funcs']) && - !empty($GLOBALS['_PEAR_shutdown_funcs']) - ) { - foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { - call_user_func_array($value[0], $value[1]); - } - } -} - -/** - * Standard PEAR error class for PHP 4 - * - * This class is supserseded by {@link PEAR_Exception} in PHP 5 - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Gregory Beaver - * @copyright 1997-2006 The PHP Group - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/manual/en/core.pear.pear-error.php - * @see PEAR::raiseError(), PEAR::throwError() - * @since Class available since PHP 4.0.2 - */ -class PEAR_Error -{ - var $error_message_prefix = ''; - var $mode = PEAR_ERROR_RETURN; - var $level = E_USER_NOTICE; - var $code = -1; - var $message = ''; - var $userinfo = ''; - var $backtrace = null; - - /** - * PEAR_Error constructor - * - * @param string $message message - * - * @param int $code (optional) error code - * - * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, - * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION - * - * @param mixed $options (optional) error level, _OR_ in the case of - * PEAR_ERROR_CALLBACK, the callback function or object/method - * tuple. - * - * @param string $userinfo (optional) additional user/debug info - * - * @access public - * - */ - function PEAR_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - if ($mode === null) { - $mode = PEAR_ERROR_RETURN; - } - $this->message = $message; - $this->code = $code; - $this->mode = $mode; - $this->userinfo = $userinfo; - - if (PEAR_ZE2) { - $skiptrace = PEAR5::getStaticProperty('PEAR_Error', 'skiptrace'); - } else { - $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace'); - } - - if (!$skiptrace) { - $this->backtrace = debug_backtrace(); - if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) { - unset($this->backtrace[0]['object']); - } - } - - if ($mode & PEAR_ERROR_CALLBACK) { - $this->level = E_USER_NOTICE; - $this->callback = $options; - } else { - if ($options === null) { - $options = E_USER_NOTICE; - } - - $this->level = $options; - $this->callback = null; - } - - if ($this->mode & PEAR_ERROR_PRINT) { - if (is_null($options) || is_int($options)) { - $format = "%s"; - } else { - $format = $options; - } - - printf($format, $this->getMessage()); - } - - if ($this->mode & PEAR_ERROR_TRIGGER) { - trigger_error($this->getMessage(), $this->level); - } - - if ($this->mode & PEAR_ERROR_DIE) { - $msg = $this->getMessage(); - if (is_null($options) || is_int($options)) { - $format = "%s"; - if (substr($msg, -1) != "\n") { - $msg .= "\n"; - } - } else { - $format = $options; - } - die(sprintf($format, $msg)); - } - - if ($this->mode & PEAR_ERROR_CALLBACK && is_callable($this->callback)) { - call_user_func($this->callback, $this); - } - - if ($this->mode & PEAR_ERROR_EXCEPTION) { - trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); - eval('$e = new Exception($this->message, $this->code);throw($e);'); - } - } - - /** - * Get the error mode from an error object. - * - * @return int error mode - * @access public - */ - function getMode() - { - return $this->mode; - } - - /** - * Get the callback function/method from an error object. - * - * @return mixed callback function or object/method array - * @access public - */ - function getCallback() - { - return $this->callback; - } - - /** - * Get the error message from an error object. - * - * @return string full error message - * @access public - */ - function getMessage() - { - return ($this->error_message_prefix . $this->message); - } - - /** - * Get error code from an error object - * - * @return int error code - * @access public - */ - function getCode() - { - return $this->code; - } - - /** - * Get the name of this error/exception. - * - * @return string error/exception name (type) - * @access public - */ - function getType() - { - return get_class($this); - } - - /** - * Get additional user-supplied information. - * - * @return string user-supplied information - * @access public - */ - function getUserInfo() - { - return $this->userinfo; - } - - /** - * Get additional debug information supplied by the application. - * - * @return string debug information - * @access public - */ - function getDebugInfo() - { - return $this->getUserInfo(); - } - - /** - * Get the call backtrace from where the error was generated. - * Supported with PHP 4.3.0 or newer. - * - * @param int $frame (optional) what frame to fetch - * @return array Backtrace, or NULL if not available. - * @access public - */ - function getBacktrace($frame = null) - { - if (defined('PEAR_IGNORE_BACKTRACE')) { - return null; - } - if ($frame === null) { - return $this->backtrace; - } - return $this->backtrace[$frame]; - } - - function addUserInfo($info) - { - if (empty($this->userinfo)) { - $this->userinfo = $info; - } else { - $this->userinfo .= " ** $info"; - } - } - - function __toString() - { - return $this->getMessage(); - } - - /** - * Make a string representation of this object. - * - * @return string a string with an object summary - * @access public - */ - function toString() - { - $modes = array(); - $levels = array(E_USER_NOTICE => 'notice', - E_USER_WARNING => 'warning', - E_USER_ERROR => 'error'); - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_array($this->callback)) { - $callback = (is_object($this->callback[0]) ? - strtolower(get_class($this->callback[0])) : - $this->callback[0]) . '::' . - $this->callback[1]; - } else { - $callback = $this->callback; - } - return sprintf('[%s: message="%s" code=%d mode=callback '. - 'callback=%s prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - $callback, $this->error_message_prefix, - $this->userinfo); - } - if ($this->mode & PEAR_ERROR_PRINT) { - $modes[] = 'print'; - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - $modes[] = 'trigger'; - } - if ($this->mode & PEAR_ERROR_DIE) { - $modes[] = 'die'; - } - if ($this->mode & PEAR_ERROR_RETURN) { - $modes[] = 'return'; - } - return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. - 'prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - implode("|", $modes), $levels[$this->level], - $this->error_message_prefix, - $this->userinfo); - } -} - -/* - * Local Variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/data/module/PEAR5.php b/data/module/PEAR5.php deleted file mode 100644 index 5cee090351f..00000000000 --- a/data/module/PEAR5.php +++ /dev/null @@ -1,33 +0,0 @@ - Original Author - * @author Shane Caraveo Port to PEAR and more - * @author Chuck Hagenbuch Maintenance - * @author Jan Schneider Maintenance - * @copyright 2003-2007 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** Define linebreak sequence for the Mail_Mime package. */ -define('MAIL_MIMEPART_CRLF', "\r\n"); - -require_once 'PEAR.php'; - -if (!defined('INF')) { - define('INF', 1.8e307); -} -if (!defined('NAN')) { - define('NAN', 0.0); -} - -define('SOAP_LIBRARY_VERSION', '@version@'); -define('SOAP_LIBRARY_NAME', 'PEAR-SOAP @version@-beta'); - -// Set schema version. -define('SOAP_XML_SCHEMA_VERSION', 'http://www.w3.org/2001/XMLSchema'); -define('SOAP_XML_SCHEMA_INSTANCE', 'http://www.w3.org/2001/XMLSchema-instance'); -define('SOAP_XML_SCHEMA_1999', 'http://www.w3.org/1999/XMLSchema'); -define('SOAP_SCHEMA', 'http://schemas.xmlsoap.org/wsdl/soap/'); -define('SOAP_SCHEMA_ENCODING', 'http://schemas.xmlsoap.org/soap/encoding/'); -define('SOAP_ENVELOP', 'http://schemas.xmlsoap.org/soap/envelope/'); - -define('SCHEMA_DISCO', 'http://schemas.xmlsoap.org/disco/'); -define('SCHEMA_DISCO_SCL', 'http://schemas.xmlsoap.org/disco/scl/'); - -define('SCHEMA_SOAP', 'http://schemas.xmlsoap.org/wsdl/soap/'); -define('SCHEMA_SOAP12', 'http://schemas.xmlsoap.org/wsdl/soap12/'); -define('SCHEMA_SOAP_HTTP', 'http://schemas.xmlsoap.org/soap/http'); -define('SCHEMA_WSDL_HTTP', 'http://schemas.xmlsoap.org/wsdl/http/'); -define('SCHEMA_MIME', 'http://schemas.xmlsoap.org/wsdl/mime/'); -define('SCHEMA_WSDL', 'http://schemas.xmlsoap.org/wsdl/'); -define('SCHEMA_DIME', 'http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/'); -define('SCHEMA_CONTENT', 'http://schemas.xmlsoap.org/ws/2002/04/content-type/'); -define('SCHEMA_REF', 'http://schemas.xmlsoap.org/ws/2002/04/reference/'); - -define('SOAP_DEFAULT_ENCODING', 'UTF-8'); - -/** - * @package SOAP - */ -class SOAP_Base_Object extends PEAR -{ - /** - * Supported encodings, limited by XML extension. - * - * @var array $_encodings - */ - var $_encodings = array('ISO-8859-1', 'US-ASCII', 'UTF-8'); - - /** - * Fault code. - * - * @var string $_myfaultcode - */ - var $_myfaultcode = ''; - - /** - * Recent PEAR_Error object. - * - * @var PEAR_Error $fault - */ - var $fault = null; - - /** - * Constructor. - * - * @param string $faultcode Error code. - */ - function SOAP_Base_Object($faultcode = 'Client') - { - $this->_myfaultcode = $faultcode; - parent::PEAR('SOAP_Fault'); - } - - /** - * Raises a SOAP error. - * - * Please refer to the SOAP definition for an impression of what a certain - * parameter stands for. - * - * @param string|object $str Error message or object. - * @param string $detail Detailed error message. - * @param string $actorURI - * @param mixed $code - * @param mixed $mode - * @param mixed $options - * @param boolean $skipmsg - */ - function &_raiseSoapFault($str, $detail = '', $actorURI = '', $code = null, - $mode = null, $options = null, $skipmsg = false) - { - // Pass through previous faults. - $is_instance = isset($this) && is_a($this, 'SOAP_Base_Object'); - if (is_object($str)) { - $fault = $str; - } else { - if (!$code) { - $code = $is_instance ? $this->_myfaultcode : 'Client'; - } - require_once 'SOAP/Fault.php'; - $fault = new SOAP_Fault($str, $code, $actorURI, $detail, $mode, - $options); - } - if ($is_instance) { - $this->fault = $fault; - } - - return $fault; - } - - function _isfault() - { - return $this->fault != null; - } - - function &_getfault() - { - return $this->fault; - } - -} - -/** - * Common base class of all SOAP classes. - * - * @access public - * @package SOAP - * @author Shane Caraveo Conversion to PEAR and updates - */ -class SOAP_Base extends SOAP_Base_Object -{ - var $_XMLSchema = array('http://www.w3.org/2001/XMLSchema', - 'http://www.w3.org/1999/XMLSchema'); - var $_XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; - - // load types into typemap array - var $_typemap = array( - 'http://www.w3.org/2001/XMLSchema' => array( - 'string' => 'string', - 'boolean' => 'boolean', - 'float' => 'float', - 'double' => 'float', - 'decimal' => 'float', - 'duration' => 'integer', - 'dateTime' => 'string', - 'time' => 'string', - 'date' => 'string', - 'gYearMonth' => 'integer', - 'gYear' => 'integer', - 'gMonthDay' => 'integer', - 'gDay' => 'integer', - 'gMonth' => 'integer', - 'hexBinary' => 'string', - 'base64Binary' => 'string', - // derived datatypes - 'normalizedString' => 'string', - 'token' => 'string', - 'language' => 'string', - 'NMTOKEN' => 'string', - 'NMTOKENS' => 'string', - 'Name' => 'string', - 'NCName' => 'string', - 'ID' => 'string', - 'IDREF' => 'string', - 'IDREFS' => 'string', - 'ENTITY' => 'string', - 'ENTITIES' => 'string', - 'integer' => 'integer', - 'nonPositiveInteger' => 'integer', - 'negativeInteger' => 'integer', - // longs (64bit ints) are not supported cross-platform. - 'long' => 'string', - 'int' => 'integer', - 'short' => 'integer', - 'byte' => 'string', - 'nonNegativeInteger' => 'integer', - 'unsignedLong' => 'integer', - 'unsignedInt' => 'integer', - 'unsignedShort' => 'integer', - 'unsignedByte' => 'integer', - 'positiveInteger' => 'integer', - 'anyType' => 'string', - 'anyURI' => 'string', - 'QName' => 'string' - ), - 'http://www.w3.org/1999/XMLSchema' => array( - 'i4' => 'integer', - 'int' => 'integer', - 'boolean' => 'boolean', - 'string' => 'string', - 'double' => 'float', - 'float' => 'float', - 'dateTime' => 'string', - 'timeInstant' => 'string', - 'base64Binary' => 'string', - 'base64' => 'string', - 'ur-type' => 'string' - ), - 'http://schemas.xmlsoap.org/soap/encoding/' => array( - 'base64' => 'string', - 'array' => 'array', - 'Array' => 'array', - 'Struct' => 'array') - ); - - /** - * Default class name to use for decoded response objects. - * - * @var string $_defaultObjectClassname - */ - var $_defaultObjectClassname = 'stdClass'; - - /** - * Hash with used namespaces. - * - * @var array - */ - var $_namespaces; - - /** - * The default namespace. - * - * @var string - */ - var $_namespace; - - var $_xmlEntities = array('&' => '&', - '<' => '<', - '>' => '>', - "'" => ''', - '"' => '"'); - - var $_doconversion = false; - - var $_attachments = array(); - - var $_wsdl = null; - - /** - * True if we use section 5 encoding, or false if this is literal. - * - * @var boolean $_section5 - */ - var $_section5 = true; - - // Handle type to class mapping. - var $_auto_translation = false; - var $_type_translation = array(); - - /** - * Constructor. - * - * @param string $faultcode Error code. - */ - function SOAP_Base($faultcode = 'Client') - { - parent::SOAP_Base_Object($faultcode); - $this->_resetNamespaces(); - } - - /** - * Sets the SOAP-ENV prefix and returns the current value. - * - * @access public - * - * @param string SOAP-ENV prefix - * - * @return string current SOAP-ENV prefix. - */ - function SOAPENVPrefix($prefix = null) - { - static $_soapenv_prefix = 'SOAP-ENV'; - if (!is_null($prefix)) { - $_soapenv_prefix = $prefix; - } - return $_soapenv_prefix; - } - - /** - * Sets the SOAP-ENC prefix and returns the current value. - * - * @access public - * - * @param string SOAP-ENC prefix - * - * @return string current SOAP-ENC prefix. - */ - function SOAPENCPrefix($prefix = null) - { - static $_soapenv_prefix = 'SOAP-ENC'; - if (!is_null($prefix)) { - $_soapenv_prefix = $prefix; - } - return $_soapenv_prefix; - } - - /** - * Sets the default namespace. - * - * @param string $namespace The default namespace. - */ - function setDefaultNamespace($namespace) - { - $this->_namespace = $namespace; - } - - function _resetNamespaces() - { - $this->_namespaces = array( - 'http://schemas.xmlsoap.org/soap/envelope/' => SOAP_BASE::SOAPENVPrefix(), - 'http://www.w3.org/2001/XMLSchema' => 'xsd', - 'http://www.w3.org/2001/XMLSchema-instance' => 'xsi', - 'http://schemas.xmlsoap.org/soap/encoding/' => SOAP_BASE::SOAPENCPrefix()); - } - - /** - * Sets the schema version used in the SOAP message. - * - * @access private - * @see $_XMLSchema - * - * @param string $schemaVersion The schema version. - */ - function _setSchemaVersion($schemaVersion) - { - if (!in_array($schemaVersion, $this->_XMLSchema)) { - return $this->_raiseSoapFault("unsuported XMLSchema $schemaVersion"); - } - $this->_XMLSchemaVersion = $schemaVersion; - $tmpNS = array_flip($this->_namespaces); - $tmpNS['xsd'] = $this->_XMLSchemaVersion; - $tmpNS['xsi'] = $this->_XMLSchemaVersion . '-instance'; - $this->_namespaces = array_flip($tmpNS); - } - - function _getNamespacePrefix($ns) - { - if ($this->_namespace && $ns == $this->_namespace) { - return ''; - } - if (isset($this->_namespaces[$ns])) { - return $this->_namespaces[$ns]; - } - $prefix = 'ns' . count($this->_namespaces); - $this->_namespaces[$ns] = $prefix; - return $prefix; - } - - function _getNamespaceForPrefix($prefix) - { - $flipped = array_flip($this->_namespaces); - if (isset($flipped[$prefix])) { - return $flipped[$prefix]; - } - return null; - } - - /** - * Serializes a value, array or object according to the rules set by this - * object. - * - * @see SOAP_Value - * - * @param mixed $value The actual value. - * @param QName $name The value name. - * @param QName $type The value type. - * @param array $options A list of encoding and serialization options. - * @param array $attributes A hash of additional attributes. - * @param string $artype The type of any array elements. - */ - function _serializeValue($value, $name = null, $type = null, - $options = array(), $attributes = array(), - $artype = '') - { - $namespaces = array(); - $arrayType = $array_depth = $xmlout_value = null; - $typePrefix = $elPrefix = $xmlout_arrayType = ''; - $xmlout_type = $xmlns = $ptype = $array_type_ns = ''; - - if (!$name->name || is_numeric($name->name)) { - $name->name = 'item'; - } - - if ($this->_wsdl) { - list($ptype, $arrayType, $array_type_ns, $array_depth) - = $this->_wsdl->getSchemaType($type, $name); - } - - if (!$arrayType) { - $arrayType = $artype; - } - if (!$ptype) { - $ptype = $this->_getType($value); - } - if (!$type) { - $type = new QName($ptype); - } - - if (strcasecmp($ptype, 'Struct') == 0 || - strcasecmp($type->name, 'Struct') == 0) { - // Struct - $vars = is_object($value) ? get_object_vars($value) : $value; - if (is_array($vars)) { - foreach (array_keys($vars) as $k) { - // Hide private vars. - if ($k[0] == '_') { - continue; - } - - if (is_object($vars[$k])) { - if (is_a($vars[$k], 'SOAP_Value')) { - $xmlout_value .= $vars[$k]->serialize($this); - } else { - // XXX get the members and serialize them instead - // converting to an array is more overhead than we - // should really do. - $xmlout_value .= $this->_serializeValue(get_object_vars($vars[$k]), new QName($k, $this->_section5 ? null : $name->namepace), null, $options); - } - } else { - $xmlout_value .= $this->_serializeValue($vars[$k], new QName($k, $this->_section5 ? null : $name->namespace), false, $options); - } - } - } - } elseif (strcasecmp($ptype, 'Array') == 0 || - strcasecmp($type->name, 'Array') == 0) { - // Array. - $type = new QName('Array', SOAP_SCHEMA_ENCODING); - $numtypes = 0; - $value = (array)$value; - // XXX this will be slow on larger arrays. Basically, it flattens - // arrays to allow us to serialize multi-dimensional arrays. We - // only do this if arrayType is set, which will typically only - // happen if we are using WSDL - if (isset($options['flatten']) || - ($arrayType && - (strchr($arrayType, ',') || strstr($arrayType, '][')))) { - $numtypes = $this->_multiArrayType($value, $arrayType, - $ar_size, $xmlout_value); - } - - $array_type = $array_type_prefix = ''; - if ($numtypes != 1) { - $arrayTypeQName = new QName($arrayType); - $arrayType = $arrayTypeQName->name; - $array_types = array(); - $array_val = null; - - // Serialize each array element. - $ar_size = count($value); - foreach ($value as $array_val) { - if (is_a($array_val, 'SOAP_Value')) { - $array_type = $array_val->type; - $array_types[$array_type] = 1; - $array_type_ns = $array_val->type_namespace; - $xmlout_value .= $array_val->serialize($this); - } else { - $array_type = $this->_getType($array_val); - $array_types[$array_type] = 1; - if (empty($options['keep_arrays_flat'])) { - $xmlout_value .= $this->_serializeValue($array_val, new QName('item', $this->_section5 ? null : $name->namespace), new QName($array_type), $options); - } else { - $xmlout_value .= $this->_serializeValue($array_val, $name, new QName($array_type), $options, $attributes); - } - } - } - - if (!$arrayType) { - $numtypes = count($array_types); - if ($numtypes == 1) { - $arrayType = $array_type; - } - // Using anyType is more interoperable. - if ($array_type == 'Struct') { - $array_type = ''; - } elseif ($array_type == 'Array') { - $arrayType = 'anyType'; - $array_type_prefix = 'xsd'; - } else { - if (!$arrayType) { - $arrayType = $array_type; - } - } - } - } - if (!$arrayType || $numtypes > 1) { - // Should reference what schema we're using. - $arrayType = 'xsd:anyType'; - } else { - if ($array_type_ns) { - $array_type_prefix = $this->_getNamespacePrefix($array_type_ns); - } elseif (isset($this->_typemap[$this->_XMLSchemaVersion][$arrayType])) { - $array_type_prefix = $this->_namespaces[$this->_XMLSchemaVersion]; - } elseif (isset($this->_typemap[SOAP_SCHEMA_ENCODING][$arrayType])) { - $array_type_prefix = SOAP_BASE::SOAPENCPrefix(); - } - if ($array_type_prefix) { - $arrayType = $array_type_prefix . ':' . $arrayType; - } - } - - $xmlout_arrayType = ' ' . SOAP_BASE::SOAPENCPrefix() - . ':arrayType="' . $arrayType; - if ($array_depth != null) { - for ($i = 0; $i < $array_depth; $i++) { - $xmlout_arrayType .= '[]'; - } - } - $xmlout_arrayType .= "[$ar_size]\""; - } elseif (is_a($value, 'SOAP_Value')) { - $xmlout_value = $value->serialize($this); - } elseif ($type->name == 'string') { - $xmlout_value = htmlspecialchars($value); - } elseif ($type->name == 'rawstring') { - $xmlout_value = $value; - } elseif ($type->name == 'boolean') { - $xmlout_value = $value ? 'true' : 'false'; - } else { - $xmlout_value = $value; - } - - // Add namespaces. - if ($name->namespace) { - $elPrefix = $this->_getNamespacePrefix($name->namespace); - if ($elPrefix) { - $xmlout_name = $elPrefix . ':' . $name->name; - } else { - $xmlout_name = $name->name; - } - } else { - $xmlout_name = $name->name; - } - - if ($type->namespace) { - $typePrefix = false; - if (empty($options['no_type_prefix'])) { - $typePrefix = $this->_getNamespacePrefix($type->namespace); - } - if ($typePrefix) { - $xmlout_type = $typePrefix . ':' . $type->name; - } else { - $xmlout_type = $type->name; - } - } elseif ($type->name && - isset($this->_typemap[$this->_XMLSchemaVersion][$type->name])) { - $typePrefix = $this->_namespaces[$this->_XMLSchemaVersion]; - if ($typePrefix) { - $xmlout_type = $typePrefix . ':' . $type->name; - } else { - $xmlout_type = $type->name; - } - } - - // Handle additional attributes. - $xml_attr = ''; - if (count($attributes)) { - foreach ($attributes as $k => $v) { - $kqn = new QName($k); - $vqn = new QName($v); - $xml_attr .= ' ' . $kqn->fqn() . '="' . $vqn->fqn() . '"'; - } - } - - // Store the attachment for mime encoding. - if (isset($options['attachment']) && - !PEAR::isError($options['attachment'])) { - $this->_attachments[] = $options['attachment']; - } - - if ($this->_section5) { - if ($xmlout_type) { - $xmlout_type = " xsi:type=\"$xmlout_type\""; - } - if (is_null($xmlout_value)) { - $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType" . - "$xml_attr xsi:nil=\"true\"/>"; - } else { - $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType" . - "$xml_attr>$xmlout_value"; - } - } elseif ($type->name == 'Array' && !empty($options['keep_arrays_flat'])) { - $xml = $xmlout_value; - } else { - if (is_null($xmlout_value)) { - $xml = "\r\n<$xmlout_name$xmlns$xml_attr/>"; - } else { - $xml = "\r\n<$xmlout_name$xmlns$xml_attr>" . - $xmlout_value . ""; - } - } - - return $xml; - } - - /** - * Converts a PHP type to a SOAP type. - * - * @param mixed $value The value to inspect. - * - * @return string The value's SOAP type. - */ - function _getType($value) - { - $type = gettype($value); - switch ($type) { - case 'object': - if (is_a($value, 'soap_value')) { - $type = $value->type; - } else { - $type = 'Struct'; - } - break; - - case 'array': - // Hashes are always handled as structs. - if ($this->_isHash($value)) { - $type = 'Struct'; - break; - } - if (count($value) > 1) { - // For non-wsdl structs that are all the same type - reset($value); - $value1 = next($value); - $value2 = next($value); - if (is_a($value1, 'SOAP_Value') && - is_a($value2, 'SOAP_Value') && - $value1->name != $value2->name) { - // This is a struct, not an array. - $type = 'Struct'; - break; - } - } - $type = 'Array'; - break; - - case 'integer': - case 'long': - $type = 'int'; - break; - - case 'boolean': - break; - - case 'double': - // double is deprecated in PHP 4.2 and later. - $type = 'float'; - break; - - case 'null': - $type = ''; - break; - - case 'string': - default: - break; - } - - return $type; - } - - function _multiArrayType($value, &$type, &$size, &$xml) - { - if (is_array($value)) { - // Seems we have a multi dimensional array, figure it out if we - // do. - for ($i = 0, $c = count($value); $i < $c; ++$i) { - $this->_multiArrayType($value[$i], $type, $size, $xml); - } - - $sz = count($value); - if ($size) { - $size = $sz . ',' . $size; - } else { - $size = $sz; - } - return 1; - } elseif (is_object($value)) { - $type = $value->type; - $xml .= $value->serialize($this); - } else { - $type = $this->_getType($value); - $xml .= $this->_serializeValue($value, new QName('item'), new QName($type)); - } - $size = null; - - return 1; - } - - /** - * Returns whether a type is a base64 type. - * - * @param string $type A type name. - * - * @return boolean True if the type name is a base64 type. - */ - function _isBase64Type($type) - { - return $type == 'base64' || $type == 'base64Binary'; - } - - /** - * Returns whether an array is a hash. - * - * @param array $a An array to check. - * - * @return boolean True if the specified array is a hash. - */ - function _isHash($a) - { - foreach (array_keys($a) as $k) { - // Checking the type is faster than regexp. - if (!is_int($k)) { - return true; - } - } - return false; - } - - function _un_htmlentities($string) - { - $trans_tbl = get_html_translation_table(HTML_ENTITIES); - $trans_tbl = array_flip($trans_tbl); - return strtr($string, $trans_tbl); - } - - /** - * Converts a SOAP_Value object into a PHP value. - */ - function _decode($soapval) - { - if (!is_a($soapval, 'SOAP_Value')) { - return $soapval; - } - - if (is_array($soapval->value)) { - $isstruct = $soapval->type != 'Array'; - if ($isstruct) { - $classname = $this->_defaultObjectClassname; - if (isset($this->_type_translation[$soapval->tqn->fqn()])) { - // This will force an error in PHP if the class does not - // exist. - $classname = $this->_type_translation[$soapval->tqn->fqn()]; - } elseif (isset($this->_type_translation[$soapval->type])) { - // This will force an error in PHP if the class does not - // exist. - $classname = $this->_type_translation[$soapval->type]; - } elseif ($this->_auto_translation) { - if (class_exists($soapval->type)) { - $classname = $soapval->type; - } elseif ($this->_wsdl) { - $t = $this->_wsdl->getComplexTypeNameForElement($soapval->name, $soapval->namespace); - if ($t && class_exists($t)) { - $classname = $t; - } - } - } - $return = new $classname; - } else { - $return = array(); - } - - foreach ($soapval->value as $item) { - if ($isstruct) { - if ($this->_wsdl) { - // Get this child's WSDL information. - // /$soapval->prefix/$soapval->type/$item->prefix/$item->name - $child_type = $this->_wsdl->getComplexTypeChildType( - $soapval->namespace, - $soapval->name, - $item->namespace, - $item->name); - if ($child_type) { - $item->type = $child_type; - } - } - if ($item->type == 'Array') { - if (isset($return->{$item->name}) && - is_object($return->{$item->name})) { - $return->{$item->name} = $this->_decode($item); - } elseif (isset($return->{$item->name}) && - is_array($return->{$item->name})) { - $return->{$item->name}[] = $this->_decode($item); - } elseif (isset($return->{$item->name})) { - $return->{$item->name} = array( - $return->{$item->name}, - $this->_decode($item) - ); - } elseif (is_array($return)) { - $return[] = $this->_decode($item); - } else { - $return->{$item->name} = $this->_decode($item); - } - } elseif (isset($return->{$item->name})) { - $d = $this->_decode($item); - if (count(get_object_vars($return)) == 1) { - $isstruct = false; - $return = array($return->{$item->name}, $d); - } else { - if (is_array($return->{$item->name})) { - $return->{$item->name} = array_merge($return->{$item->name}, array($d)); - } else { - $return->{$item->name} = array($return->{$item->name}, $d); - } - } - } else { - $return->{$item->name} = $this->_decode($item); - } - // Set the attributes as members in the class. - if (method_exists($return, '__set_attribute')) { - foreach ($soapval->attributes as $key => $value) { - call_user_func_array(array(&$return, - '__set_attribute'), - array($key, $value)); - } - } - } else { - if ($soapval->arrayType && is_a($item, 'SOAP_Value')) { - if ($this->_isBase64Type($item->type) && - !$this->_isBase64Type($soapval->arrayType)) { - // Decode the value if we're losing the base64 - // type information. - $item->value = base64_decode($item->value); - } - $item->type = $soapval->arrayType; - } - $return[] = $this->_decode($item); - } - } - - return $return; - } - - if ($soapval->type == 'boolean') { - if ($soapval->value != '0' && - strcasecmp($soapval->value, 'false') != 0) { - $soapval->value = true; - } else { - $soapval->value = false; - } - } elseif ($soapval->type && - isset($this->_typemap[SOAP_XML_SCHEMA_VERSION][$soapval->type])) { - // If we can, set variable type. - settype($soapval->value, - $this->_typemap[SOAP_XML_SCHEMA_VERSION][$soapval->type]); - } elseif ($soapval->type == 'Struct') { - $soapval->value = null; - } - - return $soapval->value; - } - - /** - * Creates the SOAP envelope with the SOAP envelop data. - * - * @param SOAP_Value $method SOAP_Value instance with the method name as - * the name, and the method arguments as the - * value. - * @param array $headers A list of additional SOAP_Header objects. - * @param string $encoding The charset of the SOAP message. - * @param array $options A list of encoding/serialization options. - * - * @return string The complete SOAP message. - */ - function makeEnvelope($method, $headers, $encoding = SOAP_DEFAULT_ENCODING, - $options = array()) - { - $smsg = $header_xml = $ns_string = ''; - - if ($headers) { - for ($i = 0, $c = count($headers); $i < $c; $i++) { - $header_xml .= $headers[$i]->serialize($this); - } - $header_xml = sprintf("<%s:Header>\r\n%s\r\n\r\n", - SOAP_BASE::SOAPENVPrefix(), $header_xml, - SOAP_BASE::SOAPENVPrefix()); - } - - if (!isset($options['input']) || $options['input'] == 'parse') { - if (is_array($method)) { - for ($i = 0, $c = count($method); $i < $c; $i++) { - $smsg .= $method[$i]->serialize($this); - } - } else { - $smsg = $method->serialize($this); - } - } else { - $smsg = $method; - } - $body = sprintf("<%s:Body>%s\r\n\r\n", - SOAP_BASE::SOAPENVPrefix(), $smsg, - SOAP_BASE::SOAPENVPrefix()); - - foreach ($this->_namespaces as $k => $v) { - $ns_string .= "\r\n " . sprintf('xmlns:%s="%s"', $v, $k); - } - if ($this->_namespace) { - $ns_string .= "\r\n " . sprintf('xmlns="%s"', $this->_namespace); - } - - /* If 'use' == 'literal', do not put in the encodingStyle. This is - * denoted by $this->_section5 being false. 'use' can be defined at a - * more granular level than we are dealing with here, so this does not - * work for all services. */ - $xml = sprintf('%s<%s:Envelope%s', - $encoding, "\r\n", SOAP_BASE::SOAPENVPrefix(), - $ns_string); - if ($this->_section5) { - $xml .= "\r\n " . sprintf('%s:encodingStyle="%s"', - SOAP_BASE::SOAPENVPrefix(), - SOAP_SCHEMA_ENCODING); - } - $xml .= sprintf('>%s%s%s' . "\r\n", - "\r\n", $header_xml, $body, SOAP_BASE::SOAPENVPrefix()); - - return $xml; - } - - function _makeMimeMessage($xml, $encoding = SOAP_DEFAULT_ENCODING) - { - if (!@include_once 'Mail/mimePart.php') { - return $this->_raiseSoapFault('MIME messages are unsupported, the Mail_Mime package is not installed'); - } - - // Encode any attachments. See http://www.w3.org/TR/SOAP-attachments - // Now we have to mime encode the message. - $params = array('content_type' => 'multipart/related; type="text/xml"'); - $msg = new Mail_mimePart('', $params); - - // Add the xml part. - $params['content_type'] = 'text/xml'; - $params['charset'] = $encoding; - $msg->addSubPart($xml, $params); - - // Add the attachements - for ($i = 0, $c = count($this->_attachments); $i < $c; ++$i) { - $msg->addSubPart($this->_attachments[$i]['body'], - $this->_attachments[$i]); - } - - return $msg->encode(); - } - - // TODO: this needs to be used from the Transport system. - function _makeDIMEMessage($xml) - { - if (!@include_once 'Net/DIME.php') { - return $this->_raiseSoapFault('DIME messages are unsupported, the Net_DIME package is not installed'); - } - - // Encode any attachments. See - // http://search.ietf.org/internet-drafts/draft-nielsen-dime-soap-00.txt - // Now we have to DIME encode the message - $dime = new Net_DIME_Message(); - $msg = $dime->encodeData($xml, SOAP_ENVELOP, null, NET_DIME_TYPE_URI); - - // Add the attachments. - $c = count($this->_attachments); - for ($i = 0; $i < $c; $i++) { - $msg .= $dime->encodeData($this->_attachments[$i]['body'], - $this->_attachments[$i]['content_type'], - $this->_attachments[$i]['cid'], - NET_DIME_TYPE_MEDIA); - } - $msg .= $dime->endMessage(); - - return $msg; - } - - function _decodeMimeMessage(&$data, &$headers, &$attachments) - { - if (!@include_once 'Mail/mimeDecode.php') { - return $this->_raiseSoapFault('MIME messages are unsupported, the Mail_Mime package is not installed'); - } - - $params['include_bodies'] = true; - $params['decode_bodies'] = true; - $params['decode_headers'] = true; - - // Lame thing to have to do for decoding. - $decoder = new Mail_mimeDecode($data); - $structure = $decoder->decode($params); - - if (isset($structure->body)) { - $data = $structure->body; - $headers = $structure->headers; - unset($headers['']); - return; - } elseif (isset($structure->parts)) { - $data = $structure->parts[0]->body; - $headers = array_merge($structure->headers, - $structure->parts[0]->headers); - unset($headers['']); - if (count($structure->parts) <= 1) { - return; - } - - $mime_parts = array_splice($structure->parts, 1); - // Prepare the parts for the SOAP parser. - for ($i = 0, $c = count($mime_parts); $i < $c; $i++) { - $p = $mime_parts[$i]; - if (isset($p->headers['content-location'])) { - // TODO: modify location per SwA note section 3 - // http://www.w3.org/TR/SOAP-attachments - $attachments[$p->headers['content-location']] = $p->body; - } else { - $cid = 'cid:' . substr($p->headers['content-id'], 1, -1); - $attachments[$cid] = $p->body; - } - } - - return; - } - - $this->_raiseSoapFault('Mime parsing error', '', '', 'Server'); - } - - function _decodeDIMEMessage(&$data, &$headers, &$attachments) - { - if (!@include_once 'Net/DIME.php') { - return $this->_raiseSoapFault('DIME messages are unsupported, the Net_DIME package is not installed'); - } - - // This SHOULD be moved to the transport layer, e.g. PHP itself should - // handle parsing DIME ;) - $dime = new Net_DIME_Message(); - $err = $dime->decodeData($data); - if (PEAR::isError($err)) { - $this->_raiseSoapFault('Failed to decode the DIME message!', '', '', 'Server'); - return; - } - if (strcasecmp($dime->parts[0]['type'], SOAP_ENVELOP) != 0) { - $this->_raiseSoapFault('DIME record 1 is not a SOAP envelop!', '', '', 'Server'); - return; - } - - $data = $dime->parts[0]['data']; - // Fake it for now. - $headers['content-type'] = 'text/xml'; - $c = count($dime->parts); - for ($i = 0; $i < $c; $i++) { - $part =& $dime->parts[$i]; - // We need to handle URI's better. - $id = strncmp($part['id'], 'cid:', 4) - ? 'cid:' . $part['id'] - : $part['id']; - $attachments[$id] = $part['data']; - } - } - - /** - * Explicitly sets the translation for a specific class. - * - * Auto translation works for all cases, but opens ANY class in the script - * to be used as a data type, and may not be desireable. - * - * @param string $type A SOAP type. - * @param string $class A PHP class name. - */ - function setTypeTranslation($type, $class = null) - { - $tq = new QName($type); - if (!$class) { - $class = $tq->name; - } - $this->_type_translation[$type]=$class; - } - -} - -/** - * Class used to handle QNAME values in XML. - * - * @package SOAP - * @author Shane Caraveo Conversion to PEAR and updates - */ -class QName -{ - var $name = ''; - var $prefix = ''; - var $namespace = ''; - - function QName($name, $namespace = '') - { - if ($name && $name[0] == '{') { - preg_match('/\{(.*?)\}(.*)/', $name, $m); - $this->name = $m[2]; - $this->namespace = $m[1]; - } elseif (substr_count($name, ':') == 1) { - $s = explode(':', $name); - $this->prefix = $s[0]; - $this->name = $s[1]; - $this->namespace = $namespace; - } else { - $this->name = $name; - $this->namespace = $namespace; - } - - // A little more magic than should be in a qname. - $p = strpos($this->name, '['); - if ($p) { - // TODO: Need to re-examine this logic later. - // Chop off []. - $this->arraySize = explode(',', substr($this->name, $p + 1, -$p - 2)); - $this->arrayInfo = substr($this->name, $p); - $this->name = substr($this->name, 0, $p); - } - } - - function fqn() - { - if ($this->namespace) { - return '{' . $this->namespace . '}' . $this->name; - } elseif ($this->prefix) { - return $this->prefix . ':' . $this->name; - } - return $this->name; - } - -} diff --git a/data/module/SOAP/Client.php b/data/module/SOAP/Client.php deleted file mode 100644 index 3f621283e65..00000000000 --- a/data/module/SOAP/Client.php +++ /dev/null @@ -1,837 +0,0 @@ - Original Author - * @author Shane Caraveo Port to PEAR and more - * @author Chuck Hagenbuch Maintenance - * @author Jan Schneider Maintenance - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** SOAP_Value */ -require_once 'SOAP/Value.php'; -require_once 'SOAP/Base.php'; -require_once 'SOAP/Transport.php'; -require_once 'SOAP/WSDL.php'; -require_once 'SOAP/Fault.php'; -require_once 'SOAP/Parser.php'; - -// Arnaud: the following code was taken from DataObject and adapted to suit - -// this will be horrifically slow!!!! -// NOTE: Overload SEGFAULTS ON PHP4 + Zend Optimizer -// these two are BC/FC handlers for call in PHP4/5 - -/** - * @package SOAP - */ -if (!class_exists('SOAP_Client_Overload')) { - if (substr(zend_version(), 0, 1) > 1) { - class SOAP_Client_Overload extends SOAP_Base { - function __call($method, $args) - { - $return = null; - $this->_call($method, $args, $return); - return $return; - } - } - } else { - if (!function_exists('clone')) { - eval('function clone($t) { return $t; }'); - } - eval(' - class SOAP_Client_Overload extends SOAP_Base { - function __call($method, $args, &$return) - { - return $this->_call($method, $args, $return); - } - }'); - } -} - -/** - * SOAP Client Class - * - * This class is the main interface for making soap requests. - * - * basic usage: - * $soapclient = new SOAP_Client( string path [ , boolean wsdl] ); - * echo $soapclient->call( string methodname [ , array parameters] ); - * - * or, if using PHP 5+ or the overload extension: - * $soapclient = new SOAP_Client( string path [ , boolean wsdl] ); - * echo $soapclient->methodname( [ array parameters] ); - * - * - * Originally based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @access public - * @package SOAP - * @author Shane Caraveo Conversion to PEAR and updates - * @author Stig Bakken Conversion to PEAR - * @author Dietrich Ayala Original Author - */ -class SOAP_Client extends SOAP_Client_Overload -{ - /** - * Communication endpoint. - * - * Currently the following transport formats are supported: - * - HTTP - * - SMTP - * - * Example endpoints: - * http://www.example.com/soap/server.php - * https://www.example.com/soap/server.php - * mailto:soap@example.com - * - * @see SOAP_Client() - * @var string - */ - var $_endpoint = ''; - - /** - * The SOAP PORT name that is used by the client. - * - * @var string - */ - var $_portName = ''; - - /** - * Endpoint type e.g. 'wdsl'. - * - * @var string - */ - var $_endpointType = ''; - - /** - * The received xml. - * - * @var string - */ - var $xml; - - /** - * The outgoing and incoming data stream for debugging. - * - * @var string - */ - var $wire; - - /** - * The outgoing data stream for debugging. - * - * @var string - */ - var $_last_request = null; - - /** - * The incoming data stream for debugging. - * - * @var string - */ - var $_last_response = null; - - /** - * Options. - * - * @var array - */ - var $_options = array('trace' => false); - - /** - * The character encoding used for XML parser, etc. - * - * @var string - */ - var $_encoding = SOAP_DEFAULT_ENCODING; - - /** - * The array of SOAP_Headers that we are sending. - * - * @var array - */ - var $headersOut = null; - - /** - * The headers we recieved back in the response. - * - * @var array - */ - var $headersIn = null; - - /** - * Options for the HTTP_Request class (see HTTP/Request.php). - * - * @var array - */ - var $_proxy_params = array(); - - /** - * The SOAP_Transport instance. - * - * @var SOAP_Transport - */ - var $_soap_transport = null; - - /** - * Constructor. - * - * @access public - * - * @param string $endpoint An URL. - * @param boolean $wsdl Whether the endpoint is a WSDL file. - * @param string $portName The service's port name to use. - * @param array $proxy_params Options for the HTTP_Request class - * @see HTTP_Request - * @param boolean|string $cache Use WSDL caching? The cache directory if - * a string. - */ - function SOAP_Client($endpoint, $wsdl = false, $portName = false, - $proxy_params = array(), $cache = false) - { - parent::SOAP_Base('Client'); - - $this->_endpoint = $endpoint; - $this->_portName = $portName; - $this->_proxy_params = $proxy_params; - - // This hack should perhaps be removed as it might cause unexpected - // behaviour. - $wsdl = $wsdl - ? $wsdl - : strtolower(substr($endpoint, -4)) == 'wsdl'; - - // make values - if ($wsdl) { - $this->_endpointType = 'wsdl'; - // instantiate wsdl class - $this->_wsdl = new SOAP_WSDL($this->_endpoint, - $this->_proxy_params, - $cache); - if ($this->_wsdl->fault) { - $this->_raiseSoapFault($this->_wsdl->fault); - } - } - } - - function _reset() - { - $this->xml = null; - $this->wire = null; - $this->_last_request = null; - $this->_last_response = null; - $this->headersIn = null; - $this->headersOut = null; - } - - /** - * Sets the character encoding. - * - * Limited to 'UTF-8', 'US_ASCII' and 'ISO-8859-1'. - * - * @access public - * - * @param string encoding - * - * @return mixed SOAP_Fault on error. - */ - function setEncoding($encoding) - { - if (in_array($encoding, $this->_encodings)) { - $this->_encoding = $encoding; - return; - } - return $this->_raiseSoapFault('Invalid Encoding'); - } - - /** - * Adds a header to the envelope. - * - * @access public - * - * @param SOAP_Header $soap_value A SOAP_Header or an array with the - * elements 'name', 'namespace', - * 'mustunderstand', and 'actor' to send - * as a header. - */ - function addHeader($soap_value) - { - // Add a new header to the message. - if (is_a($soap_value, 'SOAP_Header')) { - $this->headersOut[] = $soap_value; - } elseif (is_array($soap_value)) { - // name, value, namespace, mustunderstand, actor - $this->headersOut[] = new SOAP_Header($soap_value[0], - null, - $soap_value[1], - $soap_value[2], - $soap_value[3]); - } else { - $this->_raiseSoapFault('Invalid parameter provided to addHeader(). Must be an array or a SOAP_Header.'); - } - } - - /** - * Calls a method on the SOAP endpoint. - * - * The namespace parameter is overloaded to accept an array of options - * that can contain data necessary for various transports if it is used as - * an array, it MAY contain a namespace value and a soapaction value. If - * it is overloaded, the soapaction parameter is ignored and MUST be - * placed in the options array. This is done to provide backwards - * compatibility with current clients, but may be removed in the future. - * The currently supported values are: - * - 'namespace' - * - 'soapaction' - * - 'timeout': HTTP socket timeout - * - 'transfer-encoding': SMTP transport, Content-Transfer-Encoding: header - * - 'from': SMTP transport, From: header - * - 'subject': SMTP transport, Subject: header - * - 'headers': SMTP transport, hash of extra SMTP headers - * - 'attachments': what encoding to use for attachments (Mime, Dime) - * - 'trace': whether to trace the SOAP communication - * - 'style': 'document' or 'rpc'; when set to 'document' the parameters - * are not wrapped inside a tag with the SOAP action name - * - 'use': 'literal' for literal encoding, anything else for section 5 - * encoding; when set to 'literal' SOAP types will be omitted. - * - 'keep_arrays_flat': use the tag name multiple times for each element - * when passing in an array in literal mode - * - 'no_type_prefix': supress adding of the namespace prefix - * - * @access public - * - * @param string $method The method to call. - * @param array $params The method parameters. - * @param string|array $namespace Namespace or hash with options. Note: - * most options need to be repeated for - * SOAP_Value instances. - * @param string $soapAction - * - * @return mixed The method result or a SOAP_Fault on error. - */ - function call($method, $params, $namespace = false, $soapAction = false) - { - $this->headersIn = null; - $this->_last_request = null; - $this->_last_response = null; - $this->wire = null; - $this->xml = null; - - $soap_data = $this->_generate($method, $params, $namespace, $soapAction); - if (PEAR::isError($soap_data)) { - $fault = $this->_raiseSoapFault($soap_data); - return $fault; - } - - // _generate() may have changed the endpoint if the WSDL has more - // than one service, so we need to see if we need to generate a new - // transport to hook to a different URI. Since the transport protocol - // can also change, we need to get an entirely new object. This could - // probably be optimized. - if (!$this->_soap_transport || - $this->_endpoint != $this->_soap_transport->url) { - $this->_soap_transport = SOAP_Transport::getTransport($this->_endpoint); - if (PEAR::isError($this->_soap_transport)) { - $fault = $this->_raiseSoapFault($this->_soap_transport); - $this->_soap_transport = null; - return $fault; - } - } - $this->_soap_transport->encoding = $this->_encoding; - - // Send the message. - $transport_options = array_merge_recursive($this->_proxy_params, - $this->_options); - $this->xml = $this->_soap_transport->send($soap_data, $transport_options); - - // Save the wire information for debugging. - if ($this->_options['trace']) { - $this->_last_request = $this->_soap_transport->outgoing_payload; - $this->_last_response = $this->_soap_transport->incoming_payload; - $this->wire = $this->getWire(); - } - if ($this->_soap_transport->fault) { - $fault = $this->_raiseSoapFault($this->xml); - return $fault; - } - - if (isset($this->_options['result']) && - $this->_options['result'] != 'parse') { - return $this->xml; - } - - $this->__result_encoding = $this->_soap_transport->result_encoding; - - $result = $this->parseResponse($this->xml, $this->__result_encoding, - $this->_soap_transport->attachments); - return $result; - } - - /** - * Sets an option to use with the transport layers. - * - * For example: - * - * $soapclient->setOpt('curl', CURLOPT_VERBOSE, 1) - * - * to pass a specific option to curl if using an SSL connection. - * - * @access public - * - * @param string $category Category to which the option applies or option - * name. - * @param string $option An option name if $category is a category name, - * an option value if $category is an option name. - * @param string $value An option value if $category is a category - * name. - */ - function setOpt($category, $option, $value = null) - { - if (!is_null($value)) { - if (!isset($this->_options[$category])) { - $this->_options[$category] = array(); - } - $this->_options[$category][$option] = $value; - } else { - $this->_options[$category] = $option; - } - } - - /** - * Call method supporting the overload extension. - * - * If the overload extension is loaded, you can call the client class with - * a soap method name: - * - * $soap = new SOAP_Client(....); - * $value = $soap->getStockQuote('MSFT'); - * - * - * @access public - * - * @param string $method The method to call. - * @param array $params The method parameters. - * @param mixed $return_value Will get the method's return value - * assigned. - * - * @return boolean Always true. - */ - function _call($method, $params, &$return_value) - { - // Overloading lowercases the method name, we need to look into the - // WSDL and try to find the correct method name to get the correct - // case for the call. - if ($this->_wsdl) { - $this->_wsdl->matchMethod($method); - } - - $return_value = $this->call($method, $params); - - return true; - } - - /** - * Returns the XML content of the last SOAP request. - * - * @return string The last request. - */ - function getLastRequest() - { - return $this->_last_request; - } - - /** - * Returns the XML content of the last SOAP response. - * - * @return string The last response. - */ - function getLastResponse() - { - return $this->_last_response; - } - - /** - * Sets the SOAP encoding. - * - * The default encoding is section 5 encoded. - * - * @param string $use Either 'literal' or 'encoded' (section 5). - */ - function setUse($use) - { - $this->_options['use'] = $use; - } - - /** - * Sets the SOAP encoding style. - * - * The default style is rpc. - * - * @param string $style Either 'document' or 'rpc'. - */ - function setStyle($style) - { - $this->_options['style'] = $style; - } - - /** - * Sets whether to trace the traffic on the transport level. - * - * @see getWire() - * - * @param boolean $trace - */ - function setTrace($trace) - { - $this->_options['trace'] = $trace; - } - - /** - * Generates the complete XML SOAP message for an RPC call. - * - * @see call() - * - * @param string $method The method to call. - * @param array $params The method parameters. - * @param string|array $namespace Namespace or hash with options. Note: - * most options need to be repeated for - * SOAP_Value instances. - * @param string $soapAction - * - * @return string The SOAP message including envelope. - */ - function _generate($method, $params, $namespace = false, - $soapAction = false) - { - $this->fault = null; - $this->_options['input'] = 'parse'; - $this->_options['result'] = 'parse'; - $this->_options['parameters'] = false; - - if ($params && !is_array($params)) { - $params = array($params); - } - - if (is_array($namespace)) { - // Options passed as a hash. - foreach ($namespace as $optname => $opt) { - $this->_options[strtolower($optname)] = $opt; - } - } else { - // We'll place $soapAction into our array for usage in the - // transport. - if ($soapAction) { - $this->_options['soapaction'] = $soapAction; - } - if ($namespace) { - $this->_options['namespace'] = $namespace; - } - } - if (isset($this->_options['namespace'])) { - $namespace = $this->_options['namespace']; - } else { - $namespace = false; - } - - if ($this->_endpointType == 'wsdl') { - $this->_setSchemaVersion($this->_wsdl->xsd); - - // Get port name. - if (!$this->_portName) { - $this->_portName = $this->_wsdl->getPortName($method); - } - if (PEAR::isError($this->_portName)) { - return $this->_raiseSoapFault($this->_portName); - } - - // Get endpoint. - $this->_endpoint = $this->_wsdl->getEndpoint($this->_portName); - if (PEAR::isError($this->_endpoint)) { - return $this->_raiseSoapFault($this->_endpoint); - } - - // Get operation data. - $opData = $this->_wsdl->getOperationData($this->_portName, $method); - - if (PEAR::isError($opData)) { - return $this->_raiseSoapFault($opData); - } - $namespace = $opData['namespace']; - $this->_options['style'] = $opData['style']; - $this->_options['use'] = $opData['input']['use']; - $this->_options['soapaction'] = $opData['soapAction']; - - // Set input parameters. - if ($this->_options['input'] == 'parse') { - $this->_options['parameters'] = $opData['parameters']; - $nparams = array(); - if (isset($opData['input']['parts']) && - count($opData['input']['parts'])) { - foreach ($opData['input']['parts'] as $name => $part) { - $xmlns = ''; - $attrs = array(); - // Is the name a complex type? - if (isset($part['element'])) { - $xmlns = $this->_wsdl->namespaces[$part['namespace']]; - $part = $this->_wsdl->elements[$part['namespace']][$part['type']]; - $name = $part['name']; - } - if (isset($params[$name]) || - $this->_wsdl->getDataHandler($name, $part['namespace'])) { - $nparams[$name] =& $params[$name]; - } else { - // We now force an associative array for - // parameters if using WSDL. - return $this->_raiseSoapFault("The named parameter $name is not in the call parameters."); - } - if (gettype($nparams[$name]) != 'object' || - !is_a($nparams[$name], 'SOAP_Value')) { - // Type is likely a qname, split it apart, and get - // the type namespace from WSDL. - $qname = new QName($part['type']); - if ($qname->prefix) { - $type_namespace = $this->_wsdl->namespaces[$qname->prefix]; - } elseif (isset($part['namespace'])) { - $type_namespace = $this->_wsdl->namespaces[$part['namespace']]; - } else { - $type_namespace = null; - } - $qname->namespace = $type_namespace; - $pqname = $name; - if ($xmlns) { - $pqname = '{' . $xmlns . '}' . $name; - } - $nparams[$name] = new SOAP_Value($pqname, - $qname->fqn(), - $nparams[$name], - $attrs); - } else { - // WSDL fixups to the SOAP value. - } - } - } - $params =& $nparams; - unset($nparams); - } - } else { - $this->_setSchemaVersion(SOAP_XML_SCHEMA_VERSION); - } - - // Serialize the message. - $this->_section5 = (!isset($this->_options['use']) || - $this->_options['use'] != 'literal'); - - if (!isset($this->_options['style']) || - $this->_options['style'] == 'rpc') { - $this->_options['style'] = 'rpc'; - $this->docparams = true; - $mqname = new QName($method, $namespace); - $methodValue = new SOAP_Value($mqname->fqn(), 'Struct', $params, - array(), $this->_options); - $soap_msg = $this->makeEnvelope($methodValue, - $this->headersOut, - $this->_encoding, - $this->_options); - } else { - if (!$params) { - $mqname = new QName($method, $namespace); - $params = new SOAP_Value($mqname->fqn(), 'Struct', null); - } elseif ($this->_options['input'] == 'parse') { - if (is_array($params)) { - $nparams = array(); - $keys = array_keys($params); - foreach ($keys as $k) { - if (gettype($params[$k]) != 'object') { - $nparams[] = new SOAP_Value($k, - false, - $params[$k]); - } else { - $nparams[] =& $params[$k]; - } - } - $params =& $nparams; - } - if ($this->_options['parameters']) { - $mqname = new QName($method, $namespace); - $params = new SOAP_Value($mqname->fqn(), - 'Struct', - $params); - } - } - $soap_msg = $this->makeEnvelope($params, - $this->headersOut, - $this->_encoding, - $this->_options); - } - $this->headersOut = null; - - if (PEAR::isError($soap_msg)) { - return $this->_raiseSoapFault($soap_msg); - } - - // Handle MIME or DIME encoding. - // TODO: DIME encoding should move to the transport, do it here for - // now and for ease of getting it done. - if (count($this->_attachments)) { - if ((isset($this->_options['attachments']) && - $this->_options['attachments'] == 'Mime') || - isset($this->_options['Mime'])) { - $soap_msg = $this->_makeMimeMessage($soap_msg, $this->_encoding); - } else { - // default is dime - $soap_msg = $this->_makeDIMEMessage($soap_msg, $this->_encoding); - $this->_options['headers']['Content-Type'] = 'application/dime'; - } - if (PEAR::isError($soap_msg)) { - return $this->_raiseSoapFault($soap_msg); - } - } - - // Instantiate client. - if (is_array($soap_msg)) { - $soap_data = $soap_msg['body']; - if (count($soap_msg['headers'])) { - if (isset($this->_options['headers'])) { - $this->_options['headers'] = array_merge($this->_options['headers'], $soap_msg['headers']); - } else { - $this->_options['headers'] = $soap_msg['headers']; - } - } - } else { - $soap_data = $soap_msg; - } - - return $soap_data; - } - - /** - * Parses a SOAP response. - * - * @see SOAP_Parser:: - * - * @param string $response XML content of SOAP response. - * @param string $encoding Character set encoding, defaults to 'UTF-8'. - * @param array $attachments List of attachments. - */ - function parseResponse($response, $encoding, $attachments) - { - // Parse the response. - $response = new SOAP_Parser($response, $encoding, $attachments); - if ($response->fault) { - $fault = $this->_raiseSoapFault($response->fault); - return $fault; - } - - // Return array of parameters. - $return = $response->getResponse(); - $headers = $response->getHeaders(); - if ($headers) { - $this->headersIn = $this->_decodeResponse($headers, false); - } - - $decoded = $this->_decodeResponse($return); - return $decoded; - } - - /** - * Converts a complex SOAP_Value into a PHP Array - * - * @param SOAP_Value $response Value object. - * @param boolean $shift - * - * @return array - */ - function _decodeResponse($response, $shift = true) - { - if (!$response) { - $decoded = null; - return $decoded; - } - - // Check for valid response. - if (PEAR::isError($response)) { - $fault = $this->_raiseSoapFault($response); - return $fault; - } elseif (!is_a($response, 'soap_value')) { - $fault = $this->_raiseSoapFault("Didn't get SOAP_Value object back from client"); - return $fault; - } - - // Decode to native php datatype. - $returnArray = $this->_decode($response); - - // Fault? - if (PEAR::isError($returnArray)) { - $fault = $this->_raiseSoapFault($returnArray); - return $fault; - } - - if (is_object($returnArray) && - strcasecmp(get_class($returnArray), 'stdClass') == 0) { - $returnArray = get_object_vars($returnArray); - } - - if (is_array($returnArray)) { - if (isset($returnArray['faultcode']) || - isset($returnArray[SOAP_BASE::SOAPENVPrefix().':faultcode'])) { - $faultcode = $faultstring = $faultdetail = $faultactor = ''; - foreach ($returnArray as $k => $v) { - if (stristr($k, 'faultcode')) $faultcode = $v; - if (stristr($k, 'faultstring')) $faultstring = $v; - if (stristr($k, 'detail')) $faultdetail = $v; - if (stristr($k, 'faultactor')) $faultactor = $v; - } - $fault = $this->_raiseSoapFault($faultstring, $faultdetail, - $faultactor, $faultcode); - return $fault; - } - // Return array of return values. - if ($shift && count($returnArray) == 1) { - $decoded = array_shift($returnArray); - return $decoded; - } - return $returnArray; - } - - return $returnArray; - } - - /** - * Returns the outgoing and incoming traffic on the transport level. - * - * Tracing has to be enabled. - * - * @see setTrace() - * - * @return string The complete traffic between the client and the server. - */ - function getWire() - { - if ($this->_options['trace'] && - ($this->_last_request || $this->_last_response)) { - return "OUTGOING:\n\n" . - $this->_last_request . - "\n\nINCOMING\n\n" . - preg_replace("/>\r\n<", $this->_last_response); - } - - return null; - } - -} diff --git a/data/module/SOAP/Disco.php b/data/module/SOAP/Disco.php deleted file mode 100644 index 6c510abf945..00000000000 --- a/data/module/SOAP/Disco.php +++ /dev/null @@ -1,387 +0,0 @@ - - * @author Chuck Hagenbuch - * @author Jan Schneider - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** SOAP_Base */ -require_once 'SOAP/Base.php'; - -/** - * @package SOAP - */ -class SOAP_DISCO_Server extends SOAP_Base_Object { - - var $namespaces = array(SCHEMA_WSDL => 'wsdl', SCHEMA_SOAP => 'soap'); - var $import_ns = array(); - var $wsdl = ''; - var $disco = ''; - var $_wsdl = array(); - var $_disco = array(); - var $_service_name = ''; - var $_service_ns = ''; - var $_service_desc = ''; - var $_portname = ''; - var $_bindingname = ''; - var $soap_server = NULL; - - - function SOAP_DISCO_Server($soap_server, $service_name, $service_desc = '', - $import_ns = null) - { - parent::SOAP_Base_Object('Server'); - - if ( !is_object($soap_server) - || !get_class($soap_server) == 'soap_server') return; - - $this->_service_name = $service_name; - $this->_service_ns = "urn:$service_name"; - $this->_service_desc = $service_desc; - $this->import_ns = isset($import_ns) ? $import_ns : $this->import_ns; - $this->soap_server = $soap_server; - $this->host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; - } - - function getDISCO() - { - $this->_generate_DISCO(); - return $this->disco; - } - - function getWSDL() - { - $this->_generate_WSDL(); - return $this->wsdl; - } - - function _generate_DISCO() - { - // DISCO - $this->_disco['disco:discovery']['attr']['xmlns:disco'] = SCHEMA_DISCO; - $this->_disco['disco:discovery']['attr']['xmlns:scl'] = SCHEMA_DISCO_SCL; - $this->_disco['disco:discovery']['scl:contractRef']['attr']['ref'] = - (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on') - ? 'https://' . $this->host . $_SERVER['PHP_SELF'] . '?wsdl' - : 'http://' . $this->host . $_SERVER['PHP_SELF'] . '?wsdl'; - - // generate disco xml - $this->_generate_DISCO_XML($this->_disco); - } - - function _generate_WSDL() - { - // WSDL - if (is_array($this->soap_server->_namespaces)) { - // need to get: typens, xsd & SOAP-ENC - $flipped = array_flip($this->soap_server->_namespaces); - $this->namespaces[$this->_service_ns] = 'tns'; - $this->namespaces[$flipped['xsd']] = 'xsd'; - $this->namespaces[$flipped[SOAP_BASE::SOAPENCPrefix()]] = SOAP_BASE::SOAPENCPrefix(); - } - - // DEFINITIONS - $this->_wsdl['definitions']['attr']['name'] = $this->_service_name; - $this->_wsdl['definitions']['attr']['targetNamespace'] = $this->_service_ns; - foreach ($this->namespaces as $ns => $prefix) { - $this->_wsdl['definitions']['attr']['xmlns:' . $prefix] = $ns; - } - $this->_wsdl['definitions']['attr']['xmlns'] = SCHEMA_WSDL; - - // Import namespaces. Seems to not work yet: wsdl.exe fom .NET can't - // handle imported complete wsdl-definitions. - if (count($this->import_ns)) { - $i = 0; - foreach ($this->import_ns as $_ns => $_location) { - $this->_wsdl['definitions']['import'][$i]['attr']['location'] = $_location; - $this->_wsdl['definitions']['import'][$i]['attr']['namespace'] = $_ns; - $i++; - } - } - $this->_wsdl['definitions']['types']['attr']['xmlns']='http://schemas.xmlsoap.org/wsdl/'; - $this->_wsdl['definitions']['types']['schema']=array(); - - // Placeholder for messages - $this->_wsdl['definitions']['message'] = array(); - - // PORTTYPE-NAME - $this->_portname = $this->_service_name . 'Port'; - $this->_wsdl['definitions']['portType']['attr']['name'] = $this->_portname; - - // BINDING-NAME - $this->_bindingname = $this->_service_name . 'Binding'; - $this->_wsdl['definitions']['binding']['attr']['name'] = $this->_bindingname; - $this->_wsdl['definitions']['binding']['attr']['type'] = 'tns:' . $this->_portname; - $this->_wsdl['definitions']['binding']['soap:binding']['attr']['style'] = 'rpc'; - $this->_wsdl['definitions']['binding']['soap:binding']['attr']['transport'] = SCHEMA_SOAP_HTTP; - - // SERVICE - $this->_wsdl['definitions']['service']['attr']['name'] = $this->_service_name . 'Service'; - $this->_wsdl['definitions']['service']['documentation']['attr'] = ''; - $this->_wsdl['definitions']['service']['documentation'] = htmlentities($this->_service_desc); - $this->_wsdl['definitions']['service']['port']['attr']['name'] = $this->_portname; - $this->_wsdl['definitions']['service']['port']['attr']['binding'] = 'tns:' . $this->_bindingname; - $this->_wsdl['definitions']['service']['port']['soap:address']['attr']['location'] = - (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on') - ? 'https://' . $this->host . $_SERVER['PHP_SELF'] - : 'http://' . $this->host . $_SERVER['PHP_SELF']; - - // - $dispatch_keys = array_keys($this->soap_server->dispatch_objects); - $dc = count($dispatch_keys); - for ($di = 0; $di < $dc; $di++) { - $namespace = $dispatch_keys[$di]; - $namespace_objects =& $this->soap_server->dispatch_objects[$namespace]; - $oc = count($namespace_objects); - for ($oi = 0; $oi < $oc; $oi++) { - $object = $namespace_objects[$oi]; - // types definitions - $this->addSchemaFromMap($object->__typedef); - // MESSAGES - $this->addMethodsFromMap($object->__dispatch_map, $namespace, get_class($object)); - } - } - if (isset($this->soap_server->dispatch_map)) { - $this->addMethodsFromMap($this->soap_server->dispatch_map, $namespace); - } - - // generate wsdl - $this->_generate_WSDL_XML(); - } - - function &_getSchema($namespace) - { - // SCHEMA - $c = count($this->_wsdl['definitions']['types']['schema']); - for($i = 0; $i < $c; $i++) { - if ($this->_wsdl['definitions']['types']['schema'][$i]['attr']['targetNamespace'] == $namespace) { - return $this->_wsdl['definitions']['types']['schema'][$i]; - } - } - - // don't have this namespace - $schema = array(); - $schema['attr'] = array(); - $schema['complexType'] = array(); - $schema['attr']['xmlns'] = array_search('xsd',$this->namespaces); - $schema['attr']['targetNamespace'] = $namespace; - $this->_wsdl['definitions']['types']['schema'][] =& $schema; - - return $schema; - } - - function addSchemaFromMap(&$map) - { - if (!$map) { - return; - } - - foreach ($map as $_type_name => $_type_def) { - list($typens,$type) = $this->_getTypeNs($_type_name); - if ($typens == 'xsd') { - // cannot add to xsd, lets use method_namespace - $typens = 'tns'; - } - $schema =& $this->_getSchema(array_search($typens, $this->namespaces)); - if (!$this->_ifComplexTypeExists($schema['complexType'], $type)) { - $ctype =& $schema['complexType'][]; - $ctype['attr']['name'] = $type; - foreach ($_type_def as $_varname => $_vartype) { - if (!is_int($_varname)) { - list($_vartypens,$_vartype) = $this->_getTypeNs($_vartype); - $ctype['all']['attr'] = ''; - $el =& $ctype['all']['element'][]; - $el['attr']['name'] = $_varname; - $el['attr']['type'] = $_vartypens . ':' . $_vartype; - } else { - $ctype['complexContent']['attr'] = ''; - $ctype['complexContent']['restriction']['attr']['base'] = SOAP_BASE::SOAPENCPrefix().':Array'; - foreach ($_vartype as $array_type) { - list($_vartypens, $_vartype) = $this->_getTypeNs($array_type); - $ctype['complexContent']['restriction']['attribute']['attr']['ref'] = SOAP_BASE::SOAPENCPrefix().':arrayType'; - $ctype['complexContent']['restriction']['attribute']['attr']['wsdl:arrayType'] = $_vartypens . ':' . $_vartype . '[]'; - } - } - } - } - } - } - - function addMethodsFromMap(&$map, $namespace, $classname = null) - { - if (!$map) { - return; - } - - foreach ($map as $method_name => $method_types) { - if (array_key_exists('namespace', $method_types)) { - $method_namespace = $method_types['namespace']; - } else { - $method_namespace = $namespace; - } - - // INPUT - $input_message = array('attr' => array('name' => $method_name . 'Request')); - if (isset($method_types['in']) && is_array($method_types['in'])) { - foreach ($method_types['in'] as $name => $type) { - list($typens, $type) = $this->_getTypeNs($type); - $part = array(); - $part['attr']['name'] = $name; - $part['attr']['type'] = $typens . ':' . $type; - $input_message['part'][] = $part; - } - } - $this->_wsdl['definitions']['message'][] = $input_message; - - // OUTPUT - $output_message = array('attr' => array('name' => $method_name . 'Response')); - if (isset($method_types['out']) && is_array($method_types['out'])) { - foreach ($method_types['out'] as $name => $type) { - list($typens, $type) = $this->_getTypeNs($type); - $part = array(); - $part['attr']['name'] = $name; - $part['attr']['type'] = $typens . ':' . $type; - $output_message['part'][] = $part; - } - } - $this->_wsdl['definitions']['message'][] = $output_message; - - // PORTTYPES - $operation = array(); - $operation['attr']['name'] = $method_name; - // INPUT - $operation['input']['attr']['message'] = 'tns:' . $input_message['attr']['name']; - // OUTPUT - $operation['output']['attr']['message'] = 'tns:' . $output_message['attr']['name']; - $this->_wsdl['definitions']['portType']['operation'][] = $operation; - - // BINDING - $binding = array(); - $binding['attr']['name'] = $method_name; - $action = $method_namespace . '#' . ($classname ? $classname . '#' : '') . $method_name; - $binding['soap:operation']['attr']['soapAction'] = $action; - // INPUT - $binding['input']['attr'] = ''; - $binding['input']['soap:body']['attr']['use'] = 'encoded'; - $binding['input']['soap:body']['attr']['namespace'] = $method_namespace; - $binding['input']['soap:body']['attr']['encodingStyle'] = SOAP_SCHEMA_ENCODING; - // OUTPUT - $binding['output']['attr'] = ''; - $binding['output']['soap:body']['attr']['use'] = 'encoded'; - $binding['output']['soap:body']['attr']['namespace'] = $method_namespace; - $binding['output']['soap:body']['attr']['encodingStyle'] = SOAP_SCHEMA_ENCODING; - $this->_wsdl['definitions']['binding']['operation'][] = $binding; - } - } - - function _generate_DISCO_XML($disco_array) - { - $disco = ''; - foreach ($disco_array as $key => $val) { - $disco .= $this->_arrayToNode($key,$val); - } - $this->disco = $disco; - } - - function _generate_WSDL_XML() - { - $wsdl = ''; - foreach ($this->_wsdl as $key => $val) { - $wsdl .= $this->_arrayToNode($key, $val); - } - $this->wsdl = $wsdl; - } - - function _arrayToNode($node_name = '', $array) - { - $return = ''; - if (is_array($array)) { - // we have a node if there's key 'attr' - if (array_key_exists('attr',$array)) { - $return .= "<$node_name"; - if (is_array($array['attr'])) { - foreach ($array['attr'] as $attr_name => $attr_value) { - $return .= " $attr_name=\"$attr_value\""; - } - } - - // unset 'attr' and proceed other childs... - unset($array['attr']); - - if (count($array) > 0) { - $i = 0; - foreach ($array as $child_node_name => $child_node_value) { - $return .= $i == 0 ? ">\n" : ''; - $return .= $this->_arrayToNode($child_node_name,$child_node_value); - $i++; - } - $return .= "\n"; - } else { - $return .= " />\n"; - } - } else { - // we have no 'attr' key in array - so it's list of nodes with - // the same name ... - foreach ($array as $child_node_name => $child_node_value) { - $return .= $this->_arrayToNode($node_name,$child_node_value); - } - } - } else { - // $array is not an array - if ($array !='') { - // and its not empty - $return .= "<$node_name>$array\n"; - } else { - // and its empty... - $return .= "<$node_name />\n"; - } - } - return $return; - } - - function _getTypeNs($type) - { - preg_match_all("'\{(.*)\}'sm", $type, $m); - if (isset($m[1][0]) && $m[1][0] != '') { - if (!array_key_exists($m[1][0],$this->namespaces)) { - $ns_pref = 'ns' . count($this->namespaces); - $this->namespaces[$m[1][0]] = $ns_pref; - $this->_wsdl['definitions']['attr']['xmlns:' . $ns_pref] = $m[1][0]; - } - $typens = $this->namespaces[$m[1][0]]; - $type = preg_replace('/'.$m[0][0].'/', '', $type); - } else { - $typens = 'xsd'; - } - return array($typens,$type); - } - - function _ifComplexTypeExists($typesArray, $type_name) - { - if (is_array($typesArray)) { - foreach ($typesArray as $type_data) { - if ($type_data['attr']['name'] == $type_name) { - return true; - } - } - } - return false; - } -} diff --git a/data/module/SOAP/Fault.php b/data/module/SOAP/Fault.php deleted file mode 100644 index d9b1c9a5003..00000000000 --- a/data/module/SOAP/Fault.php +++ /dev/null @@ -1,129 +0,0 @@ - Original Author - * @author Shane Caraveo Port to PEAR and more - * @author Chuck Hagenbuch Maintenance - * @author Jan Schneider Maintenance - * @copyright 2003-2006 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** PEAR_Error */ -require_once 'PEAR.php'; - -/** - * PEAR::Error wrapper used to match SOAP Faults to PEAR Errors - * - * SOAP_Fault can provide a complete backtrace of the error. Revealing these - * details in a public web services is a bad idea because it can be used by - * attackers. Thus you have to enable backtrace information in SOAP_Fault - * responses by putting the following code in your script after your - * "require_once 'SOAP/Server.php';" line: - * - * - * $backtrace =& PEAR::getStaticProperty('SOAP_Fault', 'backtrace'); - * $backtrace = true; - * - * - * @package SOAP - * @access public - * @author Shane Caraveo Port to PEAR and more - * @author Dietrich Ayala Original Author - */ -class SOAP_Fault extends PEAR_Error -{ - /** - * Constructor. - * - * @param string $faultstring Message string for fault. - * @param mixed $faultcode The faultcode. - * @param mixed $faultactor - * @param mixed $detail @see PEAR_Error - * @param array $mode @see PEAR_Error - * @param array $options @see PEAR_Error - */ - function SOAP_Fault($faultstring = 'unknown error', $faultcode = 'Client', - $faultactor = null, $detail = null, $mode = null, - $options = null) - { - parent::PEAR_Error($faultstring, $faultcode, $mode, $options, $detail); - if ($faultactor) { - $this->error_message_prefix = $faultactor; - } - } - - /** - * Returns a SOAP XML message that can be sent as a server response. - * - * @return string - */ - function message($encoding = SOAP_DEFAULT_ENCODING) - { - $msg = new SOAP_Base(); - $params = array(); - $params[] = new SOAP_Value('faultcode', 'QName', SOAP_BASE::SOAPENVPrefix().':' . $this->code); - $params[] = new SOAP_Value('faultstring', 'string', $this->message); - $params[] = new SOAP_Value('faultactor', 'anyURI', $this->error_message_prefix); - if (PEAR::getStaticProperty('SOAP_Fault', 'backtrace') && - isset($this->backtrace)) { - $params[] = new SOAP_Value('detail', 'string', $this->backtrace); - } else { - $params[] = new SOAP_Value('detail', 'string', $this->userinfo); - } - - $methodValue = new SOAP_Value('{' . SOAP_ENVELOP . '}Fault', 'Struct', $params); - $headers = null; - return $msg->makeEnvelope($methodValue, $headers, $encoding); - } - - /** - * Returns a simple native PHP array containing the fault data. - * - * @return array - */ - function getFault() - { - $fault = new stdClass(); - $fault->faultcode = $this->code; - $fault->faultstring = $this->message; - $fault->faultactor = $this->error_message_prefix; - $fault->detail = $this->userinfo; - return $fault; - } - - /** - * Returns the SOAP actor for the fault. - * - * @return string - */ - function getActor() - { - return $this->error_message_prefix; - } - - /** - * Returns the fault detail. - * - * @return string - */ - function getDetail() - { - return $this->userinfo; - } - -} diff --git a/data/module/SOAP/Parser.php b/data/module/SOAP/Parser.php deleted file mode 100644 index bcdbaf20695..00000000000 --- a/data/module/SOAP/Parser.php +++ /dev/null @@ -1,499 +0,0 @@ - Original Author - * @author Shane Caraveo Port to PEAR and more - * @author Chuck Hagenbuch Maintenance - * @author Jan Schneider Maintenance - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'SOAP/Base.php'; -require_once 'SOAP/Value.php'; - -/** - * SOAP Parser - * - * This class is used by SOAP::Message and SOAP::Server to parse soap - * packets. Originally based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @access public - * @package SOAP - * @author Shane Caraveo Conversion to PEAR and updates - * @author Dietrich Ayala Original Author - */ -class SOAP_Parser extends SOAP_Base -{ - var $status = ''; - var $position = 0; - var $depth = 0; - var $default_namespace = ''; - var $message = array(); - var $depth_array = array(); - var $parent = 0; - var $root_struct_name = array(); - var $header_struct_name = array(); - var $curent_root_struct_name = ''; - var $root_struct = array(); - var $header_struct = array(); - var $curent_root_struct = 0; - var $references = array(); - var $need_references = array(); - - /** - * Used to handle non-root elements before root body element. - * - * @var integer - */ - var $bodyDepth; - - /** - * Constructor. - * - * @param string $xml XML content. - * @param string $encoding Character set encoding, defaults to 'UTF-8'. - * @param array $attachments List of attachments. - */ - function SOAP_Parser($xml, $encoding = SOAP_DEFAULT_ENCODING, - $attachments = null) - { - parent::SOAP_Base('Parser'); - $this->_setSchemaVersion(SOAP_XML_SCHEMA_VERSION); - - $this->attachments = $attachments; - - // Check the XML tag for encoding. - if (preg_match('/<\?xml[^>]+encoding\s*?=\s*?(\'([^\']*)\'|"([^"]*)")[^>]*?[\?]>/', $xml, $m)) { - $encoding = strtoupper($m[2] ? $m[2] : $m[3]); - } - - // Determine where in the message we are (envelope, header, body, - // method). Check whether content has been read. - if (!empty($xml)) { - // Prepare the XML parser. - $parser = xml_parser_create($encoding); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_set_object($parser, $this); - xml_set_element_handler($parser, '_startElement', '_endElement'); - xml_set_character_data_handler($parser, '_characterData'); - - // Some lame SOAP implementations add nul bytes at the end of the - // SOAP stream, and expat chokes on that. - if ($xml[strlen($xml) - 1] == 0) { - $xml = trim($xml); - } - - // Parse the XML file. - if (!xml_parse($parser, $xml, true)) { - $err = sprintf('XML error on line %d col %d byte %d %s', - xml_get_current_line_number($parser), - xml_get_current_column_number($parser), - xml_get_current_byte_index($parser), - xml_error_string(xml_get_error_code($parser))); - $this->_raiseSoapFault($err, htmlspecialchars($xml)); - } - xml_parser_free($parser); - } - } - - /** - * Returns an array of responses. - * - * After parsing a SOAP message, use this to get the response. - * - * @return array - */ - function getResponse() - { - if (!empty($this->root_struct[0])) { - return $this->_buildResponse($this->root_struct[0]); - } else { - return $this->_raiseSoapFault('Cannot build response'); - } - } - - /** - * Returns an array of header responses. - * - * After parsing a SOAP message, use this to get the response. - * - * @return array - */ - function getHeaders() - { - if (!empty($this->header_struct[0])) { - return $this->_buildResponse($this->header_struct[0]); - } else { - // We don't fault if there are no headers; that can be handled by - // the application if necessary. - return null; - } - } - - /** - * Recurses to build a multi dimensional array. - * - * @see _buildResponse() - */ - function _domulti($d, &$ar, &$r, &$v, $ad = 0) - { - if ($d) { - $this->_domulti($d - 1, $ar, $r[$ar[$ad]], $v, $ad + 1); - } else { - $r = $v; - } - } - - /** - * Loops through the message, building response structures. - * - * @param integer $pos Position. - * - * @return SOAP_Value - */ - function _buildResponse($pos) - { - $response = null; - - if (isset($this->message[$pos]['children'])) { - $children = explode('|', $this->message[$pos]['children']); - foreach ($children as $c => $child_pos) { - if ($this->message[$child_pos]['type'] != null) { - $response[] = $this->_buildResponse($child_pos); - } - } - if (isset($this->message[$pos]['arraySize'])) { - $ardepth = count($this->message[$pos]['arraySize']); - if ($ardepth > 1) { - $ar = array_pad(array(), $ardepth, 0); - if (isset($this->message[$pos]['arrayOffset'])) { - for ($i = 0; $i < $ardepth; $i++) { - $ar[$i] += $this->message[$pos]['arrayOffset'][$i]; - } - } - $elc = count($response); - for ($i = 0; $i < $elc; $i++) { - // Recurse to build a multi dimensional array. - $this->_domulti($ardepth, $ar, $newresp, $response[$i]); - - // Increment our array pointers. - $ad = $ardepth - 1; - $ar[$ad]++; - while ($ad > 0 && - $ar[$ad] >= $this->message[$pos]['arraySize'][$ad]) { - $ar[$ad] = 0; - $ad--; - $ar[$ad]++; - } - } - $response = $newresp; - } elseif (isset($this->message[$pos]['arrayOffset']) && - $this->message[$pos]['arrayOffset'][0] > 0) { - // Check for padding. - $pad = $this->message[$pos]['arrayOffset'][0] + count($response) * -1; - $response = array_pad($response, $pad, null); - } - } - } - - // Build attributes. - $attrs = array(); - foreach ($this->message[$pos]['attrs'] as $atn => $atv) { - if (!strstr($atn, 'xmlns') && !strpos($atn, ':')) { - $attrs[$atn] = $atv; - } - } - - // Add current node's value. - $nqn = new QName($this->message[$pos]['name'], - $this->message[$pos]['namespace']); - $tqn = new QName($this->message[$pos]['type'], - $this->message[$pos]['type_namespace']); - if ($response) { - $response = new SOAP_Value($nqn->fqn(), $tqn->fqn(), $response, - $attrs); - if (isset($this->message[$pos]['arrayType'])) { - $response->arrayType = $this->message[$pos]['arrayType']; - } - } else { - // Check if value is an empty array - if ($tqn->name == 'Array') { - $response = new SOAP_Value($nqn->fqn(), $tqn->fqn(), array(), - $attrs); - //if ($pos == 4) var_dump($this->message[$pos], $response); - } else { - $response = new SOAP_Value($nqn->fqn(), $tqn->fqn(), - $this->message[$pos]['cdata'], - $attrs); - } - } - - // Handle header attribute that we need. - if (array_key_exists('actor', $this->message[$pos])) { - $response->actor = $this->message[$pos]['actor']; - } - if (array_key_exists('mustUnderstand', $this->message[$pos])) { - $response->mustunderstand = $this->message[$pos]['mustUnderstand']; - } - - return $response; - } - - /** - * Start element handler used with the XML parser. - */ - function _startElement($parser, $name, $attrs) - { - // Position in a total number of elements, starting from 0. - // Update class level position. - $pos = $this->position++; - - // And set mine. - $this->message[$pos] = array( - 'type' => '', - 'type_namespace' => '', - 'cdata' => '', - 'pos' => $pos, - 'id' => ''); - - // Parent/child/depth determinations. - - // depth = How many levels removed from root? - // Set mine as current global depth and increment global depth value. - $this->message[$pos]['depth'] = $this->depth++; - - // Else add self as child to whoever the current parent is. - if ($pos != 0) { - if (isset($this->message[$this->parent]['children'])) { - $this->message[$this->parent]['children'] .= '|' . $pos; - } else { - $this->message[$this->parent]['children'] = $pos; - } - } - - // Set my parent. - $this->message[$pos]['parent'] = $this->parent; - - // Set self as current value for this depth. - $this->depth_array[$this->depth] = $pos; - // Set self as current parent. - $this->parent = $pos; - $qname = new QName($name); - // Set status. - if (strcasecmp('envelope', $qname->name) == 0) { - $this->status = 'envelope'; - } elseif (strcasecmp('header', $qname->name) == 0) { - $this->status = 'header'; - $this->header_struct_name[] = $this->curent_root_struct_name = $qname->name; - $this->header_struct[] = $this->curent_root_struct = $pos; - $this->message[$pos]['type'] = 'Struct'; - } elseif (strcasecmp('body', $qname->name) == 0) { - $this->status = 'body'; - $this->bodyDepth = $this->depth; - - // Set method - } elseif ($this->status == 'body') { - // Is this element allowed to be a root? - // TODO: this needs to be optimized, we loop through $attrs twice - // now. - $can_root = $this->depth == $this->bodyDepth + 1; - if ($can_root) { - foreach ($attrs as $key => $value) { - if (stristr($key, ':root') && !$value) { - $can_root = false; - } - } - } - - if ($can_root) { - $this->status = 'method'; - $this->root_struct_name[] = $this->curent_root_struct_name = $qname->name; - $this->root_struct[] = $this->curent_root_struct = $pos; - $this->message[$pos]['type'] = 'Struct'; - } - } - - // Set my status. - $this->message[$pos]['status'] = $this->status; - - // Set name. - $this->message[$pos]['name'] = htmlspecialchars($qname->name); - - // Set attributes. - $this->message[$pos]['attrs'] = $attrs; - - // Loop through attributes, logging ns and type declarations. - foreach ($attrs as $key => $value) { - // If ns declarations, add to class level array of valid - // namespaces. - $kqn = new QName($key); - if ($kqn->prefix == 'xmlns') { - $prefix = $kqn->name; - - if (in_array($value, $this->_XMLSchema)) { - $this->_setSchemaVersion($value); - } - - $this->_namespaces[$value] = $prefix; - - // Set method namespace. - } elseif ($key == 'xmlns') { - $qname->prefix = $this->_getNamespacePrefix($value); - $qname->namespace = $value; - } elseif ($kqn->name == 'actor') { - $this->message[$pos]['actor'] = $value; - } elseif ($kqn->name == 'mustUnderstand') { - $this->message[$pos]['mustUnderstand'] = $value; - - // If it's a type declaration, set type. - } elseif ($kqn->name == 'type') { - $vqn = new QName($value); - $this->message[$pos]['type'] = $vqn->name; - $this->message[$pos]['type_namespace'] = $this->_getNamespaceForPrefix($vqn->prefix); - - // Should do something here with the namespace of specified - // type? - - } elseif ($kqn->name == 'arrayType') { - $vqn = new QName($value); - $this->message[$pos]['type'] = 'Array'; - if (isset($vqn->arraySize)) { - $this->message[$pos]['arraySize'] = $vqn->arraySize; - } - $this->message[$pos]['arrayType'] = $vqn->name; - - } elseif ($kqn->name == 'offset') { - $this->message[$pos]['arrayOffset'] = explode(',', substr($value, 1, strlen($value) - 2)); - - } elseif ($kqn->name == 'id') { - // Save id to reference array. - $this->references[$value] = $pos; - $this->message[$pos]['id'] = $value; - - } elseif ($kqn->name == 'href') { - if ($value[0] == '#') { - $ref = substr($value, 1); - if (isset($this->references[$ref])) { - // cdata, type, inval. - $ref_pos = $this->references[$ref]; - $this->message[$pos]['children'] = &$this->message[$ref_pos]['children']; - $this->message[$pos]['cdata'] = &$this->message[$ref_pos]['cdata']; - $this->message[$pos]['type'] = &$this->message[$ref_pos]['type']; - $this->message[$pos]['arraySize'] = &$this->message[$ref_pos]['arraySize']; - $this->message[$pos]['arrayType'] = &$this->message[$ref_pos]['arrayType']; - } else { - // Reverse reference, store in 'need reference'. - if (!isset($this->need_references[$ref])) { - $this->need_references[$ref] = array(); - } - $this->need_references[$ref][] = $pos; - } - } elseif (isset($this->attachments[$value])) { - $this->message[$pos]['cdata'] = $this->attachments[$value]; - } - } - } - // See if namespace is defined in tag. - if (isset($attrs['xmlns:' . $qname->prefix])) { - $namespace = $attrs['xmlns:' . $qname->prefix]; - } elseif ($qname->prefix && !$qname->namespace) { - $namespace = $this->_getNamespaceForPrefix($qname->prefix); - } else { - // Get namespace. - $namespace = $qname->namespace ? $qname->namespace : $this->default_namespace; - } - $this->message[$pos]['namespace'] = $namespace; - $this->default_namespace = $namespace; - } - - /** - * End element handler used with the XML parser. - */ - function _endElement($parser, $name) - { - // Position of current element is equal to the last value left in - // depth_array for my depth. - $pos = $this->depth_array[$this->depth]; - - // Bring depth down a notch. - $this->depth--; - $qname = new QName($name); - - // Get type if not explicitly declared in an xsi:type attribute. - // TODO: check on integrating WSDL validation here. - if ($this->message[$pos]['type'] == '') { - if (isset($this->message[$pos]['children'])) { - /* this is slow, need to look at some faster method - $children = explode('|', $this->message[$pos]['children']); - if (count($children) > 2 && - $this->message[$children[1]]['name'] == $this->message[$children[2]]['name']) { - $this->message[$pos]['type'] = 'Array'; - } else { - $this->message[$pos]['type'] = 'Struct'; - }*/ - $this->message[$pos]['type'] = 'Struct'; - } else { - $parent = $this->message[$pos]['parent']; - if ($this->message[$parent]['type'] == 'Array' && - isset($this->message[$parent]['arrayType'])) { - $this->message[$pos]['type'] = $this->message[$parent]['arrayType']; - } else { - $this->message[$pos]['type'] = 'string'; - } - } - } - - // If tag we are currently closing is the method wrapper. - if ($pos == $this->curent_root_struct) { - $this->status = 'body'; - } elseif ($qname->name == 'Body' || $qname->name == 'Header') { - $this->status = 'envelope'; - } - - // Set parent back to my parent. - $this->parent = $this->message[$pos]['parent']; - - // Handle any reverse references now. - $idref = $this->message[$pos]['id']; - - if ($idref != '' && isset($this->need_references[$idref])) { - foreach ($this->need_references[$idref] as $ref_pos) { - // XXX is this stuff there already? - $this->message[$ref_pos]['children'] = &$this->message[$pos]['children']; - $this->message[$ref_pos]['cdata'] = &$this->message[$pos]['cdata']; - $this->message[$ref_pos]['type'] = &$this->message[$pos]['type']; - $this->message[$ref_pos]['arraySize'] = &$this->message[$pos]['arraySize']; - $this->message[$ref_pos]['arrayType'] = &$this->message[$pos]['arrayType']; - } - } - } - - /** - * Element content handler used with the XML parser. - */ - function _characterData($parser, $data) - { - $pos = $this->depth_array[$this->depth]; - if (isset($this->message[$pos]['cdata'])) { - $this->message[$pos]['cdata'] .= $data; - } else { - $this->message[$pos]['cdata'] = $data; - } - } - -} diff --git a/data/module/SOAP/Server.php b/data/module/SOAP/Server.php deleted file mode 100644 index db99d85dbc0..00000000000 --- a/data/module/SOAP/Server.php +++ /dev/null @@ -1,831 +0,0 @@ - Original Author - * @author Shane Caraveo Port to PEAR and more - * @author Chuck Hagenbuch Maintenance - * @author Jan Schneider Maintenance - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'SOAP/Base.php'; -require_once 'SOAP/Fault.php'; -require_once 'SOAP/Parser.php'; -require_once 'SOAP/Value.php'; -require_once 'SOAP/WSDL.php'; - -/** - * SOAP Server Class - * - * Originaly based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @access public - * @package SOAP - * @author Shane Caraveo Conversion to PEAR and updates - * @author Dietrich Ayala Original Author - */ -class SOAP_Server extends SOAP_Base -{ - /** - * - * @var array - */ - var $dispatch_map = array(); // create empty dispatch map - var $dispatch_objects = array(); - var $soapobject = null; - var $call_methodname = null; - var $callHandler = null; - var $callValidation = true; - - /** - * A list of headers that are going to be sent back to the client. - * - * @var array - */ - var $headers = array(); - - /** - * - * @var string - */ - var $request = ''; - - /** - * - * @var string XML-Encoding - */ - var $xml_encoding = SOAP_DEFAULT_ENCODING; - var $response_encoding = 'UTF-8'; - - var $result = 'successful'; // for logging interop results to db - - var $endpoint = ''; // the uri to ME! - - var $service = ''; //soapaction header - var $method_namespace = null; - - /** - * Options. - * - * @var array - */ - var $_options = array('use' => 'encoded', - 'style' => 'rpc', - 'parameters' => 0, - 'http_status_success' => '200 OK', - 'http_status_fault' => '500 SOAP Fault'); - - function SOAP_Server($options = null) - { - ini_set('track_errors', 1); - parent::SOAP_Base('Server'); - - if (is_array($options)) { - if (isset($options['use'])) { - $this->_options['use'] = $options['use']; - } - if (isset($options['style'])) { - $this->_options['style'] = $options['style']; - } - if (isset($options['parameters'])) { - $this->_options['parameters'] = $options['parameters']; - } - } - // assume we encode with section 5 - $this->_section5 = true; - if ($this->_options['use'] == 'literal') { - $this->_section5 = false; - } - } - - /** - * Error handler for errors that happen in proxied methods. - * - * To always return a valid SOAP response even on errors that don't happen - * in this code, the errors are catched, transformed to a SOAP fault and - * immediately sent to the client. - * - * @see http://www.php.net/set_error_handler - */ - function _errorHandler($errno, $errmsg, $filename, $linenum) - { - /* The error handler should ignore '0' errors, eg. hidden by @ - see - * the set_error_handler manual page. (thanks to Alan Knowles). */ - if (!$errno || !error_reporting() || $errno == E_NOTICE || - (defined('E_STRICT') && $errno == constant('E_STRICT'))) { - return false; - } - - $this->fault = new SOAP_Fault($errmsg, 'Server', 'PHP', "Errno: $errno\nFilename: $filename\nLineno: $linenum\n"); - - $this->_sendResponse(); - exit; - } - - function _getContentEncoding($content_type) - { - /* Get the character encoding of the incoming request treat incoming - * data as UTF-8 if no encoding set. */ - $this->xml_encoding = 'UTF-8'; - if (strpos($content_type, '=')) { - $enc = strtoupper(str_replace('"', '', substr(strstr($content_type, '='), 1))); - if (!in_array($enc, $this->_encodings)) { - return false; - } - $this->xml_encoding = $enc; - } - - return true; - } - - - /** - * Parses the request and posts or returns the response. - * - * @param string $data The SOAP request data. - * @param string $endpoint The service endpoint. Determined automatically - * if left empty. - * @param boolean $test - * @param boolean $return Whether to return the SOAP response data - * instead of sending it to the client. - */ - function service($data, $endpoint = '', $test = false, $return = false) - { - $response = null; - $attachments = array(); - $useEncoding = 'DIME'; - - /* Figure out our endpoint. */ - $this->endpoint = $endpoint; - if (!$test && !$this->endpoint) { - /* We'll try to build our endpoint. */ - $this->endpoint = 'http://' . $_SERVER['SERVER_NAME']; - if (isset($_SERVER['SERVER_PORT'])) { - $this->endpoint .= ':' . $_SERVER['SERVER_PORT']; - } - $this->endpoint .= $_SERVER['SCRIPT_NAME']; - } - - /* Get the character encoding of the incoming request treat incoming - * data as UTF-8 if no encoding set. */ - if (isset($_SERVER['CONTENT_TYPE'])) { - if (strcasecmp($_SERVER['CONTENT_TYPE'], 'application/dime') == 0) { - $this->_decodeDIMEMessage($data, $this->headers, $attachments); - $useEncoding = 'DIME'; - } elseif (stristr($_SERVER['CONTENT_TYPE'], 'multipart/related')) { - /* This is a mime message, let's decode it. */ - $data = 'Content-Type: ' . - stripslashes($_SERVER['CONTENT_TYPE']) . - "\r\n\r\n" . $data; - $this->_decodeMimeMessage($data, $this->headers, $attachments); - $useEncoding = 'Mime'; - } - if (!isset($this->headers['content-type'])) { - $this->headers['content-type'] = stripslashes($_SERVER['CONTENT_TYPE']); - } - if (!$this->fault && - !$this->_getContentEncoding($this->headers['content-type'])) { - $this->xml_encoding = SOAP_DEFAULT_ENCODING; - /* Found encoding we don't understand; return a fault. */ - $this->_raiseSoapFault('Unsupported encoding, use one of ISO-8859-1, US-ASCII, UTF-8', '', '', 'Server'); - } - } - - /* If this is not a POST with Content-Type text/xml, try to return a - * WSDL file. */ - if (!$this->fault && !$test && - ((isset($_SERVER['REQUEST_METHOD']) && - $_SERVER['REQUEST_METHOD'] != 'POST') || - (isset($this->headers['content-type']) && - strncmp($this->headers['content-type'], 'text/xml', 8) != 0))) { - /* This is not possibly a valid SOAP request, try to return a WSDL - * file. */ - $got = isset($this->headers['content-type']) ? $this->headers['content-type'] : 'Nothing!'; - $this->_raiseSoapFault('Invalid SOAP request, must be POST with content-type: text/xml, got: ' . $got, '', '', 'Server'); - } - - if (!$this->fault) { - /* $response is a SOAP_Msg object. */ - $soap_msg = $this->parseRequest($data, $attachments); - - /* Handle Mime or DIME encoding. */ - /* TODO: DIME decoding should move to the transport, do it here - * for now and for ease of getting it done. */ - if (count($this->_attachments)) { - if ($useEncoding == 'Mime') { - $soap_msg = $this->_makeMimeMessage($soap_msg); - } else { - // default is dime - $soap_msg = $this->_makeDIMEMessage($soap_msg); - $this->headers['Content-Type'] = 'application/dime'; - } - if (PEAR::isError($soap_msg)) { - return $this->_raiseSoapFault($soap_msg); - } - } - - if (is_array($soap_msg)) { - $response = $soap_msg['body']; - if (count($soap_msg['headers'])) { - $this->headers = $soap_msg['headers']; - } - } else { - $response = $soap_msg; - } - } - - if ($return) { - if ($this->fault) { - $response = $this->fault->message(); - } - return $response; - } - - $this->_sendResponse($response); - } - - /** - * Sends the final HTTP response to the client, including the HTTP header - * and the HTTP body. - * - * If an error happened, it returns a SOAP fault instead of the response - * body. - * - * @param string $response The response body. - */ - function _sendResponse($response = '') - { - /* Make distinction between the different SAPIs, running PHP as CGI or - * as a module. */ - if (stristr(php_sapi_name(), 'cgi') === 0) { - $hdrs_type = 'Status:'; - } else { - $hdrs_type = 'HTTP/1.1'; - } - - if ($this->fault) { - $hdrs = $hdrs_type . ' ' . $this->_options['http_status_fault'] . "\r\n"; - $response = $this->fault->message($this->response_encoding); - } else { - $hdrs = $hdrs_type . ' ' . $this->_options['http_status_success'] . "\r\n"; - } - header($hdrs); - - $this->headers['Server'] = SOAP_LIBRARY_NAME; - if (!isset($this->headers['Content-Type'])) { - $this->headers['Content-Type'] = 'text/xml; charset=' . - $this->response_encoding; - } - $this->headers['Content-Length'] = strlen($response); - - foreach ($this->headers as $k => $v) { - $v = str_replace(array("\r", "\n"), '', $v); - header("$k: $v"); - $hdrs .= "$k: $v\r\n"; - } - - $this->response = $hdrs . "\r\n" . $response; - print $response; - } - - function &callMethod($methodname, &$args) - { - if ($this->callHandler) { - $ret = @call_user_func_array($this->callHandler, array($methodname, $args)); - return $ret; - } - - set_error_handler(array($this, '_errorHandler')); - - if ($args) { - /* Call method with parameters. */ - if (isset($this->soapobject) && is_object($this->soapobject)) { - $ret = call_user_func_array(array(&$this->soapobject, $methodname), $args); - } else { - $ret = call_user_func_array($methodname, $args); - } - } else { - /* Call method withour parameters. */ - if (is_object($this->soapobject)) { - $ret = call_user_func(array(&$this->soapobject, $methodname)); - } else { - $ret = call_user_func($methodname); - } - } - - restore_error_handler(); - - return $ret; - } - - /** - * Creates SOAP_Value objects with return values from method. - * Uses method signature to determine type. - * - * @param mixed $method_response The result(s). - * @param array|string $type The type(s) of the return value(s). - * @param string $return_name The name of the return value. - * @param string $namespace The namespace of the return value. - * - * @return array List of SOAP_Value objects. - */ - function buildResult(&$method_response, &$return_type, - $return_name = 'return', $namespace = '') - { - if (is_a($method_response, 'SOAP_Value')) { - $return_val = array($method_response); - } else { - if (is_array($return_type) && is_array($method_response)) { - $i = 0; - - foreach ($return_type as $key => $type) { - if (is_numeric($key)) { - $key = 'item'; - } - if (is_a($method_response[$i], 'SOAP_Value')) { - $return_val[] =& $method_response[$i++]; - } else { - $qn = new QName($key, $namespace); - $return_val[] = new SOAP_Value($qn->fqn(), $type, $method_response[$i++]); - } - } - } else { - if (is_array($return_type)) { - $keys = array_keys($return_type); - if (!is_numeric($keys[0])) { - $return_name = $keys[0]; - } - $values = array_values($return_type); - $return_type = $values[0]; - } - $qn = new QName($return_name, $namespace); - $return_val = array(new SOAP_Value($qn->fqn(), $return_type, $method_response)); - } - } - return $return_val; - } - - function parseRequest($data = '', $attachments = null) - { - /* Parse response, get SOAP_Parser object. */ - $parser = new SOAP_Parser($data, $this->xml_encoding, $attachments); - - if ($parser->fault) { - /* Fault occurred during message parsing. */ - $this->fault = $parser->fault; - return null; - } - if (!count($parser->root_struct_name)) { - /* No method specified. */ - $this->_raiseSoapFault('No method specified in request.'); - return null; - } - - /* Handle message headers. */ - $request_headers = $parser->getHeaders(); - $header_results = array(); - - if ($request_headers) { - if (!is_a($request_headers, 'SOAP_Value')) { - $this->_raiseSoapFault('Parser did not return SOAP_Value object: ' . $request_headers, '', '', 'Server'); - return null; - } - if ($request_headers->value) { - /* Handle headers now. */ - foreach ($request_headers->value as $header_val) { - $f_exists = $this->validateMethod($header_val->name, $header_val->namespace); - - /* TODO: this does not take into account message routing - * yet. */ - $myactor = !$header_val->actor || - $header_val->actor == 'http://schemas.xmlsoap.org/soap/actor/next' || - $header_val->actor == $this->endpoint; - - if (!$f_exists && $header_val->mustunderstand && $myactor) { - $this->_raiseSoapFault('I don\'t understand header ' . $header_val->name, '', '', 'MustUnderstand'); - return null; - } - - /* We only handle the header if it's for us. */ - $isok = $f_exists && $myactor; - - if ($isok) { - /* Call our header now! */ - $header_method = $header_val->name; - $header_data = array($this->_decode($header_val)); - /* If there are parameters to pass. */ - $hr =& $this->callMethod($header_method, $header_data); - if (PEAR::isError($hr)) { - $this->_raiseSoapFault($hr); - return null; - } - $results = $this->buildResult($hr, $this->return_type, $header_method, $header_val->namespace); - $header_results[] = $results[0]; - } - } - } - } - - /* Handle the method call. */ - /* Evaluate message, getting back a SOAP_Value object. */ - $this->call_methodname = $this->methodname = $parser->root_struct_name[0]; - - /* Figure out the method namespace. */ - $this->method_namespace = $parser->message[$parser->root_struct[0]]['namespace']; - - if ($this->_wsdl) { - $this->_setSchemaVersion($this->_wsdl->xsd); - $dataHandler = $this->_wsdl->getDataHandler($this->methodname, $this->method_namespace); - if ($dataHandler) - $this->call_methodname = $this->methodname = $dataHandler; - - $this->_portName = $this->_wsdl->getPortName($this->methodname); - if (PEAR::isError($this->_portName)) { - $this->_raiseSoapFault($this->_portName); - return null; - } - $opData = $this->_wsdl->getOperationData($this->_portName, $this->methodname); - if (PEAR::isError($opData)) { - $this->_raiseSoapFault($opData); - return null; - } - $this->_options['style'] = $opData['style']; - $this->_options['use'] = $opData['output']['use']; - $this->_options['parameters'] = $opData['parameters']; - } - - /* Does method exist? */ - if (!$this->methodname || - !$this->validateMethod($this->methodname, $this->method_namespace)) { - $this->_raiseSoapFault('method "' . $this->method_namespace . $this->methodname . '" not defined in service', '', '', 'Server'); - return null; - } - - if (!$request_val = $parser->getResponse()) { - return null; - } - if (!is_a($request_val, 'SOAP_Value')) { - $this->_raiseSoapFault('Parser did not return SOAP_Value object: ' . $request_val, '', '', 'Server'); - return null; - } - - /* Verify that SOAP_Value objects in request match the methods - * signature. */ - if (!$this->verifyMethod($request_val)) { - /* verifyMethod() creates the fault. */ - return null; - } - - /* Need to set special error detection inside the value class to - * differentiate between no params passed, and an error decoding. */ - $request_data = $this->__decodeRequest($request_val); - if (PEAR::isError($request_data)) { - $this->_raiseSoapFault($request_data); - return null; - } - $method_response =& $this->callMethod($this->call_methodname, $request_data); - if (PEAR::isError($method_response)) { - $this->_raiseSoapFault($method_response); - return null; - } - - if ($this->_options['parameters'] || - !$method_response || - $this->_options['style'] == 'rpc') { - /* Get the method result. */ - if (is_null($method_response)) { - $return_val = null; - } else { - $return_val = $this->buildResult($method_response, $this->return_type); - } - - $qn = new QName($this->methodname . 'Response', $this->method_namespace); - $methodValue = new SOAP_Value($qn->fqn(), 'Struct', $return_val); - } else { - $methodValue =& $method_response; - } - return $this->makeEnvelope($methodValue, $header_results, $this->response_encoding); - } - - function &__decodeRequest($request, $shift = false) - { - if (!$request) { - $decoded = null; - return $decoded; - } - - /* Check for valid response. */ - if (PEAR::isError($request)) { - $fault = &$this->_raiseSoapFault($request); - return $fault; - } else if (!is_a($request, 'SOAP_Value')) { - $fault = &$this->_raiseSoapFault('Invalid data in server::__decodeRequest'); - return $fault; - } - - /* Decode to native php datatype. */ - $requestArray = $this->_decode($request); - /* Fault? */ - if (PEAR::isError($requestArray)) { - $fault = &$this->_raiseSoapFault($requestArray); - return $fault; - } - if (is_object($requestArray) && - get_class($requestArray) == 'stdClass') { - $requestArray = get_object_vars($requestArray); - } elseif ($this->_options['style'] == 'document') { - $requestArray = array($requestArray); - } - if (is_array($requestArray)) { - if (isset($requestArray['faultcode']) || - isset($requestArray[SOAP_BASE::SOAPENVPrefix().':faultcode'])) { - $faultcode = $faultstring = $faultdetail = $faultactor = ''; - foreach ($requestArray as $k => $v) { - if (stristr($k, 'faultcode')) { - $faultcode = $v; - } - if (stristr($k, 'faultstring')) { - $faultstring = $v; - } - if (stristr($k, 'detail')) { - $faultdetail = $v; - } - if (stristr($k, 'faultactor')) { - $faultactor = $v; - } - } - $fault = &$this->_raiseSoapFault($faultstring, $faultdetail, $faultactor, $faultcode); - return $fault; - } - /* Return array of return values. */ - if ($shift && count($requestArray) == 1) { - $decoded = array_shift($requestArray); - return $decoded; - } - return $requestArray; - } - return $requestArray; - } - - function verifyMethod($request) - { - if (!$this->callValidation) { - return true; - } - - $params = $request->value; - - /* Get the dispatch map if one exists. */ - $map = null; - if (array_key_exists($this->methodname, $this->dispatch_map)) { - $map = $this->dispatch_map[$this->methodname]; - } elseif (isset($this->soapobject)) { - if (method_exists($this->soapobject, '__dispatch')) { - $map = $this->soapobject->__dispatch($this->methodname); - } elseif (method_exists($this->soapobject, $this->methodname)) { - if (isset($this->soapobject->__dispatch_map[$this->methodname])) { - // pdp - 2011-04-29 - declared output will be copied to return_type and use in buildResult - $map = $this->soapobject->__dispatch_map[$this->methodname]; - } else { - /* No map, all public functions are SOAP functions. */ - return true; - } - } - } - if (!$map) { - $this->_raiseSoapFault('SOAP request specified an unhandled method "' . $this->methodname . '"', '', '', 'Client'); - return false; - } - - /* If we aliased the SOAP method name to a PHP function, change - * call_methodname so we do the right thing. */ - if (array_key_exists('alias', $map) && !empty($map['alias'])) { - $this->call_methodname = $map['alias']; - } - - /* If there are input parameters required. */ - if ($map['in']) { - $this->input_value = count($map['in']); - $this->return_type = false; - if (is_array($map['out'])) { - $this->return_type = count($map['out']) > 1 - ? $map['out'] - : array_shift($map['out']); - } - if (is_array($params)) { - /* Validate the number of parameters. */ - if (count($params) == count($map['in'])) { - /* Make array of param types. */ - foreach ($params as $param) { - $p[] = strtolower($param->type); - } - $sig_t = array_values($map['in']); - /* Validate each param's type. */ - for ($i = 0; $i < count($p); $i++) { - /* If SOAP types do not match, it's still fine if the - * mapped php types match this allows using plain PHP - * variables to work (i.e. stuff like Decimal would - * fail otherwise). We consider this only error if the - * types exist in our type maps, and they differ. */ - if (strcasecmp($sig_t[$i], $p[$i]) != 0 && - isset($this->_typemap[SOAP_XML_SCHEMA_VERSION][$sig_t[$i]]) && - strcasecmp($this->_typemap[SOAP_XML_SCHEMA_VERSION][$sig_t[$i]], $this->_typemap[SOAP_XML_SCHEMA_VERSION][$p[$i]]) != 0) { - - $param = $params[$i]; - $this->_raiseSoapFault("SOAP request contained mismatching parameters of name $param->name had type [{$p[$i]}], which did not match signature's type: [{$sig_t[$i]}], matched? " . (strcasecmp($sig_t[$i], $p[$i])), '', '', 'Client'); - return false; - } - } - return true; - } else { - /* Wrong number of params. */ - $this->_raiseSoapFault('SOAP request contained incorrect number of parameters. method "' . $this->methodname . '" required ' . count($map['in']) . ' and request provided ' . count($params), '', '', 'Client'); - return false; - } - } else { - /* No params. */ - $this->_raiseSoapFault('SOAP request contained incorrect number of parameters. method "' . $this->methodname . '" requires ' . count($map['in']) . ' parameters, and request provided none.', '', '', 'Client'); - return false; - } - } - - /* We'll try it anyway. */ - return true; - } - - function validateMethod($methodname, $namespace = null) - { - unset($this->soapobject); - - if (!$this->callValidation) { - return true; - } - - /* No SOAP access to private functions. */ - if ($methodname[0] == '_') { - return false; - } - - /* if it's in our function list, ok */ - if (array_key_exists($methodname, $this->dispatch_map) && - (!$namespace || - !array_key_exists('namespace', $this->dispatch_map[$methodname]) || - $namespace == $this->dispatch_map[$methodname]['namespace'])) { - if (array_key_exists('namespace', $this->dispatch_map[$methodname])) - $this->method_namespace = $this->dispatch_map[$methodname]['namespace']; - return true; - } - - /* if it's in an object, it's ok */ - if (isset($this->dispatch_objects[$namespace])) { - $c = count($this->dispatch_objects[$namespace]); - for ($i = 0; $i < $c; $i++) { - $obj =& $this->dispatch_objects[$namespace][$i]; - /* If we have a dispatch map, and the function is not in the - * dispatch map, then it is not callable! */ - if (method_exists($obj, '__dispatch')) { - if ($obj->__dispatch($methodname)) { - $this->method_namespace = $namespace; - $this->soapobject =& $obj; - return true; - } - } elseif (method_exists($obj, $methodname)) { - $this->method_namespace = $namespace; - $this->soapobject =& $obj; - return true; - } - } - } - - return false; - } - - function addObjectMap(&$obj, $namespace = null, $service_name = 'Default', - $service_desc = '') - { - if (!$namespace) { - if (isset($obj->namespace)) { - // XXX a bit of backwards compatibility - $namespace = $obj->namespace; - } else { - $this->_raiseSoapFault('No namespace provided for class!', '', '', 'Server'); - return false; - } - } - if (!isset($this->dispatch_objects[$namespace])) { - $this->dispatch_objects[$namespace] = array(); - } - $this->dispatch_objects[$namespace][] =& $obj; - - // Create internal WSDL structures for object - - // XXX Because some internal workings of PEAR::SOAP decide whether to - // do certain things by the presence or absence of _wsdl, we should - // only create a _wsdl structure if we know we can fill it; if - // __dispatch_map or __typedef for the object is missing, we should - // avoid creating it. Later, when we are using PHP 5 introspection, we - // will be able to make the data for all objects without any extra - // information from the developers, and this condition should be - // dropped. - - // XXX Known issue: if imported WSDL (bindWSDL) or another WSDL source - // is used to add _wsdl structure information, then addObjectWSDL is - // used, there is a high possibility of _wsdl data corruption; - // therefore you should avoid using __dispatch_map/__typedef - // definitions AND other WSDL data sources in the same service. We - // exclude classes that don't have __typedefs to allow external WSDL - // files to be used with classes with no internal type definitions - // (the types are defined in the WSDL file). When addObjectWSDL is - // refactored to not cause corruption, this restriction can be - // relaxed. - - // In summary, if you add an object with both a dispatch map and type - // definitions, then previous WSDL file operation and type definitions - // will be overwritten. - if (isset($obj->__dispatch_map) && isset($obj->__typedef)) { - $this->addObjectWSDL($obj, $namespace, $service_name, $service_desc); - } - - return true; - } - - /** - * Adds a method to the dispatch map. - */ - function addToMap($methodname, $in, $out, $namespace = null, $alias = null) - { - if (!$this->callHandler && !function_exists($methodname)) { - $this->_raiseSoapFault('Error mapping function', '', '', 'Server'); - return false; - } - - $this->dispatch_map[$methodname]['in'] = $in; - $this->dispatch_map[$methodname]['out'] = $out; - $this->dispatch_map[$methodname]['alias'] = $alias; - if ($namespace) { - $this->dispatch_map[$methodname]['namespace'] = $namespace; - } - - return true; - } - - function setCallHandler($callHandler, $validation = true) - { - $this->callHandler = $callHandler; - $this->callValidation = $validation; - } - - /** - * @deprecated use bindWSDL from now on - */ - function bind($wsdl_url) - { - $this->bindWSDL($wsdl_url); - } - - /** - * @param string a url to a WSDL resource - * @return void - */ - function bindWSDL($wsdl_url) - { - /* Instantiate WSDL class. */ - $this->_wsdl = new SOAP_WSDL($wsdl_url); - if ($this->_wsdl->fault) { - $this->_raiseSoapFault($this->_wsdl->fault); - } - } - - /** - * @return void - */ - function addObjectWSDL($wsdl_obj, $targetNamespace, $service_name, - $service_desc = '') - { - if (!isset($this->_wsdl)) { - $this->_wsdl = new SOAP_WSDL; - } - - $this->_wsdl->parseObject($wsdl_obj, $targetNamespace, $service_name, $service_desc); - - if ($this->_wsdl->fault) { - $this->_raiseSoapFault($this->_wsdl->fault); - } - } - -} diff --git a/data/module/SOAP/Server/Email.php b/data/module/SOAP/Server/Email.php deleted file mode 100644 index abeec61f057..00000000000 --- a/data/module/SOAP/Server/Email.php +++ /dev/null @@ -1,199 +0,0 @@ - Port to PEAR and more - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** SOAP_Server */ -require_once 'SOAP/Server.php'; -require_once 'SOAP/Client.php'; -require_once 'SOAP/Transport.php'; -require_once 'Mail/mimeDecode.php'; - -/** - * SOAP Server Class that implements an email SOAP server. - * http://www.pocketsoap.com/specs/smtpbinding/ - * - * This class overrides the default HTTP server, providing the ability to - * parse an email message and execute SOAP calls. This class DOES NOT pop the - * message; the message, complete with headers, must be passed in as a - * parameter to the service function call. - * - * @access public - * @package SOAP - * @author Shane Caraveo - */ -class SOAP_Server_Email extends SOAP_Server { - - var $headers = array(); - - function SOAP_Server_Email($send_response = true) - { - parent::SOAP_Server(); - $this->send_response = $send_response; - } - - /** - * Removes HTTP headers from response. - * - * TODO: use PEAR email classes - * - * @return boolean - * @access private - */ - function _parseEmail(&$data) - { - if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $data, $match)) { - - if (preg_match_all('/^(.*?):\s+(.*)$/m', $match[1], $matches)) { - $hc = count($matches[0]); - for ($i = 0; $i < $hc; $i++) { - $this->headers[strtolower($matches[1][$i])] = trim($matches[2][$i]); - } - } - - if (!stristr($this->headers['content-type'], 'text/xml')) { - $this->_raiseSoapFault('Invalid Content Type', '', '', 'Client'); - return false; - } - - if (strcasecmp($this->headers['content-transfer-encoding'], 'base64')==0) { - /* Unfold lines. */ - $enctext = preg_replace("/[\r|\n]/", '', $match[2]); - $data = base64_decode($enctext); - } else { - $data = $match[2]; - } - - /* If no content, return false. */ - return strlen($this->request) > 0; - } - - $this->_raiseSoapFault('Invalid Email Format', '', '', 'Client'); - - return false; - } - - function client(&$data) - { - $attachments = array(); - - /* If neither matches, we'll just try it anyway. */ - if (stristr($data, 'Content-Type: application/dime')) { - $this->_decodeDIMEMessage($data, $this->headers, $attachments); - } elseif (stristr($data, 'MIME-Version:')) { - /* This is a mime message, let's decode it. */ - $this->_decodeMimeMessage($data, $this->headers, $attachments); - } else { - /* The old fallback, but decodeMimeMessage handles things fine. */ - $this->_parseEmail($data); - } - - /* Get the character encoding of the incoming request treat incoming - * data as UTF-8 if no encoding set. */ - if (!$this->soapfault && - !$this->_getContentEncoding($this->headers['content-type'])) { - $this->xml_encoding = SOAP_DEFAULT_ENCODING; - /* An encoding we don't understand, return a fault. */ - $this->_raiseSoapFault('Unsupported encoding, use one of ISO-8859-1, US-ASCII, UTF-8', '', '', 'Server'); - } - - if ($this->soapfault) { - return $this->soapfault->getFault(); - } - - $client = new SOAP_Client(null); - - return $client->parseResponse($data, $this->xml_encoding, $this->attachments); - } - - function service(&$data, $endpoint = '', $send_response = true, - $dump = false) - { - $this->endpoint = $endpoint; - $attachments = array(); - $headers = array(); - - /* If neither matches, we'll just try it anyway. */ - if (stristr($data, 'Content-Type: application/dime')) { - $this->_decodeDIMEMessage($data, $this->headers, $attachments); - $useEncoding = 'DIME'; - } elseif (stristr($data, 'MIME-Version:')) { - /* This is a mime message, let's decode it. */ - $this->_decodeMimeMessage($data, $this->headers, $attachments); - $useEncoding = 'Mime'; - } else { - /* The old fallback, but decodeMimeMessage handles things fine. */ - $this->_parseEmail($data); - } - - /* Get the character encoding of the incoming request treat incoming - * data as UTF-8 if no encoding set. */ - if (!$this->_getContentEncoding($this->headers['content-type'])) { - $this->xml_encoding = SOAP_DEFAULT_ENCODING; - /* An encoding we don't understand, return a fault. */ - $this->_raiseSoapFault('Unsupported encoding, use one of ISO-8859-1, US-ASCII, UTF-8', '', '', 'Server'); - $response = $this->getFaultMessage(); - } - - if ($this->soapfault) { - $response = $this->soapfault->message(); - } else { - $soap_msg = $this->parseRequest($data,$attachments); - - /* Handle Mime or DIME encoding. */ - /* TODO: DIME Encoding should move to the transport, do it here - * for now and for ease of getting it done. */ - if (count($this->_attachments)) { - if ($useEncoding == 'Mime') { - $soap_msg = $this->_makeMimeMessage($soap_msg); - } else { - /* Default is DIME. */ - $soap_msg = $this->_makeDIMEMessage($soap_msg); - $soap_msg['headers']['Content-Type'] = 'application/dime'; - } - if (PEAR::isError($soap_msg)) { - return $this->raiseSoapFault($soap_msg); - } - } - - if (is_array($soap_msg)) { - $response = $soap_msg['body']; - if (count($soap_msg['headers'])) { - $headers = $soap_msg['headers']; - } - } else { - $response = $soap_msg; - } - } - - if ($this->send_response) { - if ($dump) { - print $response; - } else { - $from = array_key_exists('reply-to', $this->headers) ? $this->headers['reply-to'] : $this->headers['from']; - - $soap_transport =& SOAP_Transport::getTransport('mailto:' . $from, $this->response_encoding); - $from = $this->endpoint ? $this->endpoint : $this->headers['to']; - $headers['In-Reply-To'] = $this->headers['message-id']; - $options = array('from' => $from, 'subject' => $this->headers['subject'], 'headers' => $headers); - $soap_transport->send($response, $options); - } - } - } -} diff --git a/data/module/SOAP/Server/Email_Gateway.php b/data/module/SOAP/Server/Email_Gateway.php deleted file mode 100644 index f31bd89d503..00000000000 --- a/data/module/SOAP/Server/Email_Gateway.php +++ /dev/null @@ -1,139 +0,0 @@ - Port to PEAR and more - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** SOAP_Server_Email */ -require_once 'SOAP/Server/Email.php'; -require_once 'SOAP/Transport.php'; - -/** - * SOAP Server Class that implements an email SOAP server. - * http://www.pocketsoap.com/specs/smtpbinding/ - * - * This class overrides the default HTTP server, providing the ability to - * parse an email message and execute soap calls. This class DOES NOT pop the - * message; the message, complete with headers, must be passed in as a - * parameter to the service function call. - * - * This class calls a provided HTTP SOAP server, forwarding the email request, - * then sending the HTTP response out as an email. - * - * @access public - * @package SOAP - * @author Shane Caraveo - */ -class SOAP_Server_Email_Gateway extends SOAP_Server_Email { - - var $gateway = null; - var $dump = false; - - function SOAP_Server_Email_Gateway($gateway = '', $send_response = true, - $dump = false) - { - parent::SOAP_Server(); - $this->send_response = $send_response; - $this->gateway = $gateway; - $this->dump = $dump; - } - - function service(&$data, $gateway = '', $endpoint = '', - $send_response = true, $dump = false) - { - $this->endpoint = $endpoint; - $response = ''; - $useEncoding = 'Mime'; - $options = array(); - if (!$gateway) { - $gateway = $this->gateway; - } - - /* We have a full set of headers, need to find the first blank - * line. */ - $this->_parseEmail($data); - if ($this->fault) { - $response = $this->fault->message(); - } - if ($this->headers['content-type'] == 'application/dime') - $useEncoding = 'DIME'; - - /* Call the HTTP Server. */ - if (!$response) { - $soap_transport =& SOAP_Transport::getTransport($gateway, $this->xml_encoding); - if ($soap_transport->fault) { - $response = $soap_transport->fault->message(); - } - } - - /* Send the message. */ - if (!$response) { - $options['soapaction'] = $this->headers['soapaction']; - $options['headers']['Content-Type'] = $this->headers['content-type']; - - $response = $soap_transport->send($data, $options); - if (isset($this->headers['mime-version'])) - $options['headers']['MIME-Version'] = $this->headers['mime-version']; - - if ($soap_transport->fault) { - $response = $soap_transport->fault->message(); - } else { - foreach ($soap_transport->transport->attachments as $cid => $body) { - $this->attachments[] = array('body' => $body, 'cid' => $cid, 'encoding' => 'base64'); - } - if (count($this->_attachments)) { - if ($useEncoding == 'Mime') { - $soap_msg = $this->_makeMimeMessage($response); - $options['headers']['MIME-Version'] = '1.0'; - } else { - /* Default is DIME. */ - $soap_msg = $this->_makeDIMEMessage($response); - $options['headers']['Content-Type'] = 'application/dime'; - } - if (PEAR::isError($soap_msg)) { - return $this->_raiseSoapFault($soap_msg); - } - if (is_array($soap_msg)) { - $response = $soap_msg['body']; - if (count($soap_msg['headers'])) { - if (isset($options['headers'])) { - $options['headers'] = array_merge($options['headers'], $soap_msg['headers']); - } else { - $options['headers'] = $soap_msg['headers']; - } - } - } - } - } - } - - if ($this->send_response) { - if ($this->dump || $dump) { - print $response; - } else { - $from = array_key_exists('reply-to', $this->headers) ? $this->headers['reply-to'] : $this->headers['from']; - - $soap_transport =& SOAP_Transport::getTransport('mailto:' . $from, $this->response_encoding); - $from = $this->endpoint ? $this->endpoint : $this->headers['to']; - $headers = array('In-Reply-To' => $this->headers['message-id']); - $options = array('from' => $from, 'subject'=> $this->headers['subject'], 'headers' => $headers); - $soap_transport->send($response, $options); - } - } - } -} diff --git a/data/module/SOAP/Server/TCP.php b/data/module/SOAP/Server/TCP.php deleted file mode 100644 index ad273b4494f..00000000000 --- a/data/module/SOAP/Server/TCP.php +++ /dev/null @@ -1,96 +0,0 @@ - Port to PEAR and more - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'SOAP/Server.php'; - -require_once 'SOAP/Server/TCP/Handler.php'; - - -/** - * SOAP Server Class that implements a TCP SOAP Server. - * http://www.pocketsoap.com/specs/smtpbinding/ - * - * This class overrides the default HTTP server, providing the ability to - * accept socket connections and execute SOAP calls. - * - * TODO: - * use Net_Socket - * implement some security scheme - * implement support for attachments - * - * @access public - * @package SOAP - * @author Shane Caraveo - */ -class SOAP_Server_TCP extends SOAP_Server { - - var $headers = array(); - var $localaddr; - var $port; - var $type; - - function SOAP_Server_TCP($localaddr = '127.0.0.1', $port = 10000, - $type = 'sequential') - { - parent::SOAP_Server(); - $this->localaddr = $localaddr; - $this->port = $port; - $this->type = $type; - } - - function run($idleTimeout = null) - { - $server = &Net_Server::create($this->type, $this->localaddr, - $this->port); - if (PEAR::isError($server)) { - echo $server->getMessage()."\n"; - } - - $handler = &new SOAP_Server_TCP_Handler; - $handler->setSOAPServer($this); - - // hand over the object that handles server events - $server->setCallbackObject($handler); - $server->readEndCharacter = ''; - $server->setIdleTimeout($idleTimeout); - - // start the server - $server->start(); - } - - function service(&$data) - { - /* TODO: we need to handle attachments somehow. */ - $response = $this->parseRequest($data); - if ($this->fault) { - $response = $this->fault->message($this->response_encoding); - } - return $response; - } - - function onStart() - { - } - - function onIdle() - { - } -} diff --git a/data/module/SOAP/Server/TCP/Handler.php b/data/module/SOAP/Server/TCP/Handler.php deleted file mode 100644 index 0ca6f778685..00000000000 --- a/data/module/SOAP/Server/TCP/Handler.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** - * server base class - */ -require_once 'Net/Server.php'; - -/** - * base class for the handler - */ -require_once 'Net/Server/Handler.php'; - - -/** - * SOAP Server Class that implements a TCP SOAP Server. - * http://www.pocketsoap.com/specs/smtpbinding/ - * - * This class overrides the default HTTP server, providing the ability to - * accept socket connections and execute SOAP calls. - * - * @access public - * @package SOAP - * @author Tomasz Rup - */ -class SOAP_Server_TCP_Handler extends Net_Server_Handler { - - var $_SOAP_Server; - - function setSOAPServer(&$server) - { - $this->_SOAP_Server =& $server; - } - - /** - * If the user sends data, send it back to him - * - * @access public - * @param integer $clientId - * @param string $data - */ - function onReceiveData($clientId = 0, $data = '') - { - if (trim($data) <> '') { - $response = $this->_SOAP_Server->service($data); - $this->_server->sendData($clientId, $response); - } - } - - function onStart() - { - $this->_SOAP_Server->onStart(); - } - - function onIdle() - { - $this->_SOAP_Server->onIdle(); - } -} diff --git a/data/module/SOAP/Transport.php b/data/module/SOAP/Transport.php deleted file mode 100644 index 26414570534..00000000000 --- a/data/module/SOAP/Transport.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @author Shane Caraveo - * @author Jan Schneider - * @copyright 2003-2006 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'SOAP/Base.php'; - -/** - * SOAP Transport Layer - * - * This layer can use different protocols dependant on the endpoint url - * provided. - * - * No knowlege of the SOAP protocol is available at this level. - * No knowlege of the transport protocols is available at this level. - * - * @access public - * @package SOAP - * @author Shane Caraveo - * @author Jan Schneider - */ -class SOAP_Transport extends SOAP_Base -{ - /** - * Connection endpoint URL. - * - * @var string - */ - var $url = ''; - - /** - * Array containing urlparts. - * - * @see parse_url() - * - * @var mixed - */ - var $urlparts = null; - - /** - * Incoming payload. - * - * @var string - */ - var $incoming_payload = ''; - - /** - * Outgoing payload. - * - * @var string - */ - var $outgoing_payload = ''; - - /** - * Request encoding. - * - * @var string - */ - var $encoding = SOAP_DEFAULT_ENCODING; - - /** - * Response encoding. - * - * We assume UTF-8 if no encoding is set. - * - * @var string - */ - var $result_encoding = 'UTF-8'; - - /** - * Decoded attachments from the reponse. - * - * @var array - */ - var $attachments; - - /** - * Request User-Agent. - * - * @var string - */ - var $_userAgent = SOAP_LIBRARY_NAME; - - /** - * Sends and receives SOAP data. - * - * @access public - * @abstract - * - * @param string Outgoing SOAP data. - * @param array Options. - * - * @return string|SOAP_Fault - */ - function send($msg, $options = null) - { - return $this->_raiseSoapFault('SOAP_Transport::send() not implemented.'); - } - - function getTransport($url, $encoding = SOAP_DEFAULT_ENCODING) - { - $urlparts = @parse_url($url); - - if (!$urlparts['scheme']) { - return SOAP_Base_Object::_raiseSoapFault("Invalid transport URI: $url"); - } - - if (strcasecmp($urlparts['scheme'], 'mailto') == 0) { - $transport_type = 'SMTP'; - } elseif (strcasecmp($urlparts['scheme'], 'https') == 0) { - $transport_type = 'HTTP'; - } else { - /* Handle other transport types */ - $transport_type = strtoupper($urlparts['scheme']); - } - $transport_class = "SOAP_Transport_$transport_type"; - if (!class_exists($transport_class)) { - if (!(@include_once('SOAP/Transport/' . basename($transport_type) . '.php'))) { - return SOAP_Base_Object::_raiseSoapFault("No Transport for {$urlparts['scheme']}"); - } - } - if (!class_exists($transport_class)) { - return SOAP_Base_Object::_raiseSoapFault("No Transport class $transport_class"); - } - - return new $transport_class($url, $encoding); - } - -} diff --git a/data/module/SOAP/Transport/HTTP.php b/data/module/SOAP/Transport/HTTP.php deleted file mode 100644 index db6eae364aa..00000000000 --- a/data/module/SOAP/Transport/HTTP.php +++ /dev/null @@ -1,624 +0,0 @@ - - * @author Jan Schneider - * @copyright 2003-2006 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** - * HTTP Transport class - * - * @package SOAP - * @category Web Services - */ - -/** - * Needed Classes - */ -require_once 'SOAP/Transport.php'; - -/** - * HTTP Transport for SOAP - * - * @access public - * @package SOAP - * @author Shane Caraveo - * @author Jan Schneider - */ -class SOAP_Transport_HTTP extends SOAP_Transport -{ - /** - * Basic Auth string. - * - * @var array - */ - var $headers = array(); - - /** - * Cookies. - * - * @var array - */ - var $cookies; - - /** - * Connection timeout in seconds. 0 = none. - * - * @var integer - */ - var $timeout = 4; - - /** - * HTTP-Response Content-Type. - */ - var $result_content_type; - - var $result_headers = array(); - - var $result_cookies = array(); - - /** - * SOAP_Transport_HTTP Constructor - * - * @access public - * - * @param string $url HTTP url to SOAP endpoint. - * @param string $encoding Encoding to use. - */ - function SOAP_Transport_HTTP($url, $encoding = SOAP_DEFAULT_ENCODING) - { - parent::SOAP_Base('HTTP'); - $this->urlparts = @parse_url($url); - $this->url = $url; - $this->encoding = $encoding; - } - - /** - * Sends and receives SOAP data. - * - * @access public - * - * @param string Outgoing SOAP data. - * @param array Options. - * - * @return string|SOAP_Fault - */ - function send($msg, $options = array()) - { - $this->fault = null; - - if (!$this->_validateUrl()) { - return $this->fault; - } - - if (isset($options['timeout'])) { - $this->timeout = (int)$options['timeout']; - } - - if (strcasecmp($this->urlparts['scheme'], 'HTTP') == 0) { - return $this->_sendHTTP($msg, $options); - } elseif (strcasecmp($this->urlparts['scheme'], 'HTTPS') == 0) { - return $this->_sendHTTPS($msg, $options); - } - - return $this->_raiseSoapFault('Invalid url scheme ' . $this->url); - } - - /** - * Sets data for HTTP authentication, creates authorization header. - * - * @param string $username Username. - * @param string $password Response data, minus HTTP headers. - * - * @access public - */ - function setCredentials($username, $password) - { - $this->headers['Authorization'] = 'Basic ' . base64_encode($username . ':' . $password); - } - - /** - * Adds a cookie. - * - * @access public - * @param string $name Cookie name. - * @param mixed $value Cookie value. - */ - function addCookie($name, $value) - { - $this->cookies[$name] = $value; - } - - /** - * Generates the correct headers for the cookies. - * - * @access private - * - * @param array $options Cookie options. If 'nocookies' is set and true - * the cookies from the last response are added - * automatically. 'cookies' is name-value-hash with - * a list of cookies to add. - * - * @return string The cookie header value. - */ - function _generateCookieHeader($options) - { - $this->cookies = array(); - - if (empty($options['nocookies']) && - isset($this->result_cookies)) { - // Add the cookies we got from the last request. - foreach ($this->result_cookies as $cookie) { - if ($cookie['domain'] == $this->urlparts['host']) { - $this->cookies[$cookie['name']] = $cookie['value']; - } - } - } - - // Add cookies the user wants to set. - if (isset($options['cookies'])) { - foreach ($options['cookies'] as $cookie) { - if ($cookie['domain'] == $this->urlparts['host']) { - $this->cookies[$cookie['name']] = $cookie['value']; - } - } - } - - $cookies = ''; - foreach ($this->cookies as $name => $value) { - if (!empty($cookies)) { - $cookies .= '; '; - } - $cookies .= urlencode($name) . '=' . urlencode($value); - } - - return $cookies; - } - - /** - * Validate url data passed to constructor. - * - * @access private - * @return boolean - */ - function _validateUrl() - { - if (!is_array($this->urlparts) ) { - $this->_raiseSoapFault('Unable to parse URL ' . $this->url); - return false; - } - if (!isset($this->urlparts['host'])) { - $this->_raiseSoapFault('No host in URL ' . $this->url); - return false; - } - if (!isset($this->urlparts['port'])) { - if (strcasecmp($this->urlparts['scheme'], 'HTTP') == 0) { - $this->urlparts['port'] = 80; - } elseif (strcasecmp($this->urlparts['scheme'], 'HTTPS') == 0) { - $this->urlparts['port'] = 443; - } - - } - if (isset($this->urlparts['user'])) { - $this->setCredentials(urldecode($this->urlparts['user']), - urldecode($this->urlparts['pass'])); - } - if (!isset($this->urlparts['path']) || !$this->urlparts['path']) { - $this->urlparts['path'] = '/'; - } - - return true; - } - - /** - * Finds out what the encoding is. - * Sets the object property accordingly. - * - * @access private - * @param array $headers Headers. - */ - function _parseEncoding($headers) - { - $h = stristr($headers, 'Content-Type'); - preg_match_all('/^Content-Type:\s*(.*)$/im', $h, $ct, PREG_SET_ORDER); - $n = count($ct); - $ct = $ct[$n - 1]; - - // Strip the string of \r. - $this->result_content_type = str_replace("\r", '', $ct[1]); - - if (preg_match('/(.*?)(?:;\s?charset=)(.*)/i', - $this->result_content_type, - $m)) { - $this->result_content_type = $m[1]; - if (count($m) > 2) { - $enc = strtoupper(str_replace('"', '', $m[2])); - if (in_array($enc, $this->_encodings)) { - $this->result_encoding = $enc; - } - } - } - - // Deal with broken servers that don't set content type on faults. - if (!$this->result_content_type) { - $this->result_content_type = 'text/xml'; - } - } - - /** - * Parses the headers. - * - * @param array $headers The headers. - */ - function _parseHeaders($headers) - { - /* Largely borrowed from HTTP_Request. */ - $this->result_headers = array(); - $headers = preg_split("/\r?\n/", $headers); - foreach ($headers as $value) { - if (strpos($value, ':') === false) { - $this->result_headers[0] = $value; - continue; - } - list($name, $value) = explode(':', $value); - $headername = strtolower($name); - $headervalue = trim($value); - $this->result_headers[$headername] = $headervalue; - - if ($headername == 'set-cookie') { - // Parse a SetCookie header to fill _cookies array. - $cookie = array('expires' => null, - 'domain' => $this->urlparts['host'], - 'path' => null, - 'secure' => false); - - if (!strpos($headervalue, ';')) { - // Only a name=value pair. - list($cookie['name'], $cookie['value']) = array_map('trim', explode('=', $headervalue)); - $cookie['name'] = urldecode($cookie['name']); - $cookie['value'] = urldecode($cookie['value']); - - } else { - // Some optional parameters are supplied. - $elements = explode(';', $headervalue); - list($cookie['name'], $cookie['value']) = array_map('trim', explode('=', $elements[0])); - $cookie['name'] = urldecode($cookie['name']); - $cookie['value'] = urldecode($cookie['value']); - - for ($i = 1; $i < count($elements);$i++) { - list($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName OR 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->result_cookies[] = $cookie; - } - } - } - - /** - * Removes HTTP headers from response. - * - * @return boolean - * @access private - */ - function _parseResponse() - { - if (!preg_match("/^(.*?)\r?\n\r?\n(.*)/s", - $this->incoming_payload, - $match)) { - $this->_raiseSoapFault('Invalid HTTP Response'); - return false; - } - - $this->response = $match[2]; - // Find the response error, some servers response with 500 for - // SOAP faults. - $this->_parseHeaders($match[1]); - - list(, $code, $msg) = sscanf($this->result_headers[0], '%s %s %s'); - unset($this->result_headers[0]); - - switch($code) { - // Continue - case 100: - $this->incoming_payload = $match[2]; - return $this->_parseResponse(); - case 200: - case 202: - if (!strlen(trim($match[2]))) { - /* Valid one-way message response. */ - return true; - } - break; - case 400: - $this->_raiseSoapFault("HTTP Response $code Bad Request"); - return false; - case 401: - $this->_raiseSoapFault("HTTP Response $code Authentication Failed"); - return false; - case 403: - $this->_raiseSoapFault("HTTP Response $code Forbidden"); - return false; - case 404: - $this->_raiseSoapFault("HTTP Response $code Not Found"); - return false; - case 407: - $this->_raiseSoapFault("HTTP Response $code Proxy Authentication Required"); - return false; - case 408: - $this->_raiseSoapFault("HTTP Response $code Request Timeout"); - return false; - case 410: - $this->_raiseSoapFault("HTTP Response $code Gone"); - return false; - default: - if ($code >= 400 && $code < 500) { - $this->_raiseSoapFault("HTTP Response $code Not Found, Server message: $msg"); - return false; - } - break; - } - - $this->_parseEncoding($match[1]); - - if ($this->result_content_type == 'application/dime') { - // XXX quick hack insertion of DIME - if (PEAR::isError($this->_decodeDIMEMessage($this->response, $this->headers, $this->attachments))) { - // _decodeDIMEMessage already raised $this->fault - return false; - } - $this->result_content_type = $this->headers['content-type']; - } elseif (stristr($this->result_content_type, 'multipart/related')) { - $this->response = $this->incoming_payload; - if (PEAR::isError($this->_decodeMimeMessage($this->response, $this->headers, $this->attachments))) { - // _decodeMimeMessage already raised $this->fault - return false; - } - } elseif ($this->result_content_type != 'text/xml') { - $this->_raiseSoapFault($this->response); - return false; - } - - // if no content, return false - return strlen($this->response) > 0; - } - - /** - * Creates an HTTP request, including headers, for the outgoing request. - * - * @access private - * - * @param string $msg Outgoing SOAP package. - * @param array $options Options. - * - * @return string Outgoing payload. - */ - function _getRequest($msg, $options) - { - $this->headers = array(); - - $action = isset($options['soapaction']) ? $options['soapaction'] : ''; - $fullpath = $this->urlparts['path']; - if (isset($this->urlparts['query'])) { - $fullpath .= '?' . $this->urlparts['query']; - } - if (isset($this->urlparts['fragment'])) { - $fullpath .= '#' . $this->urlparts['fragment']; - } - - if (isset($options['proxy_host'])) { - $fullpath = 'http://' . $this->urlparts['host'] . ':' . - $this->urlparts['port'] . $fullpath; - } - - if (isset($options['proxy_user'])) { - $this->headers['Proxy-Authorization'] = 'Basic ' . - base64_encode($options['proxy_user'] . ':' . - $options['proxy_pass']); - } - - if (isset($options['user'])) { - $this->setCredentials($options['user'], $options['pass']); - } - - $this->headers['User-Agent'] = $this->_userAgent; - $this->headers['Host'] = $this->urlparts['host']; - $this->headers['Content-Type'] = "text/xml; charset=$this->encoding"; - $this->headers['Content-Length'] = strlen($msg); - $this->headers['SOAPAction'] = '"' . $action . '"'; - $this->headers['Connection'] = 'close'; - - if (isset($options['headers'])) { - $this->headers = array_merge($this->headers, $options['headers']); - } - - $cookies = $this->_generateCookieHeader($options); - if ($cookies) { - $this->headers['Cookie'] = $cookies; - } - - $headers = ''; - foreach ($this->headers as $k => $v) { - $headers .= "$k: $v\r\n"; - } - $this->outgoing_payload = "POST $fullpath HTTP/1.0\r\n" . $headers . - "\r\n" . $msg; - - return $this->outgoing_payload; - } - - /** - * Sends the outgoing HTTP request and reads and parses the response. - * - * @access private - * - * @param string $msg Outgoing SOAP package. - * @param array $options Options. - * - * @return string Response data without HTTP headers. - */ - function _sendHTTP($msg, $options) - { - $this->incoming_payload = ''; - $this->_getRequest($msg, $options); - $host = $this->urlparts['host']; - $port = $this->urlparts['port']; - if (isset($options['proxy_host'])) { - $host = $options['proxy_host']; - $port = isset($options['proxy_port']) ? $options['proxy_port'] : 8080; - } - // Send. - if ($this->timeout > 0) { - $fp = @fsockopen($host, $port, $this->errno, $this->errmsg, $this->timeout); - } else { - $fp = @fsockopen($host, $port, $this->errno, $this->errmsg); - } - if (!$fp) { - return $this->_raiseSoapFault("Connect Error to $host:$port"); - } - if ($this->timeout > 0) { - // some builds of PHP do not support this, silence the warning - @socket_set_timeout($fp, $this->timeout); - } - if (!fputs($fp, $this->outgoing_payload, strlen($this->outgoing_payload))) { - return $this->_raiseSoapFault("Error POSTing Data to $host"); - } - - // get reponse - // XXX time consumer - do { - $data = fread($fp, 4096); - $_tmp_status = socket_get_status($fp); - if ($_tmp_status['timed_out']) { - return $this->_raiseSoapFault("Timed out read from $host"); - } else { - $this->incoming_payload .= $data; - } - } while (!$_tmp_status['eof']); - - fclose($fp); - - if (!$this->_parseResponse()) { - return $this->fault; - } - return $this->response; - } - - /** - * Sends the outgoing HTTPS request and reads and parses the response. - * - * @access private - * - * @param string $msg Outgoing SOAP package. - * @param array $options Options. - * - * @return string Response data without HTTP headers. - */ - function _sendHTTPS($msg, $options) - { - /* Check if the required curl extension is installed. */ - if (!extension_loaded('curl')) { - return $this->_raiseSoapFault('CURL Extension is required for HTTPS'); - } - - $ch = curl_init(); - - if (isset($options['proxy_host'])) { - $port = isset($options['proxy_port']) ? $options['proxy_port'] : 8080; - curl_setopt($ch, CURLOPT_PROXY, - $options['proxy_host'] . ':' . $port); - } - if (isset($options['proxy_user'])) { - curl_setopt($ch, CURLOPT_PROXYUSERPWD, - $options['proxy_user'] . ':' . $options['proxy_pass']); - } - - if (isset($options['user'])) { - curl_setopt($ch, CURLOPT_USERPWD, - $options['user'] . ':' . $options['pass']); - } - - $headers = array(); - $action = isset($options['soapaction']) ? $options['soapaction'] : ''; - $headers['Content-Type'] = "text/xml; charset=$this->encoding"; - $headers['SOAPAction'] = '"' . $action . '"'; - if (isset($options['headers'])) { - $headers = array_merge($headers, $options['headers']); - } - foreach ($headers as $header => $value) { - $headers[$header] = $header . ': ' . $value; - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_USERAGENT, $this->_userAgent); - - if ($this->timeout) { - curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); - } - - curl_setopt($ch, CURLOPT_POSTFIELDS, $msg); - curl_setopt($ch, CURLOPT_URL, $this->url); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_FAILONERROR, 0); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, 1); - if (defined('CURLOPT_HTTP_VERSION')) { - curl_setopt($ch, CURLOPT_HTTP_VERSION, 1); - } - if (!ini_get('safe_mode') && !ini_get('open_basedir')) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); - } - $cookies = $this->_generateCookieHeader($options); - if ($cookies) { - curl_setopt($ch, CURLOPT_COOKIE, $cookies); - } - - if (isset($options['curl'])) { - foreach ($options['curl'] as $key => $val) { - curl_setopt($ch, $key, $val); - } - } - - // Save the outgoing XML. This doesn't quite match _sendHTTP as CURL - // generates the headers, but having the XML is usually the most - // important part for tracing/debugging. - $this->outgoing_payload = $msg; - - $this->incoming_payload = curl_exec($ch); - if (!$this->incoming_payload) { - $m = 'curl_exec error ' . curl_errno($ch) . ' ' . curl_error($ch); - curl_close($ch); - return $this->_raiseSoapFault($m); - } - curl_close($ch); - - if (!$this->_parseResponse()) { - return $this->fault; - } - - return $this->response; - } - -} diff --git a/data/module/SOAP/Transport/SMTP.php b/data/module/SOAP/Transport/SMTP.php deleted file mode 100644 index 5157317f62b..00000000000 --- a/data/module/SOAP/Transport/SMTP.php +++ /dev/null @@ -1,206 +0,0 @@ - - * @author Jan Schneider - * @copyright 2003-2006 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'SOAP/Transport.php'; -require_once 'Mail/smtp.php'; - -/** - * SMTP Transport for SOAP - * - * Implements SOAP-SMTP as defined at - * http://www.pocketsoap.com/specs/smtpbinding/ - * - * @todo use PEAR smtp and Mime classes - * - * @access public - * @package SOAP - * @author Shane Caraveo - * @author Jan Schneider - */ -class SOAP_Transport_SMTP extends SOAP_Transport -{ - var $credentials = ''; - var $timeout = 4; // connect timeout - var $host = '127.0.0.1'; - var $port = 25; - var $auth = null; - - /** - * SOAP_Transport_SMTP Constructor - * - * @param string $url mailto: address. - * - * @access public - */ - function SOAP_Transport_SMTP($url, $encoding = 'US-ASCII') - { - parent::SOAP_Base('SMTP'); - $this->encoding = $encoding; - $this->urlparts = @parse_url($url); - $this->url = $url; - } - - /** - * Sends and receives SOAP data. - * - * @access public - * - * @param string Outgoing SOAP data. - * @param array Options. - * - * @return string|SOAP_Fault - */ - function send($msg, $options = array()) - { - $this->fault = null; - $this->incoming_payload = ''; - $this->outgoing_payload = $msg; - if (!$this->_validateUrl()) { - return $this->fault; - } - if (!$options || !isset($options['from'])) { - return $this->_raiseSoapFault('No From: address to send message with'); - } - - if (isset($options['host'])) $this->host = $options['host']; - if (isset($options['port'])) $this->port = $options['port']; - if (isset($options['auth'])) $this->auth = $options['auth']; - if (isset($options['username'])) $this->username = $options['username']; - if (isset($options['password'])) $this->password = $options['password']; - - $headers = array(); - $headers['From'] = $options['from']; - $headers['X-Mailer'] = $this->_userAgent; - $headers['MIME-Version'] = '1.0'; - $headers['Message-ID'] = md5(time()) . '.soap@' . $this->host; - $headers['To'] = $this->urlparts['path']; - if (isset($options['soapaction'])) { - $headers['Soapaction'] = "\"{$options['soapaction']}\""; - } - - if (isset($options['headers'])) - $headers = array_merge($headers, $options['headers']); - - // If the content type is already set, we assume that MIME encoding is - // already done. - if (isset($headers['Content-Type'])) { - $out = $msg; - } else { - // Do a simple inline MIME encoding. - $headers['Content-Disposition'] = 'inline'; - $headers['Content-Type'] = "text/xml; charset=\"$this->encoding\""; - if (isset($options['transfer-encoding'])) { - if (strcasecmp($options['transfer-encoding'], 'quoted-printable') == 0) { - $headers['Content-Transfer-Encoding'] = $options['transfer-encoding']; - $out = $msg; - } elseif (strcasecmp($options['transfer-encoding'],'base64') == 0) { - $headers['Content-Transfer-Encoding'] = 'base64'; - $out = chunk_split(base64_encode($msg), 76, "\n"); - } else { - return $this->_raiseSoapFault("Invalid Transfer Encoding: {$options['transfer-encoding']}"); - } - } else { - // Default to base64. - $headers['Content-Transfer-Encoding'] = 'base64'; - $out = chunk_split(base64_encode($msg)); - } - } - - $headers['Subject'] = isset($options['subject']) ? $options['subject'] : 'SOAP Message'; - - foreach ($headers as $key => $value) { - $header_text .= "$key: $value\n"; - } - $this->outgoing_payload = $header_text . "\r\n" . $this->outgoing_payload; - - $mailer_params = array( - 'host' => $this->host, - 'port' => $this->port, - 'username' => $this->username, - 'password' => $this->password, - 'auth' => $this->auth - ); - $mailer = new Mail_smtp($mailer_params); - $result = $mailer->send($this->urlparts['path'], $headers, $out); - if (!PEAR::isError($result)) { - $val = new SOAP_Value('Message-ID', 'string', $headers['Message-ID']); - } else { - $sval[] = new SOAP_Value('faultcode', 'QName', SOAP_BASE::SOAPENVPrefix().':Client'); - $sval[] = new SOAP_Value('faultstring', 'string', "couldn't send SMTP message to {$this->urlparts['path']}"); - $val = new SOAP_Value('Fault', 'Struct', $sval); - } - - $methodValue = new SOAP_Value('Response', 'Struct', array($val)); - - $this->incoming_payload = $this->makeEnvelope($methodValue, - $this->headers, - $this->encoding); - - return $this->incoming_payload; - } - - /** - * Sets data for HTTP authentication, creates Authorization header. - * - * @param string $username Username. - * @param string $password Response data, minus HTTP headers. - * - * @access public - */ - function setCredentials($username, $password) - { - $this->username = $username; - $this->password = $password; - } - - /** - * Validates url data passed to constructor. - * - * @return boolean - * @access private - */ - function _validateUrl() - { - if (!is_array($this->urlparts)) { - $this->_raiseSoapFault("Unable to parse URL $this->url"); - return false; - } - if (!isset($this->urlparts['scheme']) || - strcasecmp($this->urlparts['scheme'], 'mailto') != 0) { - $this->_raiseSoapFault("Unable to parse URL $this->url"); - return false; - } - if (!isset($this->urlparts['path'])) { - $this->_raiseSoapFault("Unable to parse URL $this->url"); - return false; - } - return true; - } - -} diff --git a/data/module/SOAP/Transport/TCP.php b/data/module/SOAP/Transport/TCP.php deleted file mode 100644 index cc386c7b82b..00000000000 --- a/data/module/SOAP/Transport/TCP.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @author Jan Schneider - * @copyright 2003-2006 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'SOAP/Transport.php'; - -/** - * TCP transport for SOAP. - * - * @todo use Net_Socket; implement some security scheme; implement support - * for attachments - * @access public - * @package SOAP - * @author Shane Hanna - * @author Jan Schneider - */ -class SOAP_Transport_TCP extends SOAP_Transport -{ - /** - * Socket. - */ - var $socket = null; - - /** - * Constructor. - * - * @param string $url HTTP url to SOAP endpoint. - * - * @access public - */ - function SOAP_Transport_TCP($url, $encoding = SOAP_DEFAULT_ENCODING) - { - parent::SOAP_Base_Object('TCP'); - $this->urlparts = @parse_url($url); - $this->url = $url; - $this->encoding = $encoding; - } - - function _socket_ping() - { - // XXX how do we restart after socket_shutdown? - //if (!$this->socket) { - // Create socket resource. - $this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); - if ($this->socket < 0) { - return 0; - } - - // Connect. - $result = socket_connect($this->socket, $this->urlparts['host'], - $this->urlparts['port']); - if ($result < 0) { - return 0; - } - //} - return 1; - } - - /** - * Sends and receives SOAP data. - * - * @access public - * - * @param string Outgoing SOAP data. - * @param array Options. - * - * @return string|SOAP_Fault - */ - function send($msg, $options = array()) - { - $this->fault = null; - $this->incoming_payload = ''; - $this->outgoing_payload = $msg; - if (!$this->_validateUrl()) { - return $this->fault; - } - - // Check for TCP scheme. - if (strcasecmp($this->urlparts['scheme'], 'TCP') == 0) { - // Check connection. - if (!$this->_socket_ping()) { - return $this->_raiseSoapFault('Error connecting to ' . $this->url . '; reason: ' . socket_strerror(socket_last_error($this->socket))); - } - - // Write to the socket. - if (!@socket_write($this->socket, $this->outgoing_payload, - strlen($this->outgoing_payload))) { - return $this->_raiseSoapFault('Error sending data to ' . $this->url . '; reason: ' . socket_strerror(socket_last_error($this->socket))); - } - - // Shutdown writing. - if(!socket_shutdown($this->socket, 1)) { - return $this->_raiseSoapFault('Cannot change socket mode to read.'); - } - - // Read everything we can. - while ($buf = @socket_read($this->socket, 1024, PHP_BINARY_READ)) { - $this->incoming_payload .= $buf; - } - - // Return payload or die. - if ($this->incoming_payload) { - return $this->incoming_payload; - } - - return $this->_raiseSoapFault('Error reveiving data from ' . $this->url); - } - - return $this->_raiseSoapFault('Invalid url scheme ' . $this->url); - } - - /** - * Validates the url data passed to the constructor. - * - * @return boolean - * @access private - */ - function _validateUrl() - { - if (!is_array($this->urlparts) ) { - $this->_raiseSoapFault("Unable to parse URL $this->url"); - return false; - } - if (!isset($this->urlparts['host'])) { - $this->_raiseSoapFault("No host in URL $this->url"); - return false; - } - if (!isset($this->urlparts['path']) || !$this->urlparts['path']) { - $this->urlparts['path'] = '/'; - } - - return true; - } - -} diff --git a/data/module/SOAP/Transport/TEST.php b/data/module/SOAP/Transport/TEST.php deleted file mode 100644 index fabeba5e868..00000000000 --- a/data/module/SOAP/Transport/TEST.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright 2008 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'SOAP/Transport.php'; - -/** - * Test transport for SOAP. - * - * @access public - * @package SOAP - * @author Jan Schneider - */ -class SOAP_Transport_TEST extends SOAP_Transport -{ - /** - * Sends and receives SOAP data. - * - * @param string $msg Outgoing SOAP data. - * @param array $options Options. - * - * @return string|SOAP_Fault - */ - function send($msg, $options = array()) - { - $_SERVER['REQUEST_METHOD'] = 'POST'; - $this->outgoing_payload = $msg; - ob_start(); - $server = clone($options['server']); - $server->service($msg); - $this->incoming_payload = ob_get_contents(); - ob_end_clean(); - return $this->incoming_payload; - } - -} diff --git a/data/module/SOAP/Type/dateTime.php b/data/module/SOAP/Type/dateTime.php deleted file mode 100644 index 4fcec72f73f..00000000000 --- a/data/module/SOAP/Type/dateTime.php +++ /dev/null @@ -1,243 +0,0 @@ - Original Author - * @author Shane Caraveo Port to PEAR and more - * @author Jan Schneider Maintenance - * @copyright 2003-2007 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** - * This class converts from and to unix timestamps and ISO 8601 date/time. - * - * @access public - * @package SOAP - * @author Dietrich Ayala Original Author - * @author Shane Caraveo Port to PEAR and more - * @author Jan Schneider Maintenance - */ -class SOAP_Type_dateTime -{ - var $_iso8601 = - '# 1: centuries & years CCYY- - (-?[0-9]{4})- - # 2: months MM- - ([0-9]{2})- - # 3: days DD - ([0-9]{2}) - # 4: separator T - T - # 5: hours hh: - ([0-9]{2}): - # 6: minutes mm: - ([0-9]{2}): - # 7: seconds ss.ss... - ([0-9]{2})(\.[0-9]*)? - # 8: Z to indicate UTC, -+HH:MM:SS.SS... for local zones - (Z|[+\-][0-9]{4}|[+\-][0-9]{2}:[0-9]{2})?'; - - var $timestamp = -1; - - /** - * Constructor. - * - * @param string|integer $date The timestamp or ISO 8601 formatted - * date and time this object is going to - * represent. - */ - function SOAP_Type_dateTime($date = -1) - { - if ($date == -1) { - $this->timestamp = time(); - } elseif (is_int($date)) { - $this->timestamp = $date; - } else { - $this->timestamp = $this->toUnixtime($date); - } - } - - /** - * Alias of {@link SOAP_Type_dateTime::toUTC}. - */ - function toSOAP($date = NULL) - { - return $this->toUTC($date); - } - - /** - * Converts this object or a timestamp to an ISO 8601 date/time string. - * - * @param integer $timestamp A unix timestamp - * - * @return string An ISO 8601 formatted date/time string. - */ - function toString($timestamp = 0) - { - if (!$timestamp) { - $timestamp = $this->timestamp; - } - if ($timestamp < 0) { - return 0; - } - - //simulate PHP5's P parameter - $zone = date('O', $timestamp); - if (strlen($zone) === 5) { - $zone = substr($zone, 0, 3) . ':' . substr($zone, 3); - } - return date('Y-m-d\TH:i:s', $timestamp) . $zone; - } - - /** - * Splits a date/time into its components. - * - * @param string|integer $datestr A unix timestamp or ISO 8601 date/time - * string. If empty, this object is used. - * - * @return boolean|array An array with the date and time components or - * false on failure. - */ - function _split($datestr) - { - if (!$datestr) { - $datestr = $this->toString(); - } elseif (is_int($datestr)) { - $datestr = $this->toString($datestr); - } - - if (preg_match('/' . $this->_iso8601 . '/x', $datestr, $regs)) { - if (empty($regs[8])) { - $timestamp = strtotime(sprintf('%04d-%02d-%02d %02d:%02d:%02d', - $regs[1], - $regs[2], - $regs[3], - $regs[4], - $regs[5], - $regs[6])); - $regs[8] = date('O', $timestamp); - } - if ($regs[8] != 'Z') { - $op = substr($regs[8], 0, 1); - $h = substr($regs[8], 1, 2); - if (strstr($regs[8], ':')) { - $m = substr($regs[8], 4, 2); - } else { - $m = substr($regs[8], 3, 2); - } - if ($op == '+') { - $regs[4] = $regs[4] - $h; - if ($regs[4] < 0) { - $regs[4] += 24; - } - $regs[5] = $regs[5] - $m; - if ($regs[5] < 0) { - $regs[5] += 60; - } - } else { - $regs[4] = $regs[4] + $h; - if ($regs[4] > 23) { - $regs[4] -= 24; - } - $regs[5] = $regs[5] + $m; - if ($regs[5] > 59) { - $regs[5] -= 60; - } - } - } - return $regs; - } - - return false; - } - - /** - * Returns an ISO 8601 formatted UTC date/time string. - * - * @param string|integer $datestr @see SOAP_Type_dateTime::_split - * - * @return string The ISO 8601 formatted UTC date/time string. - */ - function toUTC($datestr = null) - { - $regs = $this->_split($datestr); - - if ($regs) { - return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', - $regs[1], - $regs[2], - $regs[3], - $regs[4], - $regs[5], - $regs[6]); - } - - return ''; - } - - /** - * Returns a unix timestamp. - * - * @param string|integer $datestr @see SOAP_Type_dateTime::_split - * - * @return integer The unix timestamp. - */ - function toUnixtime($datestr = null) - { - $regs = $this->_split($datestr); - if ($regs) { - return strtotime(sprintf('%04d-%02d-%02d %02d:%02d:%02dZ', - $regs[1], - $regs[2], - $regs[3], - $regs[4], - $regs[5], - $regs[6])); - } - return -1; - } - - /** - * Compares two dates or this object with a second date. - * - * @param string|integer $date1 A unix timestamp or ISO 8601 date/time - * string. - * @param string|integer $date2 A unix timestamp or ISO 8601 date/time - * string. If empty, this object is used. - * - * @return integer The difference between the first and the second date. - */ - function compare($date1, $date2 = null) - { - if (is_null($date2)) { - $date2 = $date1; - $date1 = $this->timestamp; - } - if (!is_int($date1)) { - $date1 = $this->toUnixtime($date1); - } - if (!is_int($date2)) { - $date2 = $this->toUnixtime($date2); - } - - if ($date1 != -1 && $date2 != -1) { - return $date1 - $date2; - } - - return -1; - } - -} diff --git a/data/module/SOAP/Type/duration.php b/data/module/SOAP/Type/duration.php deleted file mode 100644 index 64be22f8a3a..00000000000 --- a/data/module/SOAP/Type/duration.php +++ /dev/null @@ -1,194 +0,0 @@ - Port to PEAR and more - * @author Jan Schneider Maintenance - * @copyright 2003-2007 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -/** - * This is only an aproximation of duration, more work still to do. See the - * schema url for more info on duration. - * - * http://www.w3.org/TR/xmlschema-2/ - * - * [Definition:] duration represents a duration of time. The value space of - * duration is a six-dimensional space where the coordinates designate the - * Gregorian year, month, day, hour, minute, and second components - * defined in 5.5.3.2 of [ISO 8601], respectively. These components are - * ordered in their significance by their order of appearance i.e. as year, - * month, day, hour, minute, and second. - * - * 3.2.6.1 Lexical representation - * The lexical representation for duration is the [ISO 8601] extended - * format PnYn MnDTnH nMnS, where nY represents the number of - * years, nM the number of months, nD the number of days, 'T' is the - * date/time separator, nH the number of hours, nM the number of - * minutes and nS the number of seconds. The number of seconds - * can include decimal digits to arbitrary precision. - * - * The values of the Year, Month, Day, Hour and Minutes components - * are not restricted but allow an arbitrary integer. Similarly, the - * value of the Seconds component allows an arbitrary decimal. - * Thus, the lexical representation of duration does not follow the - * alternative format of 5.5.3.2.1 of [ISO 8601]. - * - * An optional preceding minus sign ('-') is allowed, to indicate a - * negative duration. If the sign is omitted a positive duration is - * indicated. See also ISO 8601 Date and Time Formats (D). - * - * For example, to indicate a duration of 1 year, 2 months, 3 days, - * 10 hours, and 30 minutes, one would write: P1Y2M3DT10H30M. - * One could also indicate a duration of minus 120 days as: -P120D. - * - * Reduced precision and truncated representations of this format - * are allowed provided they conform to the following: - * - * If the number of years, months, days, hours, minutes, or seconds - * in any expression equals zero, the number and its corresponding - * designator *may* be omitted. However, at least one number and - * its designator *must* be present. - * The seconds part *may* have a decimal fraction. - * The designator 'T' shall be absent if all of the time items are absent. - * The designator 'P' must always be present. - * For example, P1347Y, P1347M and P1Y2MT2H are all allowed; P0Y1347M - * and P0Y1347M0D are allowed. P-1347M is not allowed although -P1347M - * is allowed. P1Y2MT is not allowed. - * - * @access public - * @package SOAP - * @author Shane Caraveo Port to PEAR and more - * @author Jan Schneider Maintenance - * @todo Figure out best aproximation for year and month conversion to - * seconds - */ -class SOAP_Type_duration -{ - // format PnYnMnDTnHnMnS - function unix_to_duration($seconds) - { - return SOAP_Type_duration::getduration($seconds); - } - - function mod($a, $b, &$d, &$r) - { - $d = floor($a / $b); - $r = $a % $b; - } - - function getduration($seconds) - { - $neg = ''; - if ($seconds < 0) { - $neg = '-'; - $seconds = $seconds * -1; - } - - $_mi = 60; - $_h = $_mi * 60; - $_d = $_h * 24; - // XXX how do we properly handle month and year values? - $_m = $_d * 30; - $_y = $_d * 365; - - SOAP_Type_duration::mod($seconds, $_y, $y, $seconds); - SOAP_Type_duration::mod($seconds, $_m, $m, $seconds); - SOAP_Type_duration::mod($seconds, $_d, $d, $seconds); - SOAP_Type_duration::mod($seconds, $_h, $h, $seconds); - SOAP_Type_duration::mod($seconds, $_mi, $mi, $s); - - $duration = $neg.'P'; - if ($y) $duration .= $y.'Y'; - if ($m) $duration .= $m.'M'; - if ($d) $duration .= $d.'D'; - if ($h || $mi || $s) $duration .='T'; - if ($h) $duration .= $h.'H'; - if ($mi) $duration .= $mi.'M'; - if ($s) $duration .= $s.'S'; - if ($duration == 'P' || $duration == '-P') $duration = 'PT0S'; - - return $duration; - } - - function mkduration($n, $Y, $Mo, $D, $H, $Mi, $S) - { - $_mi = 60; - $_h = $_mi * 60; - $_d = $_h * 24; - // XXX how do we properly handle month and year values? - $_m = $_d * 30; - $_y = $_d * 365; - - $sec = $Y * $_y + $Mo * $_m + $D * $_d + $H * $_h + $Mi * $_mi + $S; - if ($n == '-') $sec = $sec * -1; - - return $sec; - } - - function duration_to_unix($duration) - { - if (preg_match('/(-)?P([0-9]+Y)?([0-9]+M)?([0-9]+D)?T?([0-9]+H)?([0-9]+M)?([0-9]+S)?/', $duration, $regs)) { - return SOAP_Type_duration::mkduration($regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6], $regs[7]); - } - return false; - } - - function is_duration($duration) - { - return preg_match('/(-)?P([0-9]+Y)?([0-9]+M)?([0-9]+D)?T?([0-9]+H)?([0-9]+M)?([0-9]+S)?/', $duration, $regs); - } - - function _test($time) - { - if (SOAP_Type_duration::is_duration($time)) { - $t = SOAP_Type_duration::duration_to_unix($time); - echo "Duration: $time is ".$t." seconds\n"; - } else { - $t = SOAP_Type_duration::unix_to_duration($time); - echo "Seconds: $time is ".$t." duration\n"; - } - return $t; - } - - function add($d1, $d2) - { - $s1 = SOAP_Type_duration::duration_to_unix($d1); - $s2 = SOAP_Type_duration::duration_to_unix($d2); - return SOAP_Type_duration::unix_to_duration($s1 + $s2); - } - - function subtract($d1, $d2) - { - $s1 = SOAP_Type_duration::duration_to_unix($d1); - $s2 = SOAP_Type_duration::duration_to_unix($d2); - return SOAP_Type_duration::unix_to_duration($s1 - $s2); - } - -} - -/* Tests. */ -$t = SOAP_Type_duration::_test('P1Y2M3DT10H30M'); -SOAP_Type_duration::_test($t); -$t = SOAP_Type_duration::_test('-P120D'); -SOAP_Type_duration::_test($t); - -/* Duration since 1970. */ -$t = SOAP_Type_duration::_test(time()); -SOAP_Type_duration::_test($t); - -echo 'Add should be PT0S: ' . SOAP_Type_duration::add('-P120D','P4M') . "\n"; -echo 'Subtract should be PT0S: ' . SOAP_Type_duration::subtract('P120D','P4M') . "\n"; diff --git a/data/module/SOAP/Type/hexBinary.php b/data/module/SOAP/Type/hexBinary.php deleted file mode 100644 index e6bbdf43da8..00000000000 --- a/data/module/SOAP/Type/hexBinary.php +++ /dev/null @@ -1,45 +0,0 @@ - Original Author - * @author Shane Caraveo Port to PEAR and more - * @copyright 2003-2007 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ -class SOAP_Type_hexBinary { - - function to_bin($value) - { - return pack('H' . strlen($value), $value); - } - - function to_hex($value) - { - return bin2hex($value); - } - - function is_hexbin($value) - { - // First see if there are any invalid chars. - if (!strlen($value) || preg_match('/[^A-Fa-f0-9]/', $value)) { - return false; - } - - return strcasecmp($value, SOAP_Type_hexBinary::to_hex(SOAP_Type_hexBinary::to_bin($value))) == 0; - } - -} diff --git a/data/module/SOAP/Value.php b/data/module/SOAP/Value.php deleted file mode 100644 index 6f944bf154e..00000000000 --- a/data/module/SOAP/Value.php +++ /dev/null @@ -1,286 +0,0 @@ - Original Author - * @author Shane Caraveo Port to PEAR and more - * @author Chuck Hagenbuch Maintenance - * @author Jan Schneider Maintenance - * @copyright 2003-2007 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'SOAP/Base.php'; - -/** - * SOAP::Value - * - * This class converts values between PHP and SOAP. - * - * Originally based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @access public - * @package SOAP - * @author Shane Caraveo Conversion to PEAR and updates - * @author Dietrich Ayala Original Author - */ -class SOAP_Value -{ - /** - * The actual value. - * - * @var mixed - */ - var $value = null; - - /** - * QName instance representing the value name. - * - * @var QName - */ - var $nqn; - - /** - * The value name, without namespace information. - * - * @var string - */ - var $name = ''; - - /** - * The namespace of the value name. - * - * @var string - */ - var $namespace = ''; - - /** - * QName instance representing the value type. - * - * @var QName - */ - var $tqn; - - /** - * The value type, without namespace information. - * - * @var string - */ - var $type = ''; - - /** - * The namespace of the value type. - * - * @var string - */ - var $type_namespace = ''; - - /** - * The type of the array elements, if this value is an array. - * - * @var string - */ - var $arrayType = ''; - - /** - * A hash of additional attributes. - * - * @see SOAP_Value() - * @var array - */ - var $attributes = array(); - - /** - * List of encoding and serialization options. - * - * @see SOAP_Value() - * @var array - */ - var $options = array(); - - /** - * Constructor. - * - * @param string $name Name of the SOAP value {namespace}name. - * @param mixed $type SOAP value {namespace}type. Determined - * automatically if not set. - * @param mixed $value Value to set. - * @param array $attributes A has of additional XML attributes to be - * added to the serialized value. - * @param array $options A list of encoding and serialization options: - * - 'attachment': array with information about - * the attachment - * - 'soap_encoding': defines encoding for SOAP - * message part of a MIME encoded SOAP request - * (default: base64) - * - 'keep_arrays_flat': use the tag name - * multiple times for each element when - * passing in an array in literal mode - * - 'no_type_prefix': supress adding of the - * namespace prefix - */ - function SOAP_Value($name = '', $type = false, $value = null, - $attributes = array(), $options = array()) - { - $this->nqn = new QName($name); - $this->name = $this->nqn->name; - $this->namespace = $this->nqn->namespace; - $this->tqn = new QName($type); - $this->type = $this->tqn->name; - $this->type_namespace = $this->tqn->namespace; - $this->value = $value; - $this->attributes = $attributes; - $this->options = $options; - } - - /** - * Serializes this value. - * - * @param SOAP_Base $serializer A SOAP_Base instance or subclass to - * serialize with. - * - * @return string XML representation of $this. - */ - function serialize(&$serializer) - { - return $serializer->_serializeValue($this->value, - $this->nqn, - $this->tqn, - $this->options, - $this->attributes, - $this->arrayType); - } - -} - -/** - * This class converts values between PHP and SOAP. It is a simple wrapper - * around SOAP_Value, adding support for SOAP actor and mustunderstand - * parameters. - * - * Originally based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @access public - * @package SOAP - * @author Shane Caraveo Conversion to PEAR and updates - * @author Dietrich Ayala Original Author - */ -class SOAP_Header extends SOAP_Value -{ - /** - * Constructor - * - * @param string $name Name of the SOAP value {namespace}name. - * @param mixed $type SOAP value {namespace}type. Determined - * automatically if not set. - * @param mixed $value Value to set - * @param integer $mustunderstand Zero or one. - * @param mixed $attributes Attributes. - */ - function SOAP_Header($name = '', $type, $value, $mustunderstand = 0, - $attributes = array()) - { - if (!is_array($attributes)) { - $actor = $attributes; - $attributes = array(); - } - - parent::SOAP_Value($name, $type, $value, $attributes); - - if (isset($actor)) { - $this->attributes[SOAP_BASE::SOAPENVPrefix().':actor'] = $actor; - } elseif (!isset($this->attributes[SOAP_BASE::SOAPENVPrefix().':actor'])) { - $this->attributes[SOAP_BASE::SOAPENVPrefix().':actor'] = 'http://schemas.xmlsoap.org/soap/actor/next'; - } - $this->attributes[SOAP_BASE::SOAPENVPrefix().':mustUnderstand'] = (int)$mustunderstand; - } - -} - -/** - * This class handles MIME attachements per W3C's Note on Soap Attachements at - * http://www.w3.org/TR/SOAP-attachments - * - * @access public - * @package SOAP - * @author Shane Caraveo Conversion to PEAR and updates - */ -class SOAP_Attachment extends SOAP_Value -{ - /** - * Constructor. - * - * @param string $name Name of the SOAP value - * @param string $type The attachment's MIME type. - * @param string $filename The attachment's file name. Ignored if $file - * is provide. - * @param string $file The attachment data. - * @param array $attributes Attributes. - */ - function SOAP_Attachment($name = '', $type = 'application/octet-stream', - $filename, $file = null, $attributes = null) - { - parent::SOAP_Value($name, null, null); - - $filedata = $file === null ? $this->_file2str($filename) : $file; - $filename = basename($filename); - if (PEAR::isError($filedata)) { - $this->options['attachment'] = $filedata; - return; - } - - $cid = md5(uniqid(time())); - - $this->attributes = $attributes; - $this->attributes['href'] = 'cid:' . $cid; - - $this->options['attachment'] = array('body' => $filedata, - 'disposition' => $filename, - 'content_type' => $type, - 'encoding' => 'base64', - 'cid' => $cid); - } - - /** - * Returns the contents of the given file name as string. - * - * @access private - * - * @param string $file_name The file location. - * - * @return string The file data or a PEAR_Error. - */ - function _file2str($file_name) - { - if (!is_readable($file_name)) { - return PEAR::raiseError('File is not readable: ' . $file_name); - } - - if (function_exists('file_get_contents')) { - return file_get_contents($file_name); - } - - if (!$fd = fopen($file_name, 'rb')) { - return PEAR::raiseError('Could not open ' . $file_name); - } - $cont = fread($fd, filesize($file_name)); - fclose($fd); - - return $cont; - } - -} diff --git a/data/module/SOAP/WSDL.php b/data/module/SOAP/WSDL.php deleted file mode 100644 index b7f8ec31cf3..00000000000 --- a/data/module/SOAP/WSDL.php +++ /dev/null @@ -1,2307 +0,0 @@ - Original Author - * @author Shane Caraveo Port to PEAR and more - * @author Chuck Hagenbuch Maintenance - * @author Jan Schneider Maintenance - * @copyright 2003-2005 The PHP Group - * @license http://www.php.net/license/2_02.txt PHP License 2.02 - * @link http://pear.php.net/package/SOAP - */ - -require_once 'SOAP/Base.php'; -require_once 'SOAP/Fault.php'; -require_once 'HTTP/Request.php'; - -define('WSDL_CACHE_MAX_AGE', 43200); - -/** - * This class parses WSDL files, and can be used by SOAP::Client to properly - * register soap values for services. - * - * Originally based on SOAPx4 by Dietrich Ayala - * http://dietrich.ganx4.com/soapx4 - * - * @todo - * - refactor namespace handling ($namespace/$ns) - * - implement IDL type syntax declaration so we can generate WSDL - * - * @access public - * @package SOAP - * @author Shane Caraveo Conversion to PEAR and updates - * @author Dietrich Ayala Original Author - */ -class SOAP_WSDL extends SOAP_Base -{ - var $tns = null; - var $definition = array(); - var $namespaces = array(); - var $ns = array(); - var $xsd = SOAP_XML_SCHEMA_VERSION; - var $complexTypes = array(); - var $elements = array(); - var $messages = array(); - var $portTypes = array(); - var $bindings = array(); - var $imports = array(); - var $services = array(); - var $service = ''; - - /** - * URL to WSDL file. - * - * @var string - */ - var $uri; - - /** - * Parse documentation in the WSDL? - * - * @var boolean - */ - var $docs; - - /** - * Proxy parameters. - * - * @var array - */ - var $proxy; - - /** - * Enable tracing in the generated proxy class? - * - * @var boolean - */ - var $trace = false; - - /** - * Use WSDL cache? - * - * @var boolean - */ - var $cacheUse; - - /** - * WSDL cache directory. - * - * @var string - */ - var $cacheDir; - - /** - * Cache maximum lifetime (in seconds). - * - * @var integer - */ - var $cacheMaxAge; - - /** - * Class to use for WSDL parsing. Can be overridden for special cases, - * subclasses, etc. - * - * @var string - */ - var $wsdlParserClass = 'SOAP_WSDL_Parser'; - - /** - * Reserved PHP keywords. - * - * @link http://www.php.net/manual/en/reserved.php - * - * @var array - */ - var $_reserved = array('abstract', 'and', 'array', 'as', 'break', 'case', - 'catch', 'cfunction', 'class', 'clone', 'const', - 'continue', 'declare', 'default', 'die', 'do', - 'echo', 'else', 'elseif', 'empty', 'enddeclare', - 'endfor', 'endforeach', 'endif', 'endswitch', - 'endwhile', 'eval', 'exception', 'exit', 'extends', - 'final', 'for', 'foreach', 'function', 'global', - 'if', 'implements', 'include', 'include_once', - 'interface', 'isset', 'list', 'new', 'old_function', - 'or', 'php_user_filter', 'print', 'private', - 'protected', 'public', 'require', 'require_once', - 'return', 'static', 'switch', 'this', 'throw', - 'try', 'unset', 'use', 'var', 'while', 'xor'); - - /** - * Regular expressions for invalid PHP labels. - * - * @link http://www.php.net/manual/en/language.variables.php. - * - * @var string - */ - var $_invalid = array('/^[^a-zA-Z_\x7f-\xff]/', '/[^a-zA-Z0-9_\x7f-\xff]/'); - - /** - * SOAP_WSDL constructor. - * - * @param string $wsdl_uri URL to WSDL file. - * @param array $proxy Options for HTTP_Request class - * @see HTTP_Request. - * @param boolean|string $cacheUse Use WSDL caching? The cache directory - * if a string. - * @param integer $cacheMaxAge Cache maximum lifetime (in seconds). - * @param boolean $docs Parse documentation in the WSDL? - * - * @access public - */ - function SOAP_WSDL($wsdl_uri = false, - $proxy = array(), - $cacheUse = false, - $cacheMaxAge = WSDL_CACHE_MAX_AGE, - $docs = false) - { - parent::SOAP_Base('WSDL'); - $this->uri = $wsdl_uri; - $this->proxy = $proxy; - $this->cacheUse = !empty($cacheUse); - $this->cacheMaxAge = $cacheMaxAge; - $this->docs = $docs; - if (is_string($cacheUse)) { - $this->cacheDir = $cacheUse; - } - - if ($wsdl_uri) { - if (!PEAR::isError($this->parseURL($wsdl_uri))) { - reset($this->services); - $this->service = key($this->services); - } - } - } - - /** - * @deprecated Use setService(). - */ - function set_service($service) - { - $this->setService($service); - } - - /** - * Sets the service currently to be used. - * - * @param string $service An (existing) service name. - */ - function setService($service) - { - if (array_key_exists($service, $this->services)) { - $this->service = $service; - } - } - - /** - * Fills the WSDL array tree with data from a WSDL file. - * - * @param string $wsdl_uri URL to WSDL file. - */ - function parseURL($wsdl_uri) - { - $parser = new $this->wsdlParserClass($wsdl_uri, $this, $this->docs); - - if ($parser->fault) { - $this->_raiseSoapFault($parser->fault); - } - } - - /** - * Fills the WSDL array tree with data from one or more PHP class objects. - * - * @param mixed $wsdl_obj An object or array of objects to add to - * the internal WSDL tree. - * @param string $targetNamespace The target namespace of schema types - * etc. - * @param string $service_name Name of the WSDL service. - * @param string $service_desc Optional description of the WSDL - * service. - */ - function parseObject($wsdl_obj, $targetNamespace, $service_name, - $service_desc = '') - { - $parser = new SOAP_WSDL_ObjectParser($wsdl_obj, $this, - $targetNamespace, $service_name, - $service_desc); - - if ($parser->fault) { - $this->_raiseSoapFault($parser->fault); - } - } - - function getEndpoint($portName) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - return (isset($this->services[$this->service]['ports'][$portName]['address']['location'])) - ? $this->services[$this->service]['ports'][$portName]['address']['location'] - : $this->_raiseSoapFault("No endpoint for port for $portName", $this->uri); - } - - function _getPortName($operation, $service) - { - if (isset($this->services[$service]['ports'])) { - $ports = $this->services[$service]['ports']; - foreach ($ports as $port => $portAttrs) { - $type = $ports[$port]['type']; - if ($type == 'soap' && - isset($this->bindings[$portAttrs['binding']]['operations'][$operation])) { - return $port; - } - } - } - return null; - } - - /** - * Finds the name of the first port that contains an operation of name - * $operation. Always returns a SOAP portName. - */ - function getPortName($operation, $service = null) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - if (!$service) { - $service = $this->service; - } - if (isset($this->services[$service]['ports'])) { - if ($portName = $this->_getPortName($operation, $service)) { - return $portName; - } - } - // Try any service in the WSDL. - foreach ($this->services as $serviceName => $service) { - if (isset($this->services[$serviceName]['ports'])) { - if ($portName = $this->_getPortName($operation, $serviceName)) { - $this->service = $serviceName; - return $portName; - } - } - } - return $this->_raiseSoapFault("No operation $operation in WSDL.", $this->uri); - } - - function getOperationData($portName, $operation) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - if (!isset($this->services[$this->service]['ports'][$portName]['binding']) || - !($binding = $this->services[$this->service]['ports'][$portName]['binding'])) { - return $this->_raiseSoapFault("No binding for port $portName in WSDL.", $this->uri); - } - - // Get operation data from binding. - if (is_array($this->bindings[$binding]['operations'][$operation])) { - $opData = $this->bindings[$binding]['operations'][$operation]; - } - // Get operation data from porttype. - $portType = $this->bindings[$binding]['type']; - if (!$portType) { - return $this->_raiseSoapFault("No port type for binding $binding in WSDL.", $this->uri); - } - if (is_array($type = $this->portTypes[$portType][$operation])) { - if (isset($type['parameterOrder'])) { - $opData['parameterOrder'] = $type['parameterOrder']; - } - $opData['input'] = array_merge($opData['input'], $type['input']); - $opData['output'] = array_merge($opData['output'], $type['output']); - } - if (!$opData) - return $this->_raiseSoapFault("No operation $operation for port $portName in WSDL.", $this->uri); - $opData['parameters'] = false; - if (isset($this->bindings[$binding]['operations'][$operation]['input']['namespace'])) - $opData['namespace'] = $this->bindings[$binding]['operations'][$operation]['input']['namespace']; - // Message data from messages. - $inputMsg = $opData['input']['message']; - if (isset($opData['input']['parts']) && - !is_array($opData['input']['parts'])) { - $opData['input']['parts'] = array($opData['input']['parts'] => ''); - - } - if (is_array($this->messages[$inputMsg])) { - foreach ($this->messages[$inputMsg] as $pname => $pattrs) { - if ($opData['style'] == 'document' && - $opData['input']['use'] == 'literal' && - $pname == 'parameters') { - $opData['parameters'] = true; - $opData['namespace'] = $this->namespaces[$pattrs['namespace']]; - $el = $this->elements[$pattrs['namespace']][$pattrs['type']]; - if (isset($el['elements'])) { - foreach ($el['elements'] as $elname => $elattrs) { - $opData['input']['parts'][$elname] = $elattrs; - } - } - } else { - $opData['input']['parts'][$pname] = $pattrs; - } - } - } - $outputMsg = $opData['output']['message']; - if (isset($opData['output']['parts']) && - !is_array($opData['output']['parts'])) { - $opData['output']['parts'] = array($opData['output']['parts'] => ''); - } - if (is_array($this->messages[$outputMsg])) { - foreach ($this->messages[$outputMsg] as $pname => $pattrs) { - if ($opData['style'] == 'document' && - $opData['output']['use'] == 'literal' && - $pname == 'parameters') { - - $el = $this->elements[$pattrs['namespace']][$pattrs['type']]; - if (isset($el['elements'])) { - foreach ($el['elements'] as $elname => $elattrs) { - $opData['output']['parts'][$elname] = $elattrs; - } - } - } else { - $opData['output']['parts'][$pname] = $pattrs; - } - } - } - return $opData; - } - - function matchMethod(&$operation) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - // Overloading lowercases function names :( - foreach ($this->services[$this->service]['ports'] as $portAttrs) { - foreach (array_keys($this->bindings[$portAttrs['binding']]['operations']) as $op) { - if (strcasecmp($op, $operation) == 0) { - $operation = $op; - } - } - } - } - - /** - * Given a datatype, what function handles the processing? - * - * This is used for doc/literal requests where we receive a datatype, and - * we need to pass it to a method in out server class. - * - * @param string $datatype - * @param string $namespace - * @return string - * @access public - */ - function getDataHandler($datatype, $namespace) - { - // See if we have an element by this name. - if (isset($this->namespaces[$namespace])) { - $namespace = $this->namespaces[$namespace]; - } - - if (!isset($this->ns[$namespace])) { - return null; - } - - $nsp = $this->ns[$namespace]; - //if (!isset($this->elements[$nsp])) - // $nsp = $this->namespaces[$nsp]; - if (!isset($this->elements[$nsp][$datatype])) { - return null; - } - - $checkmessages = array(); - // Find what messages use this datatype. - foreach ($this->messages as $messagename => $message) { - foreach ($message as $part) { - if ($part['type'] == $datatype) { - $checkmessages[] = $messagename; - break; - } - } - } - // Find the operation that uses this message. - foreach($this->portTypes as $porttype) { - foreach ($porttype as $opname => $opinfo) { - foreach ($checkmessages as $messagename) { - if ($opinfo['input']['message'] == $messagename) { - return $opname; - } - } - } - } - - return null; - } - - function getSoapAction($portName, $operation) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - if (!empty($this->bindings[$this->services[$this->service]['ports'][$portName]['binding']]['operations'][$operation]['soapAction'])) { - return $this->bindings[$this->services[$this->service]['ports'][$portName]['binding']]['operations'][$operation]['soapAction']; - } - - return false; - } - - function getNamespace($portName, $operation) - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - if (!empty($this->bindings[$this->services[$this->service]['ports'][$portName]['binding']]['operations'][$operation]['input']['namespace'])) { - return $this->bindings[$this->services[$this->service]['ports'][$portName]['binding']]['operations'][$operation]['input']['namespace']; - } - - return false; - } - - function getNamespaceAttributeName($namespace) - { - /* If it doesn't exist at first, flip the array and check again. */ - if (empty($this->ns[$namespace])) { - $this->ns = array_flip($this->namespaces); - } - - /* If it doesn't exist now, add it. */ - if (empty($this->ns[$namespace])) { - return $this->addNamespace($namespace); - } - - return $this->ns[$namespace]; - } - - function addNamespace($namespace) - { - if (!empty($this->ns[$namespace])) { - return $this->ns[$namespace]; - } - - $n = count($this->ns); - $attr = 'ns' . $n; - $this->namespaces['ns' . $n] = $namespace; - $this->ns[$namespace] = $attr; - - return $attr; - } - - function _validateString($string) - { - return preg_match('/^[\w_:#\/]+$/', $string); - } - - function _addArg(&$args, &$argarray, $argname) - { - if ($args) { - $args .= ', '; - } - $args .= '$' . $argname; - if (!$this->_validateString($argname)) { - return; - } - if ($argarray) { - $argarray .= ', '; - } - $argarray .= "'$argname' => $" . $argname; - } - - function _elementArg(&$args, &$argarray, &$_argtype, $_argname) - { - $comments = ''; - $el = $this->elements[$_argtype['namespace']][$_argtype['type']]; - $tns = isset($this->ns[$el['namespace']]) - ? $this->ns[$el['namespace']] - : $_argtype['namespace']; - - if (!empty($el['complex']) || - (isset($el['type']) && - isset($this->complexTypes[$tns][$el['type']]))) { - // The element is a complex type. - $comments .= " // {$_argtype['type']} is a ComplexType, refer to the WSDL for more info.\n"; - $attrname = "{$_argtype['type']}_attr"; - if (isset($el['type']) && - isset($this->complexTypes[$tns][$el['type']]['attribute'])) { - $comments .= " // {$_argtype['type']} may require attributes, refer to the WSDL for more info.\n"; - } - $comments .= " \${$attrname}['xmlns'] = '{$this->namespaces[$_argtype['namespace']]}';\n"; - $comments .= " \${$_argtype['type']} = new SOAP_Value('{$_argtype['type']}', false, \${$_argtype['type']}, \$$attrname);\n"; - $this->_addArg($args, $argarray, $_argtype['type']); - if (isset($el['type']) && - isset($this->complexTypes[$tns][$el['type']]['attribute'])) { - if ($args) { - $args .= ', '; - } - $args .= '$' . $attrname; - } - } elseif (isset($el['elements'])) { - foreach ($el['elements'] as $ename => $element) { - $comments .= " \$$ename = new SOAP_Value('{{$this->namespaces[$element['namespace']]}}$ename', '" . - (isset($element['type']) ? $element['type'] : false) . - "', \$$ename);\n"; - $this->_addArg($args, $argarray, $ename); - } - } else { - $comments .= " \$$_argname = new SOAP_Value('{{$this->namespaces[$tns]}}$_argname', '{$el['type']}', \$$_argname);\n"; - $this->_addArg($args, $argarray, $_argname); - } - - return $comments; - } - - function _complexTypeArg(&$args, &$argarray, &$_argtype, $_argname) - { - $comments = ''; - if (isset($this->complexTypes[$_argtype['namespace']][$_argtype['type']])) { - $comments = " // $_argname is a ComplexType {$_argtype['type']},\n" . - " // refer to wsdl for more info\n"; - if (isset($this->complexTypes[$_argtype['namespace']][$_argtype['type']]['attribute'])) { - $comments .= " // $_argname may require attributes, refer to wsdl for more info\n"; - } - $wrapname = '{' . $this->namespaces[$_argtype['namespace']].'}' . $_argtype['type']; - $comments .= " \$$_argname = new SOAP_Value('$_argname', '$wrapname', \$$_argname);\n"; - } - - $this->_addArg($args, $argarray, $_argname); - - return $comments; - } - - /** - * Generates stub code from the WSDL that can be saved to a file or eval'd - * into existence. - */ - function generateProxyCode($port = '', $classname = '') - { - if ($this->_isfault()) { - return $this->_getfault(); - } - - $multiport = count($this->services[$this->service]['ports']) > 1; - if (!$port) { - reset($this->services[$this->service]['ports']); - $port = current($this->services[$this->service]['ports']); - } - // XXX currently do not support HTTP ports - if ($port['type'] != 'soap') { - return null; - } - - // XXX currentPort is BAD - $clienturl = $port['address']['location']; - if (!$classname) { - if ($multiport || $port) { - $classname = 'WebService_' . $this->service . '_' . $port['name']; - } else { - $classname = 'WebService_' . $this->service; - } - $classname = $this->_sanitize($classname); - } - - if (!$this->_validateString($classname)) { - return null; - } - - if (is_array($this->proxy) && count($this->proxy)) { - $class = "class $classname extends SOAP_Client\n{\n" . - " function $classname(\$path = '$clienturl')\n {\n" . - " \$this->SOAP_Client(\$path, 0, 0,\n" . - ' array('; - - foreach ($this->proxy as $key => $val) { - if (is_array($val)) { - $class .= "'$key' => array("; - foreach ($val as $key2 => $val2) { - $class .= "'$key2' => '$val2', "; - } - $class .= ')'; - } else { - $class .= "'$key' => '$val', "; - } - } - $class .= "));\n }\n"; - $class = str_replace(', ))', '))', $class); - } else { - $class = "class $classname extends SOAP_Client\n{\n" . - " function $classname(\$path = '$clienturl')\n {\n" . - " \$this->SOAP_Client(\$path, 0);\n" . - " }\n"; - } - - // Get the binding, from that get the port type. - $primaryBinding = $port['binding']; - $primaryBinding = preg_replace("/^(.*:)/", '', $primaryBinding); - $portType = $this->bindings[$primaryBinding]['type']; - $portType = preg_replace("/^(.*:)/", '', $portType); - $style = $this->bindings[$primaryBinding]['style']; - - // XXX currentPortType is BAD - foreach ($this->portTypes[$portType] as $opname => $operation) { - $binding = $this->bindings[$primaryBinding]['operations'][$opname]; - if (isset($binding['soapAction'])) { - $soapaction = $binding['soapAction']; - } else { - $soapaction = null; - } - if (isset($binding['style'])) { - $opstyle = $binding['style']; - } else { - $opstyle = $style; - } - $use = $binding['input']['use']; - if ($use == 'encoded') { - $namespace = $binding['input']['namespace']; - } else { - $bindingType = $this->bindings[$primaryBinding]['type']; - $ns = $this->portTypes[$bindingType][$opname]['input']['namespace']; - $namespace = $this->namespaces[$ns]; - } - - $args = ''; - $argarray = ''; - $comments = ''; - $wrappers = ''; - foreach ($operation['input'] as $argname => $argtype) { - if ($argname == 'message') { - foreach ($this->messages[$argtype] as $_argname => $_argtype) { - $_argname = $this->_sanitize($_argname); - if ($opstyle == 'document' && $use == 'literal' && - $_argtype['name'] == 'parameters') { - // The type or element refered to is used for - // parameters. - $elattrs = null; - $el = $this->elements[$_argtype['namespace']][$_argtype['type']]; - - if ($el['complex']) { - $namespace = $this->namespaces[$_argtype['namespace']]; - // XXX need to wrap the parameters in a - // SOAP_Value. - } - if (isset($el['elements'])) { - foreach ($el['elements'] as $elname => $elattrs) { - $elname = $this->_sanitize($elname); - // Is the element a complex type? - if (isset($this->complexTypes[$elattrs['namespace']][$elname])) { - $comments .= $this->_complexTypeArg($args, $argarray, $_argtype, $_argname); - } else { - $this->_addArg($args, $argarray, $elname); - } - } - } - if ($el['complex'] && $argarray) { - $wrapname = '{' . $this->namespaces[$_argtype['namespace']].'}' . $el['name']; - $comments .= " \${$el['name']} = new SOAP_Value('$wrapname', false, \$v = array($argarray));\n"; - $argarray = "'{$el['name']}' => \${$el['name']}"; - } - } else { - if (isset($_argtype['element'])) { - // Element argument. - $comments .= $this->_elementArg($args, $argarray, $_argtype, $_argtype['type']); - } else { - // Complex type argument. - $comments .= $this->_complexTypeArg($args, $argarray, $_argtype, $_argname); - } - } - } - } - } - - // Validate entries. - - // Operation names are function names, so try to make sure it's - // legal. This could potentially cause collisions, but let's try - // to make everything callable and see how many problems that - // causes. - $opname_php = $this->_sanitize($opname); - if (!$this->_validateString($opname_php)) { - return null; - } - - if ($argarray) { - $argarray = "array($argarray)"; - } else { - $argarray = 'null'; - } - - $class .= " function &$opname_php($args)\n {\n$comments$wrappers" . - " \$result = \$this->call('$opname',\n" . - " \$v = $argarray,\n" . - " array('namespace' => '$namespace',\n" . - " 'soapaction' => '$soapaction',\n" . - " 'style' => '$opstyle',\n" . - " 'use' => '$use'" . - ($this->trace ? ",\n 'trace' => true" : '') . "));\n" . - " return \$result;\n" . - " }\n"; - } - - $class .= "}\n"; - - return $class; - } - - function generateAllProxies() - { - $proxycode = ''; - foreach (array_keys($this->services[$this->service]['ports']) as $key) { - $port =& $this->services[$this->service]['ports'][$key]; - $proxycode .= $this->generateProxyCode($port); - } - return $proxycode; - } - - function &getProxy($port = '', $name = '') - { - if ($this->_isfault()) { - $fault =& $this->_getfault(); - return $fault; - } - - $multiport = count($this->services[$this->service]['ports']) > 1; - - if (!$port) { - reset($this->services[$this->service]['ports']); - $port = current($this->services[$this->service]['ports']); - } - - if ($multiport || $port) { - $classname = 'WebService_' . $this->service . '_' . $port['name']; - } else { - $classname = 'WebService_' . $this->service; - } - - if ($name) { - $classname = $name . '_' . $classname; - } - - $classname = $this->_sanitize($classname); - if (!class_exists($classname)) { - $proxy = $this->generateProxyCode($port, $classname); - require_once 'SOAP/Client.php'; - eval($proxy); - } - $proxy = new $classname; - - return $proxy; - } - - /** - * Sanitizes a SOAP value, method or class name so that it can be used as - * a valid PHP identifier. Invalid characters are converted into - * underscores and reserved words are prefixed with an underscore. - * - * @param string $name The identifier to sanitize. - * - * @return string The sanitized identifier. - */ - function _sanitize($name) - { - $name = preg_replace($this->_invalid, '_', $name); - if (in_array($name, $this->_reserved)) { - $name = '_' . $name; - } - return $name; - } - - function &_getComplexTypeForElement($name, $namespace) - { - $t = null; - if (isset($this->ns[$namespace]) && - isset($this->elements[$this->ns[$namespace]][$name]['type'])) { - - $type = $this->elements[$this->ns[$namespace]][$name]['type']; - $ns = $this->elements[$this->ns[$namespace]][$name]['namespace']; - - if (isset($this->complexTypes[$ns][$type])) { - $t = $this->complexTypes[$ns][$type]; - } - } - return $t; - } - - function getComplexTypeNameForElement($name, $namespace) - { - $t = $this->_getComplexTypeForElement($name, $namespace); - if ($t) { - return $t['name']; - } - return null; - } - - function getComplexTypeChildType($ns, $name, $child_ns, $child_name) - { - // Is the type an element? - $t = $this->_getComplexTypeForElement($name, $ns); - if ($t) { - // No, get it from complex types directly. - if (isset($t['elements'][$child_name]['type'])) - return $t['elements'][$child_name]['type']; - } elseif (isset($this->ns[$ns]) && - isset($this->elements[$this->ns[$ns]][$name]['complex']) && - $this->elements[$this->ns[$ns]][$name]['complex']) { - // Type is not an element but complex. - return $this->elements[$this->ns[$ns]][$name]['elements'][$child_name]['type']; - } - return null; - } - - /** - * @param QName $name A parameter name. - * @param QName $type A parameter type. - * - * @return array A list of [type, array element type, array element - * namespace, array length]. - */ - function getSchemaType($type, $name) - { - // see if it's a complex type so we can deal properly with - // SOAPENC:arrayType. - if ($name && $type) { - // XXX TODO: - // look up the name in the wsdl and validate the type. - foreach ($this->complexTypes as $types) { - if (isset($types[$type->name])) { - if (isset($types[$type->name]['type'])) { - list($arraytype_ns, $arraytype, $array_depth) = isset($types[$type->name]['arrayType']) - ? $this->_getDeepestArrayType($types[$type->name]['namespace'], $types[$type->name]['arrayType']) - : array($this->namespaces[$types[$type->name]['namespace']], null, 0); - return array($types[$type->name]['type'], $arraytype, $arraytype_ns, $array_depth); - } - if (isset($types[$type->name]['arrayType'])) { - list($arraytype_ns, $arraytype, $array_depth) = - $this->_getDeepestArrayType($types[$type->name]['namespace'], $types[$type->name]['arrayType']); - return array('Array', $arraytype, $arraytype_ns, $array_depth); - } - if (!empty($types[$type->name]['elements'][$name->name])) { - $type->name = $types[$type->name]['elements']['type']; - return array($type->name, null, $this->namespaces[$types[$type->name]['namespace']], null); - } - break; - } - } - } - if ($type && $type->namespace) { - $arrayType = null; - // XXX TODO: - // this code currently handles only one way of encoding array - // types in wsdl need to do a generalized function to figure out - // complex types - $p = $this->ns[$type->namespace]; - if ($p && !empty($this->complexTypes[$p][$type->name])) { - if ($arrayType = $this->complexTypes[$p][$type->name]['arrayType']) { - $type->name = 'Array'; - } elseif ($this->complexTypes[$p][$type->name]['order'] == 'sequence' && - array_key_exists('elements', $this->complexTypes[$p][$type->name])) { - reset($this->complexTypes[$p][$type->name]['elements']); - // assume an array - if (count($this->complexTypes[$p][$type->name]['elements']) == 1) { - $arg = current($this->complexTypes[$p][$type->name]['elements']); - $arrayType = $arg['type']; - $type->name = 'Array'; - } else { - foreach ($this->complexTypes[$p][$type->name]['elements'] as $element) { - if ($element['name'] == $type->name) { - $arrayType = $element['type']; - $type->name = $element['type']; - } - } - } - } else { - $type->name = 'Struct'; - } - return array($type->name, $arrayType, $type->namespace, null); - } - } - return array(null, null, null, null); - } - - /** - * Recurse through the WSDL structure looking for the innermost array type - * of multi-dimensional arrays. - * - * Takes a namespace prefix and a type, which can be in the form 'type' or - * 'type[]', and returns the full namespace URI, the type of the most - * deeply nested array type found, and the number of levels of nesting. - * - * @access private - * @return mixed array or nothing - */ - function _getDeepestArrayType($nsPrefix, $arrayType) - { - static $trail = array(); - - $arrayType = preg_replace('/\[\]$/', '', $arrayType); - - // Protect against circular references XXX We really need to remove - // trail from this altogether (it's very inefficient and in the wrong - // place!) and put circular reference checking in when the WSDL info - // is generated in the first place - if (array_search($nsPrefix . ':' . $arrayType, $trail)) { - return array(null, null, -count($trail)); - } - - if (array_key_exists($nsPrefix, $this->complexTypes) && - array_key_exists($arrayType, $this->complexTypes[$nsPrefix]) && - array_key_exists('arrayType', $this->complexTypes[$nsPrefix][$arrayType])) { - $trail[] = $nsPrefix . ':' . $arrayType; - $result = $this->_getDeepestArrayType($this->complexTypes[$nsPrefix][$arrayType]['namespace'], - $this->complexTypes[$nsPrefix][$arrayType]['arrayType']); - return array($result[0], $result[1], $result[2] + 1); - } - return array($this->namespaces[$nsPrefix], $arrayType, 0); - } - -} - -class SOAP_WSDL_Cache extends SOAP_Base -{ - /** - * Use WSDL cache? - * - * @var boolean - */ - var $_cacheUse; - - /** - * WSDL cache directory. - * - * @var string - */ - var $_cacheDir; - - /** - * Cache maximum lifetime (in seconds) - * - * @var integer - */ - var $_cacheMaxAge; - - /** - * Constructor. - * - * @param boolean $cashUse Use caching? - * @param integer $cacheMaxAge Cache maximum lifetime (in seconds) - */ - function SOAP_WSDL_Cache($cacheUse = false, - $cacheMaxAge = WSDL_CACHE_MAX_AGE, - $cacheDir = null) - { - parent::SOAP_Base('WSDLCACHE'); - $this->_cacheUse = $cacheUse; - $this->_cacheDir = $cacheDir; - $this->_cacheMaxAge = $cacheMaxAge; - } - - /** - * Returns the path to the cache and creates it, if it doesn't exist. - * - * @private - * - * @return string The directory to use for the cache. - */ - function _cacheDir() - { - if (!empty($this->_cacheDir)) { - $dir = $this->_cacheDir; - } else { - $dir = getenv('WSDLCACHE'); - if (empty($dir)) { - $dir = './wsdlcache'; - } - } - @mkdir($dir, 0700); - return $dir; - } - - /** - * Retrieves a file from cache if it exists, otherwise retreive from net, - * add to cache, and return from cache. - * - * @param string URL to WSDL - * @param array proxy parameters - * @param int expected MD5 of WSDL URL - * @access public - * @return string data - */ - function get($wsdl_fname, $proxy_params = array(), $cache = 0) - { - $cachename = $md5_wsdl = $file_data = ''; - if ($this->_cacheUse) { - // Try to retrieve WSDL from cache - $cachename = $this->_cacheDir() . '/' . md5($wsdl_fname). ' .wsdl'; - if (file_exists($cachename) && - $file_data = file_get_contents($cachename)) { - $md5_wsdl = md5($file_data); - if ($cache) { - if ($cache != $md5_wsdl) { - return $this->_raiseSoapFault('WSDL Checksum error!', $wsdl_fname); - } - } else { - $fi = stat($cachename); - $cache_mtime = $fi[8]; - if ($cache_mtime + $this->_cacheMaxAge < time()) { - // Expired, refetch. - $md5_wsdl = ''; - } - } - } - } - - // Not cached or not using cache. Retrieve WSDL from URL - if (!$md5_wsdl) { - // Is it a local file? - if (strpos($wsdl_fname, 'file://') === 0) { - $wsdl_fname = substr($wsdl_fname, 7); - if (!file_exists($wsdl_fname)) { - return $this->_raiseSoapFault('Unable to read local WSDL file', $wsdl_fname); - } - $file_data = file_get_contents($wsdl_fname); - } elseif (!preg_match('|^https?://|', $wsdl_fname)) { - return $this->_raiseSoapFault('Unknown schema of WSDL URL', $wsdl_fname); - } else { - $uri = explode('?', $wsdl_fname); - $rq = new HTTP_Request($uri[0], $proxy_params); - // the user agent HTTP_Request uses fouls things up - if (isset($uri[1])) { - $rq->addRawQueryString($uri[1]); - } - - if (isset($proxy_params['proxy_host']) && - isset($proxy_params['proxy_port']) && - isset($proxy_params['proxy_user']) && - isset($proxy_params['proxy_pass'])) { - $rq->setProxy($proxy_params['proxy_host'], - $proxy_params['proxy_port'], - $proxy_params['proxy_user'], - $proxy_params['proxy_pass']); - } elseif (isset($proxy_params['proxy_host']) && - isset($proxy_params['proxy_port'])) { - $rq->setProxy($proxy_params['proxy_host'], - $proxy_params['proxy_port']); - } - - $result = $rq->sendRequest(); - if (PEAR::isError($result)) { - return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname," . $rq->getResponseCode(), $wsdl_fname); - } - $file_data = $rq->getResponseBody(); - if (!$file_data) { - return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname, no http body", $wsdl_fname); - } - } - - $md5_wsdl = md5($file_data); - - if ($this->_cacheUse) { - $fp = fopen($cachename, "wb"); - fwrite($fp, $file_data); - fclose($fp); - } - } - - if ($this->_cacheUse && $cache && $cache != $md5_wsdl) { - return $this->_raiseSoapFault('WSDL Checksum error!', $wsdl_fname); - } - - return $file_data; - } - -} - -class SOAP_WSDL_Parser extends SOAP_Base -{ - - /** - * Define internal arrays of bindings, ports, operations, - * messages, etc. - */ - var $currentMessage; - var $currentOperation; - var $currentPortType; - var $currentBinding; - var $currentPort; - - /** - * Parser vars. - */ - var $cache; - - var $tns = null; - var $soapns = array('soap'); - var $uri = ''; - var $wsdl = null; - - var $status = ''; - var $element_stack = array(); - var $parentElement = ''; - - var $schema = ''; - var $schemaStatus = ''; - var $schema_stack = array(); - var $currentComplexType; - var $schema_element_stack = array(); - var $currentElement; - - /** - * Constructor. - */ - function SOAP_WSDL_Parser($uri, &$wsdl, $docs = false) - { - parent::SOAP_Base('WSDLPARSER'); - $this->cache = new SOAP_WSDL_Cache($wsdl->cacheUse, - $wsdl->cacheMaxAge, - $wsdl->cacheDir); - $this->uri = $uri; - $this->wsdl = &$wsdl; - $this->docs = $docs; - $this->parse($uri); - } - - function parse($uri) - { - // Check whether content has been read. - $fd = $this->cache->get($uri, $this->wsdl->proxy); - if (PEAR::isError($fd)) { - return $this->_raiseSoapFault($fd); - } - - // Create an XML parser. - $parser = xml_parser_create(); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_set_object($parser, $this); - xml_set_element_handler($parser, 'startElement', 'endElement'); - if ($this->docs) { - xml_set_character_data_handler($parser, 'characterData'); - } - - if (!xml_parse($parser, $fd, true)) { - $detail = sprintf('XML error on line %d: %s', - xml_get_current_line_number($parser), - xml_error_string(xml_get_error_code($parser))); - return $this->_raiseSoapFault("Unable to parse WSDL file $uri\n$detail"); - } - xml_parser_free($parser); - return true; - } - - /** - * start-element handler - */ - function startElement($parser, $name, $attrs) - { - // Get element prefix. - $qname = new QName($name); - if ($qname->prefix) { - $ns = $qname->prefix; - if ($ns && ((!$this->tns && strcasecmp($qname->name, 'definitions') == 0) || $ns == $this->tns)) { - $name = $qname->name; - } - } - $this->currentTag = $qname->name; - $this->parentElement = ''; - $stack_size = count($this->element_stack); - if ($stack_size) { - $this->parentElement = $this->element_stack[$stack_size - 1]; - } - $this->element_stack[] = $this->currentTag; - - // Find status, register data. - switch ($this->status) { - case 'types': - // sect 2.2 wsdl:types - // children: xsd:schema - $parent_tag = ''; - $stack_size = count($this->schema_stack); - if ($stack_size) { - $parent_tag = $this->schema_stack[$stack_size - 1]; - } - - switch ($qname->name) { - case 'schema': - // No parent should be in the stack. - if (!$parent_tag || $parent_tag == 'types') { - if (array_key_exists('targetNamespace', $attrs)) { - $this->schema = $this->wsdl->getNamespaceAttributeName($attrs['targetNamespace']); - } else { - $this->schema = $this->wsdl->getNamespaceAttributeName($this->wsdl->tns); - } - $this->wsdl->complexTypes[$this->schema] = array(); - $this->wsdl->elements[$this->schema] = array(); - } - break; - - case 'complexType': - if ($parent_tag == 'schema') { - $this->currentComplexType = $attrs['name']; - if (!isset($attrs['namespace'])) { - $attrs['namespace'] = $this->schema; - } - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType] = $attrs; - if (array_key_exists('base', $attrs)) { - $qn = new QName($attrs['base']); - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = $qn->name; - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['namespace'] = $qn->prefix; - } else { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Struct'; - } - $this->schemaStatus = 'complexType'; - } else { - $this->wsdl->elements[$this->schema][$this->currentElement]['complex'] = true; - } - break; - - case 'element': - if (isset($attrs['type'])) { - $qn = new QName($attrs['type']); - $attrs['type'] = $qn->name; - if ($qn->prefix && array_key_exists($qn->prefix, $this->wsdl->namespaces)) { - $attrs['namespace'] = $qn->prefix; - } - } - - $parentElement = ''; - $stack_size = count($this->schema_element_stack); - if ($stack_size > 0) { - $parentElement = $this->schema_element_stack[$stack_size - 1]; - } - - if (isset($attrs['ref'])) { - $qn = new QName($attrs['ref']); - $this->currentElement = $qn->name; - } else { - $this->currentElement = $attrs['name']; - } - $this->schema_element_stack[] = $this->currentElement; - if (!isset($attrs['namespace'])) { - $attrs['namespace'] = $this->schema; - } - - if ($parent_tag == 'schema') { - $this->wsdl->elements[$this->schema][$this->currentElement] = $attrs; - $this->wsdl->elements[$this->schema][$this->currentElement]['complex'] = false; - $this->schemaStatus = 'element'; - } elseif ($this->currentComplexType) { - // we're inside a complexType - if ((isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['order']) && - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['order'] == 'sequence') - && $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] == 'Array') { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['arrayType'] = isset($attrs['type']) ? $attrs['type'] : null; - } - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['elements'][$this->currentElement] = $attrs; - } else { - $this->wsdl->elements[$this->schema][$parentElement]['elements'][$this->currentElement] = $attrs; - } - break; - - case 'complexContent': - case 'simpleContent': - break; - - case 'extension': - case 'restriction': - if ($this->schemaStatus == 'complexType') { - if (!empty($attrs['base'])) { - $qn = new QName($attrs['base']); - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = $qn->name; - - // Types that extend from other types aren't - // *of* those types. Reflect this by denoting - // which type they extend. I'm leaving the - // 'type' setting here since I'm not sure what - // removing it might break at the moment. - if ($qname->name == 'extension') { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['extends'] = $qn->name; - } - } else { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Struct'; - } - } - break; - - case 'sequence': - if ($this->schemaStatus == 'complexType') { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['order'] = $qname->name; - if (!isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'])) { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Array'; - } - } - break; - - case 'all': - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['order'] = $qname->name; - if (!isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'])) { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Struct'; - } - break; - - case 'choice': - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['order'] = $qname->name; - if (!isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'])) { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Array'; - } - - case 'attribute': - if ($this->schemaStatus == 'complexType') { - if (isset($attrs['name'])) { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['attribute'][$attrs['name']] = $attrs; - } else { - if (isset($attrs['ref'])) { - $q = new QName($attrs['ref']); - foreach ($attrs as $k => $v) { - if ($k != 'ref' && strstr($k, $q->name)) { - $vq = new QName($v); - if ($q->name == 'arrayType') { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType][$q->name] = $vq->name. $vq->arrayInfo; - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Array'; - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['namespace'] = $vq->prefix; - } else { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType][$q->name] = $vq->name; - } - } - } - } - } - } - break; - } - - $this->schema_stack[] = $qname->name; - break; - - case 'message': - // sect 2.3 wsdl:message child wsdl:part - switch ($qname->name) { - case 'part': - $qn = null; - if (isset($attrs['type'])) { - $qn = new QName($attrs['type']); - } elseif (isset($attrs['element'])) { - $qn = new QName($attrs['element']); - } - if ($qn) { - $attrs['type'] = $qn->name; - $attrs['namespace'] = $qn->prefix; - } - $this->wsdl->messages[$this->currentMessage][$attrs['name']] = $attrs; - // error in wsdl - - case 'documentation': - break; - - default: - break; - } - break; - - case 'portType': - // sect 2.4 - switch ($qname->name) { - case 'operation': - // attributes: name - // children: wsdl:input wsdl:output wsdl:fault - $this->currentOperation = $attrs['name']; - $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation] = $attrs; - break; - - case 'input': - case 'output': - case 'fault': - // wsdl:input wsdl:output wsdl:fault - // attributes: name message parameterOrder(optional) - if ($this->currentOperation) { - if (isset($this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name])) { - $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name] = array_merge($this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name], $attrs); - } else { - $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name] = $attrs; - } - if (array_key_exists('message', $attrs)) { - $qn = new QName($attrs['message']); - $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name]['message'] = $qn->name; - $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name]['namespace'] = $qn->prefix; - } - } - break; - - case 'documentation': - break; - - default: - break; - } - break; - - case 'binding': - $ns = $qname->prefix ? $this->wsdl->namespaces[$qname->prefix] : SCHEMA_WSDL; - switch ($ns) { - case SCHEMA_SOAP: - case SCHEMA_SOAP12: - // this deals with wsdl section 3 soap binding - switch ($qname->name) { - case 'binding': - // sect 3.3 - // soap:binding, attributes: transport(required), style(optional, default = document) - // if style is missing, it is assumed to be 'document' - if (!isset($attrs['style'])) { - $attrs['style'] = 'document'; - } - $this->wsdl->bindings[$this->currentBinding] = array_merge($this->wsdl->bindings[$this->currentBinding], $attrs); - break; - - case 'operation': - // sect 3.4 - // soap:operation, attributes: soapAction(required), style(optional, default = soap:binding:style) - if (!isset($attrs['style'])) { - $attrs['style'] = $this->wsdl->bindings[$this->currentBinding]['style']; - } - if (isset($this->wsdl->bindings[$this->currentBinding]['operations'][$this->currentOperation])) { - $this->wsdl->bindings[$this->currentBinding]['operations'][$this->currentOperation] = array_merge($this->wsdl->bindings[$this->currentBinding]['operations'][$this->currentOperation], $attrs); - } else { - $this->wsdl->bindings[$this->currentBinding]['operations'][$this->currentOperation] = $attrs; - } - break; - - case 'body': - // sect 3.5 - // soap:body attributes: - // part - optional. listed parts must appear in body, missing means all parts appear in body - // use - required. encoded|literal - // encodingStyle - optional. space seperated list of encodings (uri's) - $this->wsdl->bindings[$this->currentBinding] - ['operations'][$this->currentOperation][$this->opStatus] = $attrs; - break; - - case 'fault': - // sect 3.6 - // soap:fault attributes: name use encodingStyle namespace - $this->wsdl->bindings[$this->currentBinding] - ['operations'][$this->currentOperation][$this->opStatus] = $attrs; - break; - - case 'header': - // sect 3.7 - // soap:header attributes: message part use encodingStyle namespace - $this->wsdl->bindings[$this->currentBinding] - ['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; - break; - - case 'headerfault': - // sect 3.7 - // soap:header attributes: message part use encodingStyle namespace - $header = count($this->wsdl->bindings[$this->currentBinding] - ['operations'][$this->currentOperation][$this->opStatus]['headers'])-1; - $this->wsdl->bindings[$this->currentBinding] - ['operations'][$this->currentOperation][$this->opStatus]['headers'][$header]['fault'] = $attrs; - break; - - case 'documentation': - break; - - default: - // error! not a valid element inside binding - break; - } - break; - - case SCHEMA_WSDL: - // XXX verify correct namespace - // for now, default is the 'wsdl' namespace - // other possible namespaces include smtp, http, etc. for alternate bindings - switch ($qname->name) { - case 'operation': - // sect 2.5 - // wsdl:operation attributes: name - $this->currentOperation = $attrs['name']; - break; - - case 'output': - case 'input': - case 'fault': - // sect 2.5 - // wsdl:input attributes: name - $this->opStatus = $qname->name; - break; - - case 'documentation': - break; - - default: - break; - } - break; - - case SCHEMA_WSDL_HTTP: - switch ($qname->name) { - case 'binding': - // sect 4.4 - // http:binding attributes: verb - // parent: wsdl:binding - $this->wsdl->bindings[$this->currentBinding] = array_merge($this->wsdl->bindings[$this->currentBinding], $attrs); - break; - - case 'operation': - // sect 4.5 - // http:operation attributes: location - // parent: wsdl:operation - $this->wsdl->bindings[$this->currentBinding]['operations'] - [$this->currentOperation] = $attrs; - break; - - case 'urlEncoded': - // sect 4.6 - // http:urlEncoded attributes: location - // parent: wsdl:input wsdl:output etc. - $this->wsdl->bindings[$this->currentBinding]['operations'][$this->opStatus] - [$this->currentOperation]['uri'] = 'urlEncoded'; - break; - - case 'urlReplacement': - // sect 4.7 - // http:urlReplacement attributes: location - // parent: wsdl:input wsdl:output etc. - $this->wsdl->bindings[$this->currentBinding]['operations'][$this->opStatus] - [$this->currentOperation]['uri'] = 'urlReplacement'; - break; - - case 'documentation': - break; - - default: - // error - break; - } - - case SCHEMA_MIME: - // sect 5 - // all mime parts are children of wsdl:input, wsdl:output, etc. - // unsuported as of yet - switch ($qname->name) { - case 'content': - // sect 5.3 mime:content - // - // part attribute only required if content is child of multipart related, - // it contains the name of the part - // type attribute contains the mime type - case 'multipartRelated': - // sect 5.4 mime:multipartRelated - case 'part': - case 'mimeXml': - // sect 5.6 mime:mimeXml - // - // - case 'documentation': - break; - - default: - // error - break; - } - - case SCHEMA_DIME: - // DIME is defined in: - // http://gotdotnet.com/team/xml_wsspecs/dime/WSDL-Extension-for-DIME.htm - // all DIME parts are children of wsdl:input, wsdl:output, etc. - // unsuported as of yet - switch ($qname->name) { - case 'message': - // sect 4.1 dime:message - // appears in binding section - $this->wsdl->bindings[$this->currentBinding]['dime'] = $attrs; - break; - - default: - break; - } - - default: - break; - } - break; - - case 'service': - $ns = $qname->prefix ? $this->wsdl->namespaces[$qname->prefix] : SCHEMA_WSDL; - - switch ($qname->name) { - case 'port': - // sect 2.6 wsdl:port attributes: name binding - $this->currentPort = $attrs['name']; - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort] = $attrs; - // XXX hack to deal with binding namespaces - $qn = new QName($attrs['binding']); - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['binding'] = $qn->name; - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['namespace'] = $qn->prefix; - break; - - case 'address': - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['address'] = $attrs; - // what TYPE of port is it? SOAP or HTTP? - $ns = $qname->prefix ? $this->wsdl->namespaces[$qname->prefix] : SCHEMA_WSDL; - switch ($ns) { - case SCHEMA_WSDL_HTTP: - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['type']='http'; - break; - - case SCHEMA_SOAP: - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['type']='soap'; - break; - - default: - // Shouldn't happen, we'll assume SOAP. - $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['type']='soap'; - } - - break; - - case 'documentation': - break; - - default: - break; - } - } - - // Top level elements found under wsdl:definitions. - switch ($qname->name) { - case 'import': - case 'include': - // WSDL 2.1.1 wsdl:import, XML Schema 4.2.3 xsd:import, XML Schema - // 4.2.1 xsd:include attributes - $this->status = 'types'; - if (isset($attrs['location']) || isset($attrs['schemaLocation'])) { - $uri = isset($attrs['location']) ? $attrs['location'] : $attrs['schemaLocation']; - $location = @parse_url($uri); - if (!isset($location['scheme'])) { - $base = @parse_url($this->uri); - $uri = $this->mergeUrl($base, $uri); - } - if (isset($this->wsdl->imports[$uri])) { - break; - } - $this->wsdl->imports[$uri] = $attrs; - - $import_parser_class = get_class($this); - $import_parser = new $import_parser_class($uri, $this->wsdl, $this->docs); - if ($import_parser->fault) { - unset($this->wsdl->imports[$uri]); - return false; - } - } - $this->status = 'types'; - break; - - case 'types': - // sect 2.2 wsdl:types - $this->status = 'types'; - break; - - case 'schema': - // We can hit this at the top level if we've been asked to - // import an XSD file. - if (!empty($attrs['targetNamespace'])) { - $this->schema = $this->wsdl->getNamespaceAttributeName($attrs['targetNamespace']); - } else { - $this->schema = $this->wsdl->getNamespaceAttributeName($this->wsdl->tns); - } - $this->wsdl->complexTypes[$this->schema] = array(); - $this->wsdl->elements[$this->schema] = array(); - $this->schema_stack[] = $qname->name; - $this->status = 'types'; - break; - - case 'message': - // sect 2.3 wsdl:message attributes: name children:wsdl:part - $this->status = 'message'; - if (isset($attrs['name'])) { - $this->currentMessage = $attrs['name']; - $this->wsdl->messages[$this->currentMessage] = array(); - } - break; - - case 'portType': - // sect 2.4 wsdl:portType - // attributes: name - // children: wsdl:operation - $this->status = 'portType'; - $this->currentPortType = $attrs['name']; - $this->wsdl->portTypes[$this->currentPortType] = array(); - break; - - case 'binding': - // sect 2.5 wsdl:binding attributes: name type - // children: wsdl:operation soap:binding http:binding - if ($qname->prefix && $qname->prefix != $this->tns) { - break; - } - $this->status = 'binding'; - $this->currentBinding = $attrs['name']; - $qn = new QName($attrs['type']); - $this->wsdl->bindings[$this->currentBinding]['type'] = $qn->name; - $this->wsdl->bindings[$this->currentBinding]['namespace'] = $qn->prefix; - break; - - case 'service': - // sect 2.7 wsdl:service attributes: name children: ports - $this->currentService = $attrs['name']; - $this->wsdl->services[$this->currentService]['ports'] = array(); - $this->status = 'service'; - break; - - case 'definitions': - // sec 2.1 wsdl:definitions - // attributes: name targetNamespace xmlns:* - // children: wsdl:import wsdl:types wsdl:message wsdl:portType wsdl:binding wsdl:service - $this->wsdl->definition = $attrs; - foreach ($attrs as $key => $value) { - if (strstr($key, 'xmlns:') !== false) { - $qn = new QName($key); - // XXX need to refactor ns handling. - $this->wsdl->namespaces[$qn->name] = $value; - $this->wsdl->ns[$value] = $qn->name; - if ($key == 'targetNamespace' || - strcasecmp($value,SOAP_SCHEMA) == 0) { - $this->soapns[] = $qn->name; - } else { - if (in_array($value, $this->_XMLSchema)) { - $this->wsdl->xsd = $value; - } - } - } - } - if (isset($ns) && $ns) { - $namespace = 'xmlns:' . $ns; - if (!$this->wsdl->definition[$namespace]) { - return $this->_raiseSoapFault("parse error, no namespace for $namespace", $this->uri); - } - $this->tns = $ns; - } - break; - } - } - - /** - * end-element handler. - */ - function endElement($parser, $name) - { - $stacksize = count($this->element_stack); - if ($stacksize) { - if ($this->element_stack[$stacksize - 1] == 'definitions') { - $this->status = ''; - } - array_pop($this->element_stack); - } - - if (stristr($name, 'schema')) { - array_pop($this->schema_stack); - $this->schema = ''; - } - - if ($this->schema) { - array_pop($this->schema_stack); - if (count($this->schema_stack) <= 1) { - /* Correct the type for sequences with multiple - * elements. */ - if (isset($this->currentComplexType) && isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type']) - && $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] == 'Array' - && array_key_exists('elements', $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]) - && count($this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['elements']) > 1) { - $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Struct'; - } - } - if (stristr($name, 'complexType')) { - $this->currentComplexType = ''; - if (count($this->schema_element_stack)) { - $this->currentElement = array_pop($this->schema_element_stack); - } else { - $this->currentElement = ''; - } - } elseif (stristr($name, 'element')) { - if (count($this->schema_element_stack)) { - $this->currentElement = array_pop($this->schema_element_stack); - } else { - $this->currentElement = ''; - } - } - } - } - - /** - * Element content handler. - */ - function characterData($parser, $data) - { - // Store the documentation in the WSDL file. - if ($this->currentTag == 'documentation') { - $data = trim(preg_replace('/\s+/', ' ', $data)); - if (!strlen($data)) { - return; - } - - switch ($this->status) { - case 'service': - $ptr =& $this->wsdl->services[$this->currentService]; - break; - - case 'portType': - $ptr =& $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation]; - break; - - case 'binding': - $ptr =& $this->wsdl->bindings[$this->currentBinding]; - break; - - case 'message': - $ptr =& $this->wsdl->messages[$this->currentMessage]; - break; - - case 'operation': - break; - - case 'types': - if (isset($this->currentComplexType) && - isset($this->wsdl->complexTypes[$this->schema][$this->currentComplexType])) { - if ($this->currentElement) { - $ptr =& $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['elements'][$this->currentElement]; - } else { - $ptr =& $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]; - } - } - break; - } - - if (isset($ptr)) { - if (!isset($ptr['documentation'])) { - $ptr['documentation'] = ''; - } else { - $ptr['documentation'] .= ' '; - } - $ptr['documentation'] .= $data; - } - } - } - - /** - * $parsed is an array returned by parse_url(). - * - * @access private - */ - function mergeUrl($parsed, $path) - { - if (!is_array($parsed)) { - return false; - } - - $uri = ''; - if (!empty($parsed['scheme'])) { - $sep = (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://'); - $uri = $parsed['scheme'] . $sep; - } - - if (isset($parsed['pass'])) { - $uri .= "$parsed[user]:$parsed[pass]@"; - } elseif (isset($parsed['user'])) { - $uri .= "$parsed[user]@"; - } - - if (isset($parsed['host'])) { - $uri .= $parsed['host']; - } - if (isset($parsed['port'])) { - $uri .= ":$parsed[port]"; - } - if ($path[0] != '/' && isset($parsed['path'])) { - if ($parsed['path'][strlen($parsed['path']) - 1] != '/') { - $path = dirname($parsed['path']) . '/' . $path; - } else { - $path = $parsed['path'] . $path; - } - $path = $this->_normalize($path); - } - $sep = $path[0] == '/' ? '' : '/'; - $uri .= $sep . $path; - - return $uri; - } - - function _normalize($path_str) - { - $pwd = ''; - $strArr = preg_split('/(\/)/', $path_str, -1, PREG_SPLIT_NO_EMPTY); - $pwdArr = ''; - $j = 0; - for ($i = 0; $i < count($strArr); $i++) { - if ($strArr[$i] != ' ..') { - if ($strArr[$i] != ' .') { - $pwdArr[$j] = $strArr[$i]; - $j++; - } - } else { - array_pop($pwdArr); - $j--; - } - } - $pStr = implode('/', $pwdArr); - $pwd = (strlen($pStr) > 0) ? ('/' . $pStr) : '/'; - return $pwd; - } - -} - -/** - * Parses the types and methods used in web service objects into the internal - * data structures used by SOAP_WSDL. - * - * Assumes the SOAP_WSDL class is unpopulated to start with. - * - * @author Chris Coe - */ -class SOAP_WSDL_ObjectParser extends SOAP_Base -{ - /** - * Target namespace for the WSDL document will have the following - * prefix. - */ - var $tnsPrefix = 'tns'; - - /** - * Reference to the SOAP_WSDL object to populate. - */ - var $wsdl = null; - - /** - * Constructor. - * - * @param object|array $objects Reference to the object or array of - * objects to parse. - * @param SOAP_WSDL $wsdl Reference to the SOAP_WSDL object to - * populate. - * @param string $targetNamespace The target namespace of schema types - * etc. - * @param string $service_name Name of the WSDL . - * @param string $service_desc Optional description of the WSDL - * . - */ - function SOAP_WSDL_ObjectParser($objects, &$wsdl, $targetNamespace, - $service_name, $service_desc = '') - { - parent::SOAP_Base('WSDLOBJECTPARSER'); - - $this->wsdl = &$wsdl; - - // Set up the SOAP_WSDL object - $this->_initialise($service_name); - - // Parse each web service object - $wsdl_ref = is_array($objects) ? $objects : array($objects); - - foreach ($wsdl_ref as $ref_item) { - if (!is_object($ref_item)) { - $this->_raiseSoapFault('Invalid web service object passed to object parser'); - continue; - } - - if (!$this->_parse($ref_item, $targetNamespace, $service_name)) { - break; - } - } - - // Build bindings from abstract data. - if ($this->fault == null) { - $this->_generateBindingsAndServices($targetNamespace, $service_name, $service_desc); - } - } - - /** - * Initialise the SOAP_WSDL tree (destructive). - * - * If the object has already been initialised, the only effect - * will be to change the tns namespace to the new service name. - * - * @param $service_name Name of the WSDL - * @access private - */ - function _initialise($service_name) - { - // Set up the basic namespaces that all WSDL definitions use. - $this->wsdl->namespaces['wsdl'] = SCHEMA_WSDL; // WSDL language - $this->wsdl->namespaces['soap'] = SCHEMA_SOAP; // WSDL SOAP bindings - $this->wsdl->namespaces[$this->tnsPrefix] = 'urn:' . $service_name; // Target namespace - $this->wsdl->namespaces['xsd'] = array_search('xsd', $this->_namespaces); // XML Schema - $this->wsdl->namespaces[SOAP_BASE::SOAPENCPrefix()] = array_search(SOAP_BASE::SOAPENCPrefix(), $this->_namespaces); // SOAP types - - // XXX Refactor $namespace/$ns for Shane :-) - unset($this->wsdl->ns['urn:' . $service_name]); - $this->wsdl->ns += array_flip($this->wsdl->namespaces); - - // Imports are not implemented in WSDL generation from classes. - // *** *** - } - - /** - * Parser - takes a single object to add to tree (non-destructive). - * - * @access private - * - * @param object $object Reference to the object to parse. - * @param string $schemaNamespace - * @param string $service_name Name of the WSDL . - */ - function _parse($object, $schemaNamespace, $service_name) - { - // Create namespace prefix for the schema - list($schPrefix,) = $this->_getTypeNs('{' . $schemaNamespace . '}'); - - // Parse all the types defined by the object in whatever - // schema language we are using (currently __typedef arrays) - // *** *** - foreach ($object->__typedef as $typeName => $typeValue) { - // Get/create namespace definition - list($nsPrefix, $typeName) = $this->_getTypeNs($typeName); - - // Create type definition - $this->wsdl->complexTypes[$schPrefix][$typeName] = array('name' => $typeName); - $thisType =& $this->wsdl->complexTypes[$schPrefix][$typeName]; - - // According to Dmitri's documentation, __typedef comes in two - // flavors: - // Array = array(array("item" => "value")) - // Struct = array("item1" => "value1", "item2" => "value2", ...) - if (is_array($typeValue)) { - if (is_array(current($typeValue)) && count($typeValue) == 1 - && count(current($typeValue)) == 1) { - // It's an array - $thisType['type'] = 'Array'; - $nsType = current(current($typeValue)); - list($nsPrefix, $typeName) = $this->_getTypeNs($nsType); - $thisType['namespace'] = $nsPrefix; - $thisType['arrayType'] = $typeName . '[]'; - } elseif (!is_array(current($typeValue))) { - // It's a struct - $thisType['type'] = 'Struct'; - $thisType['order'] = 'all'; - $thisType['namespace'] = $nsPrefix; - $thisType['elements'] = array(); - - foreach ($typeValue as $elementName => $elementType) { - list($nsPrefix, $typeName) = $this->_getTypeNs($elementType); - $thisType['elements'][$elementName]['name'] = $elementName; - $thisType['elements'][$elementName]['type'] = $typeName; - $thisType['elements'][$elementName]['namespace'] = $nsPrefix; - } - } else { - // It's erroneous - return $this->_raiseSoapFault("The type definition for $nsPrefix:$typeName is invalid.", 'urn:' . get_class($object)); - } - } else { - // It's erroneous - return $this->_raiseSoapFault("The type definition for $nsPrefix:$typeName is invalid.", 'urn:' . get_class($object)); - } - } - - // Create an empty element array with the target namespace - // prefix, to match the results of WSDL parsing. - $this->wsdl->elements[$schPrefix] = array(); - - // Populate tree with message information - // *** *** - foreach ($object->__dispatch_map as $operationName => $messages) { - // We need at least 'in' and 'out' parameters. - if (!isset($messages['in']) || !isset($messages['out'])) { - return $this->_raiseSoapFault('The dispatch map for the method "' . $operationName . '" is missing an "in" or "out" definition.', 'urn:' . get_class($object)); - } - foreach ($messages as $messageType => $messageParts) { - unset($thisMessage); - - switch ($messageType) { - case 'in': - $this->wsdl->messages[$operationName . 'Request'] = array(); - $thisMessage =& $this->wsdl->messages[$operationName . 'Request']; - break; - - case 'out': - $this->wsdl->messages[$operationName . 'Response'] = array(); - $thisMessage =& $this->wsdl->messages[$operationName . 'Response']; - break; - - case 'alias': - // Do nothing - break; - - default: - // Error condition - break; - } - - if (isset($thisMessage)) { - foreach ($messageParts as $partName => $partType) { - list ($nsPrefix, $typeName) = $this->_getTypeNs($partType); - - $thisMessage[$partName] = array( - 'name' => $partName, - 'type' => $typeName, - 'namespace' => $nsPrefix - ); - } - } - } - } - - // Populate tree with portType information - // XXX Current implementation only supports one portType that - // encompasses all of the operations available. - // *** *** - if (!isset($this->wsdl->portTypes[$service_name . 'Port'])) { - $this->wsdl->portTypes[$service_name . 'Port'] = array(); - } - $thisPortType =& $this->wsdl->portTypes[$service_name . 'Port']; - - foreach ($object->__dispatch_map as $operationName => $messages) { - $thisPortType[$operationName] = array('name' => $operationName); - - foreach ($messages as $messageType => $messageParts) { - switch ($messageType) { - case 'in': - $thisPortType[$operationName]['input'] = array( - 'message' => $operationName . 'Request', - 'namespace' => $this->tnsPrefix); - break; - - case 'out': - $thisPortType[$operationName]['output'] = array( - 'message' => $operationName . 'Response', - 'namespace' => $this->tnsPrefix); - break; - } - } - } - - return true; - } - - /** - * Takes all the abstract WSDL data and builds concrete bindings and - * services (destructive). - * - * @access private - * @todo Current implementation discards $service_desc. - * - * @param string $schemaNamespace Namespace for types etc. - * @param string $service_name Name of the WSDL . - * @param string $service_desc Optional description of the WSDL - * . - */ - function _generateBindingsAndServices($schemaNamespace, $service_name, - $service_desc = '') - { - // Populate tree with bindings information - // XXX Current implementation only supports one binding that - // matches the single portType and all of its operations. - // XXX Is this the correct use of $schemaNamespace here? - // *** *** - $this->wsdl->bindings[$service_name . 'Binding'] = array( - 'type' => $service_name . 'Port', - 'namespace' => $this->tnsPrefix, - 'style' => 'rpc', - 'transport' => SCHEMA_SOAP_HTTP, - 'operations' => array()); - $thisBinding =& $this->wsdl->bindings[$service_name . 'Binding']; - - foreach ($this->wsdl->portTypes[$service_name . 'Port'] as $operationName => $operationData) { - $thisBinding['operations'][$operationName] = array( - 'soapAction' => $schemaNamespace . '#' . $operationName, - 'style' => $thisBinding['style']); - - foreach (array('input', 'output') as $messageType) - if (isset($operationData[$messageType])) { - $thisBinding['operations'][$operationName][$messageType] = array( - 'use' => 'encoded', - 'namespace' => $schemaNamespace, - 'encodingStyle' => SOAP_SCHEMA_ENCODING); - } - } - - // Populate tree with service information - // XXX Current implementation supports one service which groups - // all of the ports together, one port per binding - // *** *** - - $this->wsdl->services[$service_name . 'Service'] = array('ports' => array()); - $thisService =& $this->wsdl->services[$service_name . 'Service']['ports']; - $https = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) || - getenv('SSL_PROTOCOL_VERSION'); - - foreach ($this->wsdl->bindings as $bindingName => $bindingData) { - $thisService[$bindingData['type']] = array( - 'name' => $bindingData['type'], - 'binding' => $bindingName, - 'namespace' => $this->tnsPrefix, - 'address' => array('location' => - ($https ? 'https://' : 'http://') . - $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . - (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')), - 'type' => 'soap'); - } - - // Set service - $this->wsdl->set_service($service_name . 'Service'); - $this->wsdl->uri = $this->wsdl->namespaces[$this->tnsPrefix]; - - // Create WSDL definition - // *** *** - - $this->wsdl->definition = array( - 'name' => $service_name, - 'targetNamespace' => $this->wsdl->namespaces[$this->tnsPrefix], - 'xmlns' => SCHEMA_WSDL); - - foreach ($this->wsdl->namespaces as $nsPrefix => $namespace) { - $this->wsdl->definition['xmlns:' . $nsPrefix] = $namespace; - } - } - - /** - * This function is adapted from Dmitri V's implementation of - * DISCO/WSDL generation. It separates namespace from type name in - * a __typedef key and creates a new namespace entry in the WSDL - * structure if the namespace has not been used before. The - * namespace prefix and type name are returned. If no namespace is - * specified, xsd is assumed. - * - * We will not need this function anymore once __typedef is - * eliminated. - */ - function _getTypeNs($type) - { - preg_match_all('/\{(.*)\}/sm', $type, $m); - if (!empty($m[1][0])) { - if (!isset($this->wsdl->ns[$m[1][0]])) { - $ns_pref = 'ns' . count($this->wsdl->namespaces); - $this->wsdl->ns[$m[1][0]] = $ns_pref; - $this->wsdl->namespaces[$ns_pref] = $m[1][0]; - } - $typens = $this->wsdl->ns[$m[1][0]]; - $type = str_replace($m[0][0], '', $type); - } else { - $typens = 'xsd'; - } - - return array($typens, $type); - } - -} diff --git a/data/module/SearchReplace.php b/data/module/SearchReplace.php deleted file mode 100644 index fd5abb78107..00000000000 --- a/data/module/SearchReplace.php +++ /dev/null @@ -1,547 +0,0 @@ - | -// +-----------------------------------------------------------------------+ -// -// $Id$ -// -// Search and Replace Utility -// - -/** - * Search and Replace Utility - * - * - * @author Richard Heyes - * @version 1.0 - * @package File - */ -class File_SearchReplace -{ - - // {{{ Properties (All private) - - var $find; - var $replace; - var $files; - var $directories; - var $include_subdir; - var $ignore_lines; - var $ignore_sep; - var $occurences; - var $search_function; - var $php5; - var $last_error; - - // }}} - // {{{ Constructor - - /** - * Sets up the object - * - * @access public - * @param string $find The string/regex to find. - * @param string $replace The string/regex to replace $find with. - * @param array $files The file(s) to perform this operation on. - * @param array $directories (optional) The directories to perform this operation on. - * @param bool $include_subdir If performing on directories, whether to traverse subdirectories. - * @param array $ignore_lines Ignore lines beginning with any of the strings in this array. This - * feature only works with the "normal" search. - */ - function File_SearchReplace($find, $replace, $files, $directories = '', $include_subdir = TRUE, $ignore_lines = array()) - { - - $this->find = $find; - $this->replace = $replace; - $this->files = $files; - $this->directories = $directories; - $this->include_subdir = $include_subdir; - $this->ignore_lines = (array) $ignore_lines; - - $this->occurences = 0; - $this->search_function = 'search'; - $this->php5 = (substr(PHP_VERSION, 0, 1) == 5) ? TRUE : FALSE; - $this->last_error = ''; - - } - - // }}} - // {{{ getNumOccurences() - - /** - * Accessor to return the number of occurences found. - * - * @access public - * @return int Number of occurences found. - */ - function getNumOccurences() - { - return $this->occurences; - } - - // }}} - // {{{ getLastError() - - /** - * Accessor for retrieving last error. - * - * @access public - * @return string The last error that occurred, if any. - */ - function getLastError() - { - return $this->last_error; - } - - // }}} - // {{{ setFind() - - /** - * Accessor for setting find variable. - * - * @access public - * @param string $find The string/regex to find. - */ - function setFind($find) - { - $this->find = $find; - } - - // }}} - // {{{ setReplace() - - /** - * Accessor for setting replace variable. - * - * @access public - * @param string $replace The string/regex to replace the find string/regex with. - */ - function setReplace($replace) - { - $this->replace = $replace; - } - - // }}} - // {{{ setFiles() - - /** - * Accessor for setting files variable. - * - * @access public - * @param array $files The file(s) to perform this operation on. - */ - function setFiles($files) - { - $this->files = $files; - } - - // }}} - // {{{ setDirectories() - - /** - * Accessor for setting directories variable. - * - * @access public - * @param array $directories The directories to perform this operation on. - */ - function setDirectories($directories) - { - $this->directories = $directories; - } - - // }}} - // {{{ setIncludeSubdir - - /** - * Accessor for setting include_subdir variable. - * - * @access public - * @param bool $include_subdir Whether to traverse subdirectories or not. - */ - function setIncludeSubdir($include_subdir) - { - $this->include_subdir = $include_subdir; - } - - // }}} - // {{{ setIgnoreLines() - - /** - * Accessor for setting ignore_lines variable. - * - * @access public - * @param array $ignore_lines Ignore lines beginning with any of the strings in this array. This - * feature only works with the "normal" search. - */ - function setIgnoreLines($ignore_lines) - { - $this->ignore_lines = $ignore_lines; - } - - // }}} - // {{{ setSearchFunction() - - /** - * Function to determine which search function is used. - * - * @access public - * @param string The search function that should be used. Can be any one of: - * normal - Default search. Goes line by line. Ignore lines feature only works with this type. - * quick - Uses str_replace for straight replacement throughout file. Quickest of the lot. - * preg - Uses preg_replace(), so any regex valid with this function is valid here. - * ereg - Uses ereg_replace(), so any regex valid with this function is valid here. - */ - function setSearchFunction($search_function) - { - switch($search_function) { - case 'normal': $this->search_function = 'search'; - return TRUE; - break; - - case 'quick' : $this->search_function = 'quickSearch'; - return TRUE; - break; - - case 'preg' : $this->search_function = 'pregSearch'; - return TRUE; - break; - - case 'ereg' : $this->search_function = 'eregSearch'; - return TRUE; - break; - - default : $this->last_error = 'Invalid search function specified'; - return FALSE; - break; - } - } - - // }}} - // {{{ search() - - /** - * Default ("normal") search routine. - * - * @access private - * @param string $filename The filename to search and replace upon. - * @return array Will return an array containing the new file contents and the number of occurences. - * Will return FALSE if there are no occurences. - */ - function search($filename) - { - $occurences = 0; - $file_array = file($filename); - - if (empty($this->ignore_lines) && $this->php5) { // PHP5 acceleration - $file_array = str_replace($this->find, $this->replace, $file_array, $occurences); - - } else { // str_replace() doesn't return number of occurences in PHP4 - // so we need to count them manually and/or filter strings - $ignore_lines_num = count($this->ignore_lines); - - // just for the sake of catching occurences - $local_find = array_values((array) $this->find); - $local_replace = (is_array($this->replace)) ? array_values($this->replace) : $this->replace; - - for ($i=0; $i < count($file_array); $i++) { - - if ($ignore_lines_num > 0) { - for ($j=0; $j < $ignore_lines_num; $j++) { - if (substr($file_array[$i],0,strlen($this->ignore_lines[$j])) == $this->ignore_lines[$j]) continue 2; - } - } - - if ($this->php5) { - $file_array[$i] = str_replace($this->find, $this->replace, $file_array[$i], $counted); - $occurences += $counted; - } else { - foreach ($local_find as $fk => $ff) { - $occurences += substr_count($file_array[$i], $ff); - if (!is_array($local_replace)) { - $fr = $local_replace; - } else { - $fr = (isset($local_replace[$fk])) ? $local_replace[$fk] : ""; - } - $file_array[$i] = str_replace($ff, $fr, $file_array[$i]); - } - } - } - - } - if ($occurences > 0) $return = array($occurences, implode('', $file_array)); else $return = FALSE; - return $return; - - } - - // }}} - // {{{ quickSearch() - - /** - * Quick search routine. - * - * @access private - * @param string $filename The filename to search and replace upon. - * @return array Will return an array containing the new file contents and the number of occurences. - * Will return FALSE if there are no occurences. - */ - function quickSearch($filename) - { - - clearstatcache(); - - $file = fread($fp = fopen($filename, 'r'), max(1, filesize($filename))); fclose($fp); - $local_find = array_values((array) $this->find); - $local_replace = (is_array($this->replace)) ? array_values($this->replace) : $this->replace; - - $occurences = 0; - - // logic is the same as in str_replace function with one exception: - // if is a string and is an array - substitution - // is done from the first element of array. str_replace in this case - // usualy fails with notice and returns "ArrayArrayArray..." string - // (this exclusive logic of SearchReplace will not work for php5, though, - // because I haven't decided yet whether it is bug or feature) - - if ($this->php5) { - $file_array[$i] = str_replace($this->find, $this->replace, $file_array[$i], $counted); - $occurences += $counted; - } else { - foreach ($local_find as $fk => $ff) { - $occurences += substr_count($file, $ff); - if (!is_array($local_replace)) { - $fr = $local_replace; - } else { - $fr = (isset($local_replace[$fk])) ? $local_replace[$fk] : ""; - } - $file = str_replace($ff, $fr, $file); - } - } - - if ($occurences > 0) $return = array($occurences, $file); else $return = FALSE; - return $return; - - } - - // }}} - // {{{ pregSearch() - - /** - * Preg search routine. - * - * @access private - * @param string $filename The filename to search and replace upon. - * @return array Will return an array containing the new file contents and the number of occurences. - * Will return FALSE if there are no occurences. - */ - function pregSearch($filename) - { - - clearstatcache(); - - $file = fread($fp = fopen($filename, 'r'), max(1, filesize($filename))); fclose($fp); - $local_find = array_values((array) $this->find); - $local_replace = (is_array($this->replace)) ? array_values($this->replace) : $this->replace; - - $occurences = 0; - - foreach($local_find as $fk => $ff) { - $occurences += preg_match_all($ff, $file, $matches); - if (!is_array($local_replace)) { - $fr = $local_replace; - } else { - $fr = (isset($local_replace[$fk])) ? $local_replace[$fk] : ""; - } - $file = preg_replace($ff, $fr, $file); - } - - if ($occurences > 0) $return = array($occurences, $file); else $return = FALSE; - return $return; - - } - - // }}} - // {{{ eregSearch() - - /** - * Ereg search routine. - * - * @access private - * @param string $filename The filename to search and replace upon. - * @return array Will return an array containing the new file contents and the number of occurences. - * Will return FALSE if there are no occurences. - */ - function eregSearch($filename) - { - - clearstatcache(); - - $file = fread($fp = fopen($filename, 'r'), max(1, filesize($filename))); fclose($fp); - $local_find = array_values((array) $this->find); - $local_replace = (is_array($this->replace)) ? array_values($this->replace) : $this->replace; - - $occurences = 0; - - foreach($local_find as $fk => $ff) { - $occurences += count(split($ff, $file)) - 1; - if (!is_array($local_replace)) { - $fr = $local_replace; - } else { - $fr = (isset($local_replace[$fk])) ? $local_replace[$fk] : ""; - } - $file = ereg_replace($ff, $fr, $file); - } - - if ($occurences > 0) $return = array($occurences, $file); else $return = FALSE; - return $return; - - } - - // }}} - // {{{ writeout() - - /** - * Function to writeout the file contents. - * - * @access private - * @param string $filename The filename of the file to write. - * @param string $contents The contents to write to the file. - */ - function writeout($filename, $contents) - { - - if ($fp = @fopen($filename, 'w')) { - flock($fp,2); - fwrite($fp, $contents); - flock($fp,3); - fclose($fp); - } else { - $this->last_error = 'Could not open file: '.$filename; - } - - } - - // }}} - // {{{ doFiles() - - /** - * Function called by doSearch() to go through any files that need searching. - * - * @access private - * @param string $ser_func The search function to use. - */ - function doFiles($ser_func) - { - if (!is_array($this->files)) $this->files = explode(',', $this->files); - for ($i=0; $ifiles); $i++) { - if ($this->files[$i] == '.' OR $this->files[$i] == '..') continue; - if (is_dir($this->files[$i]) == TRUE) continue; - $newfile = $this->$ser_func($this->files[$i]); - if (is_array($newfile) == TRUE){ - $this->writeout($this->files[$i], $newfile[1]); - $this->occurences += $newfile[0]; - } - } - } - - // }}} - // {{{ doDirectories() - - /** - * Function called by doSearch() to go through any directories that need searching. - * - * @access private - * @param string $ser_func The search function to use. - */ - function doDirectories($ser_func) - { - if (!is_array($this->directories)) $this->directories = explode(',', $this->directories); - for ($i=0; $idirectories); $i++) { - $dh = opendir($this->directories[$i]); - while ($file = readdir($dh)) { - if ($file == '.' OR $file == '..') continue; - - if (is_dir($this->directories[$i].$file) == TRUE) { - if ($this->include_subdir == TRUE) { - $this->directories[] = $this->directories[$i].$file.'/'; - continue; - } else { - continue; - } - } - - $newfile = $this->$ser_func($this->directories[$i].$file); - if (is_array($newfile) == TRUE) { - $this->writeout($this->directories[$i].$file, $newfile[1]); - $this->occurences += $newfile[0]; - } - } - } - } - - // }}} - // {{{ doSearch() - - /** - * This starts the search/replace off. The behavior of this function will likely - * to be changed in future versions to work in read only mode. If you want to do - * actual replace with writing files - use doReplace method instead. - * - * @access public - */ - function doSearch() - { - $this->doReplace(); - } - - // }}} - // {{{ doReplace() - - /** - * This starts the search/replace off. Call this to do the replace. - * First do whatever files are specified, and/or if directories are specified, - * do those too. - * - * @access public - */ - function doReplace() - { - $this->occurences = 0; - if ($this->find != '') { - if ((is_array($this->files) AND count($this->files) > 0) OR $this->files != '') $this->doFiles($this->search_function); - if ($this->directories != '') $this->doDirectories($this->search_function); - } - } - - // }}} - -} -?> diff --git a/data/module/Services/JSON.php b/data/module/Services/JSON.php deleted file mode 100644 index 8283e7ef779..00000000000 --- a/data/module/Services/JSON.php +++ /dev/null @@ -1,806 +0,0 @@ - - * @author Matt Knapp - * @author Brett Stimmerman - * @copyright 2005 Michal Migurski - * @version CVS: $Id$ - * @license http://www.opensource.org/licenses/bsd-license.php - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 - */ - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_SLICE', 1); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_STR', 2); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_ARR', 3); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_OBJ', 4); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_CMT', 5); - -/** - * Behavior switch for Services_JSON::decode() - */ -define('SERVICES_JSON_LOOSE_TYPE', 16); - -/** - * Behavior switch for Services_JSON::decode() - */ -define('SERVICES_JSON_SUPPRESS_ERRORS', 32); - -/** - * Converts to and from JSON format. - * - * Brief example of use: - * - * - * // create a new instance of Services_JSON - * $json = new Services_JSON(); - * - * // convert a complexe value to JSON notation, and send it to the browser - * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4))); - * $output = $json->encode($value); - * - * print($output); - * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]] - * - * // accept incoming POST data, assumed to be in JSON notation - * $input = file_get_contents('php://input', 1000000); - * $value = $json->decode($input); - * - */ -class Services_JSON -{ - /** - * constructs a new JSON instance - * - * @param int $use object behavior flags; combine with boolean-OR - * - * possible values: - * - SERVICES_JSON_LOOSE_TYPE: loose typing. - * "{...}" syntax creates associative arrays - * instead of objects in decode(). - * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression. - * Values which can't be encoded (e.g. resources) - * appear as NULL instead of throwing errors. - * By default, a deeply-nested resource will - * bubble up with an error, so all return values - * from encode() should be checked with isError() - */ - function Services_JSON($use = 0) - { - $this->use = $use; - } - - /** - * convert a string from one UTF-16 char to one UTF-8 char - * - * Normally should be handled by mb_convert_encoding, but - * provides a slower PHP-only method for installations - * that lack the multibye string extension. - * - * @param string $utf16 UTF-16 character - * @return string UTF-8 character - * @access private - */ - function utf162utf8($utf16) - { - // oh please oh please oh please oh please oh please - if(function_exists('mb_convert_encoding')) { - return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); - } - - $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); - - switch(true) { - case ((0x7F & $bytes) == $bytes): - // this case should never be reached, because we are in ASCII range - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x7F & $bytes); - - case (0x07FF & $bytes) == $bytes: - // return a 2-byte UTF-8 character - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0xC0 | (($bytes >> 6) & 0x1F)) - . chr(0x80 | ($bytes & 0x3F)); - - case (0xFFFF & $bytes) == $bytes: - // return a 3-byte UTF-8 character - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0xE0 | (($bytes >> 12) & 0x0F)) - . chr(0x80 | (($bytes >> 6) & 0x3F)) - . chr(0x80 | ($bytes & 0x3F)); - } - - // ignoring UTF-32 for now, sorry - return ''; - } - - /** - * convert a string from one UTF-8 char to one UTF-16 char - * - * Normally should be handled by mb_convert_encoding, but - * provides a slower PHP-only method for installations - * that lack the multibye string extension. - * - * @param string $utf8 UTF-8 character - * @return string UTF-16 character - * @access private - */ - function utf82utf16($utf8) - { - // oh please oh please oh please oh please oh please - if(function_exists('mb_convert_encoding')) { - return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); - } - - switch(strlen($utf8)) { - case 1: - // this case should never be reached, because we are in ASCII range - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return $utf8; - - case 2: - // return a UTF-16 character from a 2-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8{0}) >> 2)) - . chr((0xC0 & (ord($utf8{0}) << 6)) - | (0x3F & ord($utf8{1}))); - - case 3: - // return a UTF-16 character from a 3-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8{0}) << 4)) - | (0x0F & (ord($utf8{1}) >> 2))) - . chr((0xC0 & (ord($utf8{1}) << 6)) - | (0x7F & ord($utf8{2}))); - } - - // ignoring UTF-32 for now, sorry - return ''; - } - - /** - * encodes an arbitrary variable into JSON format - * - * @param mixed $var any number, boolean, string, array, or object to be encoded. - * see argument 1 to Services_JSON() above for array-parsing behavior. - * if var is a strng, note that encode() always expects it - * to be in ASCII or UTF-8 format! - * - * @return mixed JSON string representation of input var or an error if a problem occurs - * @access public - */ - function encode($var) - { - switch (gettype($var)) { - case 'boolean': - return $var ? 'true' : 'false'; - - case 'NULL': - return 'null'; - - case 'integer': - return (int) $var; - - case 'double': - case 'float': - return (float) $var; - - case 'string': - // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT - $ascii = ''; - $strlen_var = strlen($var); - - /* - * Iterate over every character in the string, - * escaping with a slash or encoding to UTF-8 where necessary - */ - for ($c = 0; $c < $strlen_var; ++$c) { - - $ord_var_c = ord($var{$c}); - - switch (true) { - case $ord_var_c == 0x08: - $ascii .= '\b'; - break; - case $ord_var_c == 0x09: - $ascii .= '\t'; - break; - case $ord_var_c == 0x0A: - $ascii .= '\n'; - break; - case $ord_var_c == 0x0C: - $ascii .= '\f'; - break; - case $ord_var_c == 0x0D: - $ascii .= '\r'; - break; - - case $ord_var_c == 0x22: - case $ord_var_c == 0x2F: - case $ord_var_c == 0x5C: - // double quote, slash, slosh - $ascii .= '\\'.$var{$c}; - break; - - case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): - // characters U-00000000 - U-0000007F (same as ASCII) - $ascii .= $var{$c}; - break; - - case (($ord_var_c & 0xE0) == 0xC0): - // characters U-00000080 - U-000007FF, mask 110XXXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($var{$c + 1})); - $c += 1; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xF0) == 0xE0): - // characters U-00000800 - U-0000FFFF, mask 1110XXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2})); - $c += 2; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xF8) == 0xF0): - // characters U-00010000 - U-001FFFFF, mask 11110XXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3})); - $c += 3; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xFC) == 0xF8): - // characters U-00200000 - U-03FFFFFF, mask 111110XX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4})); - $c += 4; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xFE) == 0xFC): - // characters U-04000000 - U-7FFFFFFF, mask 1111110X - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4}), - ord($var{$c + 5})); - $c += 5; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - } - } - - return '"'.$ascii.'"'; - - case 'array': - /* - * As per JSON spec if any array key is not an integer - * we must treat the the whole array as an object. We - * also try to catch a sparsely populated associative - * array with numeric keys here because some JS engines - * will create an array with empty indexes up to - * max_index which can cause memory issues and because - * the keys, which may be relevant, will be remapped - * otherwise. - * - * As per the ECMA and JSON specification an object may - * have any string as a property. Unfortunately due to - * a hole in the ECMA specification if the key is a - * ECMA reserved word or starts with a digit the - * parameter is only accessible using ECMAScript's - * bracket notation. - */ - - // treat as a JSON object - if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { - $properties = array_map(array($this, 'name_value'), - array_keys($var), - array_values($var)); - - foreach($properties as $property) { - if(Services_JSON::isError($property)) { - return $property; - } - } - - return '{' . join(',', $properties) . '}'; - } - - // treat it like a regular array - $elements = array_map(array($this, 'encode'), $var); - - foreach($elements as $element) { - if(Services_JSON::isError($element)) { - return $element; - } - } - - return '[' . join(',', $elements) . ']'; - - case 'object': - $vars = get_object_vars($var); - - $properties = array_map(array($this, 'name_value'), - array_keys($vars), - array_values($vars)); - - foreach($properties as $property) { - if(Services_JSON::isError($property)) { - return $property; - } - } - - return '{' . join(',', $properties) . '}'; - - default: - return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) - ? 'null' - : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string"); - } - } - - /** - * array-walking function for use in generating JSON-formatted name-value pairs - * - * @param string $name name of key to use - * @param mixed $value reference to an array element to be encoded - * - * @return string JSON-formatted name-value pair, like '"name":value' - * @access private - */ - function name_value($name, $value) - { - $encoded_value = $this->encode($value); - - if(Services_JSON::isError($encoded_value)) { - return $encoded_value; - } - - return $this->encode(strval($name)) . ':' . $encoded_value; - } - - /** - * reduce a string by removing leading and trailing comments and whitespace - * - * @param $str string string value to strip of comments and whitespace - * - * @return string string value stripped of comments and whitespace - * @access private - */ - function reduce_string($str) - { - $str = preg_replace(array( - - // eliminate single line comments in '// ...' form - '#^\s*//(.+)$#m', - - // eliminate multi-line comments in '/* ... */' form, at start of string - '#^\s*/\*(.+)\*/#Us', - - // eliminate multi-line comments in '/* ... */' form, at end of string - '#/\*(.+)\*/\s*$#Us' - - ), '', $str); - - // eliminate extraneous space - return trim($str); - } - - /** - * decodes a JSON string into appropriate variable - * - * @param string $str JSON-formatted string - * - * @return mixed number, boolean, string, array, or object - * corresponding to given JSON input string. - * See argument 1 to Services_JSON() above for object-output behavior. - * Note that decode() always returns strings - * in ASCII or UTF-8 format! - * @access public - */ - function decode($str) - { - $str = $this->reduce_string($str); - - switch (strtolower($str)) { - case 'true': - return true; - - case 'false': - return false; - - case 'null': - return null; - - default: - $m = array(); - - if (is_numeric($str)) { - // Lookie-loo, it's a number - - // This would work on its own, but I'm trying to be - // good about returning integers where appropriate: - // return (float)$str; - - // Return float or int, as appropriate - return ((float)$str == (integer)$str) - ? (integer)$str - : (float)$str; - - } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) { - // STRINGS RETURNED IN UTF-8 FORMAT - $delim = substr($str, 0, 1); - $chrs = substr($str, 1, -1); - $utf8 = ''; - $strlen_chrs = strlen($chrs); - - for ($c = 0; $c < $strlen_chrs; ++$c) { - - $substr_chrs_c_2 = substr($chrs, $c, 2); - $ord_chrs_c = ord($chrs{$c}); - - switch (true) { - case $substr_chrs_c_2 == '\b': - $utf8 .= chr(0x08); - ++$c; - break; - case $substr_chrs_c_2 == '\t': - $utf8 .= chr(0x09); - ++$c; - break; - case $substr_chrs_c_2 == '\n': - $utf8 .= chr(0x0A); - ++$c; - break; - case $substr_chrs_c_2 == '\f': - $utf8 .= chr(0x0C); - ++$c; - break; - case $substr_chrs_c_2 == '\r': - $utf8 .= chr(0x0D); - ++$c; - break; - - case $substr_chrs_c_2 == '\\"': - case $substr_chrs_c_2 == '\\\'': - case $substr_chrs_c_2 == '\\\\': - case $substr_chrs_c_2 == '\\/': - if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || - ($delim == "'" && $substr_chrs_c_2 != '\\"')) { - $utf8 .= $chrs{++$c}; - } - break; - - case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)): - // single, escaped unicode character - $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2))) - . chr(hexdec(substr($chrs, ($c + 4), 2))); - $utf8 .= $this->utf162utf8($utf16); - $c += 5; - break; - - case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): - $utf8 .= $chrs{$c}; - break; - - case ($ord_chrs_c & 0xE0) == 0xC0: - // characters U-00000080 - U-000007FF, mask 110XXXXX - //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 2); - ++$c; - break; - - case ($ord_chrs_c & 0xF0) == 0xE0: - // characters U-00000800 - U-0000FFFF, mask 1110XXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 3); - $c += 2; - break; - - case ($ord_chrs_c & 0xF8) == 0xF0: - // characters U-00010000 - U-001FFFFF, mask 11110XXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 4); - $c += 3; - break; - - case ($ord_chrs_c & 0xFC) == 0xF8: - // characters U-00200000 - U-03FFFFFF, mask 111110XX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 5); - $c += 4; - break; - - case ($ord_chrs_c & 0xFE) == 0xFC: - // characters U-04000000 - U-7FFFFFFF, mask 1111110X - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 6); - $c += 5; - break; - - } - - } - - return $utf8; - - } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { - // array, or object notation - - if ($str{0} == '[') { - $stk = array(SERVICES_JSON_IN_ARR); - $arr = array(); - } else { - if ($this->use & SERVICES_JSON_LOOSE_TYPE) { - $stk = array(SERVICES_JSON_IN_OBJ); - $obj = array(); - } else { - $stk = array(SERVICES_JSON_IN_OBJ); - $obj = new stdClass(); - } - } - - array_push($stk, array('what' => SERVICES_JSON_SLICE, - 'where' => 0, - 'delim' => false)); - - $chrs = substr($str, 1, -1); - $chrs = $this->reduce_string($chrs); - - if ($chrs == '') { - if (reset($stk) == SERVICES_JSON_IN_ARR) { - return $arr; - - } else { - return $obj; - - } - } - - //print("\nparsing {$chrs}\n"); - - $strlen_chrs = strlen($chrs); - - for ($c = 0; $c <= $strlen_chrs; ++$c) { - - $top = end($stk); - $substr_chrs_c_2 = substr($chrs, $c, 2); - - if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { - // found a comma that is not inside a string, array, etc., - // OR we've reached the end of the character list - $slice = substr($chrs, $top['where'], ($c - $top['where'])); - array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false)); - //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - if (reset($stk) == SERVICES_JSON_IN_ARR) { - // we are in an array, so just push an element onto the stack - array_push($arr, $this->decode($slice)); - - } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { - // we are in an object, so figure - // out the property name and set an - // element in an associative array, - // for now - $parts = array(); - - if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { - // "name":value pair - $key = $this->decode($parts[1]); - $val = $this->decode($parts[2]); - - if ($this->use & SERVICES_JSON_LOOSE_TYPE) { - $obj[$key] = $val; - } else { - $obj->$key = $val; - } - } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { - // name:value pair, where name is unquoted - $key = $parts[1]; - $val = $this->decode($parts[2]); - - if ($this->use & SERVICES_JSON_LOOSE_TYPE) { - $obj[$key] = $val; - } else { - $obj->$key = $val; - } - } - - } - - } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { - // found a quote, and we are not inside a string - array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); - //print("Found start of string at {$c}\n"); - - } elseif (($chrs{$c} == $top['delim']) && - ($top['what'] == SERVICES_JSON_IN_STR) && - ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) { - // found a quote, we're in a string, and it's not escaped - // we know that it's not escaped becase there is _not_ an - // odd number of backslashes at the end of the string so far - array_pop($stk); - //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); - - } elseif (($chrs{$c} == '[') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { - // found a left-bracket, and we are in an array, object, or slice - array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); - //print("Found start of array at {$c}\n"); - - } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { - // found a right-bracket, and we're in an array - array_pop($stk); - //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - } elseif (($chrs{$c} == '{') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { - // found a left-brace, and we are in an array, object, or slice - array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); - //print("Found start of object at {$c}\n"); - - } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { - // found a right-brace, and we're in an object - array_pop($stk); - //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - } elseif (($substr_chrs_c_2 == '/*') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { - // found a comment start, and we are in an array, object, or slice - array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false)); - $c++; - //print("Found start of comment at {$c}\n"); - - } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) { - // found a comment end, and we're in one now - array_pop($stk); - $c++; - - for ($i = $top['where']; $i <= $c; ++$i) - $chrs = substr_replace($chrs, ' ', $i, 1); - - //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - } - - } - - if (reset($stk) == SERVICES_JSON_IN_ARR) { - return $arr; - - } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { - return $obj; - - } - - } - } - } - - /** - * @todo Ultimately, this should just call PEAR::isError() - */ - function isError($data, $code = null) - { - if (class_exists('pear')) { - return PEAR::isError($data, $code); - } elseif (is_object($data) && (get_class($data) == 'services_json_error' || - is_subclass_of($data, 'services_json_error'))) { - return true; - } - - return false; - } -} - -if (class_exists('PEAR_Error')) { - - class Services_JSON_Error extends PEAR_Error - { - function Services_JSON_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - parent::PEAR_Error($message, $code, $mode, $options, $userinfo); - } - } - -} else { - - /** - * @todo Ultimately, this class shall be descended from PEAR_Error - */ - class Services_JSON_Error - { - function Services_JSON_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - - } - } - -} - -?> diff --git a/data/module/Services/JSON/LICENSE b/data/module/Services/JSON/LICENSE deleted file mode 100644 index 4ae6bef55df..00000000000 --- a/data/module/Services/JSON/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/data/module/Services/JSON/Test-JSON.php b/data/module/Services/JSON/Test-JSON.php deleted file mode 100644 index 49ac3a43550..00000000000 --- a/data/module/Services/JSON/Test-JSON.php +++ /dev/null @@ -1,521 +0,0 @@ - - * @author Matt Knapp - * @author Brett Stimmerman - * @copyright 2005 Michal Migurski - * @version CVS: $Id$ - * @license http://www.opensource.org/licenses/bsd-license.php - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 - */ - - error_reporting(E_ALL); - - require_once 'PHPUnit.php'; - require_once 'JSON.php'; - - class Services_JSON_EncDec_TestCase extends PHPUnit_TestCase { - - function Services_JSON_EncDec_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json = new Services_JSON(); - - $obj = new stdClass(); - $obj->a_string = '"he":llo}:{world'; - $obj->an_array = array(1, 2, 3); - $obj->obj = new stdClass(); - $obj->obj->a_number = 123; - - $this->obj = $obj; - $this->obj_j = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}}'; - $this->obj_d = 'object with properties, nested object and arrays'; - - $this->arr = array(null, true, array(1, 2, 3), "hello\"],[world!"); - $this->arr_j = '[null,true,[1,2,3],"hello\"],[world!"]'; - $this->arr_d = 'array with elements and nested arrays'; - - $this->str1 = 'hello world'; - $this->str1_j = '"hello world"'; - $this->str1_j_ = "'hello world'"; - $this->str1_d = 'hello world'; - $this->str1_d_ = 'hello world, double quotes'; - - $this->str2 = "hello\t\"world\""; - $this->str2_j = '"hello\\t\\"world\\""'; - $this->str2_d = 'hello world, with tab, double-quotes'; - - $this->str3 = "\\\r\n\t\"/"; - $this->str3_j = '"\\\\\\r\\n\\t\\"\\/"'; - $this->str3_d = 'backslash, return, newline, tab, double-quote'; - - $this->str4 = 'héllö wørłd'; - $this->str4_j = '"h\u00e9ll\u00f6 w\u00f8r\u0142d"'; - $this->str4_j_ = '"héllö wørłd"'; - $this->str4_d = 'hello world, with unicode'; - } - - function test_to_JSON() - { - $this->assertEquals('null', $this->json->encode(null), 'type case: null'); - $this->assertEquals('true', $this->json->encode(true), 'type case: boolean true'); - $this->assertEquals('false', $this->json->encode(false), 'type case: boolean false'); - - $this->assertEquals('1', $this->json->encode(1), 'numeric case: 1'); - $this->assertEquals('-1', $this->json->encode(-1), 'numeric case: -1'); - $this->assertEquals('1.000000', $this->json->encode(1.0), 'numeric case: 1.0'); - $this->assertEquals('1.100000', $this->json->encode(1.1), 'numeric case: 1.1'); - - $this->assertEquals($this->str1_j, $this->json->encode($this->str1), "string case: {$this->str1_d}"); - $this->assertEquals($this->str2_j, $this->json->encode($this->str2), "string case: {$this->str2_d}"); - $this->assertEquals($this->str3_j, $this->json->encode($this->str3), "string case: {$this->str3_d}"); - $this->assertEquals($this->str4_j, $this->json->encode($this->str4), "string case: {$this->str4_d}"); - - $this->assertEquals($this->arr_j, $this->json->encode($this->arr), "array case: {$this->arr_d}"); - $this->assertEquals($this->obj_j, $this->json->encode($this->obj), "object case: {$this->obj_d}"); - } - - function test_from_JSON() - { - $this->assertEquals(null, $this->json->decode('null'), 'type case: null'); - $this->assertEquals(true, $this->json->decode('true'), 'type case: boolean true'); - $this->assertEquals(false, $this->json->decode('false'), 'type case: boolean false'); - - $this->assertEquals(1, $this->json->decode('1'), 'numeric case: 1'); - $this->assertEquals(-1, $this->json->decode('-1'), 'numeric case: -1'); - $this->assertEquals(1.0, $this->json->decode('1.0'), 'numeric case: 1.0'); - $this->assertEquals(1.1, $this->json->decode('1.1'), 'numeric case: 1.1'); - - $this->assertEquals(11.0, $this->json->decode('1.1e1'), 'numeric case: 1.1e1'); - $this->assertEquals(11.0, $this->json->decode('1.10e+1'), 'numeric case: 1.10e+1'); - $this->assertEquals(0.11, $this->json->decode('1.1e-1'), 'numeric case: 1.1e-1'); - $this->assertEquals(-0.11, $this->json->decode('-1.1e-1'), 'numeric case: -1.1e-1'); - - $this->assertEquals($this->str1, $this->json->decode($this->str1_j), "string case: {$this->str1_d}"); - $this->assertEquals($this->str1, $this->json->decode($this->str1_j_), "string case: {$this->str1_d_}"); - $this->assertEquals($this->str2, $this->json->decode($this->str2_j), "string case: {$this->str2_d}"); - $this->assertEquals($this->str3, $this->json->decode($this->str3_j), "string case: {$this->str3_d}"); - $this->assertEquals($this->str4, $this->json->decode($this->str4_j), "string case: {$this->str4_d}"); - $this->assertEquals($this->str4, $this->json->decode($this->str4_j_), "string case: {$this->str4_d}"); - - $this->assertEquals($this->arr, $this->json->decode($this->arr_j), "array case: {$this->arr_d}"); - $this->assertEquals($this->obj, $this->json->decode($this->obj_j), "object case: {$this->obj_d}"); - } - - function test_to_then_from_JSON() - { - $this->assertEquals(null, $this->json->decode($this->json->encode(null)), 'type case: null'); - $this->assertEquals(true, $this->json->decode($this->json->encode(true)), 'type case: boolean true'); - $this->assertEquals(false, $this->json->decode($this->json->encode(false)), 'type case: boolean false'); - - $this->assertEquals(1, $this->json->decode($this->json->encode(1)), 'numeric case: 1'); - $this->assertEquals(-1, $this->json->decode($this->json->encode(-1)), 'numeric case: -1'); - $this->assertEquals(1.0, $this->json->decode($this->json->encode(1.0)), 'numeric case: 1.0'); - $this->assertEquals(1.1, $this->json->decode($this->json->encode(1.1)), 'numeric case: 1.1'); - - $this->assertEquals($this->str1, $this->json->decode($this->json->encode($this->str1)), "string case: {$this->str1_d}"); - $this->assertEquals($this->str2, $this->json->decode($this->json->encode($this->str2)), "string case: {$this->str2_d}"); - $this->assertEquals($this->str3, $this->json->decode($this->json->encode($this->str3)), "string case: {$this->str3_d}"); - $this->assertEquals($this->str4, $this->json->decode($this->json->encode($this->str4)), "string case: {$this->str4_d}"); - - $this->assertEquals($this->arr, $this->json->decode($this->json->encode($this->arr)), "array case: {$this->arr_d}"); - $this->assertEquals($this->obj, $this->json->decode($this->json->encode($this->obj)), "object case: {$this->obj_d}"); - } - - function test_from_then_to_JSON() - { - $this->assertEquals('null', $this->json->encode($this->json->decode('null')), 'type case: null'); - $this->assertEquals('true', $this->json->encode($this->json->decode('true')), 'type case: boolean true'); - $this->assertEquals('false', $this->json->encode($this->json->decode('false')), 'type case: boolean false'); - - $this->assertEquals('1', $this->json->encode($this->json->decode('1')), 'numeric case: 1'); - $this->assertEquals('-1', $this->json->encode($this->json->decode('-1')), 'numeric case: -1'); - $this->assertEquals('1.0', $this->json->encode($this->json->decode('1.0')), 'numeric case: 1.0'); - $this->assertEquals('1.1', $this->json->encode($this->json->decode('1.1')), 'numeric case: 1.1'); - - $this->assertEquals($this->str1_j, $this->json->encode($this->json->decode($this->str1_j)), "string case: {$this->str1_d}"); - $this->assertEquals($this->str2_j, $this->json->encode($this->json->decode($this->str2_j)), "string case: {$this->str2_d}"); - $this->assertEquals($this->str3_j, $this->json->encode($this->json->decode($this->str3_j)), "string case: {$this->str3_d}"); - $this->assertEquals($this->str4_j, $this->json->encode($this->json->decode($this->str4_j)), "string case: {$this->str4_d}"); - $this->assertEquals($this->str4_j, $this->json->encode($this->json->decode($this->str4_j_)), "string case: {$this->str4_d}"); - - $this->assertEquals($this->arr_j, $this->json->encode($this->json->decode($this->arr_j)), "array case: {$this->arr_d}"); - $this->assertEquals($this->obj_j, $this->json->encode($this->json->decode($this->obj_j)), "object case: {$this->obj_d}"); - } - } - - class Services_JSON_AssocArray_TestCase extends PHPUnit_TestCase { - - function Services_JSON_AssocArray_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json_l = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - $this->json_s = new Services_JSON(); - - $this->arr = array('car1'=> array('color'=> 'tan', 'model' => 'sedan'), - 'car2' => array('color' => 'red', 'model' => 'sports')); - $this->arr_jo = '{"car1":{"color":"tan","model":"sedan"},"car2":{"color":"red","model":"sports"}}'; - $this->arr_d = 'associative array with nested associative arrays'; - - $this->arn = array(0=> array(0=> 'tan\\', 'model\\' => 'sedan'), 1 => array(0 => 'red', 'model' => 'sports')); - $this->arn_ja = '[{"0":"tan\\\\","model\\\\":"sedan"},{"0":"red","model":"sports"}]'; - $this->arn_d = 'associative array with nested associative arrays, and some numeric keys thrown in'; - - $this->arrs = array (1 => 'one', 2 => 'two', 5 => 'five'); - $this->arrs_jo = '{"1":"one","2":"two","5":"five"}'; - $this->arrs_d = 'associative array numeric keys which are not fully populated in a range of 0 to length-1'; - } - - function test_type() - { - $this->assertEquals('array', gettype($this->json_l->decode($this->arn_ja)), "loose type should be array"); - $this->assertEquals('array', gettype($this->json_s->decode($this->arn_ja)), "strict type should be array"); - } - - function test_to_JSON() - { - // both strict and loose JSON should result in an object - $this->assertEquals($this->arr_jo, $this->json_l->encode($this->arr), "array case - loose: {$this->arr_d}"); - $this->assertEquals($this->arr_jo, $this->json_s->encode($this->arr), "array case - strict: {$this->arr_d}"); - - // ...unless the input array has some numeric indeces, in which case the behavior is to degrade to a regular array - $this->assertEquals($this->arn_ja, $this->json_s->encode($this->arn), "array case - strict: {$this->arn_d}"); - - // Test a sparsely populated numerically indexed associative array - $this->assertEquals($this->arrs_jo, $this->json_l->encode($this->arrs), "sparse numeric assoc array: {$this->arrs_d}"); - } - - function test_to_then_from_JSON() - { - // these tests motivated by a bug in which strings that end - // with backslashes followed by quotes were incorrectly decoded. - - foreach(array('\\"', '\\\\"', '\\"\\"', '\\""\\""', '\\\\"\\\\"') as $v) { - $this->assertEquals(array($v), $this->json_l->decode($this->json_l->encode(array($v)))); - $this->assertEquals(array('a' => $v), $this->json_l->decode($this->json_l->encode(array('a' => $v)))); - } - } - } - - class Services_JSON_NestedArray_TestCase extends PHPUnit_TestCase { - - function Services_JSON_NestedArray_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - - $this->str1 = '[{"this":"that"}]'; - $this->arr1 = array(array('this' => 'that')); - - $this->str2 = '{"this":["that"]}'; - $this->arr2 = array('this' => array('that')); - - $this->str3 = '{"params":[{"foo":["1"],"bar":"1"}]}'; - $this->arr3 = array('params' => array(array('foo' => array('1'), 'bar' => '1'))); - - $this->str4 = '{"0": {"foo": "bar", "baz": "winkle"}}'; - $this->arr4 = array('0' => array('foo' => 'bar', 'baz' => 'winkle')); - - $this->str5 = '{"params":[{"options": {"old": [ ], "new": {"0": {"elements": {"old": [], "new": {"0": {"elementName": "aa", "isDefault": false, "elementRank": "0", "priceAdjust": "0", "partNumber": ""}}}, "optionName": "aa", "isRequired": false, "optionDesc": null}}}}]}'; - $this->arr5 = array ( - 'params' => array ( - 0 => array ( - 'options' => - array ( - 'old' => array(), - 'new' => array ( - 0 => array ( - 'elements' => array ( - 'old' => array(), - 'new' => array ( - 0 => array ( - 'elementName' => 'aa', - 'isDefault' => false, - 'elementRank' => '0', - 'priceAdjust' => '0', - 'partNumber' => '', - ), - ), - ), - 'optionName' => 'aa', - 'isRequired' => false, - 'optionDesc' => NULL, - ), - ), - ), - ), - ), - ); - } - - function test_type() - { - $this->assertEquals('array', gettype($this->json->decode($this->str1)), "loose type should be array"); - $this->assertEquals('array', gettype($this->json->decode($this->str2)), "loose type should be array"); - $this->assertEquals('array', gettype($this->json->decode($this->str3)), "loose type should be array"); - } - - function test_from_JSON() - { - $this->assertEquals($this->arr1, $this->json->decode($this->str1), "simple compactly-nested array"); - $this->assertEquals($this->arr2, $this->json->decode($this->str2), "simple compactly-nested array"); - $this->assertEquals($this->arr3, $this->json->decode($this->str3), "complex compactly nested array"); - $this->assertEquals($this->arr4, $this->json->decode($this->str4), "complex compactly nested array"); - $this->assertEquals($this->arr5, $this->json->decode($this->str5), "super complex compactly nested array"); - } - - function _test_from_JSON() - { - $super = '{"params":[{"options": {"old": {}, "new": {"0": {"elements": {"old": {}, "new": {"0": {"elementName": "aa", "isDefault": false, "elementRank": "0", "priceAdjust": "0", "partNumber": ""}}}, "optionName": "aa", "isRequired": false, "optionDesc": ""}}}}]}'; - print("trying {$super}...\n"); - print var_export($this->json->decode($super)); - } - } - - class Services_JSON_Object_TestCase extends PHPUnit_TestCase { - - function Services_JSON_Object_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json_l = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - $this->json_s = new Services_JSON(); - - $this->obj_j = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}}'; - - $this->obj1->car1->color = 'tan'; - $this->obj1->car1->model = 'sedan'; - $this->obj1->car2->color = 'red'; - $this->obj1->car2->model = 'sports'; - $this->obj1_j = '{"car1":{"color":"tan","model":"sedan"},"car2":{"color":"red","model":"sports"}}'; - $this->obj1_d = 'Object with nested objects'; - } - - function test_type() - { - $this->assertEquals('object', gettype($this->json_s->decode($this->obj_j)), "checking whether decoded type is object"); - $this->assertEquals('array', gettype($this->json_l->decode($this->obj_j)), "checking whether decoded type is array"); - } - - function test_to_JSON() - { - $this->assertEquals($this->obj1_j, $this->json_s->encode($this->obj1), "object - strict: {$this->obj1_d}"); - $this->assertEquals($this->obj1_j, $this->json_l->encode($this->obj1), "object - loose: {$this->obj1_d}"); - } - - function test_from_then_to_JSON() - { - $this->assertEquals($this->obj_j, $this->json_s->encode($this->json_s->decode($this->obj_j)), "object case"); - $this->assertEquals($this->obj_j, $this->json_l->encode($this->json_l->decode($this->obj_j)), "array case"); - } - } - - class Services_JSON_Spaces_Comments_TestCase extends PHPUnit_TestCase { - - function Services_JSON_Spaces_Comments_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - - $this->obj_j = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}}'; - - $this->obj_js = '{"a_string": "\"he\":llo}:{world", - "an_array":[1, 2, 3], - "obj": {"a_number":123}}'; - - $this->obj_jc1 = '{"a_string": "\"he\":llo}:{world", - // here is a comment, hoorah - "an_array":[1, 2, 3], - "obj": {"a_number":123}}'; - - $this->obj_jc2 = '/* this here is the sneetch */ "the sneetch" - // this has been the sneetch.'; - - $this->obj_jc3 = '{"a_string": "\"he\":llo}:{world", - /* here is a comment, hoorah */ - "an_array":[1, 2, 3 /* and here is another */], - "obj": {"a_number":123}}'; - - $this->obj_jc4 = '{\'a_string\': "\"he\":llo}:{world", - /* here is a comment, hoorah */ - \'an_array\':[1, 2, 3 /* and here is another */], - "obj": {"a_number":123}}'; - } - - function test_spaces() - { - $this->assertEquals($this->json->decode($this->obj_j), $this->json->decode($this->obj_js), "checking whether notation with spaces works"); - } - - function test_comments() - { - $this->assertEquals($this->json->decode($this->obj_j), $this->json->decode($this->obj_jc1), "checking whether notation with single line comments works"); - $this->assertEquals('the sneetch', $this->json->decode($this->obj_jc2), "checking whether notation with multiline comments works"); - $this->assertEquals($this->json->decode($this->obj_j), $this->json->decode($this->obj_jc3), "checking whether notation with multiline comments works"); - $this->assertEquals($this->json->decode($this->obj_j), $this->json->decode($this->obj_jc4), "checking whether notation with single-quotes and multiline comments works"); - } - } - - class Services_JSON_Empties_TestCase extends PHPUnit_TestCase { - - function Services_JSON_Empties_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json_l = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - $this->json_s = new Services_JSON(); - - $this->obj0_j = '{}'; - $this->arr0_j = '[]'; - - $this->obj1_j = '{ }'; - $this->arr1_j = '[ ]'; - - $this->obj2_j = '{ /* comment inside */ }'; - $this->arr2_j = '[ /* comment inside */ ]'; - } - - function test_type() - { - $this->assertEquals('array', gettype($this->json_l->decode($this->arr0_j)), "should be array"); - $this->assertEquals('object', gettype($this->json_s->decode($this->obj0_j)), "should be object"); - - $this->assertEquals(0, count($this->json_l->decode($this->arr0_j)), "should be empty array"); - $this->assertEquals(0, count(get_object_vars($this->json_s->decode($this->obj0_j))), "should be empty object"); - - $this->assertEquals('array', gettype($this->json_l->decode($this->arr1_j)), "should be array, even with space"); - $this->assertEquals('object', gettype($this->json_s->decode($this->obj1_j)), "should be object, even with space"); - - $this->assertEquals(0, count($this->json_l->decode($this->arr1_j)), "should be empty array, even with space"); - $this->assertEquals(0, count(get_object_vars($this->json_s->decode($this->obj1_j))), "should be empty object, even with space"); - - $this->assertEquals('array', gettype($this->json_l->decode($this->arr2_j)), "should be array, despite comment"); - $this->assertEquals('object', gettype($this->json_s->decode($this->obj2_j)), "should be object, despite comment"); - - $this->assertEquals(0, count($this->json_l->decode($this->arr2_j)), "should be empty array, despite comment"); - $this->assertEquals(0, count(get_object_vars($this->json_s->decode($this->obj2_j))), "should be empty object, despite commentt"); - } - } - - class Services_JSON_UnquotedKeys_TestCase extends PHPUnit_TestCase { - - function Services_JSON_UnquotedKeys_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - - $this->arn = array(0=> array(0=> 'tan', 'model' => 'sedan'), 1 => array(0 => 'red', 'model' => 'sports')); - $this->arn_ja = '[{0:"tan","model":"sedan"},{"0":"red",model:"sports"}]'; - $this->arn_d = 'associative array with unquoted keys, nested associative arrays, and some numeric keys thrown in'; - - $this->arrs = array (1 => 'one', 2 => 'two', 5 => 'fi"ve'); - $this->arrs_jo = '{"1":"one",2:"two","5":\'fi"ve\'}'; - $this->arrs_d = 'associative array with unquoted keys, single-quoted values, numeric keys which are not fully populated in a range of 0 to length-1'; - } - - function test_from_JSON() - { - // ...unless the input array has some numeric indeces, in which case the behavior is to degrade to a regular array - $this->assertEquals($this->arn, $this->json->decode($this->arn_ja), "array case - strict: {$this->arn_d}"); - - // Test a sparsely populated numerically indexed associative array - $this->assertEquals($this->arrs, $this->json->decode($this->arrs_jo), "sparse numeric assoc array: {$this->arrs_d}"); - } - } - - class Services_JSON_ErrorSuppression_TestCase extends PHPUnit_TestCase { - - function Services_JSON_ErrorSuppression_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json = new Services_JSON(); - $this->json_ = new Services_JSON(SERVICES_JSON_SUPPRESS_ERRORS); - - $this->res = tmpfile(); - $this->res_j_ = 'null'; - $this->res_d = 'naked resource'; - - $this->arr = array('a', 1, tmpfile()); - $this->arr_j_ = '["a",1,null]'; - $this->arr_d = 'array with string, number and resource'; - - $obj = new stdClass(); - $obj->a_string = '"he":llo}:{world'; - $obj->an_array = array(1, 2, 3); - $obj->resource = tmpfile(); - - $this->obj = $obj; - $this->obj_j_ = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"resource":null}'; - $this->obj_d = 'object with properties, array, and nested resource'; - } - - function test_to_JSON() - { - $this->assertTrue(Services_JSON::isError($this->json->encode($this->res)), "resource case: {$this->res_d}"); - $this->assertTrue(Services_JSON::isError($this->json->encode($this->arr)), "array case: {$this->arr_d}"); - $this->assertTrue(Services_JSON::isError($this->json->encode($this->obj)), "object case: {$this->obj_d}"); - } - - function test_to_JSON_suppressed() - { - $this->assertEquals($this->res_j_, $this->json_->encode($this->res), "resource case: {$this->res_d}"); - $this->assertEquals($this->arr_j_, $this->json_->encode($this->arr), "array case: {$this->arr_d}"); - $this->assertEquals($this->obj_j_, $this->json_->encode($this->obj), "object case: {$this->obj_d}"); - } - } - - $suite = new PHPUnit_TestSuite('Services_JSON_EncDec_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_AssocArray_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_NestedArray_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_Object_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_Spaces_Comments_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_Empties_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_UnquotedKeys_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_ErrorSuppression_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - -?> diff --git a/data/module/Services/JSON/doc/Services_JSON/Services_JSON.html b/data/module/Services/JSON/doc/Services_JSON/Services_JSON.html deleted file mode 100644 index 31475788b7a..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/Services_JSON.html +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - Docs For Class Services_JSON - - - - -
-

Class Services_JSON

- - -
-
Description
- -
- -

Converts to and from JSON format.

-

Brief example of use:


1 // create a new instance of Services_JSON
2 $json = new Services_JSON();
3
4 // convert a complexe value to JSON notation, and send it to the browser
5 $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
6 $output = $json->encode($value);
7
8 print($output);
9 // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
10
11 // accept incoming POST data, assumed to be in JSON notation
12 $input = file_get_contents('php://input', 1000000);
13 $value = $json->decode($input);

-

- Located in /JSON.php (line 115) -

- - -

-	
-			
-
- - - - -
-
Method Summary
- -
-
- -
- Services_JSON - Services_JSON - (int $use) -
- -
- mixed - decode - (string $str) -
- -
- mixed - encode - (mixed $var) -
- -
- void - isError - (mixed $data, [mixed $code = null]) -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor Services_JSON (line 133) -
- - -

constructs a new JSON instance

- -
- Services_JSON - - Services_JSON - - (int $use) -
- -
    -
  • - int - $use:

    object behavior flags; combine with boolean-OR

    possible values:

    • SERVICES_JSON_LOOSE_TYPE: loose typing. - "{...}" syntax creates associative arrays - instead of objects in decode().
    • SERVICES_JSON_SUPPRESS_ERRORS: error suppression. - Values which can't be encoded (e.g. resources) - appear as NULL instead of throwing errors. - By default, a deeply-nested resource will - bubble up with an error, so all return values - from encode() should be checked with isError()

  • -
- - -
- -
- -
- decode (line 484) -
- - -

decodes a JSON string into appropriate variable

-
    -
  • return: number, boolean, string, array, or object corresponding to given JSON input string. See argument 1 to Services_JSON() above for object-output behavior. Note that decode() always returns strings in ASCII or UTF-8 format!
  • -
  • access: public
  • -
- -
- mixed - - decode - - (string $str) -
- -
    -
  • - string - $str: JSON-formatted string
  • -
- - -
- -
- -
- encode (line 237) -
- - -

encodes an arbitrary variable into JSON format

-
    -
  • return: JSON string representation of input var or an error if a problem occurs
  • -
  • access: public
  • -
- -
- mixed - - encode - - (mixed $var) -
- -
    -
  • - mixed - $var: any number, boolean, string, array, or object to be encoded. see argument 1 to Services_JSON() above for array-parsing behavior. if var is a strng, note that encode() always expects it to be in ASCII or UTF-8 format!
  • -
- - -
- -
- -
- isError (line 766) -
- - -
    -
  • todo: Ultimately, this should just call PEAR::isError()
  • -
- -
- void - - isError - - (mixed $data, [mixed $code = null]) -
- - - -
- -
-
- -

- Documentation generated on Tue, 27 Jun 2006 22:54:25 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_AssocArray_TestCase.html b/data/module/Services/JSON/doc/Services_JSON/Services_JSON_AssocArray_TestCase.html deleted file mode 100644 index 4cbc05f433c..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_AssocArray_TestCase.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - Docs For Class Services_JSON_AssocArray_TestCase - - - - -
-

Class Services_JSON_AssocArray_TestCase

- - -
-
Description
- -
- -

- Located in /Test-JSON.php (line 157) -

- - -
PHPUnit_TestCase
-   |
-   --Services_JSON_AssocArray_TestCase
- -
-
- - - - -
-
Method Summary
- -
-
- -
- Services_JSON_AssocArray_TestCase - Services_JSON_AssocArray_TestCase - (mixed $name) -
- -
- void - setUp - () -
- -
- void - test_to_JSON - () -
- -
- void - test_to_then_from_JSON - () -
- -
- void - test_type - () -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor Services_JSON_AssocArray_TestCase (line 159) -
- - - -
- Services_JSON_AssocArray_TestCase - - Services_JSON_AssocArray_TestCase - - (mixed $name) -
- - - -
- -
- -
- setUp (line 163) -
- - - -
- void - - setUp - - () -
- - - -
- -
- -
- test_to_JSON (line 187) -
- - - -
- void - - test_to_JSON - - () -
- - - -
- -
- -
- test_to_then_from_JSON (line 200) -
- - - -
- void - - test_to_then_from_JSON - - () -
- - - -
- -
- -
- test_type (line 181) -
- - - -
- void - - test_type - - () -
- - - -
- -
-
- -

- Documentation generated on Tue, 27 Jun 2006 22:54:26 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Empties_TestCase.html b/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Empties_TestCase.html deleted file mode 100644 index 7184b0a1b57..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Empties_TestCase.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - Docs For Class Services_JSON_Empties_TestCase - - - - -
-

Class Services_JSON_Empties_TestCase

- - -
-
Description
- -
- -

- Located in /Test-JSON.php (line 364) -

- - -
PHPUnit_TestCase
-   |
-   --Services_JSON_Empties_TestCase
- -
-
- - - - -
-
Method Summary
- -
-
- -
- Services_JSON_Empties_TestCase - Services_JSON_Empties_TestCase - (mixed $name) -
- -
- void - setUp - () -
- -
- void - test_type - () -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor Services_JSON_Empties_TestCase (line 366) -
- - - -
- Services_JSON_Empties_TestCase - - Services_JSON_Empties_TestCase - - (mixed $name) -
- - - -
- -
- -
- setUp (line 370) -
- - - -
- void - - setUp - - () -
- - - -
- -
- -
- test_type (line 384) -
- - - -
- void - - test_type - - () -
- - - -
- -
-
- -

- Documentation generated on Tue, 27 Jun 2006 22:54:26 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_EncDec_TestCase.html b/data/module/Services/JSON/doc/Services_JSON/Services_JSON_EncDec_TestCase.html deleted file mode 100644 index 9203d6859ab..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_EncDec_TestCase.html +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - Docs For Class Services_JSON_EncDec_TestCase - - - - -
-

Class Services_JSON_EncDec_TestCase

- - -
-
Description
- -
- -

- Located in /Test-JSON.php (line 25) -

- - -
PHPUnit_TestCase
-   |
-   --Services_JSON_EncDec_TestCase
- -
-
- - - - -
-
Method Summary
- -
-
- -
- Services_JSON_EncDec_TestCase - Services_JSON_EncDec_TestCase - (mixed $name) -
- -
- void - setUp - () -
- -
- void - test_from_JSON - () -
- -
- void - test_from_then_to_JSON - () -
- -
- void - test_to_JSON - () -
- -
- void - test_to_then_from_JSON - () -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor Services_JSON_EncDec_TestCase (line 27) -
- - - -
- Services_JSON_EncDec_TestCase - - Services_JSON_EncDec_TestCase - - (mixed $name) -
- - - -
- -
- -
- setUp (line 31) -
- - - -
- void - - setUp - - () -
- - - -
- -
- -
- test_from_JSON (line 88) -
- - - -
- void - - test_from_JSON - - () -
- - - -
- -
- -
- test_from_then_to_JSON (line 135) -
- - - -
- void - - test_from_then_to_JSON - - () -
- - - -
- -
- -
- test_to_JSON (line 68) -
- - - -
- void - - test_to_JSON - - () -
- - - -
- -
- -
- test_to_then_from_JSON (line 115) -
- - - -
- void - - test_to_then_from_JSON - - () -
- - - -
- -
-
- -

- Documentation generated on Tue, 27 Jun 2006 22:54:26 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Error.html b/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Error.html deleted file mode 100644 index f607ab69855..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Error.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - Docs For Class Services_JSON_Error - - - - -
-

Class Services_JSON_Error

- - -
-
Description
- -
- -

- Located in /JSON.php (line 781) -

- - -
PEAR_Error
-   |
-   --Services_JSON_Error
- -
-
- - - - -
-
Method Summary
- -
-
- -
- Services_JSON_Error - Services_JSON_Error - ([mixed $message = 'unknown error'], [mixed $code = null], [mixed $mode = null], [mixed $options = null], [mixed $userinfo = null]) -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor Services_JSON_Error (line 783) -
- - - -
- Services_JSON_Error - - Services_JSON_Error - - ([mixed $message = 'unknown error'], [mixed $code = null], [mixed $mode = null], [mixed $options = null], [mixed $userinfo = null]) -
- - - -
- -
-
- -

- Documentation generated on Tue, 27 Jun 2006 22:54:26 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_ErrorSuppression_TestCase.html b/data/module/Services/JSON/doc/Services_JSON/Services_JSON_ErrorSuppression_TestCase.html deleted file mode 100644 index 5948f96446f..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_ErrorSuppression_TestCase.html +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - Docs For Class Services_JSON_ErrorSuppression_TestCase - - - - -
-

Class Services_JSON_ErrorSuppression_TestCase

- - -
-
Description
- -
- -

- Located in /Test-JSON.php (line 434) -

- - -
PHPUnit_TestCase
-   |
-   --Services_JSON_ErrorSuppression_TestCase
- -
-
- - - - -
-
Method Summary
- -
-
- -
- Services_JSON_ErrorSuppression_TestCase - Services_JSON_ErrorSuppression_TestCase - (mixed $name) -
- -
- void - setUp - () -
- -
- void - test_to_JSON - () -
- -
- void - test_to_JSON_suppressed - () -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor Services_JSON_ErrorSuppression_TestCase (line 436) -
- - - -
- Services_JSON_ErrorSuppression_TestCase - - Services_JSON_ErrorSuppression_TestCase - - (mixed $name) -
- - - -
- -
- -
- setUp (line 440) -
- - - -
- void - - setUp - - () -
- - - -
- -
- -
- test_to_JSON (line 462) -
- - - -
- void - - test_to_JSON - - () -
- - - -
- -
- -
- test_to_JSON_suppressed (line 469) -
- - - -
- void - - test_to_JSON_suppressed - - () -
- - - -
- -
-
- -

- Documentation generated on Tue, 27 Jun 2006 22:54:26 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_NestedArray_TestCase.html b/data/module/Services/JSON/doc/Services_JSON/Services_JSON_NestedArray_TestCase.html deleted file mode 100644 index b2ad40951f0..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_NestedArray_TestCase.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - Docs For Class Services_JSON_NestedArray_TestCase - - - - -
-

Class Services_JSON_NestedArray_TestCase

- - -
-
Description
- -
- -

- Located in /Test-JSON.php (line 212) -

- - -
PHPUnit_TestCase
-   |
-   --Services_JSON_NestedArray_TestCase
- -
-
- - - - -
-
Method Summary
- -
-
- -
- Services_JSON_NestedArray_TestCase - Services_JSON_NestedArray_TestCase - (mixed $name) -
- -
- void - setUp - () -
- -
- void - test_from_JSON - () -
- -
- void - test_type - () -
- -
- void - _test_from_JSON - () -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor Services_JSON_NestedArray_TestCase (line 214) -
- - - -
- Services_JSON_NestedArray_TestCase - - Services_JSON_NestedArray_TestCase - - (mixed $name) -
- - - -
- -
- -
- setUp (line 218) -
- - - -
- void - - setUp - - () -
- - - -
- -
- -
- test_from_JSON (line 272) -
- - - -
- void - - test_from_JSON - - () -
- - - -
- -
- -
- test_type (line 265) -
- - - -
- void - - test_type - - () -
- - - -
- -
- -
- _test_from_JSON (line 281) -
- - - -
- void - - _test_from_JSON - - () -
- - - -
- -
-
- -

- Documentation generated on Tue, 27 Jun 2006 22:54:26 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Object_TestCase.html b/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Object_TestCase.html deleted file mode 100644 index bab4319097b..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Object_TestCase.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - Docs For Class Services_JSON_Object_TestCase - - - - -
-

Class Services_JSON_Object_TestCase

- - -
-
Description
- -
- -

- Located in /Test-JSON.php (line 289) -

- - -
PHPUnit_TestCase
-   |
-   --Services_JSON_Object_TestCase
- -
-
- - - - -
-
Method Summary
- -
-
- -
- Services_JSON_Object_TestCase - Services_JSON_Object_TestCase - (mixed $name) -
- -
- void - setUp - () -
- -
- void - test_from_then_to_JSON - () -
- -
- void - test_to_JSON - () -
- -
- void - test_type - () -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor Services_JSON_Object_TestCase (line 291) -
- - - -
- Services_JSON_Object_TestCase - - Services_JSON_Object_TestCase - - (mixed $name) -
- - - -
- -
- -
- setUp (line 295) -
- - - -
- void - - setUp - - () -
- - - -
- -
- -
- test_from_then_to_JSON (line 321) -
- - - -
- void - - test_from_then_to_JSON - - () -
- - - -
- -
- -
- test_to_JSON (line 315) -
- - - -
- void - - test_to_JSON - - () -
- - - -
- -
- -
- test_type (line 309) -
- - - -
- void - - test_type - - () -
- - - -
- -
-
- -

- Documentation generated on Tue, 27 Jun 2006 22:54:26 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Spaces_Comments_TestCase.html b/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Spaces_Comments_TestCase.html deleted file mode 100644 index c9e4c2f937b..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_Spaces_Comments_TestCase.html +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - Docs For Class Services_JSON_Spaces_Comments_TestCase - - - - -
-

Class Services_JSON_Spaces_Comments_TestCase

- - -
-
Description
- -
- -

- Located in /Test-JSON.php (line 328) -

- - -
PHPUnit_TestCase
-   |
-   --Services_JSON_Spaces_Comments_TestCase
- -
-
- - - - -
-
Method Summary
- -
-
- -
- Services_JSON_Spaces_Comments_TestCase - Services_JSON_Spaces_Comments_TestCase - (mixed $name) -
- -
- void - setUp - () -
- -
- void - test_comments - () -
- -
- void - test_spaces - () -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor Services_JSON_Spaces_Comments_TestCase (line 330) -
- - - -
- Services_JSON_Spaces_Comments_TestCase - - Services_JSON_Spaces_Comments_TestCase - - (mixed $name) -
- - - -
- -
- -
- setUp (line 334) -
- - - -
- void - - setUp - - () -
- - - -
- -
- -
- test_comments (line 355) -
- - - -
- void - - test_comments - - () -
- - - -
- -
- -
- test_spaces (line 350) -
- - - -
- void - - test_spaces - - () -
- - - -
- -
-
- -

- Documentation generated on Tue, 27 Jun 2006 22:54:26 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_UnquotedKeys_TestCase.html b/data/module/Services/JSON/doc/Services_JSON/Services_JSON_UnquotedKeys_TestCase.html deleted file mode 100644 index ea2d0b81bff..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/Services_JSON_UnquotedKeys_TestCase.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - Docs For Class Services_JSON_UnquotedKeys_TestCase - - - - -
-

Class Services_JSON_UnquotedKeys_TestCase

- - -
-
Description
- -
- -

- Located in /Test-JSON.php (line 406) -

- - -
PHPUnit_TestCase
-   |
-   --Services_JSON_UnquotedKeys_TestCase
- -
-
- - - - -
-
Method Summary
- -
-
- -
- Services_JSON_UnquotedKeys_TestCase - Services_JSON_UnquotedKeys_TestCase - (mixed $name) -
- -
- void - setUp - () -
- -
- void - test_from_JSON - () -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor Services_JSON_UnquotedKeys_TestCase (line 408) -
- - - -
- Services_JSON_UnquotedKeys_TestCase - - Services_JSON_UnquotedKeys_TestCase - - (mixed $name) -
- - - -
- -
- -
- setUp (line 412) -
- - - -
- void - - setUp - - () -
- - - -
- -
- -
- test_from_JSON (line 424) -
- - - -
- void - - test_from_JSON - - () -
- - - -
- -
-
- -

- Documentation generated on Tue, 27 Jun 2006 22:54:27 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/_JSON_php.html b/data/module/Services/JSON/doc/Services_JSON/_JSON_php.html deleted file mode 100644 index 8d33a8febcb..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/_JSON_php.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - Docs for page JSON.php - - - - -
-

/JSON.php

- - -
-
Description
- -
- -

Converts to and from JSON format.

-

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. This feature can also be found in Python. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, TCL, and many others. These properties make JSON an ideal data-interchange language.

This package provides a simple encoder and decoder for JSON notation. It is intended for use with client-side Javascript applications that make use of HTTPRequest to perform server communication functions - data can be encoded into JSON notation for use in a client-side javascript, or decoded from incoming Javascript requests. JSON format is native to Javascript, and can be directly eval()'ed with no further parsing overhead

All strings should be in ASCII or UTF-8 format!

LICENSE: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
Classes
- -
- - - - - - - - - - - - - -
ClassDescription
- Services_JSON - - Converts to and from JSON format. -
- Services_JSON_Error - - -
-
-
- - - -
-
Constants
- -
- -
- -
- - SERVICES_JSON_IN_ARR = 3 - (line 72) - -
- - -

Marker constant for Services_JSON::decode(), used to flag stack state

- - -
- -
- -
- - SERVICES_JSON_IN_CMT = 5 - (line 82) - -
- - -

Marker constant for Services_JSON::decode(), used to flag stack state

- - -
- -
- -
- - SERVICES_JSON_IN_OBJ = 4 - (line 77) - -
- - -

Marker constant for Services_JSON::decode(), used to flag stack state

- - -
- -
- -
- - SERVICES_JSON_IN_STR = 2 - (line 67) - -
- - -

Marker constant for Services_JSON::decode(), used to flag stack state

- - -
- -
- -
- - SERVICES_JSON_LOOSE_TYPE = 16 - (line 87) - -
- - -

Behavior switch for Services_JSON::decode()

- - -
- -
- -
- - SERVICES_JSON_SLICE = 1 - (line 62) - -
- - -

Marker constant for Services_JSON::decode(), used to flag stack state

- - -
- -
- -
- - SERVICES_JSON_SUPPRESS_ERRORS = 32 - (line 92) - -
- - -

Behavior switch for Services_JSON::decode()

- - -
-
-
- - - -

- Documentation generated on Tue, 27 Jun 2006 22:54:25 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/Services_JSON/_Test-JSON_php.html b/data/module/Services/JSON/doc/Services_JSON/_Test-JSON_php.html deleted file mode 100644 index 789bcdb9309..00000000000 --- a/data/module/Services/JSON/doc/Services_JSON/_Test-JSON_php.html +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - Docs for page Test-JSON.php - - - - -
-

/Test-JSON.php

- - -
-
Description
- -
- -

Unit tests for Services_JSON.

- - -
-
- - -
-
Classes
- - -
- - -
-
Includes
- -
- -
- -
- - require_once - ('PHPUnit.php') - (line 22) - -
- - - -
- -
- -
- - require_once - ('JSON.php') - (line 23) - -
- - - -
-
-
- - - - -

- Documentation generated on Tue, 27 Jun 2006 22:54:26 -0700 by phpDocumentor 1.2.3 -

-
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/blank.html b/data/module/Services/JSON/doc/blank.html deleted file mode 100644 index 9b62ca9b9ce..00000000000 --- a/data/module/Services/JSON/doc/blank.html +++ /dev/null @@ -1,13 +0,0 @@ - - - Generated Documentation - - - - -

Generated Documentation

-Welcome to default!
-
-This documentation was generated by phpDocumentor v1.2.3
- - \ No newline at end of file diff --git a/data/module/Services/JSON/doc/classtrees_Services_JSON.html b/data/module/Services/JSON/doc/classtrees_Services_JSON.html deleted file mode 100644 index 535fcfd4e01..00000000000 --- a/data/module/Services/JSON/doc/classtrees_Services_JSON.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - -

- -

-

Root class Services_JSON

- - -

Root class Services_JSON_AssocArray_TestCase

- - -

Root class Services_JSON_Empties_TestCase

- - -

Root class Services_JSON_EncDec_TestCase

- - -

Root class Services_JSON_Error

- - -

Root class Services_JSON_ErrorSuppression_TestCase

- - -

Root class Services_JSON_NestedArray_TestCase

- - -

Root class Services_JSON_Object_TestCase

- - -

Root class Services_JSON_Spaces_Comments_TestCase

- - -

Root class Services_JSON_UnquotedKeys_TestCase

- - -

- Documentation generated on Tue, 27 Jun 2006 22:54:25 -0700 by phpDocumentor 1.2.3 -

- - \ No newline at end of file diff --git a/data/module/Services/JSON/doc/elementindex.html b/data/module/Services/JSON/doc/elementindex.html deleted file mode 100644 index f5a4c80ecf2..00000000000 --- a/data/module/Services/JSON/doc/elementindex.html +++ /dev/null @@ -1,457 +0,0 @@ - - - - - - - - - - - -

Full index

-

Package indexes

- -
-
- d - e - i - - s - t -
- - -
-
d
- -
-
-
-
- decode -
-
- -
decodes a JSON string into appropriate variable
-
-
- -
-
e
- -
-
-
-
- encode -
-
- -
encodes an arbitrary variable into JSON format
-
-
- -
-
i
- -
-
-
-
- isError -
-
- -
-
- -
-
j
- -
-
-
-
- JSON.php -
-
-
JSON.php in JSON.php
-
-
- -
-
s
- -
-
-
-
- Services_JSON -
-
-
Services_JSON in JSON.php
-
Converts to and from JSON format.
-
-
- Services_JSON -
-
- -
constructs a new JSON instance
-
-
- Services_JSON_AssocArray_TestCase -
-
- -
-
- Services_JSON_AssocArray_TestCase -
-
- -
-
- Services_JSON_Empties_TestCase -
-
- -
-
- Services_JSON_Empties_TestCase -
-
- -
-
- Services_JSON_EncDec_TestCase -
-
- -
-
- Services_JSON_EncDec_TestCase -
-
- -
-
- Services_JSON_Error -
-
- -
-
- Services_JSON_Error -
-
- -
-
- Services_JSON_ErrorSuppression_TestCase -
-
- -
-
- Services_JSON_ErrorSuppression_TestCase -
-
- -
-
- SERVICES_JSON_IN_ARR -
-
- -
Marker constant for Services_JSON::decode(), used to flag stack state
-
-
- SERVICES_JSON_IN_CMT -
-
- -
Marker constant for Services_JSON::decode(), used to flag stack state
-
-
- SERVICES_JSON_IN_OBJ -
-
- -
Marker constant for Services_JSON::decode(), used to flag stack state
-
-
- SERVICES_JSON_IN_STR -
-
- -
Marker constant for Services_JSON::decode(), used to flag stack state
-
-
- SERVICES_JSON_LOOSE_TYPE -
-
- -
Behavior switch for Services_JSON::decode()
-
-
- Services_JSON_NestedArray_TestCase -
-
- -
-
- Services_JSON_NestedArray_TestCase -
-
- -
-
- Services_JSON_Object_TestCase -
-
- -
-
- Services_JSON_Object_TestCase -
-
- -
-
- SERVICES_JSON_SLICE -
-
- -
Marker constant for Services_JSON::decode(), used to flag stack state
-
-
- Services_JSON_Spaces_Comments_TestCase -
-
- -
-
- Services_JSON_Spaces_Comments_TestCase -
-
- -
-
- SERVICES_JSON_SUPPRESS_ERRORS -
-
- -
Behavior switch for Services_JSON::decode()
-
-
- Services_JSON_UnquotedKeys_TestCase -
-
- -
-
- Services_JSON_UnquotedKeys_TestCase -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- -
-
t
- -
-
-
-
- Test-JSON.php -
-
-
Test-JSON.php in Test-JSON.php
-
-
- test_comments -
-
- -
-
- test_from_JSON -
-
- -
-
- test_from_JSON -
-
- -
-
- test_from_JSON -
-
- -
-
- test_from_then_to_JSON -
-
- -
-
- test_from_then_to_JSON -
-
- -
-
- test_spaces -
-
- -
-
- test_to_JSON -
-
- -
-
- test_to_JSON -
-
- -
-
- test_to_JSON -
-
- -
-
- test_to_JSON -
-
- -
-
- test_to_JSON_suppressed -
-
- -
-
- test_to_then_from_JSON -
-
- -
-
- test_to_then_from_JSON -
-
- -
-
- test_type -
-
- -
-
- test_type -
-
- -
-
- test_type -
-
- -
-
- test_type -
-
- -
-
- -
-
_
- -
-
-
-
- _test_from_JSON -
-
- -
-
- -
- d - e - i - - s - t -
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/elementindex_Services_JSON.html b/data/module/Services/JSON/doc/elementindex_Services_JSON.html deleted file mode 100644 index d1ca236cbd6..00000000000 --- a/data/module/Services/JSON/doc/elementindex_Services_JSON.html +++ /dev/null @@ -1,456 +0,0 @@ - - - - - - - - - - - -

[Services_JSON] element index

-All elements -
-
- d - e - i - j - s - t - _ -
- - -
-
_
- -
-
-
-
- _test_from_JSON -
-
- -
-
- -
-
d
- -
-
-
-
- decode -
-
- -
decodes a JSON string into appropriate variable
-
-
- -
-
e
- -
-
-
-
- encode -
-
- -
encodes an arbitrary variable into JSON format
-
-
- -
-
i
- -
-
-
-
- isError -
-
- -
-
- -
-
j
- -
-
-
-
- JSON.php -
-
-
JSON.php in JSON.php
-
-
- -
-
s
- -
-
-
-
- Services_JSON -
-
-
Services_JSON in JSON.php
-
Converts to and from JSON format.
-
-
- Services_JSON -
-
- -
constructs a new JSON instance
-
-
- Services_JSON_AssocArray_TestCase -
-
- -
-
- Services_JSON_AssocArray_TestCase -
-
- -
-
- Services_JSON_Empties_TestCase -
-
- -
-
- Services_JSON_Empties_TestCase -
-
- -
-
- Services_JSON_EncDec_TestCase -
-
- -
-
- Services_JSON_EncDec_TestCase -
-
- -
-
- Services_JSON_Error -
-
- -
-
- Services_JSON_Error -
-
- -
-
- Services_JSON_ErrorSuppression_TestCase -
-
- -
-
- Services_JSON_ErrorSuppression_TestCase -
-
- -
-
- SERVICES_JSON_IN_ARR -
-
- -
Marker constant for Services_JSON::decode(), used to flag stack state
-
-
- SERVICES_JSON_IN_CMT -
-
- -
Marker constant for Services_JSON::decode(), used to flag stack state
-
-
- SERVICES_JSON_IN_OBJ -
-
- -
Marker constant for Services_JSON::decode(), used to flag stack state
-
-
- SERVICES_JSON_IN_STR -
-
- -
Marker constant for Services_JSON::decode(), used to flag stack state
-
-
- SERVICES_JSON_LOOSE_TYPE -
-
- -
Behavior switch for Services_JSON::decode()
-
-
- Services_JSON_NestedArray_TestCase -
-
- -
-
- Services_JSON_NestedArray_TestCase -
-
- -
-
- Services_JSON_Object_TestCase -
-
- -
-
- Services_JSON_Object_TestCase -
-
- -
-
- SERVICES_JSON_SLICE -
-
- -
Marker constant for Services_JSON::decode(), used to flag stack state
-
-
- Services_JSON_Spaces_Comments_TestCase -
-
- -
-
- Services_JSON_Spaces_Comments_TestCase -
-
- -
-
- SERVICES_JSON_SUPPRESS_ERRORS -
-
- -
Behavior switch for Services_JSON::decode()
-
-
- Services_JSON_UnquotedKeys_TestCase -
-
- -
-
- Services_JSON_UnquotedKeys_TestCase -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- setUp -
-
- -
-
- -
-
t
- -
-
-
-
- Test-JSON.php -
-
-
Test-JSON.php in Test-JSON.php
-
-
- test_comments -
-
- -
-
- test_from_JSON -
-
- -
-
- test_from_JSON -
-
- -
-
- test_from_JSON -
-
- -
-
- test_from_then_to_JSON -
-
- -
-
- test_from_then_to_JSON -
-
- -
-
- test_spaces -
-
- -
-
- test_to_JSON -
-
- -
-
- test_to_JSON -
-
- -
-
- test_to_JSON -
-
- -
-
- test_to_JSON -
-
- -
-
- test_to_JSON_suppressed -
-
- -
-
- test_to_then_from_JSON -
-
- -
-
- test_to_then_from_JSON -
-
- -
-
- test_type -
-
- -
-
- test_type -
-
- -
-
- test_type -
-
- -
-
- test_type -
-
- -
-
- -
- d - e - i - j - s - t - _ -
- \ No newline at end of file diff --git a/data/module/Services/JSON/doc/errors.html b/data/module/Services/JSON/doc/errors.html deleted file mode 100644 index d4a1d0e05fa..00000000000 --- a/data/module/Services/JSON/doc/errors.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - phpDocumentor Parser Errors and Warnings - - - - - Post-parsing
-Test-JSON.php
- -

Post-parsing

-

Warnings:


-Warning - Class Services_JSON_ErrorSuppression_TestCase parent PHPUnit_TestCase not found
-Warning - Class Services_JSON_Spaces_Comments_TestCase parent PHPUnit_TestCase not found
-Warning - Class Services_JSON_Empties_TestCase parent PHPUnit_TestCase not found
-Warning - Class Services_JSON_UnquotedKeys_TestCase parent PHPUnit_TestCase not found
-Warning - Class Services_JSON_Error parent PEAR_Error not found
-Warning - Class Services_JSON_AssocArray_TestCase parent PHPUnit_TestCase not found
-Warning - Class Services_JSON_EncDec_TestCase parent PHPUnit_TestCase not found
-Warning - Class Services_JSON_NestedArray_TestCase parent PHPUnit_TestCase not found
-Warning - Class Services_JSON_Object_TestCase parent PHPUnit_TestCase not found
- -

JSON.php

-

Warnings:


-Warning on line 115 - no @package tag was used in a DocBlock for class Services_JSON
-Warning on line 781 - no @package tag was used in a DocBlock for class Services_JSON_Error
-Warning on line 795 - no @package tag was used in a DocBlock for class Services_JSON_Error
-Warning on line 795 - -duplicate class element "Services_JSON_Error" in file /Users/migurski/Sites/JSON-PHP/JSON.php will be ignored. -Use an @ignore tag on the original if you want this case to be documented.
- -

Test-JSON.php

-

Warnings:


-Warning on line 19 - package default is already in category , will now replace with category
-Warning on line 21 - Page-level DocBlock precedes "require_once Test-JSON.php", use another DocBlock to document the source element
-Warning on line 24 - no @package tag was used in a DocBlock for class Services_JSON_EncDec_TestCase
-Warning on line 156 - no @package tag was used in a DocBlock for class Services_JSON_AssocArray_TestCase
-Warning on line 211 - no @package tag was used in a DocBlock for class Services_JSON_NestedArray_TestCase
-Warning on line 288 - no @package tag was used in a DocBlock for class Services_JSON_Object_TestCase
-Warning on line 327 - no @package tag was used in a DocBlock for class Services_JSON_Spaces_Comments_TestCase
-Warning on line 363 - no @package tag was used in a DocBlock for class Services_JSON_Empties_TestCase
-Warning on line 405 - no @package tag was used in a DocBlock for class Services_JSON_UnquotedKeys_TestCase
-Warning on line 433 - no @package tag was used in a DocBlock for class Services_JSON_ErrorSuppression_TestCase
-

- Documentation generated on Tue, 27 Jun 2006 22:54:27 -0700 by phpDocumentor 1.2.3 -

- - \ No newline at end of file diff --git a/data/module/Services/JSON/doc/index.html b/data/module/Services/JSON/doc/index.html deleted file mode 100644 index 3b1f52ab3f3..00000000000 --- a/data/module/Services/JSON/doc/index.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - Generated Documentation - - - - - - - - - - - <H2>Frame Alert</H2> - <P>This document is designed to be viewed using the frames feature. - If you see this message, you are using a non-frame-capable web client.</P> - - - \ No newline at end of file diff --git a/data/module/Services/JSON/doc/li_Services_JSON.html b/data/module/Services/JSON/doc/li_Services_JSON.html deleted file mode 100644 index a9e4edb902e..00000000000 --- a/data/module/Services/JSON/doc/li_Services_JSON.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - -
Services_JSON
- -

phpDocumentor v 1.2.3

- - \ No newline at end of file diff --git a/data/module/Services/JSON/doc/media/banner.css b/data/module/Services/JSON/doc/media/banner.css deleted file mode 100644 index f2149ebb4dc..00000000000 --- a/data/module/Services/JSON/doc/media/banner.css +++ /dev/null @@ -1,32 +0,0 @@ -body -{ - background-color: #CCCCFF; - margin: 0px; - padding: 0px; -} - -/* Banner (top bar) classes */ - -.banner { } - -.banner-menu -{ - clear: both; - padding: .5em; - border-top: 2px solid #6666AA; -} - -.banner-title -{ - text-align: right; - font-size: 20pt; - font-weight: bold; - margin: .2em; -} - -.package-selector -{ - background-color: #AAAADD; - border: 1px solid black; - color: yellow; -} diff --git a/data/module/Services/JSON/doc/media/stylesheet.css b/data/module/Services/JSON/doc/media/stylesheet.css deleted file mode 100644 index 380dcee2cfd..00000000000 --- a/data/module/Services/JSON/doc/media/stylesheet.css +++ /dev/null @@ -1,134 +0,0 @@ -a { color: #336699; text-decoration: none; } -a:hover { color: #6699CC; text-decoration: underline; } -a:active { color: #6699CC; text-decoration: underline; } - -body { background : #FFFFFF; } -body, table { font-family: Georgia, Times New Roman, Times, serif; font-size: 10pt } -p, li { line-height: 140% } -a img { border: 0px; } -dd { margin-left: 0px; padding-left: 1em; } - -/* Page layout/boxes */ - -.info-box {} -.info-box-title { margin: 1em 0em 0em 0em; padding: .25em; font-weight: normal; font-size: 14pt; border: 2px solid #999999; background-color: #CCCCFF } -.info-box-body { border: 1px solid #999999; padding: .5em; } -.nav-bar { font-size: 8pt; white-space: nowrap; text-align: right; padding: .2em; margin: 0em 0em 1em 0em; } - -.oddrow { background-color: #F8F8F8; border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em} -.evenrow { border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em} - -.page-body { max-width: 800px; margin: auto; } -.tree dl { margin: 0px } - -/* Index formatting classes */ - -.index-item-body { margin-top: .5em; margin-bottom: .5em} -.index-item-description { margin-top: .25em } -.index-item-details { font-weight: normal; font-style: italic; font-size: 8pt } -.index-letter-section { background-color: #EEEEEE; border: 1px dotted #999999; padding: .5em; margin-bottom: 1em} -.index-letter-title { font-size: 12pt; font-weight: bold } -.index-letter-menu { text-align: center; margin: 1em } -.index-letter { font-size: 12pt } - -/* Docbook classes */ - -.description {} -.short-description { font-weight: bold; color: #666666; } -.tags { padding-left: 0em; margin-left: 3em; color: #666666; list-style-type: square; } -.parameters { padding-left: 0em; margin-left: 3em; font-style: italic; list-style-type: square; } -.redefinitions { font-size: 8pt; padding-left: 0em; margin-left: 2em; } -.package { } -.package-title { font-weight: bold; font-size: 14pt; border-bottom: 1px solid black } -.package-details { font-size: 85%; } -.sub-package { font-weight: bold; font-size: 120% } -.tutorial { border-width: thin; border-color: #0066ff } -.tutorial-nav-box { width: 100%; border: 1px solid #999999; background-color: #F8F8F8; } -.nav-button-disabled { color: #999999; } -.nav-button:active, -.nav-button:focus, -.nav-button:hover { background-color: #DDDDDD; outline: 1px solid #999999; text-decoration: none } -.folder-title { font-style: italic } - -/* Generic formatting */ - -.field { font-weight: bold; } -.detail { font-size: 8pt; } -.notes { font-style: italic; font-size: 8pt; } -.separator { background-color: #999999; height: 2px; } -.warning { color: #FF6600; } -.disabled { font-style: italic; color: #999999; } - -/* Code elements */ - -.line-number { } - -.class-table { width: 100%; } -.class-table-header { border-bottom: 1px dotted #666666; text-align: left} -.class-name { color: #000000; font-weight: bold; } - -.method-summary { padding-left: 1em; font-size: 8pt } -.method-header { } -.method-definition { margin-bottom: .3em } -.method-title { font-weight: bold; } -.method-name { font-weight: bold; } -.method-signature { font-size: 85%; color: #666666; margin: .5em 0em } -.method-result { font-style: italic; } - -.var-summary { padding-left: 1em; font-size: 8pt; } -.var-header { } -.var-title { margin-bottom: .3em } -.var-type { font-style: italic; } -.var-name { font-weight: bold; } -.var-default {} -.var-description { font-weight: normal; color: #000000; } - -.include-title { } -.include-type { font-style: italic; } -.include-name { font-weight: bold; } - -.const-title { } -.const-name { font-weight: bold; } - -/* Syntax highlighting */ - -.src-code { border: 1px solid #336699; padding: 1em; background-color: #EEEEEE; } - -.src-comm { color: green; } -.src-id { } -.src-inc { color: #0000FF; } -.src-key { color: #0000FF; } -.src-num { color: #CC0000; } -.src-str { color: #66cccc; } -.src-sym { font-weight: bold; } -.src-var { } - -.src-php { font-weight: bold; } - -.src-doc { color: #009999 } -.src-doc-close-template { color: #0000FF } -.src-doc-coretag { color: #0099FF; font-weight: bold } -.src-doc-inlinetag { color: #0099FF } -.src-doc-internal { color: #6699cc } -.src-doc-tag { color: #0080CC } -.src-doc-template { color: #0000FF } -.src-doc-type { font-style: italic } -.src-doc-var { font-style: italic } - -/* tutorial */ - -.authors { } -.author { font-style: italic; font-weight: bold } -.author-blurb { margin: .5em 0em .5em 2em; font-size: 85%; font-weight: normal; font-style: normal } -.example { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em } -.listing { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; white-space: nowrap } -.release-info { font-size: 85%; font-style: italic; margin: 1em 0em } -.ref-title-box { } -.ref-title { } -.ref-purpose { font-style: italic; color: #666666 } -.ref-synopsis { } -.title { font-weight: bold; margin: 1em 0em 0em 0em; padding: .25em; border: 2px solid #999999; background-color: #CCCCFF } -.cmd-synopsis { margin: 1em 0em } -.cmd-title { font-weight: bold } -.toc { margin-left: 2em; padding-left: 0em } - diff --git a/data/module/Services/JSON/doc/packages.html b/data/module/Services/JSON/doc/packages.html deleted file mode 100644 index 7058c6b73aa..00000000000 --- a/data/module/Services/JSON/doc/packages.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/data/module/Services/JSON/doc/todolist.html b/data/module/Services/JSON/doc/todolist.html deleted file mode 100644 index 4c060b9ac0c..00000000000 --- a/data/module/Services/JSON/doc/todolist.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - Todo List - - - - -

Todo List

-

Services_JSON

-

Services_JSON::isError()

-
    -
  • Ultimately, this should just call PEAR::isError()
  • -
-

- Documentation generated on Tue, 27 Jun 2006 22:54:27 -0700 by phpDocumentor 1.2.3 -

- - \ No newline at end of file diff --git a/data/module/Smarty/BUGS b/data/module/Smarty/BUGS deleted file mode 100644 index 9f1a80f31c5..00000000000 --- a/data/module/Smarty/BUGS +++ /dev/null @@ -1,7 +0,0 @@ -Smarty is supported only in PHP 4.0.6 or later. - -Smarty versions previous to 2.0 require the PEAR libraries. Be sure to include -the path to the PEAR libraries in your php include_path. Config_file.class.php -uses the PEAR library for its error handling routines. PEAR comes with the PHP -distribution. Unix users check /usr/local/lib/php, windows users check -C:/php/pear. diff --git a/data/module/Smarty/COPYING.lib b/data/module/Smarty/COPYING.lib deleted file mode 100644 index 3b204400cf3..00000000000 --- a/data/module/Smarty/COPYING.lib +++ /dev/null @@ -1,458 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS diff --git a/data/module/Smarty/ChangeLog b/data/module/Smarty/ChangeLog deleted file mode 100644 index fddc0509dfc..00000000000 --- a/data/module/Smarty/ChangeLog +++ /dev/null @@ -1,9188 +0,0 @@ -2012-09-24 Uwe Tews - - * Fixed escape Smarty error messages to avoid possible script execution - - -2010-04-17 Uwe Tews - - * Fixed security hole in {math} plugin - -2007-09-27 TAKAGI Masahiro - - * docs/ja/designers/language-custom-functions/language-function-html-checkboxes.xml: - sync with en. - -2007-09-27 Monte Ohrt - - * docs/en/designers/language-custom-functions/language-function-html-checkboxes.xml: - remove redundant attribute - -2007-09-18 Messju Mohr - - * docs/id/programmers/plugins/plugins-functions.xml: - removed errornous whitespace - -2007-09-18 Zaenal Mutaqin - - * docs/id/designers/language-basic-syntax/language-escaping.xml - docs/id/designers/language-basic-syntax/language-math.xml - docs/id/designers/language-basic-syntax/language-syntax-attributes.xml - docs/id/designers/language-basic-syntax/language-syntax-comments.xml - docs/id/designers/language-basic-syntax/language-syntax-functions.xml - docs/id/designers/language-basic-syntax/language-syntax-quotes.xml - docs/id/designers/language-basic-syntax/language-syntax-variables.xml - docs/id/designers/language-builtin-functions/language-function-capture.xml - docs/id/designers/language-builtin-functions/language-function-config-load.xml - docs/id/designers/language-builtin-functions/language-function-foreach.xml - docs/id/designers/language-builtin-functions/language-function-if.xml - docs/id/designers/language-builtin-functions/language-function-include-php.xml - docs/id/designers/language-builtin-functions/language-function-include.xml - docs/id/designers/language-builtin-functions/language-function-insert.xml - docs/id/designers/language-builtin-functions/language-function-ldelim.xml - docs/id/designers/language-builtin-functions/language-function-literal.xml - docs/id/designers/language-builtin-functions/language-function-php.xml - docs/id/designers/language-builtin-functions/language-function-section.xml - docs/id/designers/language-builtin-functions/language-function-strip.xml - docs/id/designers/language-custom-functions/language-function-assign.xml - docs/id/designers/language-custom-functions/language-function-counter.xml - docs/id/designers/language-custom-functions/language-function-cycle.xml - docs/id/designers/language-custom-functions/language-function-debug.xml - docs/id/designers/language-custom-functions/language-function-eval.xml - docs/id/designers/language-custom-functions/language-function-fetch.xml - docs/id/designers/language-custom-functions/language-function-html-checkboxes.xml - docs/id/designers/language-custom-functions/language-function-html-image.xml - docs/id/designers/language-custom-functions/language-function-html-options.xml - docs/id/designers/language-custom-functions/language-function-html-radios.xml - docs/id/designers/language-custom-functions/language-function-html-select-date.xml - docs/id/designers/language-custom-functions/language-function-html-select-time.xml - docs/id/designers/language-custom-functions/language-function-html-table.xml - docs/id/designers/language-custom-functions/language-function-mailto.xml - docs/id/designers/language-custom-functions/language-function-math.xml - docs/id/designers/language-custom-functions/language-function-popup-init.xml - docs/id/designers/language-custom-functions/language-function-popup.xml - docs/id/designers/language-custom-functions/language-function-textformat.xml - docs/id/designers/language-modifiers/language-modifier-capitalize.xml - docs/id/designers/language-modifiers/language-modifier-cat.xml - docs/id/designers/language-modifiers/language-modifier-count-characters.xml - docs/id/designers/language-modifiers/language-modifier-count-paragraphs.xml - docs/id/designers/language-modifiers/language-modifier-count-sentences.xml - docs/id/designers/language-modifiers/language-modifier-count-words.xml - docs/id/designers/language-modifiers/language-modifier-date-format.xml - docs/id/designers/language-modifiers/language-modifier-default.xml - docs/id/designers/language-modifiers/language-modifier-escape.xml - docs/id/designers/language-modifiers/language-modifier-indent.xml - docs/id/designers/language-modifiers/language-modifier-lower.xml - docs/id/designers/language-modifiers/language-modifier-nl2br.xml - docs/id/designers/language-modifiers/language-modifier-regex-replace.xml - docs/id/designers/language-modifiers/language-modifier-replace.xml - docs/id/designers/language-modifiers/language-modifier-spacify.xml - docs/id/designers/language-modifiers/language-modifier-string-format.xml - docs/id/designers/language-modifiers/language-modifier-strip-tags.xml - docs/id/designers/language-modifiers/language-modifier-strip.xml - docs/id/designers/language-modifiers/language-modifier-truncate.xml - docs/id/designers/language-modifiers/language-modifier-upper.xml - docs/id/designers/language-modifiers/language-modifier-wordwrap.xml - docs/id/designers/language-variables/language-assigned-variables.xml - docs/id/designers/language-variables/language-config-variables.xml - docs/id/designers/language-variables/language-variables-smarty.xml - docs/id/programmers/advanced-features/advanced-features-objects.xml - docs/id/programmers/advanced-features/advanced-features-outputfilters.xml - docs/id/programmers/advanced-features/advanced-features-postfilters.xml - docs/id/programmers/advanced-features/advanced-features-prefilters.xml - docs/id/programmers/advanced-features/section-template-cache-handler-func.xml - docs/id/programmers/advanced-features/template-resources.xml - docs/id/programmers/api-functions/api-append-by-ref.xml - docs/id/programmers/api-functions/api-append.xml - docs/id/programmers/api-functions/api-assign-by-ref.xml - docs/id/programmers/api-functions/api-assign.xml - docs/id/programmers/api-functions/api-clear-all-assign.xml - docs/id/programmers/api-functions/api-clear-all-cache.xml - docs/id/programmers/api-functions/api-clear-assign.xml - docs/id/programmers/api-functions/api-clear-cache.xml - docs/id/programmers/api-functions/api-clear-compiled-tpl.xml - docs/id/programmers/api-functions/api-clear-config.xml - docs/id/programmers/api-functions/api-config-load.xml - docs/id/programmers/api-functions/api-display.xml - docs/id/programmers/api-functions/api-fetch.xml - docs/id/programmers/api-functions/api-get-config-vars.xml - docs/id/programmers/api-functions/api-get-registered-object.xml - docs/id/programmers/api-functions/api-get-template-vars.xml - docs/id/programmers/api-functions/api-is-cached.xml - docs/id/programmers/api-functions/api-load-filter.xml - docs/id/programmers/api-functions/api-register-block.xml - docs/id/programmers/api-functions/api-register-compiler-function.xml - docs/id/programmers/api-functions/api-register-function.xml - docs/id/programmers/api-functions/api-register-modifier.xml - docs/id/programmers/api-functions/api-register-object.xml - docs/id/programmers/api-functions/api-register-outputfilter.xml - docs/id/programmers/api-functions/api-register-postfilter.xml - docs/id/programmers/api-functions/api-register-prefilter.xml - docs/id/programmers/api-functions/api-register-resource.xml - docs/id/programmers/api-functions/api-template-exists.xml - docs/id/programmers/api-functions/api-trigger-error.xml - docs/id/programmers/api-functions/api-unregister-block.xml - docs/id/programmers/api-functions/api-unregister-compiler-function.xml - docs/id/programmers/api-functions/api-unregister-function.xml - docs/id/programmers/api-functions/api-unregister-modifier.xml - docs/id/programmers/api-functions/api-unregister-object.xml - docs/id/programmers/api-functions/api-unregister-outputfilter.xml - docs/id/programmers/api-functions/api-unregister-postfilter.xml - docs/id/programmers/api-functions/api-unregister-prefilter.xml - docs/id/programmers/api-functions/api-unregister-resource.xml - docs/id/programmers/api-variables/variable-autoload-filters.xml - docs/id/programmers/api-variables/variable-cache-dir.xml - docs/id/programmers/api-variables/variable-cache-handler-func.xml - docs/id/programmers/api-variables/variable-cache-lifetime.xml - docs/id/programmers/api-variables/variable-cache-modified-check.xml - docs/id/programmers/api-variables/variable-caching.xml - docs/id/programmers/api-variables/variable-compile-check.xml - docs/id/programmers/api-variables/variable-compile-dir.xml - docs/id/programmers/api-variables/variable-compile-id.xml - docs/id/programmers/api-variables/variable-compiler-class.xml - docs/id/programmers/api-variables/variable-config-booleanize.xml - docs/id/programmers/api-variables/variable-config-dir.xml - docs/id/programmers/api-variables/variable-config-fix-newlines.xml - docs/id/programmers/api-variables/variable-config-overwrite.xml - docs/id/programmers/api-variables/variable-config-read-hidden.xml - docs/id/programmers/api-variables/variable-debug-tpl.xml - docs/id/programmers/api-variables/variable-debugging-ctrl.xml - docs/id/programmers/api-variables/variable-debugging.xml - docs/id/programmers/api-variables/variable-default-modifiers.xml - docs/id/programmers/api-variables/variable-default-resource-type.xml - docs/id/programmers/api-variables/variable-default-template-handler-func.xml - docs/id/programmers/api-variables/variable-error-reporting.xml - docs/id/programmers/api-variables/variable-force-compile.xml - docs/id/programmers/api-variables/variable-left-delimiter.xml - docs/id/programmers/api-variables/variable-php-handling.xml - docs/id/programmers/api-variables/variable-plugins-dir.xml - docs/id/programmers/api-variables/variable-request-use-auto-globals.xml - docs/id/programmers/api-variables/variable-request-vars-order.xml - docs/id/programmers/api-variables/variable-right-delimiter.xml - docs/id/programmers/api-variables/variable-secure-dir.xml - docs/id/programmers/api-variables/variable-security-settings.xml - docs/id/programmers/api-variables/variable-security.xml - docs/id/programmers/api-variables/variable-template-dir.xml - docs/id/programmers/api-variables/variable-trusted-dir.xml - docs/id/programmers/api-variables/variable-use-sub-dirs.xml - docs/id/programmers/caching/caching-cacheable.xml - docs/id/programmers/caching/caching-groups.xml - docs/id/programmers/caching/caching-multiple-caches.xml - docs/id/programmers/caching/caching-setting-up.xml - docs/id/programmers/plugins/plugins-block-functions.xml - docs/id/programmers/plugins/plugins-compiler-functions.xml - docs/id/programmers/plugins/plugins-functions.xml - docs/id/programmers/plugins/plugins-howto.xml - docs/id/programmers/plugins/plugins-inserts.xml - docs/id/programmers/plugins/plugins-modifiers.xml - docs/id/programmers/plugins/plugins-naming-conventions.xml - docs/id/programmers/plugins/plugins-outputfilters.xml - docs/id/programmers/plugins/plugins-prefilters-postfilters.xml - docs/id/programmers/plugins/plugins-resources.xml - docs/id/programmers/plugins/plugins-writing.xml: - Typos correction and all translated now. - -2007-09-17 Messju Mohr - - * docs/id/bookinfo.xml - docs/id/getting-started.xml - docs/id/language-defs.ent - docs/id/language-snippets.ent - docs/id/livedocs.ent - docs/id/preface.xml: - added indonesian docs - thanks Zaenal Mutaqin - - * docs/scripts/generate_web.php: - raise pcre.backtrack_limit - thanks to takagi - -2007-09-16 Monte Ohrt - - * libs/Smarty_Compiler.class.php: - fix typo - -2007-08-22 George Miroshnikov - - * docs/ru/getting-started.xml - docs/ru/getting-started.xml: - Sync with EN. - -2007-08-01 Monte Ohrt - - * NEWS - libs/Smarty_Compiler.class.php: - add append feature to capture - -2007-06-24 TAKAGI Masahiro - - * docs/ja/getting-started.xml: - sync with en. - -2007-06-24 Messju Mohr - - * docs/Makefile.in: - reverted accidently modified file - - * docs/Makefile.in - docs/de/getting-started.xml: - sync with en - - * docs/en/getting-started.xml: - fixed link to ini_set(). thanks to Lee Yunyoung. - -2007-06-18 TAKAGI Masahiro - - * docs/ja/language-snippets.ent - docs/ja/programmers/api-functions/api-register-outputfilter.xml - docs/ja/programmers/api-functions/api-register-postfilter.xml - docs/ja/programmers/api-functions/api-register-prefilter.xml: - sync with en. - -2007-06-18 Danilo Buerger - - * docs/en/language-snippets.ent - docs/en/programmers/api-functions/api-register-outputfilter.xml - docs/en/programmers/api-functions/api-register-postfilter.xml - docs/en/programmers/api-functions/api-register-prefilter.xml: - Updated docs according to the changes from the previous commit - - * NEWS - libs/Smarty.class.php: - Added the ability to (un)register multiple filters of the same type with - the same method name but different class name. Before it was not possible - due to the fact that only the method name was used to distinguish between - different filters of the same type. This does however not allow (same as - before) to register multiple filters of the same type with the same method - and class name (i.e. different instances of the same class). - -2007-05-29 Messju Mohr - - * libs/plugins/compiler.assign.php: - fixed typo - -2007-05-11 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed calling registered objects' methods with an empty argument list. - thanks marcello - -2007-05-03 TAKAGI Masahiro - - * docs/ja/designers/language-variables.xml - docs/ja/designers/language-builtin-functions/language-function-config-load.xml - docs/ja/designers/language-builtin-functions/language-function-foreach.xml - docs/ja/designers/language-builtin-functions/language-function-if.xml - docs/ja/designers/language-modifiers/language-modifier-cat.xml - docs/ja/designers/language-modifiers/language-modifier-wordwrap.xml - docs/ja/designers/language-variables/language-variables-smarty.xml: - sync with en. - -2007-05-03 Monte Ohrt - - * docs/en/designers/language-variables.xml - docs/en/designers/language-builtin-functions/language-function-config-load.xml - docs/en/designers/language-builtin-functions/language-function-foreach.xml - docs/en/designers/language-builtin-functions/language-function-if.xml - docs/en/designers/language-modifiers/language-modifier-cat.xml - docs/en/designers/language-modifiers/language-modifier-wordwrap.xml - docs/en/designers/language-variables/language-variables-smarty.xml: - update documentation corrections from marcello in the forums. Thanks - marcello! - -2007-04-22 TAKAGI Masahiro - - * docs/ja/programmers/advanced-features.xml - docs/ja/programmers/api-functions.xml - docs/ja/programmers/api-variables.xml: - corrected the garbled text. - -2007-04-21 TAKAGI Masahiro - - * docs/ja/bookinfo.xml - docs/ja/getting-started.xml - docs/ja/language-defs.ent - docs/ja/language-snippets.ent - docs/ja/livedocs.ent - docs/ja/make_chm_index.html - docs/ja/preface.xml - docs/ja/translation.xml - docs/ja/appendixes/bugs.xml - docs/ja/appendixes/resources.xml - docs/ja/appendixes/tips.xml - docs/ja/appendixes/troubleshooting.xml - docs/ja/designers/chapter-debugging-console.xml - docs/ja/designers/config-files.xml - docs/ja/designers/language-basic-syntax.xml - docs/ja/designers/language-builtin-functions.xml - docs/ja/designers/language-combining-modifiers.xml - docs/ja/designers/language-custom-functions.xml - docs/ja/designers/language-modifiers.xml - docs/ja/designers/language-variables.xml - docs/ja/designers/language-basic-syntax/language-escaping.xml - docs/ja/designers/language-basic-syntax/language-math.xml - docs/ja/designers/language-basic-syntax/language-syntax-attributes.xml - docs/ja/designers/language-basic-syntax/language-syntax-comments.xml - docs/ja/designers/language-basic-syntax/language-syntax-functions.xml - docs/ja/designers/language-basic-syntax/language-syntax-quotes.xml - docs/ja/designers/language-basic-syntax/language-syntax-variables.xml - docs/ja/designers/language-builtin-functions/language-function-capture.xml - docs/ja/designers/language-builtin-functions/language-function-config-load.xml - docs/ja/designers/language-builtin-functions/language-function-foreach.xml - docs/ja/designers/language-builtin-functions/language-function-if.xml - docs/ja/designers/language-builtin-functions/language-function-include-php.xml - docs/ja/designers/language-builtin-functions/language-function-include.xml - docs/ja/designers/language-builtin-functions/language-function-insert.xml - docs/ja/designers/language-builtin-functions/language-function-ldelim.xml - docs/ja/designers/language-builtin-functions/language-function-literal.xml - docs/ja/designers/language-builtin-functions/language-function-php.xml - docs/ja/designers/language-builtin-functions/language-function-section.xml - docs/ja/designers/language-builtin-functions/language-function-strip.xml - docs/ja/designers/language-custom-functions/language-function-assign.xml - docs/ja/designers/language-custom-functions/language-function-counter.xml - docs/ja/designers/language-custom-functions/language-function-cycle.xml - docs/ja/designers/language-custom-functions/language-function-debug.xml - docs/ja/designers/language-custom-functions/language-function-eval.xml - docs/ja/designers/language-custom-functions/language-function-fetch.xml - docs/ja/designers/language-custom-functions/language-function-html-checkboxes.xml - docs/ja/designers/language-custom-functions/language-function-html-image.xml - docs/ja/designers/language-custom-functions/language-function-html-options.xml - docs/ja/designers/language-custom-functions/language-function-html-radios.xml - docs/ja/designers/language-custom-functions/language-function-html-select-date.xml - docs/ja/designers/language-custom-functions/language-function-html-select-time.xml - docs/ja/designers/language-custom-functions/language-function-html-table.xml - docs/ja/designers/language-custom-functions/language-function-mailto.xml - docs/ja/designers/language-custom-functions/language-function-math.xml - docs/ja/designers/language-custom-functions/language-function-popup-init.xml - docs/ja/designers/language-custom-functions/language-function-popup.xml - docs/ja/designers/language-custom-functions/language-function-textformat.xml - docs/ja/designers/language-modifiers/language-modifier-capitalize.xml - docs/ja/designers/language-modifiers/language-modifier-cat.xml - docs/ja/designers/language-modifiers/language-modifier-count-characters.xml - docs/ja/designers/language-modifiers/language-modifier-count-paragraphs.xml - docs/ja/designers/language-modifiers/language-modifier-count-sentences.xml - docs/ja/designers/language-modifiers/language-modifier-count-words.xml - docs/ja/designers/language-modifiers/language-modifier-date-format.xml - docs/ja/designers/language-modifiers/language-modifier-default.xml - docs/ja/designers/language-modifiers/language-modifier-escape.xml - docs/ja/designers/language-modifiers/language-modifier-indent.xml - docs/ja/designers/language-modifiers/language-modifier-lower.xml - docs/ja/designers/language-modifiers/language-modifier-nl2br.xml - docs/ja/designers/language-modifiers/language-modifier-regex-replace.xml - docs/ja/designers/language-modifiers/language-modifier-replace.xml - docs/ja/designers/language-modifiers/language-modifier-spacify.xml - docs/ja/designers/language-modifiers/language-modifier-string-format.xml - docs/ja/designers/language-modifiers/language-modifier-strip-tags.xml - docs/ja/designers/language-modifiers/language-modifier-strip.xml - docs/ja/designers/language-modifiers/language-modifier-truncate.xml - docs/ja/designers/language-modifiers/language-modifier-upper.xml - docs/ja/designers/language-modifiers/language-modifier-wordwrap.xml - docs/ja/designers/language-variables/language-assigned-variables.xml - docs/ja/designers/language-variables/language-config-variables.xml - docs/ja/designers/language-variables/language-variables-smarty.xml - docs/ja/programmers/advanced-features.xml - docs/ja/programmers/api-functions.xml - docs/ja/programmers/api-variables.xml - docs/ja/programmers/caching.xml - docs/ja/programmers/plugins.xml - docs/ja/programmers/smarty-constants.xml - docs/ja/programmers/advanced-features/advanced-features-objects.xml - docs/ja/programmers/advanced-features/advanced-features-outputfilters.xml - docs/ja/programmers/advanced-features/advanced-features-postfilters.xml - docs/ja/programmers/advanced-features/advanced-features-prefilters.xml - docs/ja/programmers/advanced-features/section-template-cache-handler-func.xml - docs/ja/programmers/advanced-features/template-resources.xml - docs/ja/programmers/api-functions/api-append-by-ref.xml - docs/ja/programmers/api-functions/api-append.xml - docs/ja/programmers/api-functions/api-assign-by-ref.xml - docs/ja/programmers/api-functions/api-assign.xml - docs/ja/programmers/api-functions/api-clear-all-assign.xml - docs/ja/programmers/api-functions/api-clear-all-cache.xml - docs/ja/programmers/api-functions/api-clear-assign.xml - docs/ja/programmers/api-functions/api-clear-cache.xml - docs/ja/programmers/api-functions/api-clear-compiled-tpl.xml - docs/ja/programmers/api-functions/api-clear-config.xml - docs/ja/programmers/api-functions/api-config-load.xml - docs/ja/programmers/api-functions/api-display.xml - docs/ja/programmers/api-functions/api-fetch.xml - docs/ja/programmers/api-functions/api-get-config-vars.xml - docs/ja/programmers/api-functions/api-get-registered-object.xml - docs/ja/programmers/api-functions/api-get-template-vars.xml - docs/ja/programmers/api-functions/api-is-cached.xml - docs/ja/programmers/api-functions/api-load-filter.xml - docs/ja/programmers/api-functions/api-register-block.xml - docs/ja/programmers/api-functions/api-register-compiler-function.xml - docs/ja/programmers/api-functions/api-register-function.xml - docs/ja/programmers/api-functions/api-register-modifier.xml - docs/ja/programmers/api-functions/api-register-object.xml - docs/ja/programmers/api-functions/api-register-outputfilter.xml - docs/ja/programmers/api-functions/api-register-postfilter.xml - docs/ja/programmers/api-functions/api-register-prefilter.xml - docs/ja/programmers/api-functions/api-register-resource.xml - docs/ja/programmers/api-functions/api-template-exists.xml - docs/ja/programmers/api-functions/api-trigger-error.xml - docs/ja/programmers/api-functions/api-unregister-block.xml - docs/ja/programmers/api-functions/api-unregister-compiler-function.xml - docs/ja/programmers/api-functions/api-unregister-function.xml - docs/ja/programmers/api-functions/api-unregister-modifier.xml - docs/ja/programmers/api-functions/api-unregister-object.xml - docs/ja/programmers/api-functions/api-unregister-outputfilter.xml - docs/ja/programmers/api-functions/api-unregister-postfilter.xml - docs/ja/programmers/api-functions/api-unregister-prefilter.xml - docs/ja/programmers/api-functions/api-unregister-resource.xml - docs/ja/programmers/api-variables/variable-autoload-filters.xml - docs/ja/programmers/api-variables/variable-cache-dir.xml - docs/ja/programmers/api-variables/variable-cache-handler-func.xml - docs/ja/programmers/api-variables/variable-cache-lifetime.xml - docs/ja/programmers/api-variables/variable-cache-modified-check.xml - docs/ja/programmers/api-variables/variable-caching.xml - docs/ja/programmers/api-variables/variable-compile-check.xml - docs/ja/programmers/api-variables/variable-compile-dir.xml - docs/ja/programmers/api-variables/variable-compile-id.xml - docs/ja/programmers/api-variables/variable-compiler-class.xml - docs/ja/programmers/api-variables/variable-config-booleanize.xml - docs/ja/programmers/api-variables/variable-config-dir.xml - docs/ja/programmers/api-variables/variable-config-fix-newlines.xml - docs/ja/programmers/api-variables/variable-config-overwrite.xml - docs/ja/programmers/api-variables/variable-config-read-hidden.xml - docs/ja/programmers/api-variables/variable-debug-tpl.xml - docs/ja/programmers/api-variables/variable-debugging-ctrl.xml - docs/ja/programmers/api-variables/variable-debugging.xml - docs/ja/programmers/api-variables/variable-default-modifiers.xml - docs/ja/programmers/api-variables/variable-default-resource-type.xml - docs/ja/programmers/api-variables/variable-default-template-handler-func.xml - docs/ja/programmers/api-variables/variable-error-reporting.xml - docs/ja/programmers/api-variables/variable-force-compile.xml - docs/ja/programmers/api-variables/variable-left-delimiter.xml - docs/ja/programmers/api-variables/variable-php-handling.xml - docs/ja/programmers/api-variables/variable-plugins-dir.xml - docs/ja/programmers/api-variables/variable-request-use-auto-globals.xml - docs/ja/programmers/api-variables/variable-request-vars-order.xml - docs/ja/programmers/api-variables/variable-right-delimiter.xml - docs/ja/programmers/api-variables/variable-secure-dir.xml - docs/ja/programmers/api-variables/variable-security-settings.xml - docs/ja/programmers/api-variables/variable-security.xml - docs/ja/programmers/api-variables/variable-template-dir.xml - docs/ja/programmers/api-variables/variable-trusted-dir.xml - docs/ja/programmers/api-variables/variable-use-sub-dirs.xml - docs/ja/programmers/caching/caching-cacheable.xml - docs/ja/programmers/caching/caching-groups.xml - docs/ja/programmers/caching/caching-multiple-caches.xml - docs/ja/programmers/caching/caching-setting-up.xml - docs/ja/programmers/plugins/plugins-block-functions.xml - docs/ja/programmers/plugins/plugins-compiler-functions.xml - docs/ja/programmers/plugins/plugins-functions.xml - docs/ja/programmers/plugins/plugins-howto.xml - docs/ja/programmers/plugins/plugins-inserts.xml - docs/ja/programmers/plugins/plugins-modifiers.xml - docs/ja/programmers/plugins/plugins-naming-conventions.xml - docs/ja/programmers/plugins/plugins-outputfilters.xml - docs/ja/programmers/plugins/plugins-prefilters-postfilters.xml - docs/ja/programmers/plugins/plugins-resources.xml - docs/ja/programmers/plugins/plugins-writing.xml: - added Japanese translation files. - - * docs/Makefile.in - docs/configure.in: - added the configuration for Japanese translation. - -2007-04-11 Messju Mohr - - * docs/en/programmers/smarty-constants.xml: - fixed typo - -2007-04-04 Messju Mohr - - * docs/ru/getting-started.xml: - fixed uri for Zend Accelerator - -2007-04-03 Messju Mohr - - * docs/de/getting-started.xml - docs/es/getting-started.xml - docs/it/getting-started.xml - docs/pt_BR/getting-started.xml: - fixed uris for php-accelerator - -2007-03-08 Monte Ohrt - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update version numbers - -2007-03-07 Monte Ohrt - - * (Smarty_2_6_18) - NEWS: - update NEWS file with patch - - * (Smarty_2_6_18) - docs/en/designers/language-builtin-functions/language-function-section.xml: - note the fact that section loop will accept an integer - -2007-03-06 Monte Ohrt - - * NEWS - libs/plugins/function.html_select_date.php: - fix html_select_date separator when parts are missing (thanks to kayk for - the patch) - -2007-03-06 Messju Mohr - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - bumped version number - - * NEWS: - added release headline - - * libs/internals/core.write_compiled_include.php: - fixed detection of non-cached block when writing compiled includes - -2007-03-01 Danilo Buerger - - * NEWS - libs/Smarty_Compiler.class.php: - Applied boots clean up patch and removed commented out code. - Updated NEWS file - -2007-02-27 Danilo Buerger - - * NEWS - docs/en/designers/language-modifiers/language-modifier-date-format.xml - libs/internals/core.write_file.php - libs/plugins/modifier.date_format.php: - Updated smarty_core_write_file() and smarty_modifier_date_format() to speed - up Windows detection. - Emulated more parameters for Windows in smarty_modifier_date_format() and - fixed some old ones. - Updated the docs to tell what parameters are emulated on Windows. - Updated NEWS file. - - * NEWS: - Updated NEWS file to reflect changes commited in the last revision - -2007-02-27 Monte Ohrt - - * docs/en/appendixes/troubleshooting.xml: - fix typo - -2007-02-27 Danilo Buerger - - * libs/Smarty_Compiler.class.php: - Modified _(push|pop)_cacheable_state() to embedd alternate syntax. See this - bug report: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=10502 - -2007-02-26 Peter 'Mash' Morgan - - * docs/en/designers/language-custom-functions/language-function-html-options.xml: - Fix incorrect var name - -2007-02-23 Monte Ohrt - - * libs/Smarty_Compiler.class.php: - escape creating of language=php from interleaving - - * libs/Smarty_Compiler.class.php: - add removed line back in - - * libs/Smarty_Compiler.class.php: - fix up last patch, remove unnecessary lines - - * libs/Smarty_Compiler.class.php: - fix situation when no compiled tags are present - - * libs/Smarty_Compiler.class.php: - fix problem with php open tags generated from tag interleaving - -2007-02-06 boots - - * docs/en/programmers/advanced-features/template-resources.xml: - Correct default template handler function example. - -2007-01-17 Messju Mohr - - * NEWS - libs/plugins/modifier.truncate.php: - fixed handling of $etc in the truncate modifier when $etc is longer - than $length. - - thanks to Sylvinus! - -2007-01-10 boots - - * NEWS - libs/plugins/modifier.date_format.php - libs/plugins/modifier.date_format.php: - fix handling of %I with mysql timestamps - - Thanks to Danilo Buerger - - * NEWS - libs/internals/core.write_file.php: - Better recognize Windows filesystems to reduce warnings - - * NEWS - libs/plugins/modifier.date_format.php: - Emulate %R in the date_format modifier on Windows - - Thanks to Danilo Buerger - -2006-12-10 Yannick Torres - - * docs/fr/getting-started.xml: - fix build - - * docs/fr/language-snippets.ent - docs/fr/designers/language-builtin-functions/language-function-include-php.xml - docs/fr/designers/language-modifiers/language-modifier-truncate.xml - docs/fr/designers/language-variables/language-variables-smarty.xml: - sync with EN - -2006-12-02 Peter 'Mash' Morgan - - * docs/en/designers/language-builtin-functions/language-function-include-php.xml: - Tidy example, speeling andd add links - - * docs/en/getting-started.xml: - Add/correct entities - - * docs/entities/global.ent: - Fix entities (strange) - -2006-12-01 Monte Ohrt - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update dev version numbers - -2006-12-01 boots - - * (Smarty_2_6_16) - NEWS: - Fixed replacement bug introduced in trimwhitespaces output filter that - was introduced in the last release. - - Thanks to Spuerhund from the forums. - - * (Smarty_2_6_16) - libs/plugins/outputfilter.trimwhitespace.php: - Fixed replacement bug introduced by last changes. - - Thanks to Spuerhund from the forums. - -2006-11-30 Monte Ohrt - - * NEWS - docs/en/designers/language-modifiers/language-modifier-truncate.xml - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update dev version numbers, fix manual typo - -2006-11-22 George Miroshnikov - - * docs/ru/getting-started.xml - docs/ru/language-snippets.ent: - sync with EN - - * docs/en/getting-started.xml: - replaced hardcoded path separator with PATH_SEPARATOR constant - -2006-11-20 boots - - * libs/plugins/modifier.debug_print_var.php: - fix depth formatting of arrays and objects in modifier debug_print_var - -2006-11-10 Messju Mohr - - * docs/en/designers/language-variables/language-variables-smarty.xml: - fixed typo. thanks jonez. - -2006-11-08 boots - - * NEWS - libs/internals/core.write_file.php: - change file writing semantics in smarty_core_write_file() - - This avoids unlink() unless rename() fails or a Windows system is detected - - see: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=6956 - - Thanks to c960657 from the forums. - -2006-11-07 boots - - * NEWS - libs/debug.tpl: - update debug.tpl to xhtml 1.1 compliance, fix javascript escaping in debug - output and apply a Smarty based color scheme - - see: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=7178 - - thanks to cybot from the forums! - - * NEWS - libs/plugins/modifier.debug_print_var.php: - enhance reporting precision of debug_print_var modifier - - see: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=9281 - - thanks to cybot from the forums - -2006-11-01 boots - - * NEWS - libs/plugins/function.html_select_date.php: - make html_select_date work consistently with 0000-00-00 00:00:00 and - 0000-00-00 inputs - - Thanks to cybot from forums - -2006-10-16 George Miroshnikov - - * docs/en/language-snippets.ent: - minor typo fix - &$class doesn't make sense. - -2006-10-14 Yannick Torres - - * docs/fr/designers/language-basic-syntax.xml - docs/fr/designers/language-builtin-functions.xml - docs/fr/designers/language-basic-syntax/language-syntax-attributes.xml - docs/fr/designers/language-basic-syntax/language-syntax-comments.xml - docs/fr/designers/language-basic-syntax/language-syntax-quotes.xml - docs/fr/designers/language-builtin-functions/language-function-capture.xml - docs/fr/designers/language-builtin-functions/language-function-php.xml - docs/fr/designers/language-builtin-functions/language-function-section.xml - docs/fr/designers/language-custom-functions/language-function-popup-init.xml - docs/fr/designers/language-modifiers/language-modifier-escape.xml - docs/fr/programmers/api-functions/api-display.xml - docs/fr/programmers/plugins/plugins-inserts.xml: - sync with EN - -2006-10-14 Fernando Correa da Conceio - - * docs/pt_BR/programmers/api-variables/variable-error-reporting.xml: - New Translation - - * docs/pt_BR/designers/language-basic-syntax/language-escaping.xml - docs/pt_BR/designers/language-basic-syntax/language-syntax-variables.xml: - New Translations - - * docs/pt_BR/translation.xml: - Used in revcheck - - * docs/pt_BR/getting-started.xml - docs/pt_BR/language-snippets.ent - docs/pt_BR/make_chm_index.html - docs/pt_BR/preface.xml - docs/pt_BR/appendixes/resources.xml - docs/pt_BR/appendixes/troubleshooting.xml - docs/pt_BR/designers/language-modifiers/language-modifier-capitalize.xml - docs/pt_BR/designers/language-modifiers/language-modifier-cat.xml - docs/pt_BR/designers/language-modifiers/language-modifier-count-characters.xml - docs/pt_BR/designers/language-modifiers/language-modifier-count-paragraphs.xml - docs/pt_BR/designers/language-modifiers/language-modifier-count-sentences.xml - docs/pt_BR/designers/language-modifiers/language-modifier-count-words.xml - docs/pt_BR/designers/language-modifiers/language-modifier-date-format.xml - docs/pt_BR/designers/language-modifiers/language-modifier-default.xml - docs/pt_BR/designers/language-modifiers/language-modifier-escape.xml - docs/pt_BR/designers/language-modifiers/language-modifier-indent.xml - docs/pt_BR/designers/language-modifiers/language-modifier-lower.xml - docs/pt_BR/designers/language-modifiers/language-modifier-nl2br.xml - docs/pt_BR/designers/language-modifiers/language-modifier-regex-replace.xml - docs/pt_BR/designers/language-modifiers/language-modifier-replace.xml - docs/pt_BR/designers/language-modifiers/language-modifier-spacify.xml - docs/pt_BR/designers/language-modifiers/language-modifier-string-format.xml - docs/pt_BR/designers/language-modifiers/language-modifier-strip-tags.xml - docs/pt_BR/designers/language-modifiers/language-modifier-strip.xml - docs/pt_BR/designers/language-modifiers/language-modifier-truncate.xml - docs/pt_BR/designers/language-modifiers/language-modifier-upper.xml - docs/pt_BR/designers/language-modifiers/language-modifier-wordwrap.xml - docs/pt_BR/designers/language-variables/language-assigned-variables.xml - docs/pt_BR/designers/language-variables/language-config-variables.xml - docs/pt_BR/designers/language-variables/language-variables-smarty.xml - docs/pt_BR/programmers/advanced-features.xml - docs/pt_BR/programmers/api-functions.xml - docs/pt_BR/programmers/api-variables.xml - docs/pt_BR/programmers/caching.xml - docs/pt_BR/programmers/plugins.xml - docs/pt_BR/programmers/smarty-constants.xml - docs/pt_BR/programmers/advanced-features/advanced-features-objects.xml - docs/pt_BR/programmers/advanced-features/advanced-features-outputfilters.xml - docs/pt_BR/programmers/advanced-features/advanced-features-postfilters.xml - docs/pt_BR/programmers/advanced-features/advanced-features-prefilters.xml - docs/pt_BR/programmers/advanced-features/section-template-cache-handler-func.xml - docs/pt_BR/programmers/advanced-features/template-resources.xml - docs/pt_BR/programmers/api-functions/api-append-by-ref.xml - docs/pt_BR/programmers/api-functions/api-append.xml - docs/pt_BR/programmers/api-functions/api-assign-by-ref.xml - docs/pt_BR/programmers/api-functions/api-assign.xml - docs/pt_BR/programmers/api-functions/api-clear-all-assign.xml - docs/pt_BR/programmers/api-functions/api-clear-all-cache.xml - docs/pt_BR/programmers/api-functions/api-clear-assign.xml - docs/pt_BR/programmers/api-functions/api-clear-cache.xml - docs/pt_BR/programmers/api-functions/api-clear-compiled-tpl.xml - docs/pt_BR/programmers/api-functions/api-clear-config.xml - docs/pt_BR/programmers/api-functions/api-config-load.xml - docs/pt_BR/programmers/api-functions/api-display.xml - docs/pt_BR/programmers/api-functions/api-fetch.xml - docs/pt_BR/programmers/api-functions/api-get-config-vars.xml - docs/pt_BR/programmers/api-functions/api-get-registered-object.xml - docs/pt_BR/programmers/api-functions/api-get-template-vars.xml - docs/pt_BR/programmers/api-functions/api-is-cached.xml - docs/pt_BR/programmers/api-functions/api-load-filter.xml - docs/pt_BR/programmers/api-functions/api-register-block.xml - docs/pt_BR/programmers/api-functions/api-register-compiler-function.xml - docs/pt_BR/programmers/api-functions/api-register-function.xml - docs/pt_BR/programmers/api-functions/api-register-modifier.xml - docs/pt_BR/programmers/api-functions/api-register-object.xml - docs/pt_BR/programmers/api-functions/api-register-outputfilter.xml - docs/pt_BR/programmers/api-functions/api-register-postfilter.xml - docs/pt_BR/programmers/api-functions/api-register-prefilter.xml - docs/pt_BR/programmers/api-functions/api-register-resource.xml - docs/pt_BR/programmers/api-functions/api-template-exists.xml - docs/pt_BR/programmers/api-functions/api-trigger-error.xml - docs/pt_BR/programmers/api-functions/api-unregister-block.xml - docs/pt_BR/programmers/api-functions/api-unregister-compiler-function.xml - docs/pt_BR/programmers/api-functions/api-unregister-function.xml - docs/pt_BR/programmers/api-functions/api-unregister-modifier.xml - docs/pt_BR/programmers/api-functions/api-unregister-object.xml - docs/pt_BR/programmers/api-functions/api-unregister-outputfilter.xml - docs/pt_BR/programmers/api-functions/api-unregister-postfilter.xml - docs/pt_BR/programmers/api-functions/api-unregister-prefilter.xml - docs/pt_BR/programmers/api-functions/api-unregister-resource.xml - docs/pt_BR/programmers/api-variables/variable-autoload-filters.xml - docs/pt_BR/programmers/api-variables/variable-cache-dir.xml - docs/pt_BR/programmers/api-variables/variable-cache-handler-func.xml - docs/pt_BR/programmers/api-variables/variable-cache-lifetime.xml - docs/pt_BR/programmers/api-variables/variable-cache-modified-check.xml - docs/pt_BR/programmers/api-variables/variable-caching.xml - docs/pt_BR/programmers/api-variables/variable-compile-check.xml - docs/pt_BR/programmers/api-variables/variable-compile-dir.xml - docs/pt_BR/programmers/api-variables/variable-compile-id.xml - docs/pt_BR/programmers/api-variables/variable-compiler-class.xml - docs/pt_BR/programmers/api-variables/variable-config-booleanize.xml - docs/pt_BR/programmers/api-variables/variable-config-dir.xml - docs/pt_BR/programmers/api-variables/variable-config-fix-newlines.xml - docs/pt_BR/programmers/api-variables/variable-config-overwrite.xml - docs/pt_BR/programmers/api-variables/variable-config-read-hidden.xml - docs/pt_BR/programmers/api-variables/variable-debug-tpl.xml - docs/pt_BR/programmers/api-variables/variable-debugging-ctrl.xml - docs/pt_BR/programmers/api-variables/variable-debugging.xml - docs/pt_BR/programmers/api-variables/variable-default-modifiers.xml - docs/pt_BR/programmers/api-variables/variable-default-resource-type.xml - docs/pt_BR/programmers/api-variables/variable-default-template-handler-func.xml - docs/pt_BR/programmers/api-variables/variable-force-compile.xml - docs/pt_BR/programmers/api-variables/variable-global-assign.xml - docs/pt_BR/programmers/api-variables/variable-left-delimiter.xml - docs/pt_BR/programmers/api-variables/variable-php-handling.xml - docs/pt_BR/programmers/api-variables/variable-plugins-dir.xml - docs/pt_BR/programmers/api-variables/variable-request-use-auto-globals.xml - docs/pt_BR/programmers/api-variables/variable-request-vars-order.xml - docs/pt_BR/programmers/api-variables/variable-right-delimiter.xml - docs/pt_BR/programmers/api-variables/variable-secure-dir.xml - docs/pt_BR/programmers/api-variables/variable-security-settings.xml - docs/pt_BR/programmers/api-variables/variable-security.xml - docs/pt_BR/programmers/api-variables/variable-template-dir.xml - docs/pt_BR/programmers/api-variables/variable-trusted-dir.xml - docs/pt_BR/programmers/api-variables/variable-undefined.xml - docs/pt_BR/programmers/api-variables/variable-use-sub-dirs.xml - docs/pt_BR/programmers/caching/caching-cacheable.xml - docs/pt_BR/programmers/caching/caching-groups.xml - docs/pt_BR/programmers/caching/caching-multiple-caches.xml - docs/pt_BR/programmers/caching/caching-setting-up.xml - docs/pt_BR/programmers/plugins/plugins-block-functions.xml - docs/pt_BR/programmers/plugins/plugins-compiler-functions.xml - docs/pt_BR/programmers/plugins/plugins-functions.xml - docs/pt_BR/programmers/plugins/plugins-howto.xml - docs/pt_BR/programmers/plugins/plugins-inserts.xml - docs/pt_BR/programmers/plugins/plugins-modifiers.xml - docs/pt_BR/programmers/plugins/plugins-naming-conventions.xml - docs/pt_BR/programmers/plugins/plugins-outputfilters.xml - docs/pt_BR/programmers/plugins/plugins-prefilters-postfilters.xml - docs/pt_BR/programmers/plugins/plugins-resources.xml - docs/pt_BR/programmers/plugins/plugins-writing.xml: - Big update. Revision tag for all files. Some updates. Now I can update it - -2006-10-09 Peter 'Mash' Morgan - - * docs/en/getting-started.xml - docs/en/designers/language-basic-syntax.xml - docs/en/designers/language-custom-functions/language-function-popup-init.xml - docs/en/designers/language-modifiers/language-modifier-escape.xml - docs/en/programmers/api-functions/api-display.xml - docs/en/programmers/plugins/plugins-inserts.xml: - Minor changes and corrections - - * docs/en/designers/language-basic-syntax.xml - docs/en/designers/language-builtin-functions.xml - docs/en/designers/language-basic-syntax/language-syntax-attributes.xml - docs/en/designers/language-basic-syntax/language-syntax-comments.xml - docs/en/designers/language-basic-syntax/language-syntax-quotes.xml - docs/en/designers/language-modifiers/language-modifier-escape.xml: - Minor formatting and error correction - - * docs/en/designers/language-builtin-functions/language-function-capture.xml - docs/en/designers/language-builtin-functions/language-function-php.xml - docs/en/designers/language-builtin-functions/language-function-section.xml: - minor formatting and changes - - * docs/en/getting-started.xml: - Tidied up formatting so more readable, tidied up the install to the paths - are more clear (ta jj) - -2006-10-09 Yannick Torres - - * docs/fr/designers/language-builtin-functions/language-function-section.xml: - sync with EN - -2006-10-08 Yannick Torres - - * docs/fr/designers/language-builtin-functions/language-function-php.xml - docs/fr/designers/language-modifiers/language-modifier-escape.xml - docs/fr/designers/language-variables/language-variables-smarty.xml - docs/fr/programmers/api-variables/variable-request-use-auto-globals.xml: - fix build - - * docs/fr/designers/language-builtin-functions/language-function-strip.xml - docs/fr/programmers/caching.xml - docs/fr/programmers/smarty-constants.xml - docs/fr/programmers/api-variables/variable-autoload-filters.xml - docs/fr/programmers/api-variables/variable-cache-dir.xml - docs/fr/programmers/api-variables/variable-cache-handler-func.xml - docs/fr/programmers/api-variables/variable-cache-lifetime.xml - docs/fr/programmers/api-variables/variable-cache-modified-check.xml - docs/fr/programmers/api-variables/variable-caching.xml - docs/fr/programmers/api-variables/variable-compile-check.xml - docs/fr/programmers/api-variables/variable-compile-dir.xml - docs/fr/programmers/api-variables/variable-compile-id.xml - docs/fr/programmers/api-variables/variable-compiler-class.xml - docs/fr/programmers/api-variables/variable-config-booleanize.xml - docs/fr/programmers/api-variables/variable-config-dir.xml - docs/fr/programmers/api-variables/variable-config-fix-newlines.xml - docs/fr/programmers/api-variables/variable-config-overwrite.xml - docs/fr/programmers/api-variables/variable-config-read-hidden.xml - docs/fr/programmers/api-variables/variable-debug-tpl.xml - docs/fr/programmers/api-variables/variable-debugging-ctrl.xml - docs/fr/programmers/api-variables/variable-debugging.xml - docs/fr/programmers/api-variables/variable-default-modifiers.xml - docs/fr/programmers/api-variables/variable-default-resource-type.xml - docs/fr/programmers/api-variables/variable-default-template-handler-func.xml - docs/fr/programmers/api-variables/variable-error-reporting.xml - docs/fr/programmers/api-variables/variable-force-compile.xml - docs/fr/programmers/api-variables/variable-left-delimiter.xml - docs/fr/programmers/api-variables/variable-php-handling.xml - docs/fr/programmers/api-variables/variable-plugins-dir.xml - docs/fr/programmers/api-variables/variable-request-use-auto-globals.xml - docs/fr/programmers/api-variables/variable-request-vars-order.xml - docs/fr/programmers/api-variables/variable-right-delimiter.xml - docs/fr/programmers/api-variables/variable-secure-dir.xml - docs/fr/programmers/api-variables/variable-security-settings.xml - docs/fr/programmers/api-variables/variable-security.xml - docs/fr/programmers/api-variables/variable-template-dir.xml - docs/fr/programmers/api-variables/variable-trusted-dir.xml - docs/fr/programmers/api-variables/variable-use-sub-dirs.xml - docs/fr/programmers/caching/caching-cacheable.xml - docs/fr/programmers/caching/caching-groups.xml - docs/fr/programmers/caching/caching-multiple-caches.xml - docs/fr/programmers/caching/caching-setting-up.xml - docs/fr/programmers/plugins/plugins-block-functions.xml - docs/fr/programmers/plugins/plugins-compiler-functions.xml - docs/fr/programmers/plugins/plugins-functions.xml - docs/fr/programmers/plugins/plugins-inserts.xml - docs/fr/programmers/plugins/plugins-modifiers.xml - docs/fr/programmers/plugins/plugins-naming-conventions.xml - docs/fr/programmers/plugins/plugins-outputfilters.xml - docs/fr/programmers/plugins/plugins-prefilters-postfilters.xml - docs/fr/programmers/plugins/plugins-resources.xml - docs/fr/programmers/plugins/plugins-writing.xml: - sync with EN - -2006-10-07 Yannick Torres - - * docs/fr/programmers/advanced-features/advanced-features-objects.xml - docs/fr/programmers/advanced-features/advanced-features-outputfilters.xml - docs/fr/programmers/advanced-features/advanced-features-postfilters.xml - docs/fr/programmers/advanced-features/advanced-features-prefilters.xml - docs/fr/programmers/advanced-features/section-template-cache-handler-func.xml - docs/fr/programmers/advanced-features/template-resources.xml - docs/fr/programmers/api-functions/api-append-by-ref.xml - docs/fr/programmers/api-functions/api-append.xml - docs/fr/programmers/api-functions/api-assign-by-ref.xml - docs/fr/programmers/api-functions/api-assign.xml - docs/fr/programmers/api-functions/api-clear-all-assign.xml - docs/fr/programmers/api-functions/api-clear-all-cache.xml - docs/fr/programmers/api-functions/api-clear-assign.xml - docs/fr/programmers/api-functions/api-clear-cache.xml - docs/fr/programmers/api-functions/api-clear-compiled-tpl.xml - docs/fr/programmers/api-functions/api-clear-config.xml - docs/fr/programmers/api-functions/api-config-load.xml - docs/fr/programmers/api-functions/api-display.xml - docs/fr/programmers/api-functions/api-fetch.xml - docs/fr/programmers/api-functions/api-get-config-vars.xml - docs/fr/programmers/api-functions/api-get-registered-object.xml - docs/fr/programmers/api-functions/api-get-template-vars.xml - docs/fr/programmers/api-functions/api-is-cached.xml - docs/fr/programmers/api-functions/api-load-filter.xml - docs/fr/programmers/api-functions/api-register-block.xml - docs/fr/programmers/api-functions/api-register-compiler-function.xml - docs/fr/programmers/api-functions/api-register-function.xml - docs/fr/programmers/api-functions/api-register-modifier.xml - docs/fr/programmers/api-functions/api-register-object.xml - docs/fr/programmers/api-functions/api-register-outputfilter.xml - docs/fr/programmers/api-functions/api-register-postfilter.xml - docs/fr/programmers/api-functions/api-register-prefilter.xml - docs/fr/programmers/api-functions/api-register-resource.xml - docs/fr/programmers/api-functions/api-template-exists.xml - docs/fr/programmers/api-functions/api-trigger-error.xml - docs/fr/programmers/api-functions/api-unregister-block.xml - docs/fr/programmers/api-functions/api-unregister-compiler-function.xml - docs/fr/programmers/api-functions/api-unregister-function.xml - docs/fr/programmers/api-functions/api-unregister-modifier.xml - docs/fr/programmers/api-functions/api-unregister-object.xml - docs/fr/programmers/api-functions/api-unregister-outputfilter.xml - docs/fr/programmers/api-functions/api-unregister-postfilter.xml - docs/fr/programmers/api-functions/api-unregister-prefilter.xml - docs/fr/programmers/api-functions/api-unregister-resource.xml: - sync with EN - -2006-10-03 Yannick Torres - - * docs/fr/designers/language-custom-functions/language-function-html-select-time.xml - docs/fr/designers/language-custom-functions/language-function-html-table.xml - docs/fr/designers/language-custom-functions/language-function-mailto.xml - docs/fr/designers/language-custom-functions/language-function-math.xml - docs/fr/designers/language-custom-functions/language-function-popup-init.xml - docs/fr/designers/language-custom-functions/language-function-popup.xml - docs/fr/designers/language-custom-functions/language-function-textformat.xml - docs/fr/designers/language-modifiers/language-modifier-capitalize.xml - docs/fr/designers/language-modifiers/language-modifier-cat.xml - docs/fr/designers/language-modifiers/language-modifier-count-characters.xml - docs/fr/designers/language-modifiers/language-modifier-count-paragraphs.xml - docs/fr/designers/language-modifiers/language-modifier-count-sentences.xml - docs/fr/designers/language-modifiers/language-modifier-count-words.xml - docs/fr/designers/language-modifiers/language-modifier-date-format.xml - docs/fr/designers/language-modifiers/language-modifier-default.xml - docs/fr/designers/language-modifiers/language-modifier-escape.xml - docs/fr/designers/language-modifiers/language-modifier-indent.xml - docs/fr/designers/language-modifiers/language-modifier-lower.xml - docs/fr/designers/language-modifiers/language-modifier-nl2br.xml - docs/fr/designers/language-modifiers/language-modifier-regex-replace.xml - docs/fr/designers/language-modifiers/language-modifier-replace.xml - docs/fr/designers/language-modifiers/language-modifier-spacify.xml - docs/fr/designers/language-modifiers/language-modifier-string-format.xml - docs/fr/designers/language-modifiers/language-modifier-strip-tags.xml - docs/fr/designers/language-modifiers/language-modifier-strip.xml - docs/fr/designers/language-modifiers/language-modifier-truncate.xml - docs/fr/designers/language-modifiers/language-modifier-upper.xml - docs/fr/designers/language-modifiers/language-modifier-wordwrap.xml - docs/fr/designers/language-variables/language-assigned-variables.xml - docs/fr/designers/language-variables/language-config-variables.xml - docs/fr/designers/language-variables/language-variables-smarty.xml: - sync with EN - -2006-10-01 Yannick Torres - - * docs/fr/designers/language-builtin-functions/language-function-include-php.xml - docs/fr/designers/language-builtin-functions/language-function-include.xml - docs/fr/designers/language-builtin-functions/language-function-insert.xml - docs/fr/designers/language-builtin-functions/language-function-ldelim.xml - docs/fr/designers/language-builtin-functions/language-function-literal.xml - docs/fr/designers/language-builtin-functions/language-function-php.xml - docs/fr/designers/language-custom-functions/language-function-assign.xml - docs/fr/designers/language-custom-functions/language-function-counter.xml - docs/fr/designers/language-custom-functions/language-function-cycle.xml - docs/fr/designers/language-custom-functions/language-function-debug.xml - docs/fr/designers/language-custom-functions/language-function-eval.xml - docs/fr/designers/language-custom-functions/language-function-fetch.xml - docs/fr/designers/language-custom-functions/language-function-html-checkboxes.xml - docs/fr/designers/language-custom-functions/language-function-html-image.xml - docs/fr/designers/language-custom-functions/language-function-html-options.xml - docs/fr/designers/language-custom-functions/language-function-html-radios.xml - docs/fr/designers/language-custom-functions/language-function-html-select-date.xml: - sync with EN - -2006-09-30 Yannick Torres - - * docs/fr/getting-started.xml: - fix build - - * docs/fr/designers/chapter-debugging-console.xml - docs/fr/designers/config-files.xml - docs/fr/designers/language-builtin-functions.xml - docs/fr/designers/language-modifiers.xml - docs/fr/designers/language-variables.xml - docs/fr/designers/language-basic-syntax/language-escaping.xml - docs/fr/designers/language-basic-syntax/language-math.xml - docs/fr/designers/language-basic-syntax/language-syntax-comments.xml - docs/fr/designers/language-basic-syntax/language-syntax-functions.xml - docs/fr/designers/language-basic-syntax/language-syntax-quotes.xml - docs/fr/designers/language-basic-syntax/language-syntax-variables.xml - docs/fr/designers/language-builtin-functions/language-function-capture.xml - docs/fr/designers/language-builtin-functions/language-function-config-load.xml - docs/fr/designers/language-builtin-functions/language-function-foreach.xml - docs/fr/designers/language-builtin-functions/language-function-if.xml: - sync with EN - - * docs/fr/getting-started.xml - docs/fr/language-snippets.ent - docs/fr/appendixes/resources.xml - docs/fr/appendixes/tips.xml - docs/fr/appendixes/troubleshooting.xml: - sync with EN - -2006-09-27 Peter 'Mash' Morgan - - * docs/en/designers/language-builtin-functions/language-function-section.xml: - Minor tweaks and corrections - - * docs/en/getting-started.xml - docs/en/designers/chapter-debugging-console.xml - docs/en/designers/language-basic-syntax/language-syntax-comments.xml - docs/en/designers/language-custom-functions/language-function-html-image.xml - docs/en/designers/language-custom-functions/language-function-html-options.xml - docs/en/designers/language-custom-functions/language-function-html-radios.xml - docs/en/designers/language-custom-functions/language-function-html-select-date.xml - docs/en/designers/language-custom-functions/language-function-html-select-time.xml - docs/en/designers/language-custom-functions/language-function-html-table.xml - docs/en/designers/language-custom-functions/language-function-mailto.xml - docs/en/designers/language-custom-functions/language-function-popup-init.xml - docs/en/designers/language-custom-functions/language-function-textformat.xml - docs/en/designers/language-variables/language-config-variables.xml - docs/en/designers/language-variables/language-variables-smarty.xml: - Add literal tags to html, general formatting - - * docs/en/getting-started.xml - docs/en/appendixes/resources.xml - docs/en/appendixes/tips.xml - docs/en/appendixes/troubleshooting.xml - docs/en/designers/config-files.xml - docs/en/programmers/caching.xml - docs/en/programmers/smarty-constants.xml - docs/en/programmers/advanced-features/advanced-features-objects.xml - docs/en/programmers/advanced-features/advanced-features-outputfilters.xml - docs/en/programmers/advanced-features/advanced-features-postfilters.xml - docs/en/programmers/advanced-features/advanced-features-prefilters.xml - docs/en/programmers/advanced-features/section-template-cache-handler-func.xml - docs/en/programmers/advanced-features/template-resources.xml - docs/en/programmers/api-variables/variable-autoload-filters.xml - docs/en/programmers/api-variables/variable-cache-dir.xml - docs/en/programmers/api-variables/variable-cache-handler-func.xml - docs/en/programmers/api-variables/variable-cache-lifetime.xml - docs/en/programmers/api-variables/variable-cache-modified-check.xml - docs/en/programmers/api-variables/variable-caching.xml - docs/en/programmers/api-variables/variable-compile-check.xml - docs/en/programmers/api-variables/variable-compile-dir.xml - docs/en/programmers/api-variables/variable-compile-id.xml - docs/en/programmers/api-variables/variable-config-booleanize.xml - docs/en/programmers/api-variables/variable-config-dir.xml - docs/en/programmers/api-variables/variable-config-fix-newlines.xml - docs/en/programmers/api-variables/variable-config-overwrite.xml - docs/en/programmers/api-variables/variable-config-read-hidden.xml - docs/en/programmers/api-variables/variable-debug-tpl.xml - docs/en/programmers/api-variables/variable-debugging-ctrl.xml - docs/en/programmers/api-variables/variable-debugging.xml - docs/en/programmers/api-variables/variable-default-modifiers.xml - docs/en/programmers/api-variables/variable-default-resource-type.xml - docs/en/programmers/api-variables/variable-error-reporting.xml - docs/en/programmers/api-variables/variable-force-compile.xml - docs/en/programmers/api-variables/variable-left-delimiter.xml - docs/en/programmers/api-variables/variable-php-handling.xml - docs/en/programmers/api-variables/variable-plugins-dir.xml - docs/en/programmers/api-variables/variable-request-use-auto-globals.xml - docs/en/programmers/api-variables/variable-request-vars-order.xml - docs/en/programmers/api-variables/variable-right-delimiter.xml - docs/en/programmers/api-variables/variable-secure-dir.xml - docs/en/programmers/api-variables/variable-security-settings.xml - docs/en/programmers/api-variables/variable-security.xml - docs/en/programmers/api-variables/variable-template-dir.xml - docs/en/programmers/api-variables/variable-trusted-dir.xml - docs/en/programmers/api-variables/variable-use-sub-dirs.xml - docs/en/programmers/caching/caching-cacheable.xml - docs/en/programmers/caching/caching-groups.xml - docs/en/programmers/caching/caching-multiple-caches.xml - docs/en/programmers/caching/caching-setting-up.xml: - Tidy up of formatting - - * docs/entities/global.ent: - Adding some more resources - - * docs/en/programmers/plugins/plugins-block-functions.xml - docs/en/programmers/plugins/plugins-compiler-functions.xml - docs/en/programmers/plugins/plugins-functions.xml - docs/en/programmers/plugins/plugins-inserts.xml - docs/en/programmers/plugins/plugins-modifiers.xml - docs/en/programmers/plugins/plugins-naming-conventions.xml - docs/en/programmers/plugins/plugins-outputfilters.xml - docs/en/programmers/plugins/plugins-prefilters-postfilters.xml - docs/en/programmers/plugins/plugins-resources.xml - docs/en/programmers/plugins/plugins-writing.xml: - Tidy up some formatting - -2006-09-26 Peter 'Mash' Morgan - - * docs/en/programmers/api-functions/api-append-by-ref.xml - docs/en/programmers/api-functions/api-append.xml - docs/en/programmers/api-functions/api-assign-by-ref.xml - docs/en/programmers/api-functions/api-assign.xml - docs/en/programmers/api-functions/api-clear-all-assign.xml - docs/en/programmers/api-functions/api-clear-all-cache.xml - docs/en/programmers/api-functions/api-clear-assign.xml - docs/en/programmers/api-functions/api-clear-cache.xml - docs/en/programmers/api-functions/api-clear-compiled-tpl.xml - docs/en/programmers/api-functions/api-clear-config.xml - docs/en/programmers/api-functions/api-config-load.xml - docs/en/programmers/api-functions/api-display.xml - docs/en/programmers/api-functions/api-fetch.xml - docs/en/programmers/api-functions/api-get-config-vars.xml - docs/en/programmers/api-functions/api-get-registered-object.xml - docs/en/programmers/api-functions/api-get-template-vars.xml - docs/en/programmers/api-functions/api-is-cached.xml - docs/en/programmers/api-functions/api-load-filter.xml - docs/en/programmers/api-functions/api-register-block.xml - docs/en/programmers/api-functions/api-register-compiler-function.xml - docs/en/programmers/api-functions/api-register-function.xml - docs/en/programmers/api-functions/api-register-modifier.xml - docs/en/programmers/api-functions/api-register-object.xml - docs/en/programmers/api-functions/api-register-outputfilter.xml - docs/en/programmers/api-functions/api-register-postfilter.xml - docs/en/programmers/api-functions/api-register-prefilter.xml - docs/en/programmers/api-functions/api-register-resource.xml - docs/en/programmers/api-functions/api-template-exists.xml - docs/en/programmers/api-functions/api-trigger-error.xml - docs/en/programmers/api-functions/api-unregister-block.xml - docs/en/programmers/api-functions/api-unregister-compiler-function.xml - docs/en/programmers/api-functions/api-unregister-function.xml - docs/en/programmers/api-functions/api-unregister-modifier.xml - docs/en/programmers/api-functions/api-unregister-object.xml - docs/en/programmers/api-functions/api-unregister-outputfilter.xml - docs/en/programmers/api-functions/api-unregister-postfilter.xml - docs/en/programmers/api-functions/api-unregister-prefilter.xml - docs/en/programmers/api-functions/api-unregister-resource.xml: - Tidy up formatting and examples - - * docs/en/language-snippets.ent: - Moved recurring para for register_* - - * docs/en/designers/language-modifiers.xml: - Spelling on modifiers - - * docs/en/designers/language-builtin-functions.xml - docs/en/designers/language-modifiers.xml - docs/en/designers/language-custom-functions/language-function-html-options.xml - docs/en/designers/language-modifiers/language-modifier-capitalize.xml - docs/en/designers/language-modifiers/language-modifier-cat.xml - docs/en/designers/language-modifiers/language-modifier-count-characters.xml - docs/en/designers/language-modifiers/language-modifier-count-paragraphs.xml - docs/en/designers/language-modifiers/language-modifier-count-sentences.xml - docs/en/designers/language-modifiers/language-modifier-count-words.xml - docs/en/designers/language-modifiers/language-modifier-date-format.xml - docs/en/designers/language-modifiers/language-modifier-default.xml - docs/en/designers/language-modifiers/language-modifier-escape.xml - docs/en/designers/language-modifiers/language-modifier-indent.xml - docs/en/designers/language-modifiers/language-modifier-lower.xml - docs/en/designers/language-modifiers/language-modifier-nl2br.xml - docs/en/designers/language-modifiers/language-modifier-regex-replace.xml - docs/en/designers/language-modifiers/language-modifier-replace.xml - docs/en/designers/language-modifiers/language-modifier-spacify.xml - docs/en/designers/language-modifiers/language-modifier-string-format.xml - docs/en/designers/language-modifiers/language-modifier-strip-tags.xml - docs/en/designers/language-modifiers/language-modifier-strip.xml - docs/en/designers/language-modifiers/language-modifier-truncate.xml - docs/en/designers/language-modifiers/language-modifier-upper.xml - docs/en/designers/language-modifiers/language-modifier-wordwrap.xml: - Tidying up some markup - - * docs/en/designers/language-variables.xml: - typo - - * docs/en/designers/language-variables.xml - docs/en/designers/language-variables/language-assigned-variables.xml - docs/en/designers/language-variables/language-config-variables.xml - docs/en/designers/language-variables/language-variables-smarty.xml: - Tidy up formatting on variables - - * docs/en/designers/language-basic-syntax/language-escaping.xml - docs/en/designers/language-basic-syntax/language-math.xml - docs/en/designers/language-basic-syntax/language-syntax-comments.xml - docs/en/designers/language-basic-syntax/language-syntax-functions.xml - docs/en/designers/language-basic-syntax/language-syntax-quotes.xml - docs/en/designers/language-basic-syntax/language-syntax-variables.xml: - Formatting of the basic-syntax dir - - * docs/en/designers/language-custom-functions/language-function-assign.xml - docs/en/designers/language-custom-functions/language-function-counter.xml - docs/en/designers/language-custom-functions/language-function-cycle.xml - docs/en/designers/language-custom-functions/language-function-debug.xml - docs/en/designers/language-custom-functions/language-function-eval.xml - docs/en/designers/language-custom-functions/language-function-fetch.xml - docs/en/designers/language-custom-functions/language-function-html-checkboxes.xml - docs/en/designers/language-custom-functions/language-function-html-image.xml - docs/en/designers/language-custom-functions/language-function-html-options.xml - docs/en/designers/language-custom-functions/language-function-html-radios.xml - docs/en/designers/language-custom-functions/language-function-html-select-date.xml - docs/en/designers/language-custom-functions/language-function-html-select-time.xml - docs/en/designers/language-custom-functions/language-function-html-table.xml - docs/en/designers/language-custom-functions/language-function-mailto.xml - docs/en/designers/language-custom-functions/language-function-math.xml - docs/en/designers/language-custom-functions/language-function-popup-init.xml - docs/en/designers/language-custom-functions/language-function-popup.xml - docs/en/designers/language-custom-functions/language-function-textformat.xml: - More formatting and cleaning up examples - -2006-09-25 Peter 'Mash' Morgan - - * docs/en/designers/language-builtin-functions/language-function-foreach.xml - docs/en/designers/language-builtin-functions/language-function-section.xml: - Doh! removing tabs - - * docs/en/designers/language-builtin-functions/language-function-capture.xml - docs/en/designers/language-builtin-functions/language-function-config-load.xml - docs/en/designers/language-builtin-functions/language-function-foreach.xml - docs/en/designers/language-builtin-functions/language-function-if.xml - docs/en/designers/language-builtin-functions/language-function-include-php.xml - docs/en/designers/language-builtin-functions/language-function-include.xml - docs/en/designers/language-builtin-functions/language-function-insert.xml - docs/en/designers/language-builtin-functions/language-function-ldelim.xml - docs/en/designers/language-builtin-functions/language-function-literal.xml - docs/en/designers/language-builtin-functions/language-function-php.xml - docs/en/designers/language-builtin-functions/language-function-section.xml - docs/en/designers/language-builtin-functions/language-function-strip.xml: - A lot of formatting, tagging and tidy up. Some consistency at last - - * docs/en/designers/language-builtin-functions/language-function-section.xml: - Major tidy up - - * docs/en/designers/language-builtin-functions/language-function-foreach.xml: - Major tidy up, added index property and some examples - -2006-09-03 Yannick Torres - - * docs/fr/designers/language-custom-functions/language-function-popup-init.xml - docs/fr/programmers/advanced-features/advanced-features-outputfilters.xml - docs/fr/programmers/advanced-features/advanced-features-postfilters.xml - docs/fr/programmers/advanced-features/advanced-features-prefilters.xml: - sync with EN - -2006-09-01 George Miroshnikov - - * docs/ru/programmers/api-functions/api-append-by-ref.xml - docs/ru/programmers/api-functions/api-append.xml - docs/ru/programmers/api-functions/api-assign-by-ref.xml - docs/ru/programmers/api-functions/api-assign.xml - docs/ru/programmers/api-functions/api-clear-all-assign.xml - docs/ru/programmers/api-functions/api-clear-all-cache.xml - docs/ru/programmers/api-functions/api-clear-assign.xml - docs/ru/programmers/api-functions/api-clear-cache.xml - docs/ru/programmers/api-functions/api-clear-compiled-tpl.xml - docs/ru/programmers/api-functions/api-clear-config.xml - docs/ru/programmers/api-functions/api-config-load.xml - docs/ru/programmers/api-functions/api-display.xml: - sync with EN - -2006-08-25 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed wrong handling of name attribute in {insert} - thanks to Ivan Kravets for reporting this - - * libs/Smarty_Compiler.class.php: - fixed typo - -2006-08-21 George Miroshnikov - - * docs/ru/designers/language-custom-functions/language-function-popup-init.xml - docs/ru/programmers/advanced-features/advanced-features-objects.xml - docs/ru/programmers/advanced-features/advanced-features-outputfilters.xml - docs/ru/programmers/advanced-features/advanced-features-postfilters.xml - docs/ru/programmers/advanced-features/advanced-features-prefilters.xml - docs/ru/programmers/advanced-features/section-template-cache-handler-func.xml - docs/ru/programmers/advanced-features/template-resources.xml: - sync with EN - - * docs/en/programmers/advanced-features/advanced-features-prefilters.xml: - another missing dot - - * docs/en/programmers/advanced-features/advanced-features-postfilters.xml: - missing dot - - * docs/en/programmers/advanced-features/advanced-features-outputfilters.xml: - missing comma - -2006-08-19 Peter 'Mash' Morgan - - * docs/en/designers/language-custom-functions/language-function-popup-init.xml: - avoid dupes and added remote paths - -2006-08-06 Yannick Torres - - * docs/fr/designers/language-custom-functions/language-function-html-table.xml - docs/fr/designers/language-custom-functions/language-function-mailto.xml: - sync with EN - -2006-08-03 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fix false replacement of "$t" inside double quotes - thanks to checat for reporting this - -2006-07-20 George Miroshnikov - - * docs/ru/designers/language-custom-functions/language-function-html-table.xml - docs/ru/designers/language-custom-functions/language-function-mailto.xml: - incrementing EN-Revision - - * docs/ru/designers/language-custom-functions/language-function-assign.xml - docs/ru/designers/language-custom-functions/language-function-eval.xml - docs/ru/designers/language-custom-functions/language-function-fetch.xml - docs/ru/designers/language-custom-functions/language-function-html-checkboxes.xml - docs/ru/designers/language-custom-functions/language-function-html-image.xml - docs/ru/designers/language-custom-functions/language-function-html-options.xml - docs/ru/designers/language-custom-functions/language-function-html-radios.xml - docs/ru/designers/language-custom-functions/language-function-html-table.xml - docs/ru/designers/language-custom-functions/language-function-mailto.xml - docs/ru/designers/language-custom-functions/language-function-popup-init.xml - docs/ru/designers/language-custom-functions/language-function-popup.xml - docs/ru/designers/language-modifiers/language-modifier-date-format.xml - docs/ru/designers/language-modifiers/language-modifier-default.xml - docs/ru/designers/language-modifiers/language-modifier-escape.xml - docs/ru/designers/language-modifiers/language-modifier-indent.xml - docs/ru/designers/language-modifiers/language-modifier-lower.xml - docs/ru/designers/language-modifiers/language-modifier-nl2br.xml - docs/ru/designers/language-modifiers/language-modifier-strip.xml - docs/ru/designers/language-modifiers/language-modifier-truncate.xml - docs/ru/designers/language-modifiers/language-modifier-upper.xml - docs/ru/designers/language-modifiers/language-modifier-wordwrap.xml - docs/ru/designers/language-variables/language-variables-smarty.xml: - sync with EN - - * docs/en/designers/language-custom-functions/language-function-mailto.xml: - typo - -2006-07-10 boots - - * libs/plugins/function.html_table.php: - fixed email address in comments - - * NEWS - libs/plugins/function.html_table.php: - html_table: fixed th/tr output, added hdir support for column - headings,update docs to reflect new features - -2006-07-08 Messju Mohr - - * libs/plugins/function.html_table.php: - fix occasional notices on undefined variables - -2006-07-08 boots - - * libs/plugins/function.html_table.php: - Added ability to specify column headings in {html_table} - - Added th_attrs attribute which works similary to td_attr and tr_attr but - for TH elements. Changes the cols attribute to allow mixed values; a - numeric still specifies the number of columns to render but now an array - of values can be used to specify TH column values. The number of columns - is determine from the size of the array. Further, a comma-separated - string of column names can be used which is internally coverted to an - array and used as if it was specified as a normal array. - - Thanks for lynlyn for the feature request. - -2006-06-23 boots - - * libs/plugins/outputfilter.trimwhitespace.php: - fix comments in outputfilter.trimwhitespace - - * NEWS - libs/plugins/outputfilter.trimwhitespace.php: - fixed ordering of replacements in trimwhitespace output filter - - Thanks to Getty from IRC for reporting this. - -2006-06-20 boots - - * NEWS - libs/plugins/function.mailto.php: - update mailto function plugin to work around a firefox/thunderbird escaping - bug - - Thanks to elijahlofgren from the forums for reporting this and providing - the necessary patch - - * NEWS - libs/plugins/modifier.date_format.php: - emulate %l in the date_format modifier on windows - - thanks to Gibberish from the forums for reporting this - -2006-06-14 boots - - * NEWS - libs/plugins/modifier.capitalize.php: - Fix handling of apostrophes in the capitalize modifier. - - Thanks to asmecher from the forums for reporting this and providing a - partial solution. - -2006-05-28 Monte Ohrt - - * NEWS - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update version numbers - -2006-05-25 boots - - * NEWS - libs/Smarty_Compiler.class.php: - un-hide hidden xml open tags - -2006-05-09 boots - - * NEWS - libs/Smarty_Compiler.class.php: - separate handling of comment blocks from "special blocks" - - * NEWS - libs/plugins/function.popup_init.php: - reverted {popup_init} as proposed change to insertion behviour was not BC - -2006-05-04 boots - - * NEWS - libs/plugins/function.popup_init.php: - changed {popup_init} to only emit code once during a request - - Thanks to TGKnIght from forums - -2006-04-22 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fix handling of block-methods of registered objects - thanks to El Hombre Gris - -2006-04-04 Monte Ohrt - - * libs/plugins/function.html_select_date.php: - fix typo - -2006-03-09 Monte Ohrt - - * (Smarty_2_6_13) - NEWS: - update for release - -2006-03-08 Monte Ohrt - - * libs/plugins/modifier.regex_replace.php: - remove delim quote - - * libs/plugins/modifier.regex_replace.php: - fix delimiter issue - -2006-03-03 Monte Ohrt - - * libs/plugins/modifier.regex_replace.php: - use preg_replace to cover any space chars - - * libs/plugins/modifier.regex_replace.php: - fix problem with allowing "e" modifier - -2006-01-29 Messju Mohr - - * libs/Smarty_Compiler.class.php: - removed possiblity for E_NOTICE on an undefined variable in - Smarty_Compiler::_compile_if_tag() - thanks to sbeh - -2006-01-18 Monte Ohrt - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update version numbers - - * (Smarty_2_6_12) - NEWS: - commit 2.6.12 release - -2006-01-15 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed use of references $cache_attrs and $repeat in Smarty_Compiler. - - php does not allow to pass an assigned by reference to a function. since - php-5.1.2 - the reference to the lval gets lost when passing an assignment. - -2005-12-31 Messju Mohr - - * NEWS - libs/Smarty.class.php: - fixed incompatible use of fread() in Smarty::_read_file() - it choke on php-5.1.1 and later. - thanks to andig for pointing this out. - -2005-12-21 boots - - * NEWS - libs/Smarty_Compiler.class.php: - Fix improper tokenization of certain inline math expressions. - - Thanks to gerard at forums for reporting this. - -2005-12-19 Messju Mohr - - * libs/plugins/function.math.php: - fixed problem with math in certain LC_NUMERIC locales. - thanks to wiebren for providing problem+solution. - -2005-12-14 Messju Mohr - - * NEWS: - fixed iso-latin1 special chars - -2005-12-14 Monte Ohrt - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update version numbers - - * (Smarty_2_6_11) - NEWS: - commit NEWS file for 2.6.11 - -2005-12-08 Messju Mohr - - * docs/de/getting-started.xml: - sync with en - -2005-11-29 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed code generation of non-cacheable blocks to play well with php's - "Alternative syntax" used for example in compiled {if}..{else}..{/if} - blocks. - - (see: http://php.net/manual/en/control-structures.alternative-syntax.php - on "Alternative syntax") - - thanks to kihara from the forum. - -2005-11-26 Messju Mohr - - * NEWS: - fixed handling of multiple identical calls to {insert}. - - the function was called multiple times, but all inserts where replaced - by the results of the first call to the insert function. - - * libs/plugins/compiler.assign.php - libs/plugins/function.config_load.php: - added credits - - * libs/plugins/function.popup.php: - added "closeclick" from - http://www.bosrup.com/web/overlib/?Command_Reference - -2005-11-23 boots - - * NEWS - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/plugins/modifier.escape.php: - replace {} string access with equivalent substr() to avoid E_STRICT - warnings in PHP 5.1 - -2005-11-09 boots - - * NEWS - libs/Smarty.class.php: - return valid reference in get_config_vars() when given var is non-existant - -2005-10-11 Monte Ohrt - - * libs/plugins/block.textformat.php - libs/plugins/compiler.assign.php - libs/plugins/function.assign_debug_info.php - libs/plugins/function.config_load.php - libs/plugins/function.counter.php - libs/plugins/function.eval.php - libs/plugins/function.fetch.php - libs/plugins/function.html_options.php - libs/plugins/function.html_select_date.php - libs/plugins/function.html_select_time.php - libs/plugins/function.math.php - libs/plugins/function.popup.php - libs/plugins/function.popup_init.php - libs/plugins/modifier.capitalize.php - libs/plugins/modifier.count_characters.php - libs/plugins/modifier.count_paragraphs.php - libs/plugins/modifier.count_sentences.php - libs/plugins/modifier.count_words.php - libs/plugins/modifier.date_format.php - libs/plugins/modifier.debug_print_var.php - libs/plugins/modifier.default.php - libs/plugins/modifier.escape.php - libs/plugins/modifier.indent.php - libs/plugins/modifier.lower.php - libs/plugins/modifier.regex_replace.php - libs/plugins/modifier.replace.php - libs/plugins/modifier.spacify.php - libs/plugins/modifier.string_format.php - libs/plugins/modifier.strip_tags.php - libs/plugins/modifier.truncate.php - libs/plugins/modifier.upper.php - libs/plugins/modifier.wordwrap.php - libs/plugins/shared.escape_special_chars.php - libs/plugins/shared.make_timestamp.php: - Added author title to plugins where they don't exist. I put my name where I - was the original or co-author. If there needs to be more credit given - somewhere, speak up! - -2005-10-10 Monte Ohrt - - * NEWS - libs/plugins/function.html_image.php: - add path_prefix to html_image, fix incorrect secure_dir error when image - file is missing - -2005-10-04 Monte Ohrt - - * demo/templates/index.tpl: - remove popup example, update section var syntax - -2005-09-16 Nuno Lopes - - * docs/de/getting-started.xml: - more fixes - - * docs/de/getting-started.xml: - fix php bug #34520: broken example display (de only) - -2005-08-30 Monte Ohrt - - * libs/plugins/modifier.escape.php: - change default charset from utf8 to iso-8859-1 - - * NEWS - libs/plugins/modifier.escape.php: - add char_set param - -2005-08-17 Monte Ohrt - - * NEWS: - fix notice in debug security check - - * libs/Smarty.class.php: - fix typo - - * NEWS - libs/Smarty.class.php: - return valid reference in get_template_vars() when given var is - non-existant - -2005-08-12 Monte Ohrt - - * NEWS - libs/plugins/modifier.escape.php: - add "urlpathinfo" escape type to escape modifier. (apache does not like %2F - in the PATH_INFO) - -2005-08-05 Monte Ohrt - - * NEWS - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update version numbers - -2005-08-04 Monte Ohrt - - * NEWS: - update secure_dir notes - - * NEWS: - allow debug.tpl to work from arbitrary dir - -2005-08-04 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed proper escaping for literal strings passed to - Smarty_Compiler::_expand_quoted_text() by - Smarty_Compiler::_parse_var_props() - -2005-07-27 Messju Mohr - - * NEWS - libs/plugins/shared.make_timestamp.php: - removed ambiguity for numeric values passed to smarty_make_timestamp(). - numeric values are *always* treated as timestamps now. - -2005-07-18 Messju Mohr - - * libs/Config_File.class.php: - removed E_NOTICE from Config_File::get() - - * libs/Smarty.class.php: - removed E_NOTICE - -2005-07-10 Yannick Torres - - * docs/fr/getting-started.xml: - sync with EN - -2005-07-08 Monte Ohrt - - * NEWS: - correct username in NEWS file - - * NEWS - libs/plugins/function.html_select_date.php: - added passthru attribute feature to html_select_date - -2005-07-03 Yannick Torres - - * docs/fr/language-snippets.ent - docs/fr/preface.xml: - sync with EN - -2005-06-16 Messju Mohr - - * docs/de/preface.xml - docs/de/preface.xml: - sync with en - -2005-06-13 Monte Ohrt - - * NEWS - libs/plugins/modifier.truncate.php: - add "middle" parameter to truncate modifier - -2005-06-10 Messju Mohr - - * docs/de/livedocs.ent: - added german livedocs.ent - - * docs/de/language-snippets.ent - docs/de/preface.xml: - sync with en - -2005-06-09 Messju Mohr - - * docs/de/bookinfo.xml - docs/de/getting-started.xml - docs/de/getting-started.xml: - sync with en - -2005-05-24 Yannick Torres - - * docs/fr/getting-started.xml - docs/fr/language-snippets.ent: - sync with EN - -2005-05-20 Monte Ohrt - - * libs/plugins/function.html_radios.php: - fix allowable label id characters - -2005-05-06 Monte Ohrt - - * NEWS - libs/plugins/function.html_radios.php: - make form input label ids optional (monte) - -2005-05-02 Monte Ohrt - - * NEWS - libs/Smarty_Compiler.class.php: - add error message for empty if/elseif statements - -2005-04-15 Monte Ohrt - - * NEWS - libs/plugins/function.html_radios.php: - cast selected value to string for comparison in html_radios - -2005-04-07 Messju Mohr - - * NEWS - libs/plugins/function.html_select_date.php: - added xhtml compliance to html_select_date's year_as_text-feature - thanks to Mark West - - * NEWS - libs/plugins/function.html_select_date.php: - fixed handling of selected month html_select_date - thanks to Yuri Weseman for providing problem+solution - -2005-04-07 Nuno Lopes - - * docs/configure.in: - sync configure and file-entities scripts with phpdoc, for better - windows/cygwin support - -2005-03-31 Monte Ohrt - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update version numbers - - * (Smarty_2_6_9) - NEWS: - update NEWS file - -2005-03-30 Messju Mohr - - * libs/plugins/function.math.php: - re-enabled hex-constant. i hope in a sane way this time. - -2005-03-30 Monte Ohrt - - * libs/plugins/function.math.php: - fix function testing logic - - * libs/Smarty_Compiler.class.php: - disable variable func calls completely - - * libs/Smarty_Compiler.class.php: - disallow variable func calls when security is enabled - -2005-03-22 Messju Mohr - - * NEWS - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - bumped version-number to 2.6.9-dev - added headline of 2.6.6 release to NEWS file - -2005-03-21 Messju Mohr - - * (Smarty_2_6_8) - NEWS: - maybe even better this way. thanks monte :) - - * NEWS: - little more clear news-entry - -2005-03-21 Monte Ohrt - - * NEWS: - update NEWS with e-modifier removal - - * (Smarty_2_6_8) - libs/plugins/modifier.regex_replace.php: - remove e-modifier - -2005-03-19 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - objects don't get casted to arrays anymore in {foreach} - -2005-02-26 Messju Mohr - - * NEWS - libs/Smarty.class.php: - add "null" as a valid token for {if} when security is enabled - -2005-02-25 Monte Ohrt - - * NEWS - libs/plugins/function.mailto.php: - add javascript_charcode option to mailto - -2005-02-24 Monte Ohrt - - * NEWS: - update NEWS file - - * QUICK_START - libs/plugins/function.html_radios.php: - add label ids to html_radios - -2005-02-10 Monte Ohrt - - * QUICK_START: - update with directory structure - -2005-02-10 Nuno Lopes - - * docs/Makefile.in: - fix chm generation - -2005-02-10 Messju Mohr - - * libs/Smarty_Compiler.class.php: - fixed too agressive {strip} around delimiters inside strip-blocks - -2005-02-10 Monte Ohrt - - * QUICK_START: - fix a couple errors - -2005-02-10 Nuno Lopes - - * docs/Makefile.in - docs/README: - commiting the new tools to make the CHM manual. - -2005-02-09 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed handling of strip-tags with non-default delimiters - -2005-02-04 Messju Mohr - - * libs/plugins/function.html_radios.php: - fixed syntax error. shame on me. - -2005-02-03 Monte Ohrt - - * QUICK_START: - fix example - - * QUICK_START: - initial commit - - * RELEASE_NOTES - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update version numbers in cvs - - * (Smarty_2_6_7) - NEWS - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - commit version numbers for new release - -2005-02-03 Messju Mohr - - * (Smarty_2_6_7) - libs/plugins/function.html_image.php: - fixed comment (thanks to CirTap) - -2005-02-01 Monte Ohrt - - * libs/plugins/function.html_image.php: - remove border tag - -2005-02-01 Messju Mohr - - * libs/Smarty.class.php: - fixed serialization of values containing newlines (like _cache_attrs) - in core_write_cache_file() - - bumped version to 2.6.6-dev-3 to indicate that the fileformat of cache - has changed - -2005-01-30 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed handling of hashed opening php-tags inside strip-blocks - (reported by titi_rafa) - -2005-01-30 Nuno Lopes - - * docs/fr/language-snippets.ent: - fix build - -2005-01-28 Messju Mohr - - * NEWS - libs/plugins/modifier.escape.php: - escape:url now uses the (RFC 1738 compliant) rawurlencode() - -2005-01-23 Messju Mohr - - * libs/Smarty.class.php: - replaced ? true : false and removed intermediate $_cookie_var in the - handling of the SMARTY_DEBUG-cookie - -2005-01-22 Yannick Torres - - * docs/fr/bookinfo.xml: - update EN-Revision tag - -2005-01-21 Monte Ohrt - - * README - RELEASE_NOTES - docs/de/bookinfo.xml - docs/fr/bookinfo.xml - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/plugins/function.cycle.php - libs/plugins/function.debug.php - libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_image.php - libs/plugins/function.html_radios.php - libs/plugins/function.html_table.php - libs/plugins/function.mailto.php - libs/plugins/modifier.cat.php - libs/plugins/modifier.nl2br.php - libs/plugins/modifier.strip.php - libs/plugins/outputfilter.trimwhitespace.php: - de-spammify e-mails - - * README - RELEASE_NOTES - docs/de/bookinfo.xml - docs/fr/bookinfo.xml - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/plugins/function.cycle.php - libs/plugins/function.debug.php - libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_image.php - libs/plugins/function.html_radios.php - libs/plugins/function.html_table.php - libs/plugins/function.mailto.php - libs/plugins/modifier.cat.php - libs/plugins/modifier.nl2br.php - libs/plugins/modifier.strip.php - libs/plugins/outputfilter.trimwhitespace.php: - update copyright notices, e-mail addresses - -2005-01-06 Messju Mohr - - * libs/Smarty_Compiler.class.php: - reduced the code that is generated on a {foreach}-block that has a - name. - - instead of pre-computing all foreach-properties (like first, last, - show) on each iteration, they are computed on demand as soon as - {$smarty.foreach.*}-variables are used. - - * NEWS - libs/Smarty_Compiler.class.php: - slight optimization in the compilation of $smarty.const.FOO . - - more complex consts like $smarty.const.$name still compile to - constant($this->_tpl_vars['name']) - -2005-01-05 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - make block functions and registered objects' block methods use a - local variable for block_content instead of $this->_block_content - - it's not necessary to have $smarty->_block_content accessible. - -2005-01-04 Yannick Torres - - * docs/fr/bookinfo.xml: - sync with EN - -2005-01-01 Messju Mohr - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - Happy new year from germany. - -2004-12-28 Monte Ohrt - - * libs/Smarty.class.php: - fix _read_file comments - -2004-12-26 Yannick Torres - - * docs/fr/getting-started.xml - docs/fr/preface.xml: - typo - - * docs/fr/language-defs.ent - docs/fr/language-snippets.ent - docs/fr/livedocs.ent: - sync with EN & typo - -2004-12-21 Yannick Torres - - * docs/fr/bookinfo.xml - docs/fr/getting-started.xml - docs/fr/translation.xml: - sync with EN - -2004-12-17 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed escaping of template-filenames in the generated code that loads - needed plugins - -2004-12-15 Monte Ohrt - - * NEWS - libs/plugins/function.popup.php: - fix invalid HTML issue with popup - -2004-12-06 boots - - * NEWS - libs/plugins/function.popup.php: - - fixed {popup} to properly handle inarray and function parameters and - added support for mouseoff and followmouse options - -2004-11-21 Mehdi Achour - - * docs/fr/livedocs.ent: - add livedocs specific entities files - -2004-11-16 Messju Mohr - - * libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_radios.php: - cleaned up typecasting - -2004-11-15 Messju Mohr - - * libs/plugins/function.html_options.php: - fixed semantically misleading check for $options (use isset() instead - of is_array() because it is always an array). - - thanks to albert almeida. - -2004-11-08 Messju Mohr - - * libs/Smarty_Compiler.class.php: - removed unused code - -2004-10-25 Mehdi Achour - - * docs/fr/bookinfo.xml - docs/fr/getting-started.xml: - sync with en - -2004-10-13 Monte Ohrt - - * NEWS: - update header - -2004-10-02 Messju Mohr - - * NEWS: - fixed nocache-handling with nested includes. there was a logical error - in the replacement of internal nocache-tags to dynamic content that - lead to false results with deeply nested includes or with - nocache-blocks inside nocache-blocks. - - many thanks to Lars Jankowfsky for providing big help on reproducing - and tracking down this bug! - -2004-10-01 Messju Mohr - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - - better header for compiled includes (more in line with compiled - templates) - - - reuse cache_serials if a file is compiled more than once in one - process (force_compile) - - - don't print nocache-delimiters wenn already inside - process_cached_inserts() - -2004-09-29 Messju Mohr - - * libs/Smarty.class.php: - switched from @count() to !empty() . this was pointed out a few times - by a few people with buggy error-handlers - - * libs/Smarty_Compiler.class.php: - added some property declarations - -2004-09-28 Messju Mohr - - * libs/Smarty.class.php: - bumped up version number to reflect incompatibility in tempfiles of - 'core' vs. 'internals' - -2004-09-24 Messju Mohr - - * libs/plugins/function.html_select_date.php: - fixed $start_year when no value for the year in $time is given. - -2004-09-21 Messju Mohr - - * libs/plugins/function.html_table.php: - fixed handling of "inner"-attribute - - * libs/Smarty_Compiler.class.php: - fixed handling of object derefence inside backticks - -2004-09-20 Monte Ohrt - - * libs/debug.tpl: - add tags - -2004-09-18 boots - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/plugins/function.config_load.php - libs/plugins/function.debug.php - libs/plugins/function.fetch.php - libs/plugins/function.html_image.php: - Fixed \\r\\n line endings mistakenly introduced in last commit. d'oh. - -2004-09-16 boots - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.assemble_plugin_filepath.php - libs/core/core.assign_smarty_interface.php - libs/core/core.create_dir_structure.php - libs/core/core.display_debug_console.php - libs/core/core.get_include_path.php - libs/core/core.get_microtime.php - libs/core/core.get_php_resource.php - libs/core/core.is_secure.php - libs/core/core.is_trusted.php - libs/core/core.load_plugins.php - libs/core/core.load_resource_plugin.php - libs/core/core.process_cached_inserts.php - libs/core/core.process_compiled_include.php - libs/core/core.read_cache_file.php - libs/core/core.rm_auto.php - libs/core/core.rmdir.php - libs/core/core.run_insert_handler.php - libs/core/core.smarty_include_php.php - libs/core/core.write_cache_file.php - libs/core/core.write_compiled_include.php - libs/core/core.write_compiled_resource.php - libs/core/core.write_file.php - libs/plugins/function.config_load.php - libs/plugins/function.debug.php - libs/plugins/function.fetch.php - libs/plugins/function.html_image.php: - Moved /libs/core to /libs/internals and created new constant, - SMARTY_CORE_DIR which defaults to SMARTY_DIR/internals. This should help - CVS and rsynch users butupgrades will require changes and this may affect - 3rd party plugins that use the /core dir. - -2004-09-15 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - moved $this->_num_const_regexp out of $this->_var_regexp and added it - to the places that affect $this->_var_regexp - - this should fix some problems parsing plugin-names endings with digits - -2004-09-14 Messju Mohr - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update files to 2.6.6-dev - -2004-09-13 Messju Mohr - - * NEWS: - fixed typo - -2004-09-13 Monte Ohrt - - * (Smarty_2_6_5) - NEWS: - update NEWS file with parsing correction note - -2004-09-11 Messju Mohr - - * libs/plugins/function.debug.php: - removed notice from {debug} - thanks to Peter Billen for pointing this one out! - -2004-09-11 Monte Ohrt - - * libs/Smarty_Compiler.class.php: - fix more object calling syntax issues - -2004-09-10 Messju Mohr - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - added $smarty->security_settings['ALLOW_CONSTANTS'] - including test-cases for them - -2004-09-09 Monte Ohrt - - * libs/Smarty_Compiler.class.php: - break down regex to digestable chunks, fix multiple param problem with - method calls, - add object method testing to unit_test cases - - * libs/Smarty_Compiler.class.php: - update code comment with more examples - - * libs/Smarty_Compiler.class.php: - allow objects in arbitrary param positions - - * libs/Smarty_Compiler.class.php: - fix object parameter regex, allow one level of object indirection - - * libs/Smarty_Compiler.class.php: - fix compile problem with numeric constants and math operator matching - -2004-09-07 Monte Ohrt - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update files to 2.6.5-dev - - * (Smarty_2_6_4) - NEWS: - update NEWS file with 2.6.4 header - -2004-08-31 Monte Ohrt - - * libs/Smarty_Compiler.class.php: - fix preg_quote - - * libs/Smarty_Compiler.class.php: - fix math in object params, clean up some regex on the way, change - preg_ delimiters to ~ to avoid character clashes with ! and % - -2004-08-30 Monte Ohrt - - * NEWS - libs/Smarty_Compiler.class.php: - add $smarty.ldelim and $smarty.rdelim to smarty special var - -2004-08-29 Messju Mohr - - * NEWS - libs/core/core.write_file.php: - tempnam() seems to be borken on many installation. - - now we try tempnam first and if that fails we generate our own - temp-filename with uniqid() - -2004-08-23 Monte Ohrt - - * libs/plugins/modifier.capitalize.php: - dont use constant, use static var instead - - * libs/plugins/modifier.capitalize.php: - implement optional param to capitalize for digit behavior - - * libs/plugins/modifier.capitalize.php: - another commit to capitalize, taking special chars into account - -2004-08-23 Messju Mohr - - * libs/Smarty_Compiler.class.php: - cleaned up attribute-handling in Smarty_Compiler::_compile_foreach_start() - -2004-08-23 Monte Ohrt - - * NEWS - libs/plugins/function.html_select_date.php - libs/plugins/modifier.capitalize.php: - fix capitalize modifier to not rely on buggy ucwords() func - -2004-08-20 Monte Ohrt - - * libs/plugins/function.html_select_date.php: - update version - - * NEWS - libs/plugins/function.html_select_date.php: - make time param work with negative timestamps, force year range to include - given date unless explicitly set - -2004-08-19 Monte Ohrt - - * NEWS - libs/plugins/function.fetch.php: - fix bug with fetch, passing user/pass in url did not work - -2004-08-13 Messju Mohr - - * libs/Smarty_Compiler.class.php: - fixed handling of {foreachelse} and {sectionelse} that got borked with - the latest commit (v 1.330) - -2004-08-12 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed occasional wrong error messages on mismatched tags when - {else}, {elseif}, {foreachelse} or {sectionelse} is involved - - thanks to Ooypunk for pointing me on this - -2004-08-12 Nuno Lopes - - * docs/.cvsignore - docs/Makefile.in - docs/configure.in: - enable russian PDF builds - -2004-07-30 Nuno Lopes - - * docs/configure.in: - typo - - * docs/Makefile.in - docs/README - docs/configure.in: - add make test_xml - this is usefull to detect XML problems - -2004-07-29 Nuno Lopes - - * docs/configure.in: - avoid warnings in head - - * docs/.cvsignore - docs/Makefile.in - docs/README - docs/configure.in: - build pdf files - just type make pdf - -2004-07-27 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed handling of methods arguments. - - thanks to Manfred Wischin for finding this one and providing the - conceptual fix. - -2004-07-23 Messju Mohr - - * libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_radios.php: - there was little flaw in smarty_function_html_radios() and - smarty_function_html_checkboxes(): - - the newly introduced assign-attribute was still added to the - tag-output as an extra-attribute. - - fixed. - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.load_plugins.php - libs/core/core.load_resource_plugin.php - libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_image.php - libs/plugins/function.html_options.php - libs/plugins/function.html_radios.php - libs/plugins/function.html_select_date.php - libs/plugins/function.html_select_time.php - libs/plugins/modifier.date_format.php: - backed out renaming of _get_plugin_filepath() to get_plugin_filepath() - - we'll stick to _get_plugin_filepath() and look for a more viable - solution to be exposed to plugin-writers. - -2004-07-20 Messju Mohr - - * libs/Smarty_Compiler.class.php - libs/core/core.is_trusted.php - libs/plugins/compiler.assign.php: - Some fixes on PhpDocumentor comments. Thanks go to Ruben Vermeersch. - -2004-07-16 andreas halter - - * docs/de/bookinfo.xml - docs/de/getting-started.xml - docs/de/language-defs.ent - docs/de/language-snippets.ent - docs/de/preface.xml: - - updated for 2.6.3 - - updates for new build system - - added missing files - - corrections from users - - revcheck comments for all files - - big up to didou and nuno, brilliant work - - make test: ok - - make: ok - -2004-07-16 Nuno Lopes - - * docs/de/getting-started.xml: - fix the revision tracking tag - the revision number might not be right. just check it, please - -2004-07-16 andreas halter - - * docs/de/getting-started.xml: - - updated version (incl revcheck comment) for revcheck testing - -2004-07-14 Monte Ohrt - - * libs/Smarty.class.php: - replace " with ' where literal strings are quoted (ever so slight speedup) - -2004-07-12 Messju Mohr - - * libs/plugins/modifier.date_format.php: - changed call from $smarty->_get_plugin_filepath() to - $smarty->get_plugin_filepath() - - * libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_image.php - libs/plugins/function.html_options.php - libs/plugins/function.html_radios.php - libs/plugins/function.html_select_date.php - libs/plugins/function.html_select_time.php: - renamed calls to $smarty->_get_plugin_filepath() to - $smarty->get_plugin_filepath() - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.load_plugins.php - libs/core/core.load_resource_plugin.php: - renamed Smarty::_get_plugin_filepath() to Smarty::get_plugin_filepath() - - * NEWS - libs/Smarty.class.php - libs/core/core.write_compiled_include.php - libs/core/core.write_compiled_resource.php - libs/core/core.write_file.php: - removed touch() call. changing the timestamp of the compiled-template - to the source template's may be irritating for certain - source-code-caches. now a newly compiled template gets the current - time as timestamp. - -2004-07-02 gerald croes - - * docs/fr/getting-started.xml - docs/fr/preface.xml: - Fixed missing tags to be able to make doc again - - * docs/fr/preface.xml: - added the "is a good thing [TM]" as in en docs - - * docs/fr/getting-started.xml: - added ctags, updated screen => programm listing. - added the technical note founded on the en doc - -2004-07-02 Monte Ohrt - - * NEWS - libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_radios.php - libs/plugins/function.mailto.php: - add assign attribute to html_checkboxes and html_radios - -2004-07-01 Messju Mohr - - * NEWS - libs/Smarty.class.php: - removed use of get_include_filepath() inside - get_auto_filename(). thanks go to c960657 - - * NEWS - libs/Smarty_Compiler.class.php: - enhanced error-reporting for {foreach} - - * NEWS - libs/Smarty_Compiler.class.php: - fixed handling of digits inside tagnames. this problem slipped into - the regexps by adding support for numeric contants next to string - constants as variables. - -2004-06-27 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed escaping of backslashes in Smarty_Compiler::_quote_replace() - -2004-06-23 Monte Ohrt - - * libs/plugins/modifier.date_format.php: - display date_format %e, %T and %D as expected for windows - -2004-06-17 Messju Mohr - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - changed version-number to 2.6.4-dev - -2004-06-16 Monte Ohrt - - * (Smarty_2_6_3) - NEWS: - update NEWS file with version number - -2004-06-09 Monte Ohrt - - * NEWS - libs/plugins/modifier.escape.php: - added escapement of ' - - * docs/fr/translation.xml: - Add other translators. - -2004-06-08 Messju Mohr - - * libs/Smarty.class.php: - made the correct value of "use_sub_dirs" available to the compiler. - (not worth a NEWS-entry, i think) - -2004-06-01 Messju Mohr - - * libs/plugins/function.fetch.php: - fix: proper initialistaion of $content. - thanks to Dmitry Koteroff for pointing this out. - -2004-05-29 Mehdi Achour - - * docs/fr/translation.xml: - oups :) - - * docs/fr/translation.xml: - added translation file - -2004-05-28 Nuno Lopes - - * docs/Makefile.in: - clean also file-entities.php - -2004-05-28 Messju Mohr - - * NEWS - libs/plugins/function.mailto.php: - added obfuscation of protocol-string in {mailto} when using - hex-encoding (thanks to bharat) - -2004-05-26 Messju Mohr - - * NEWS - libs/Smarty.class.php: - enhanced auto-generated filenames for templates_c and cache - - incremented Smarty::_version because the tempfiles' structure changed - a little - -2004-05-23 Mehdi Achour - - * docs/fr/bookinfo.xml - docs/fr/getting-started.xml - docs/fr/preface.xml: - WS and added revcheck - -2004-05-21 Messju Mohr - - * libs/Smarty_Compiler.class.php: - fixed typo in error-messages - - * docs/de/language-snippets.ent - docs/fr/language-snippets.ent: - added empty language-snippets.ent to fix "make web" - -2004-05-12 Monte Ohrt - - * NEWS - libs/plugins/modifier.escape.php: - add 'nonstd' escape modifier - -2004-05-07 Monte Ohrt - - * NEWS - libs/plugins/block.textformat.php: - update textformat to not output wrap chars after last para - -2004-05-06 Messju Mohr - - * NEWS - libs/core/core.write_file.php: - use tempnam() instead of unqid() to create better temporary files in - smarty_core_write_file(). - - (thanks to xces for finding this race-condition and his work on - fixing it) - -2004-05-04 Messju Mohr - - * libs/Smarty.class.php: - added check if for file_exists() to Smarty::_read_file() - -2004-04-30 Monte Ohrt - - * NEWS - libs/plugins/modifier.escape.php: - add 'mail' attribute to escape modifier - -2004-04-20 Mehdi Achour - - * docs/manual.xml.in: - added the language-snippets.ent file and started using entities for notes - under en/programmers/api-functions - -2004-04-18 Mehdi Achour - - * docs/de/getting-started.xml - docs/fr/getting-started.xml: - new global entity for zend and php-accelerator - - * docs/fr/bookinfo.xml - docs/fr/getting-started.xml - docs/fr/preface.xml: - added myself as translator and added vim comments and xml tags - -2004-04-16 Messju Mohr - - * NEWS: - added entry for numeric constants - - * libs/Smarty_Compiler.class.php: - removed unused 2nd param in call to _parse_var() - - * libs/Smarty_Compiler.class.php: - added explanation for $this->_num_const_regexp - - * NEWS - libs/plugins/modifier.escape.php: - added escape type "decentity" to smarty_modifier_escape() - - * libs/Smarty_Compiler.class.php: - enabled numerical constants be parsed as statements. - (like {10} or {10|@range:12} ) - - * libs/Smarty_Compiler.class.php: - removed unused $smarty_compiler->_dvar_num_var_regexp - - * libs/Smarty.class.php: - reverted Stuff - - * libs/debug.tpl - libs/core/core.assemble_plugin_filepath.php - libs/core/core.read_cache_file.php - libs/core/core.write_file.php - libs/plugins/function.eval.php - libs/plugins/function.popup.php - libs/plugins/modifier.escape.php - libs/plugins/shared.make_timestamp.php: - reverted stuff - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/debug.tpl - libs/core/core.assemble_plugin_filepath.php - libs/core/core.read_cache_file.php - libs/core/core.write_file.php - libs/plugins/function.eval.php - libs/plugins/function.popup.php - libs/plugins/modifier.escape.php - libs/plugins/shared.make_timestamp.php: - Smarty_Compiler.class.php - -2004-04-15 Messju Mohr - - * NEWS - libs/core/core.write_compiled_include.php: - made smarty_core_write_compiled_include() php5-aware - - if someone knows a better way than patching the source with the - tokenizer, please stand up! - -2004-04-14 Nuno Lopes - - * docs/Makefile.in: - remove file-entities.ent also - - * docs/.cvsignore - docs/Makefile.in - docs/README: - allow make revcheck - -2004-04-13 Nuno Lopes - - * docs/configure.in: - do not need inipath - -2004-04-13 Mehdi Achour - - * docs/TODO: - done - - * docs/configure.in - docs/manual.xml.in: - now the files entites are generated dynamically - -2004-04-12 Messju Mohr - - * NEWS - libs/Config_File.class.php - libs/Smarty.class.php: - removed unused functionality to load a subset of lines from a file in - Smarty::_read_file() - - additionally removed a warning that is emitted since php-4.3.5 when - fread() is called on an empty file (with filesize()==0). thanks to - Andreas Streichardt who pointed this out. - - * NEWS - libs/core/core.is_secure.php: - smarty_core_is_secure() only checks the file for readability now, not - the directory where is in. - - * libs/Smarty.class.php: - removed unused security_setting 'ALLOW_CONSTANTS' - -2004-04-07 Messju Mohr - - * libs/plugins/function.assign_debug_info.php - libs/plugins/function.cycle.php - libs/plugins/function.mailto.php: - removed trailing spaces - - * libs/Smarty.class.php: - removed unused $smarty->_error_msg - -2004-04-04 Nuno Lopes - - * docs/configure.in: - fixing my crap - put build_date back on-line - -2004-04-03 Nuno Lopes - - * docs/Makefile.in - docs/configure.in - docs/manual.xml.in: - trying to fix ru problems - -2004-03-30 Monte Ohrt - - * libs/core/core.display_debug_console.php: - fix problem with debug_tpl path and security - - * NEWS - libs/core/core.display_debug_console.php: - fix problem displaying debug console when $default_resource_type is not - "file:" - -2004-03-29 Mehdi Achour - - * docs/TODO: - and finally, add a TODO here - - * docs/de/bookinfo.xml - docs/de/manual.sgml - docs/fr/bookinfo.xml - docs/fr/manual.xml: - translate bookinfo.xml and put back the translators - -2004-03-28 Mehdi Achour - - * docs/manual.xml.in: - add global.ent and define some general entities - - * docs/de/bookinfo.xml - docs/de/getting-started.xml - docs/de/language-defs.ent - docs/de/preface.xml: - add new de files - - * docs/de/appendixes.sgml - docs/de/designers.sgml - docs/de/getting-started.sgml - docs/de/html-common.dsl - docs/de/preface.sgml - docs/de/programmers.sgml: - drop old de files - - * docs/fr/bookinfo.xml - docs/fr/getting-started.xml - docs/fr/manual.xml - docs/fr/preface.xml: - add ommited files - - * docs/fr/language-defs.ent: - split the french dir - - * docs/fr/appendixes.sgml - docs/fr/designers.sgml - docs/fr/getting-started.sgml - docs/fr/html-common.dsl - docs/fr/manual.sgml - docs/fr/preface.sgml - docs/fr/programmers.sgml: - drop old french files - - * docs/manual.xml.in: - let's put the new build system - -2004-03-26 Mehdi Achour - - * docs/de/common.dsl - docs/de/html.dsl - docs/fr/common.dsl - docs/fr/html.dsl - docs/fr/php.dsl: - not needed anymore - -2004-03-24 Nuno Lopes - - * docs/Makefile.in: - updated stylesheets - highlight PHP automatically - - * docs/Makefile.in - docs/html.dsl: - remove unneeded file - -2004-03-23 Nuno Lopes - - * docs/version.ent.in: - remove this also - - * docs/getting-started.sgml: - remove this one too - - * docs/appendixes.sgml - docs/common.dsl - docs/designers.sgml - docs/html-common.dsl - docs/manual.sgml - docs/php.dsl - docs/preface.sgml - docs/programmers.sgml: - removing uneeded files - - * docs/.cvsignore: - commiting missing files for docbook - - * docs/.cvsignore - docs/Makefile.in - docs/configure.in - docs/manual.xml.in: - bundling docbook 4 - now make and make web works - -2004-03-23 Messju Mohr - - * NEWS - libs/plugins/function.config_load.php: - unrolled call to the is_compiled()-check to be able to supply the - correct resource_base_path for config_load. this avoids errors when - config-files are accessed where security is enabled. - - thanks to shuther for pointing out this bug. - -2004-03-20 Nuno Lopes - - * docs/manual.xml.in: - fix build date - -2004-03-18 Messju Mohr - - * libs/core/core.is_secure.php: - removed merging of $smarty->template_dir into $smarty->secure_dir - - the resource_base_path is considerd secure instead. this change should - have absolutely no impact on smarty's security's behaviour - -2004-03-18 Nuno Lopes - - * docs/configure.in: - correcting non-existent var - - * docs/.cvsignore - docs/Makefile.in - docs/configure.in - docs/manual.xml.in - docs/version.ent.in: - generate build date - - * docs/.cvsignore - docs/Makefile.in - docs/README - docs/configure.in - docs/manual.xml.in: - new build/test system - -2004-03-18 Messju Mohr - - * libs/Smarty.class.php: - moved setting of a default resource_base_path from - Smarty::_parse_resource_name() to Smarty::_fetch_resource_info() - - this shouldn't affect anything, since all calls to - _parse_resource_name() that are not done from within - _fetch_resource_info() all pass their own resource_base_path - -2004-03-17 Messju Mohr - - * NEWS - libs/Smarty.class.php: - removed '.' from the list of default resource_base_paths in - _parse_resource_name() - - this should only affect _parse_resource_name() for templates, not for - php-resources and not for config_files. the latter pass two their own - resource_base_path. - -2004-03-16 Mehdi Achour - - * docs/appendixes.sgml - docs/getting-started.sgml - docs/preface.sgml: - adding editor comments - - * docs/appendixes.sgml - docs/getting-started.sgml: - cleaning words spacing, killing tabulations, using roles for - programlisting.. - -2004-03-15 Messju Mohr - - * libs/Smarty.class.php: - simplified Smarty::clear_all_cache(); - -2004-03-12 boots - - * docs/programmers.sgml: - Updated is_cached prototype to indicate proper return type. (thanks to - Geoffrey Hoffman) - -2004-03-11 Messju Mohr - - * libs/core/core.assemble_plugin_filepath.php: - fixed little bug that prevented plugins filepaths that are found in - php's include_path (and not in one of the plugins_dirs) from being - cached in the internal plugins-filepath-cache - -2004-03-01 Monte Ohrt - - * docs/designers.sgml: - update include_php docs:wq - :q - - * docs/appendixes.sgml: - update componentized template example to something useful - -2004-02-24 Messju Mohr - - * NEWS - libs/Smarty.class.php: - _parse_resource_name() returned true on non-existant absolute - paths. This caused a warning on _fetch_resource_info() when used in - conjunction with template_exists(). It should be fixed now without - negative effects. - -2004-02-24 Monte Ohrt - - * docs/designers.sgml: - one more typo - - * docs/designers.sgml: - fix typo - -2004-02-24 Messju Mohr - - * NEWS - libs/core/core.is_secure.php: - smarty_resource_*_secure got &$smarty passed errornously as 3rd - parameter and not as 2nd. this is fixed. - -2004-02-23 Messju Mohr - - * NEWS: - fix handling of integer values like width and delay im - smarty_function_popup() - - * libs/plugins/function.popup.php: - fixed handling of integer-attributes - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - updated version to 2.6.3-dev - -2004-02-22 Messju Mohr - - * libs/plugins/function.html_select_date.php: - removed notice on html_select_date with the month_empty-attribute - - * libs/plugins/function.mailto.php: - removed 2 notices of undefined vars (thanks Cit) - -2004-02-17 Monte Ohrt - - * NEWS: - add header - - * (Smarty_2_6_2) - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - change some info in headers, remove fluff - -2004-02-13 Messju Mohr - - * NEWS - libs/plugins/function.html_select_date.php: - correctly handle partially empty dates (like "2004--" or "-12-"). - - * docs/programmers.sgml: - learned something about and sgml and applied this to the - use.sub.dirs-section :) - - * docs/designers.sgml: - changed attribute-name "checked" to "selected" in the docs for - html_radios and html_checkboxes. "checked" is deprecated for ages - AFAIK and selected is recommended for consistency with {html_options} - - * docs/programmers.sgml: - added note about use_sub_dirs and Smarty-2.6.2 . - fixed markup for section about clear_compiled_tpl() . - -2004-02-12 Messju Mohr - - * NEWS - libs/Config_File.class.php: - YES and NO should not be booleanized inside triple-quotes in a - config-file. this behaviour changed by accident in 2.6.1 and is now - reverted to pre-2.6.1 behaviour - -2004-02-10 Messju Mohr - - * NEWS - libs/Config_File.class.php: - fixed slurping of a the next line following a triple-quoted value in a - config-file - -2004-02-07 Messju Mohr - - * libs/Config_File.class.php: - avoid @-operator for handling empty lines in Config_File.class.php - - * libs/Smarty_Compiler.class.php: - removed two notices from Smarty_Compiler::_parse_is_expr() - (thanks shuther!) - - * NEWS - libs/Smarty.class.php: - changed default for use_sub_dirs to false - - * libs/plugins/function.mailto.php: - removed notice of undefined variable. (thanks shuther!) - -2004-01-29 Messju Mohr - - * libs/Smarty_Compiler.class.php: - added file and line-number-information to error-messages regarding - assigned objects an an error messages regarding modifiers with - security. - -2004-01-27 Messju Mohr - - * libs/Smarty_Compiler.class.php: - removed use of temporary var $_params in compiled code of block-plugins - - * NEWS - libs/plugins/function.popup.php: - fixed quoting of values in smarty_function_popup() - -2004-01-25 Messju Mohr - - * docs/programmers.sgml: - documented parameters of Smarty::clear_compiled_tpl() - - * libs/Smarty_Compiler.class.php: - Smarty_Compiler::_syntax_error() uses Smarty::_trigger_fatal_error() now - instead of the trigger_error()-function - - * libs/Smarty.class.php: - Smarty::_trigger_fatal_error() uses Smarty::trigger_error() now, - instead of the native trigger_error()-function - - * libs/Smarty_Compiler.class.php: - unrecognized custom-functions trigger an error at compile now, not at - display-time. - -2004-01-23 Monte Ohrt - - * docs/getting-started.sgml: - reword a paragraph - -2004-01-22 Messju Mohr - - * libs/plugins/function.config_load.php: - removed emission of unnecessary notices for unavailable config-files - in config_load() - - * NEWS - libs/Config_File.class.php: - fixed handling of hidden sections in Config_File - -2004-01-21 Messju Mohr - - * NEWS - libs/plugins/function.config_load.php: - added handling of resources for {config_load} - -2004-01-19 Messju Mohr - - * NEWS - libs/plugins/function.html_table.php: - fixed bug when using arrays with tr_attr and td_attr in {html_table} - -2004-01-16 Monte Ohrt - - * NEWS: - add unit testing - - * NEWS - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update version numbers, add initial unit test directory - - * (Smarty_2_6_1) - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update version numbers for 2.6.1 release - -2004-01-16 Messju Mohr - - * (Smarty_2_6_1) - NEWS - docs/programmers.sgml - libs/Smarty.class.php: - renamed $smarty->tpl_rror_reporting to $smarty->error_reporting - "tpl_" is a bit redundant here (it's a TemPLate-engine overall :) - -2004-01-15 Messju Mohr - - * libs/plugins/function.html_image.php: - forgot to remove duplicate is_secure()-check - - * NEWS - libs/plugins/function.html_image.php: - fix: $smarty->security is now correctly handled - - minor optimizations: - core/core.is_secure.php is only included when needed - $dpi_default is only determined when needed - -2004-01-14 Messju Mohr - - * docs/appendixes.sgml - docs/programmers.sgml: - removed suggestions to use extract() from the manual - - * docs/designers.sgml: - fixed typo - -2004-01-12 Messju Mohr - - * docs/designers.sgml: - mention SCRIPT_NAME below {$smarty} reserved variable because it got - lost in the docs for $smarty->global_assign - - * docs/designers.sgml: - added docs for {$smarty.version} special variable - - * docs/programmers.sgml: - removed docs for $global_assign - - * docs/programmers.sgml: - added docs for tpl_error_reporting - - * docs/designers.sgml: - added docs for year_empty-, month_empty- and day_emtpy-attributes of - html_select_date. maybe an example is needed to better explain empty - values in YYY-MM-DD. - -2004-01-10 Messju Mohr - - * libs/Smarty_Compiler.class.php: - fixed handling of {php}-tags - -2004-01-10 Monte Ohrt - - * docs/designers.sgml: - fix html_checkboxes examples - -2004-01-08 Messju Mohr - - * NEWS - libs/core/core.assemble_plugin_filepath.php: - added caching of requested paths to smarty_core_assemble_plugin_filepath() - - * NEWS: - fix handling of comments inside {php}- and {literal}-blocks - - * libs/Smarty_Compiler.class.php: - fixed handling of comments inside {php} and {literal} - -2004-01-06 Messju Mohr - - * NEWS - libs/Config_File.class.php: - fixed bug handling triple-quotes in config-files - - * libs/Config_File.class.php: - fixed bugs with triple-quotes in config-files - thanks BRDude for finding them testing! - -2004-01-02 Messju Mohr - - * libs/Smarty.class.php: - removed unnecessary param in call to _fetch_resource_info() - -2003-12-30 Messju Mohr - - * libs/Smarty.class.php: - oops! removed tabs. - -2003-12-27 Messju Mohr - - * NEWS - libs/Smarty.class.php: - made $SCRIPT_NAME available again - changes default for request_use_auto_global to prefer autoglobals - - * libs/Smarty.class.php: - removed tabs and trailing spaces - - * NEWS - libs/Smarty_Compiler.class.php: - readded default_modifiers. who removed that? - -2003-12-23 Monte Ohrt - - * NEWS: - add portuguese docs - -2003-12-22 Monte Ohrt - - * docs/designers.sgml: - fix counter example - -2003-12-19 Monte Ohrt - - * libs/Smarty.class.php: - add debug console persistance feature - -2003-12-19 Messju Mohr - - * libs/plugins/block.textformat.php - libs/plugins/function.html_table.php - libs/plugins/function.popup.php: - removed extract(). enhanced parameter parsing. - - * libs/plugins/function.counter.php - libs/plugins/function.fetch.php - libs/plugins/function.popup_init.php - libs/plugins/modifier.capitalize.php - libs/plugins/modifier.cat.php - libs/plugins/modifier.date_format.php - libs/plugins/modifier.debug_print_var.php - libs/plugins/modifier.escape.php - libs/plugins/modifier.indent.php - libs/plugins/modifier.lower.php - libs/plugins/modifier.nl2br.php - libs/plugins/modifier.strip.php - libs/plugins/modifier.upper.php - libs/plugins/modifier.wordwrap.php - libs/plugins/outputfilter.trimwhitespace.php - libs/plugins/shared.escape_special_chars.php: - removed tabs. fixed indentiation. - - * libs/plugins/modifier.truncate.php: - removed tabs - - * libs/plugins/function.counter.php - libs/plugins/function.cycle.php: - removed extract() from parameter-parsing - -2003-12-17 Messju Mohr - - * libs/plugins/function.html_select_date.php: - fix plugin-name in error message - - * libs/plugins/function.html_select_time.php: - remove extract-call from {html_select_time} - - * NEWS - libs/plugins/function.html_select_date.php: - allow single-digit days and months without smarty_make_timestamp() - this makes dates like "1968-11-6" work correctly since no strtotime() - is involved - - add warning when unknown parameter is passed - -2003-12-16 Messju Mohr - - * NEWS - libs/Smarty.class.php: - fix headers sent erroneously with cache_modified_check and fetch() - -2003-12-12 Monte Ohrt - - * libs/plugins/function.config_load.php: - move set_path() call below the conditional bracket - - * NEWS - libs/plugins/function.config_load.php: - fix config_load filepath bug - -2003-12-12 boots - - * docs/designers.sgml: - Updated language.function.if with additional annotation and to fix error - that broke docs build process - -2003-12-11 Messju Mohr - - * libs/Smarty_Compiler.class.php: - little optimization for "is odd" and "is even" - -2003-12-11 Monte Ohrt - - * NEWS - libs/Smarty_Compiler.class.php: - fix 'is even by' and 'is odd by' logic - -2003-12-11 Messju Mohr - - * docs/designers.sgml: - update example-output of {mailto} - - * libs/plugins/function.mailto.php: - removed extract-call -> cleaner parameter-handling - - * libs/plugins/function.mailto.php: - fixed indentiation - - * TODO: - removed two done topics - -2003-12-11 boots - - * docs/designers.sgml: - Updated language.function.if to describe qualifiers (thanks andre) - -2003-12-10 Messju Mohr - - * NEWS - libs/plugins/function.html_select_date.php: - added day_empty, month_empty, year_empty and all_empty attributes - to pass an undefined date use {html_select_date time="--" ...} - - * libs/plugins/function.html_select_date.php: - removed extract()-call - - * libs/plugins/function.html_select_date.php: - fixed indetiation - -2003-12-10 boots - - * NEWS - docs/designers.sgml: - Added table to language.function.if to describe qualifiers - -2003-12-09 Messju Mohr - - * libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_options.php: - strict comparason didn't work in all cases. use type-casting now. - - * NEWS - libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_options.php: - fix bug when comparing array-keys to "selected" in html_options and - html_checkboxes - - in_array() uses "strict" comparason now. - - * libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_options.php - libs/plugins/function.html_radios.php: - removed tabs, fixed indentiation - -2003-12-08 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - add better checks for correctly nested tags when compiling - -2003-12-04 Messju Mohr - - * libs/Smarty.class.php - libs/plugins/function.html_image.php: - fix: check $smarty->request_use_auto_globals at the last occurences of - HTTP_*_VARS - -2003-12-03 Messju Mohr - - * NEWS - libs/Smarty.class.php: - remove $global_assign property from Smarty and $global_assign-handling - from the constructor. the only visible change is, that $SCRIPT_NAME is - not available in the tempates anymore. $smarty.server.SCRIPT_NAME has - to be used from now. - -2003-12-03 boots - - * docs/designers.sgml: - Fixed example for count_characters - -2003-12-01 boots - - * docs/designers.sgml: - Added section "Escaping Smarty Parsing" under Basic Syntax. - -2003-12-01 Messju Mohr - - * libs/core/core.create_dir_structure.php: - thought again about my latest commit and backed it out. - - * libs/core/core.create_dir_structure.php: - fix root-dir-handling on windows filepath - -2003-11-29 boots - - * libs/plugins/function.config_load.php: - really make the fixes the last patch was supposed to do - - * libs/plugins/function.config_load.php: - removed tabs and killed trailing white-space - - * libs/plugins/function.config_load.php: - changed $smarty->_syntax_error to $smarty->trigger_error - -2003-11-27 Messju Mohr - - * NEWS - libs/plugins/modifier.debug_print_var.php: - remove warning in debug_print_var on php-resources - - * README: - fix version number - -2003-11-26 Messju Mohr - - * libs/Smarty_Compiler.class.php: - raise max_level for $smarty.config... to 3 to allow arrays of config-vars - -2003-11-25 Messju Mohr - - * libs/Smarty.class.php: - changed version-tag to indicate incompatibility to older compiled - templates - -2003-11-24 Messju Mohr - - * NEWS - libs/plugins/compiler.assign.php - libs/plugins/function.assign.php: - move function.assign.php to compiler.assign.php - - * libs/core/core.get_include_path.php: - silence occasional warnings of open_basedir- and - safe_mode-restrictions in core.get_include_path.php - -2003-11-23 Messju Mohr - - * libs/core/core.write_compiled_resource.php - libs/core/core.write_file.php: - avoid touch()-ing of recently unlinked files by touch()-ing the - tempfile before rename instead of touch()-ing the resulting file after - rename. - - * NEWS - libs/Smarty.class.php: - add property $tpl_error_reporting - -2003-11-22 Messju Mohr - - * libs/plugins/function.assign.php: - remove use of extract() in smarty_function_assign() - - * NEWS - libs/Smarty.class.php: - remove property $undefined. "null" is used literally instead - -2003-11-21 Messju Mohr - - * libs/Smarty_Compiler.class.php: - remove two E_NOTICES - -2003-11-20 Messju Mohr - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - change version to 2.6.1-dev - -2003-11-19 Monte Ohrt - - * (Smarty_2_6_0) - NEWS: - update NEWS file - - * (Smarty_2_6_0) - docs/designers.sgml - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - change version numbers to 2.6.0 - -2003-11-19 Messju Mohr - - * docs/designers.sgml - docs/de/designers.sgml - docs/fr/designers.sgml: - fix examples of escape-modifier (in docs, docs/de and docs/fr !) - -2003-11-18 Messju Mohr - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - move Smarty::quote_replace() to Smarty_Compiler::_quote_replace() - - * libs/Smarty.class.php: - removed extract-calls from _include()- and _eval()-wrappers - variables passed with {include_php} have to accessed as members of $params - now - -2003-11-17 Messju Mohr - - * docs/designers.sgml: - fixed typo - -2003-11-13 Messju Mohr - - * libs/Config_File.class.php: - fix occasional notice - -2003-11-13 andreas halter - - * docs/de/designers.sgml: - - added cat modifier, thanks messju :-) - -2003-11-13 Monte Ohrt - - * (Smarty_2_6_0-RC3) - NEWS - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - commit RC3 tags - -2003-11-13 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fix handling of $var.key inside [] - - * libs/Smarty.class.php: - fix unnecessary loading of core.load_resource_plugin.php - - * (Smarty_2_6_0-RC3) - docs/fr/designers.sgml: - fixed example of html_table - -2003-11-11 Messju Mohr - - * NEWS - libs/core/core.process_cached_inserts.php: - fix handling of assign inside {insert}-tags - -2003-11-06 Messju Mohr - - * libs/core/core.read_cache_file.php: - added $exp_time-parameter - - * docs/programmers.sgml: - added $exp_time to cache_handler_func-example - - * libs/Smarty.class.php - libs/core/core.write_cache_file.php: - added $exp_time-parameter of clear_cache() and clear_all_cache() to - cache_handler_func. - -2003-11-05 Messju Mohr - - * NEWS - libs/Config_File.class.php: - fix handling if [...] inside triple-quotes in config-files - -2003-11-04 Messju Mohr - - * libs/Smarty.class.php: - fixed little bug in _parse_resource_name() (jlgunter, messju) - -2003-11-03 andreas halter - - * docs/designers.sgml - docs/de/designers.sgml - docs/fr/designers.sgml: - - changed Smarty.php.class occurences to Smarty.class.php - -2003-10-29 boots - - * docs/appendixes.sgml - docs/designers.sgml - docs/manual.sgml - docs/programmers.sgml - docs/de/appendixes.sgml - docs/de/designers.sgml - docs/de/programmers.sgml - docs/fr/appendixes.sgml - docs/fr/designers.sgml - docs/fr/getting-started.sgml - docs/fr/manual.sgml - docs/fr/preface.sgml - docs/fr/programmers.sgml: - Fixes to documentation syntax so that all content can be processed used - xsltproc docbook-xsl tools. In particular, fixes unescaped entities, - broken tags, unquoted attributes. - -2003-10-27 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fix handling of simple-math-operators inside modifiers - -2003-10-25 Messju Mohr - - * libs/Smarty_Compiler.class.php: - removed unused property _output_type - removed unused param $tag_attrs of _parse_var_props() - cleaned up alignment of class-properties - -2003-10-23 Messju Mohr - - * libs/Smarty_Compiler.class.php: - removed notice in php-tag handling in Smarty_Compiler::_compile_file() - - * libs/Smarty_Compiler.class.php: - removed two occasional E_NOTICES from - Smarty_Compiler::_compile_include_php_tag() - - * NEWS - libs/core/core.create_dir_structure.php: - fix handling of trailing-slashes in open_basedir in - smarty_core_create_dir_structure() - -2003-10-20 Messju Mohr - - * libs/Smarty_Compiler.class.php: - elements inside `` are bracketed now inside the compiled-tpl. this - fixes some issues with simple-math inside backticks. - -2003-10-16 Monte Ohrt - - * docs/designers.sgml: - update overlib docs, no working examples - -2003-10-12 Messju Mohr - - * libs/Smarty.class.php - libs/core/core.is_secure.php: - move check for template_dir in secure_dir-array into core.is_secure.php - - this makes template_exists() work correctly with security=true even if - template_dir is not inside the secure_dir-array - -2003-10-11 Messju Mohr - - * libs/plugins/shared.make_timestamp.php: - tightened check for YYYYMMDDHHMMSS-format. thanks konstantin for - pointing this out. - - removed a few tabs. - - * libs/Smarty_Compiler.class.php: - fix precedence of simple-math-operators before modifiers. - thanks dominik! - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.assemble_plugin_filepath.php - libs/core/core.assign_smarty_interface.php - libs/core/core.create_dir_structure.php - libs/core/core.display_debug_console.php - libs/core/core.get_include_path.php - libs/core/core.get_microtime.php - libs/core/core.get_php_resource.php - libs/core/core.is_secure.php - libs/core/core.is_trusted.php - libs/core/core.load_plugins.php - libs/core/core.load_resource_plugin.php - libs/core/core.process_cached_inserts.php - libs/core/core.process_compiled_include.php - libs/core/core.read_cache_file.php - libs/core/core.rm_auto.php - libs/core/core.rmdir.php - libs/core/core.run_insert_handler.php - libs/core/core.smarty_include_php.php - libs/core/core.write_compiled_include.php - libs/core/core.write_compiled_resource.php - libs/core/core.write_file.php: - removed tabs from the main and the core/*.php files - -2003-10-08 Monte Ohrt - - * (Smarty_2_6_0-RC2) - NEWS - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - update version numbers to RC2 - -2003-09-18 Messju Mohr - - * docs/designers.sgml - docs/de/designers.sgml: - fixed description of cycle's advance-attribute - -2003-09-16 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - apply modifiers only once to section-loop and foreach-from attributes - -2003-09-15 Messju Mohr - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.write_cache_paths_file.php: - backed out _smarty_cached_paths-file-handling - - * libs/Smarty.class.php - libs/core/core.rm_auto.php: - fixed clear_compiled_tpl with explicit $tpl_file given - fixed return value of smarty_core_rm_auto() + Smarty::_unlink() - - * libs/Smarty.class.php: - little fix in _get_auto_filename() - -2003-09-14 Messju Mohr - - * libs/Smarty.class.php - libs/core/core.assemble_auto_filename.php: - removed auto-filenames from path-cache. merged assemble_auto_filename - back into Smarty::_get_auto_filename() - -2003-09-12 Messju Mohr - - * libs/Smarty_Compiler.class.php: - fixed quoting of modifier parameters - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.get_php_resource.php - libs/core/core.load_plugins.php - libs/core/core.load_resource_plugin.php: - remove Smarty::_plugin_implementation_exists() - use php's native - is_callable() - -2003-09-11 Messju Mohr - - * libs/Smarty.class.php: - silenced two notices acces HTTP_SERVER_VARS - -2003-09-10 andreas halter - - * docs/de/designers.sgml - docs/de/getting-started.sgml - docs/de/programmers.sgml: - - minor fixes (2 rep), slight wording changes - - jade transform problem fixed - -2003-09-08 andreas halter - - * docs/de/designers.sgml - docs/de/getting-started.sgml - docs/de/manual.sgml - docs/de/preface.sgml - docs/de/programmers.sgml: - all updated for 2.6.0 release, translated everything from 2_5_0 branch to - 20030908 - -2003-09-04 Messju Mohr - - * libs/Smarty.class.php: - proper checking for files in _fetch_resource_info() - -2003-09-02 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - ignore {strip}/{/strip) inside {strip}-blocks - - * libs/plugins/function.mailto.php: - fixed 2 notices in smarty_function_mailto() - -2003-09-01 Messju Mohr - - * libs/Smarty.class.php: - re-include cache_paths on multiple calls to fetch() to avoid - inconsistencies - at multiple calls to fetch() in one script - - * libs/Smarty_Compiler.class.php: - fixed handling of \r in {strip} - renamed $_trailing_lf to $_additional_newline - - * libs/Smarty_Compiler.class.php: - the weekly fix for {strip} :) - - * docs/designers.sgml: - fixed example for simple math. - -2003-08-29 Messju Mohr - - * libs/core/core.assign_smarty_interface.php - libs/core/core.display_debug_console.php - libs/plugins/function.assign.php - libs/plugins/function.html_options.php - libs/plugins/function.html_table.php: - fixed PHPDocumentor-comments (thanks Konstantin) - - * libs/core/core.rmdir.php: - made rmdir a bit more optimistic. especially it now removes - directories correctly that where created accidently by "safe_mode=On - && $use_sub_dirs=true" - -2003-08-27 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed removal of leading/trailing newlines in {strip}-blocks - -2003-08-25 Messju Mohr - - * INSTALL: - added note emphasizing the introduction of "libs/" with 2.5.0 - - * NEWS - libs/plugins/modifier.escape.php: - fixed proper escaping of " and ' with escape:javascript - -2003-08-22 Messju Mohr - - * NEWS - libs/core/core.assemble_plugin_filepath.php: - fixed bug in traversal of $smarty->plugins_dir-array in - smarty_core_assemble_plugin_filepath(). the first matching plugin in - the path should be used, not the last one. - - * libs/core/core.read_cache_file.php: - discard $_cache_info when the cache should be regenerated - -2003-08-20 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php - libs/plugins/block.strip.php: - reverted {strip} from a block-plugin back into the compiler - - * docs/programmers.sgml: - fixed examples for register_function() and register_block() - - * libs/Smarty.class.php: - made template_exists() quiet when the template does not exist (thanks - to konstatin for pointing this out) - -2003-08-18 Monte Ohrt - - * docs/getting-started.sgml: - fix example title - - * docs/README - docs/getting-started.sgml: - change installation wording confusion - -2003-08-18 Messju Mohr - - * libs/Smarty.class.php - libs/core/core.read_cache_file.php: - fixed unnecessary load of source in template_exists() and the - compile-check of smarty_core_read_cache_file() - - * libs/Smarty_Compiler.class.php: - allow section-, array- and object-dereference in $smarty-references - -2003-08-15 Messju Mohr - - * docs/designers.sgml: - added parameter-descriptions for count_characters (thanks Konstantin - A. Pelepelin) - - fixed docs for {html_checkboxes} - -2003-08-14 Messju Mohr - - * libs/Smarty.class.php - libs/core/core.read_cache_file.php: - fixed timestamp-check of config-files in smarty_core_read_cache_file() - - * libs/Smarty.class.php: - fixed typecasting for arrays in _parse_resource_name() - - * NEWS - libs/plugins/function.config_load.php: - fixes in config_load: - - handling of section-attribute - - reusing the same config-file multiple times - - serialization of config-data for php<4.2.0 (no var_export) - - many thanks to atu for pointing this out and for testing - -2003-08-13 Messju Mohr - - * libs/Smarty.class.php - libs/core/core.smarty_include_php.php: - fixed problem with vars as attributes in {include_php} - -2003-08-13 Monte Ohrt - - * docs/README: - commit README file for documentation compiling - -2003-08-13 Messju Mohr - - * libs/debug.tpl - libs/plugins/modifier.debug_print_var.php: - removed '\r' from debug_print_vars' output - properly escape vars in javascript-version of debug.tpl - -2003-08-11 Monte Ohrt - - * (Smarty_2_6_0_RC1) - NEWS - docs/designers.sgml - docs/html.dsl - docs/php.dsl - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - get ready for 2.6.0-RC1 release - -2003-08-10 Messju Mohr - - * NEWS - libs/Smarty.class.php: - fixed status-header for cache_modified_check under cgi-sapi - -2003-08-09 Messju Mohr - - * libs/core/core.is_secure.php - libs/core/core.is_trusted.php: - synced secure_dir-checking with trusted_dir-checking - - * libs/core/core.is_secure.php: - tightenend path checking in smarty_core_is_secure() - -2003-08-08 Messju Mohr - - * libs/Smarty.class.php: - fix: proper nesting of $smarty->_cache_including flag in cascaded - cached/not-cached/fetched/inserted/foo-templates - - * libs/debug.tpl: - better escaping for $_debug_tpls[templates].filenames - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - removed redundant $smarty from Smarty::_smarty_include() - - * libs/debug.tpl: - proper escaping of filenames in debug-console (thanks to prossel). - -2003-08-07 Messju Mohr - - * docs/programmers.sgml: - added docs for block-methods of registered objects - - * docs/programmers.sgml: - fixed typo in example for registered objects - - * docs/designers.sgml: - fixed exampls of html_image and html_checkboxes - - * libs/plugins/function.debug.php: - fixed {debug} and removed tabs in function.debug.php - - * docs/programmers.sgml: - fixed example for register_object - - * docs/designers.sgml - docs/programmers.sgml: - updated docs for capture, html_table, html_image and register_object - -2003-08-07 Monte Ohrt - - * docs/designers.sgml - docs/programmers.sgml: - add math and default_resource_type to docs - - * docs/getting-started.sgml: - add core to example, add tech note - -2003-08-07 Messju Mohr - - * docs/manual.sgml - docs/fr/manual.sgml: - upd copyright in the docs - -2003-08-07 Monte Ohrt - - * docs/getting-started.sgml: - added core directory to install instructions - -2003-08-07 Messju Mohr - - * docs/designers.sgml - docs/programmers.sgml: - added docs for php-functions as modifiers - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - better caching of attributes for $cacheable=false-plugins - - * docs/programmers.sgml: - added section "caching.cacheable" to the docs, explaining the usage of - the $cacheable-flag of the register_(block|compiler|function)-functions - - * libs/Smarty_Compiler.class.php: - fixed output of custom-functions with cached attributes - - * docs/programmers.sgml: - docs update on callbacks to the register_*-functions - -2003-08-06 Messju Mohr - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.process_compiled_include.php: - added optional parameter $cache_attrs to register_function() and - register_block(). $cache_attrs is an array containing attribute- names - that should be cached on calls to functions that have $cacheable set - to false. - - * libs/Smarty.class.php: - fixed bug in _run_mod_handler - - * libs/Smarty_Compiler.class.php: - fixed bug with autoload-handling of modifiers. thanks ndre. - -2003-08-05 Messju Mohr - - * libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - updated copyright notice - - * libs/Smarty.class.php - libs/core/core.load_plugins.php: - fixed bug that occurred when using the same not-cacheable plugin in - multiple includes - - * docs/programmers.sgml: - docs-update for plugins.writing - -2003-08-04 Messju Mohr - - * docs/designers.sgml - docs/programmers.sgml: - updated docs for register_block_function(), block-functions, - $request_use_auto_globals and html_checkboxes - -2003-07-31 Messju Mohr - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - enabled registration of class-methods as callbacks for the - register_*-functions - - use: array('classname', 'method_name')) as callback - -2003-07-29 Messju Mohr - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - modifiers are resolved at compile-time now. _run_mod_handler() is - still used for modifiers with map_array=true (== no preceeding '@') - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.smarty_include.php: - moved _smarty_include() back into Smarty.class.php - - * libs/Smarty.class.php - libs/core/core.load_plugins.php: - prevent unnecessary calls to _read_file() in _is_compiled() - converted method-call to internal function-call in - smarty_core_load_plugins() - -2003-07-28 Messju Mohr - - * libs/Smarty_Compiler.class.php: - quote smarty-header properly to prevent resource-names from escaping from - the comment - -2003-07-25 Messju Mohr - - * libs/core/core.create_dir_structure.php: - weakend race-condition and removed bogus error-message caused by that - in smarty_core_create_dir_structure(). - -2003-07-23 Messju Mohr - - * libs/Smarty.class.php - libs/core/core.display_debug_console.php - libs/core/core.fetch_resource_info.php - libs/core/core.get_php_resource.php - libs/core/core.parse_resource_name.php - libs/core/core.process_cached_inserts.php - libs/core/core.read_cache_file.php - libs/core/core.run_insert_handler.php - libs/core/core.smarty_include.php - libs/core/core.smarty_include_php.php - libs/plugins/function.eval.php: - moved _fetch_resource_info and _parse_resource_name back into - Smarty.class.php - renamed smarty_include and smarty_eval wrappers to _include and _eval - -2003-07-17 Messju Mohr - - * libs/core/core.process_compiled_include.php - libs/core/core.read_cache_file.php: - improved checking of compiled_include against cached-template with - non-cached-chunks - - * libs/core/core.write_compiled_include.php: - fixed too short open-tag - - * libs/plugins/function.eval.php: - fixed assign parameter for eval (must have gotton lost on its way to 2.5.0) - cleaned up indentiation - -2003-07-03 Messju Mohr - - * libs/Smarty_Compiler.class.php: - resurrected $foo->$bar syntax - - * libs/Smarty_Compiler.class.php: - i'm so stupid. kick me. - - * libs/Smarty_Compiler.class.php: - fixed initialisation of $this->_plugins in compile_block_tag() - -2003-07-03 Monte Ohrt - - * libs/Config_File.class.php: - add preg_quote delimiter - -2003-07-03 Messju Mohr - - * libs/Smarty_Compiler.class.php: - applied fix for {$var1->p1|modifier:$var2->p2}-syntax - thanks Dominik - -2003-07-02 Messju Mohr - - * libs/Smarty_Compiler.class.php: - fixed duplicate generation of arg-list in _compile_block_tag() - - * libs/Smarty_Compiler.class.php: - fixed off-by-one-error in nocache-tag-handling - -2003-06-30 Messju Mohr - - * libs/Smarty_Compiler.class.php: - backed out errornously committed support for $foo->$bar - - * libs/core/core.write_file.php: - fixed indentiation, silenced occasional warning - - * libs/plugins/function.html_image.php: - match first character of file-attribute against "/" instead of - DIRECTORY_SEPARATOR since it is a url-path and not a file-path. - - * libs/Smarty_Compiler.class.php - libs/core/core.write_file.php - libs/plugins/function.html_image.php: - libs/plugins/function.html_image.php - - * libs/Smarty_Compiler.class.php: - re-fixed cacheable_state-handling - - * libs/core/core.display_debug_console.php - libs/core/core.process_cached_inserts.php - libs/core/core.process_compiled_include.php - libs/core/core.run_insert_handler.php: - extincting $this out of smarty_core_*-functions - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - fixed handling of nocache-state - -2003-06-29 Messju Mohr - - * libs/Smarty.class.php - libs/core/core.smarty_include.php - libs/core/core.smarty_include_php.php - libs/plugins/function.eval.php: - removed $this from smarty_include and smarty_include_php - added cleaner handling of $this to {eval} - - * libs/core/core.load_resource_plugin.php: - fixed inlude_once-call - - * docs/de/designers.sgml - docs/fr/designers.sgml: - fixed examples of html_radios and html_checkboxes in german and french docs - -2003-06-25 Monte Ohrt - - * libs/core/core.assemble_auto_filename.php - libs/core/core.write_cache_paths_file.php: - fix typo, fix write_cache_paths logic - - * libs/Smarty.class.php - libs/core/core.assemble_auto_filename.php: - fix SMARTY_COMPILE_DIR_SEP problem, make local var - -2003-06-24 Monte Ohrt - - * libs/Smarty.class.php - libs/core/core.assemble_auto_filename.php - libs/core/core.write_cache_paths_file.php: - fixed cache_paths bug, simplified filename assembly logic - -2003-06-24 Messju Mohr - - * libs/plugins/function.html_image.php: - added parsing of forgotton param "basedir" - - * libs/Smarty_Compiler.class.php: - fixed $smarty.get-reference - - * libs/plugins/block.textformat.php: - removed warning - - * libs/Smarty_Compiler.class.php: - fixed value of _cacheable_state on compiler-startup - -2003-06-23 Monte Ohrt - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.write_cache_paths_file.php: - make cache_path per resource, fix a couple directory path issues - -2003-06-23 Messju Mohr - - * libs/Smarty_Compiler.class.php: - removed warning when compiling empty template - - * libs/core/core.write_compiled_include.php: - fixed bug in write_compiled_include - - * libs/core/core.assemble_plugin_filepath.php: - fixed warning - -2003-06-22 Messju Mohr - - * libs/plugins/function.eval.php: - fixed propagation of $this into evald code in smarty_function_eval() - - * libs/core/core.write_cache_paths_file.php - libs/core/core.write_compiled_include.php: - fix in compiled-include-handling - - * libs/core/core.assemble_auto_filename.php - libs/core/core.assemble_plugin_filepath.php - libs/core/core.assign_smarty_interface.php - libs/core/core.create_dir_structure.php - libs/core/core.fetch_resource_info.php - libs/core/core.get_include_path.php - libs/core/core.get_microtime.php - libs/core/core.get_php_resource.php - libs/core/core.is_secure.php - libs/core/core.is_trusted.php - libs/core/core.load_plugins.php - libs/core/core.load_resource_plugin.php - libs/core/core.parse_resource_name.php - libs/core/core.read_cache_file.php - libs/core/core.rm_auto.php - libs/core/core.rmdir.php - libs/core/core.write_cache_file.php - libs/core/core.write_cache_paths_file.php - libs/core/core.write_compiled_include.php - libs/core/core.write_compiled_resource.php - libs/core/core.write_file.php - libs/plugins/modifier.date_format.php: - started moving from $this to $smarty in core.*.php - -2003-06-21 Monte Ohrt - - * libs/core/core.create_dir_structure.php - libs/core/core.write_file.php - libs/plugins/function.config_load.php: - fix more dir paths - - * NEWS - libs/Smarty.class.php - libs/core/core.assemble_auto_filename.php - libs/core/core.assemble_plugin_filepath.php - libs/core/core.fetch_resource_info.php - libs/core/core.get_php_resource.php - libs/core/core.parse_resource_name.php - libs/core/core.process_cached_inserts.php - libs/core/core.read_cache_file.php - libs/core/core.rm_auto.php - libs/core/core.rmdir.php - libs/core/core.run_insert_handler.php - libs/core/core.smarty_include.php - libs/core/core.smarty_include_php.php - libs/core/core.write_cache_file.php - libs/core/core.write_cache_paths_file.php - libs/core/core.write_compiled_include.php - libs/core/core.write_compiled_resource.php - libs/core/core.write_file.php - libs/plugins/function.config_load.php - libs/plugins/function.fetch.php - libs/plugins/function.html_image.php: - fix filepaths to core files to use DIRECTORY_SEPARATOR - -2003-06-21 Messju Mohr - - * libs/Smarty_Compiler.class.php: - fixed {plugin|modifier} syntax - - * libs/Smarty.class.php - libs/core/core.write_compiled_include.php: - fixed compiled include handling - -2003-06-21 Monte Ohrt - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.assemble_auto_filename.php - libs/core/core.assemble_plugin_filepath.php - libs/core/core.write_cache_paths_file.php: - added filepath caching - -2003-06-20 Monte Ohrt - - * libs/Smarty_Compiler.class.php: - update more varnames - - * libs/Smarty.class.php - libs/core/core.display_debug_console.php - libs/core/core.fetch_file_info.php - libs/core/core.fetch_resource_info.php - libs/core/core.get_php_resource.php - libs/core/core.parse_file_path.php - libs/core/core.parse_resource_name.php - libs/core/core.process_cached_inserts.php - libs/core/core.read_cache_file.php - libs/core/core.run_insert_handler.php - libs/core/core.smarty_include.php - libs/core/core.smarty_include_php.php - libs/core/core.write_compiled_resource.php - libs/core/core.write_compiled_template.php - libs/plugins/function.config_load.php: - refactored var naming to better reflect "resource" instead of "file" where - appropriate - -2003-06-19 Messju Mohr - - * libs/Smarty.class.php: - updated version-number to 2.5.0-cvs - - * libs/core/core.write_cache_file.php: - omit is-cache_dir-writable-check if a cache_handler_function is in use - - * libs/core/core.smarty_include_php.php: - fixed comments in smarty_include_php - -2003-06-19 Monte Ohrt - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.display_debug_console.php - libs/core/core.smarty_include.php - libs/plugins/function.eval.php: - split up _compile_template to _compile_file and _compile_source, fix eval - function - VS: ---------------------------------------------------------------------- - - * libs/plugins/function.config_load.php: - fix logic for _is_compiled() - -2003-06-19 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - added optional assign-attribute to {capture}-tag - - * NEWS - libs/Smarty.class.php: - added $cacheable-parameter to register_compiler_function() - -2003-06-18 Messju Mohr - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.load_plugins.php - libs/core/core.process_compiled_include.php - libs/core/core.read_cache_file.php - libs/core/core.write_cache_file.php - libs/core/core.write_compiled_include.php: - added $cacheable-parameter to register_function() and register_block() - - * libs/Smarty.class.php: - append '.php' to all compiled templates regardless of the settings of - $use_sub_dirs - - * libs/Smarty.class.php - libs/core/core.read_cache_file.php: - fixed $file_path-parameters passed to smarty_core_fetch_file_info() - -2003-06-17 Monte Ohrt - - * NEWS: - fix name - - * libs/Smarty_Compiler.class.php: - change varnames to follow coding methods - - * NEWS - libs/Smarty_Compiler.class.php: - add math patch to core - -2003-06-17 Messju Mohr - - * libs/core/core.smarty_include.php: - switched _process_template() to _is_compiled()-logic - -2003-06-17 Monte Ohrt - - * libs/Smarty.class.php: - fix _is_compiled logic - - * NEWS: - update news file - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - fix _run_mod_handler routine - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.display_debug_console.php - libs/core/core.fetch_file_info.php - libs/core/core.parse_file_path.php - libs/core/core.write_compiled_template.php - libs/plugins/function.config_load.php: - fix path problems, rename some varibles from "template" to "file" - -2003-06-16 Monte Ohrt - - * libs/core/core.fetch_file_info.php - libs/core/core.fetch_template_info.php: - rename file, commit - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.parse_file_path.php - libs/core/core.read_cache_file.php - libs/plugins/block.strip.php - libs/plugins/block.textformat.php - libs/plugins/compiler.config_load.php - libs/plugins/function.config_load.php - libs/plugins/function.eval.php - libs/plugins/function.fetch.php - libs/plugins/function.html_image.php: - fix config_load, compile fetched arrays to compile_dir, switch display - back to runtime. clean up var names and function names, split up compile - testing and compiling to separate funcs, rename some template_* functions - to - file_* functions and update logic so they can be used for file resources - other than templates. - -2003-06-16 Messju Mohr - - * libs/Smarty_Compiler.class.php: - fixed little bug in _compile_custom_tag() - -2003-06-16 Monte Ohrt - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/core/core.assign_smarty_interface.php - libs/core/core.create_dir_structure.php - libs/core/core.display_debug_console.php - libs/core/core.fetch_template_info.php - libs/core/core.get_include_path.php - libs/core/core.get_microtime.php - libs/core/core.get_php_resource.php - libs/core/core.is_secure.php - libs/core/core.is_trusted.php - libs/core/core.load_plugins.php - libs/core/core.load_resource_plugin.php - libs/core/core.parse_file_path.php - libs/core/core.process_cached_inserts.php - libs/core/core.read_cache_file.php - libs/core/core.rm_auto.php - libs/core/core.rmdir.php - libs/core/core.run_insert_handler.php - libs/core/core.smarty_include.php - libs/core/core.smarty_include_php.php - libs/core/core.write_cache_file.php - libs/core/core.write_compiled_template.php - libs/core/core.write_file.php - libs/plugins/core.assign_smarty_interface.php - libs/plugins/core.create_dir_structure.php - libs/plugins/core.display_debug_console.php - libs/plugins/core.fetch_template_info.php - libs/plugins/core.get_include_path.php - libs/plugins/core.get_microtime.php - libs/plugins/core.get_php_resource.php - libs/plugins/core.is_secure.php - libs/plugins/core.is_trusted.php - libs/plugins/core.load_plugins.php - libs/plugins/core.load_resource_plugin.php - libs/plugins/core.parse_file_path.php - libs/plugins/core.process_cached_inserts.php - libs/plugins/core.read_cache_file.php - libs/plugins/core.rm_auto.php - libs/plugins/core.rmdir.php - libs/plugins/core.run_insert_handler.php - libs/plugins/core.smarty_include.php - libs/plugins/core.smarty_include_php.php - libs/plugins/core.write_cache_file.php - libs/plugins/core.write_compiled_template.php - libs/plugins/core.write_file.php: - move core files into their own directory under SMARTY_DIR, - remove abstraction function _execute_core_function - - * libs/Smarty_Compiler.class.php: - fix newline handling for template for all template tags - -2003-06-11 Monte Ohrt - - * libs/plugins/compiler.config_load.php: - add compiler function to cvs repository - -2003-06-11 Messju Mohr - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - added config-option "request_use_auto_globals" to make auto-globals be - used as request vars instead of HTTP_*_VARS - -2003-06-11 Monte Ohrt - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/plugins/function.config_load.php: - make config vars compile statically - -2003-06-11 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - backed out newlines patch - - * NEWS - libs/Smarty_Compiler.class.php: - removed newlines in compiled templates after closing tags - -2003-06-10 Messju Mohr - - * docs/de/designers.sgml: - fixed german note on html_image and disk-access - -2003-06-10 Monte Ohrt - - * libs/plugins/core.parse_file_path.php: - fix bug with resource_type resolving - -2003-06-09 Monte Ohrt - - * docs/designers.sgml: - replace example with more practical one - -2003-06-08 Messju Mohr - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - added block-methods for registered objects - -2003-06-07 Messju Mohr - - * docs/programmers.sgml: - fixed bug in documentation for $smarty->default_modifiers - -2003-06-06 Monte Ohrt - - * libs/plugins/core.parse_file_path.php: - fix problem with new default_resource_type changes - - * NEWS: - update NEWS file info - - * NEWS - libs/Smarty.class.php - libs/plugins/core.parse_file_path.php: - add default_resource_type, ignore 1 char resource names - - * NEWS - libs/Config_File.class.php: - fix bug where config file starts with hidden section - -2003-06-04 Monte Ohrt - - * NEWS - libs/Smarty.class.php: - -** empty log message *** - -2003-06-03 Monte Ohrt - - * libs/plugins/function.html_image.php: - fix example in code comments - -2003-06-03 Messju Mohr - - * NEWS - libs/plugins/function.counter.php: - fixed behaviour of start=... for {counter} - -2003-06-02 Messju Mohr - - * NEWS - libs/plugins/function.counter.php: - fixed assign for {counter} - -2003-05-30 Monte Ohrt - - * libs/plugins/core.write_cache_file.php - libs/plugins/core.write_compiled_template.php: - add discrete error checking pertaining to $cache_dir - and $compile_dir, their existance and writability - -2003-05-28 Messju Mohr - - * NEWS - libs/plugins/function.html_table.php: - added params vdir, hdir and inner to html_table to allow looping over - the data in various directions - -2003-05-28 Monte Ohrt - - * libs/plugins/core.compile_template.php - libs/plugins/core.display_debug_console.php: - fix problem with security and debug.tpl file - -2003-05-23 Monte Ohrt - - * NEWS: - upd NEWS file - - * libs/Smarty_Compiler.class.php: - allow spaces in literal tags - -2003-05-22 Monte Ohrt - - * docs/fr/programmers.sgml: - fix special chars - -2003-05-19 Monte Ohrt - - * NEWS - libs/Smarty_Compiler.class.php: - speed up compiled templates, hardcode plugin filepaths instead of - recalculate at runtime - -2003-05-19 Messju Mohr - - * docs/designers.sgml: - fixed example of {html_image} - - * docs/designers.sgml: - fixed typo - -2003-05-12 Messju Mohr - - * libs/Smarty.class.php - libs/plugins/core.read_cache_file.php - libs/plugins/core.smarty_include.php - libs/plugins/function.config_load.php: - fixed multiple redundant occurrences for 'config' and 'template' in - $smarty->_cache_info - -2003-05-10 Messju Mohr - - * libs/plugins/core.create_dir_structure.php: - refurbished create_dir_structure to use '/' internally - - * libs/plugins/core.create_dir_structure.php: - fixed windows absolute-paths in smarty_core_create_dir_structure() - - * libs/plugins/core.create_dir_structure.php: - fixed error-message - -2003-05-09 Messju Mohr - - * libs/Smarty_Compiler.class.php: - fixed warning due to missing param to _execute_core_function() - - * libs/Smarty_Compiler.class.php: - fixed quoting in _compile_include_php - - * libs/Smarty_Compiler.class.php: - fixed quoting of "file"-parameter in _compile_include_tag() - -2003-05-08 Monte Ohrt - - * docs/programmers.sgml: - fix typo - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/plugins/core.compile_template.php - libs/plugins/core.create_dir_structure.php - libs/plugins/core.fetch_template_info.php - libs/plugins/core.get_include_path.php - libs/plugins/core.get_microtime.php - libs/plugins/core.get_php_resource.php - libs/plugins/core.is_secure.php - libs/plugins/core.is_trusted.php - libs/plugins/core.load_plugins.php - libs/plugins/core.load_resource_plugin.php - libs/plugins/core.parse_file_path.php - libs/plugins/core.process_cached_inserts.php - libs/plugins/core.read_cache_file.php - libs/plugins/core.rm_auto.php - libs/plugins/core.rmdir.php - libs/plugins/core.run_insert_handler.php - libs/plugins/core.smarty_include.php - libs/plugins/core.smarty_include_php.php - libs/plugins/core.write_cache_file.php - libs/plugins/core.write_compiled_template.php - libs/plugins/core.write_file.php - libs/plugins/function.config_load.php - libs/plugins/function.fetch.php - libs/plugins/function.html_image.php: - abstract more private functions to plugin directory - - * libs/Config_File.class.php: - only add DIRECTORY_SEPARATOR if it isn't already present - - * libs/Config_File.class.php: - fix directory separator code, use DIRECTORY_SEPARATOR - -2003-05-08 Messju Mohr - - * docs/designers.sgml: - fixed example of html_checkboxes - - * NEWS - libs/Smarty.class.php: - fixed bug in _create_dir_structure() when used with - open_basedir-restriction and relative paths - - * docs/designers.sgml: - fixed example for html_radios - -2003-05-07 Monte Ohrt - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php - libs/plugins/core.assign_smarty_interface.php - libs/plugins/core.display_debug_console.php - libs/plugins/function.display_debug_console.php: - abstracted display_debug_console and assign_smarty_interface to plugin dir - as a test - - * libs/Smarty.class.php - libs/plugins/function.display_debug_console.php: - correct misc varnames, abstract debug console display to plugin function - - * libs/plugins/modifier.escape.php: - fix typo - -2003-05-05 Monte Ohrt - - * libs/Smarty_Compiler.class.php: - add % to math - - * libs/Smarty.class.php: - clean up comments, formatting - - * NEWS - libs/Smarty.class.php: - keep DIR_SEP for 3rd party compatability - - * NEWS - libs/Smarty.class.php: - remove DIR_SEP, use DIRECTORY_SEPARATOR exclusively - - * libs/Smarty_Compiler.class.php: - remove ++ and -- math operators on template vars - -2003-05-04 Messju Mohr - - * libs/Smarty_Compiler.class.php: - removed unused parameter $quote from Smarty_Compiler::_parse_attrs() - - * libs/plugins/function.html_image.php: - fixed DIR_SEP in html_image-plugin - -2003-05-04 Monte Ohrt - - * NEWS - libs/Smarty.class.php: - rename DIR_SEP to SMARTY_DIR_SEP to avoid varname collisions - -2003-05-04 Messju Mohr - - * NEWS - libs/plugins/function.html_image.php: - changed "link" to "href" in html_image. "link" is still working but - deprecated - html_image always renders an alt-tag now (default alt="") - cleaned up indentiation of function.html_image.php - -2003-05-03 Monte Ohrt - - * libs/debug.tpl: - fix typo - -2003-05-02 Messju Mohr - - * NEWS - libs/plugins/function.counter.php: - fixed assign attribute for multiple counters - -2003-05-02 Monte Ohrt - - * libs/Smarty_Compiler.class.php: - allow math on negative number - - * NEWS - libs/Smarty_Compiler.class.php: - added simple math operators to variables - -2003-05-02 Messju Mohr - - * docs/designers.sgml: - fixed typos - -2003-04-30 Monte Ohrt - - * docs/fr/appendixes.sgml - docs/fr/common.dsl - docs/fr/designers.sgml - docs/fr/getting-started.sgml - docs/fr/html-common.dsl - docs/fr/html.dsl - docs/fr/manual.sgml - docs/fr/php.dsl - docs/fr/preface.sgml - docs/fr/programmers.sgml: - add frech docs to cvs repository - -2003-04-29 Messju Mohr - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - reverted patch for case-insensitive tag-names - -2003-04-28 Messju Mohr - - * docs/programmers.sgml: - reverted back to humerous redundancy in the docs :). although we all - know we are here to generate template-based output, and not to have - fun ;-) - - * docs/getting-started.sgml: - fixed default user and group for max os x installation - - * libs/Smarty.class.php: - made $function[2] and $function[3] options for register_resource - - * libs/Smarty.class.php: - fixed issue with object-callback when fetching a php-resource - - * NEWS - libs/Smarty.class.php: - enabled array(&$obj. 'source', 'timestamp', 'secure', 'trusted') as - callback for register_resource() - - enabled array(&$obj, 'method') as callback for - $default_template_handler_func - -2003-04-27 Messju Mohr - - * docs/designers.sgml - docs/programmers.sgml: - fixed some typos, thank to mehdi - - * libs/plugins/function.counter.php: - prevent assign from overruling print-attribute in function.counter.php - - * libs/plugins/function.counter.php: - fixed problem with counter and assign - - * libs/Smarty.class.php: - fixed notice in _load_plugins() - - * NEWS - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - made plugin-names case-insensitive. this affects - compiler/block/custom-functions and modifers. - -2003-04-26 Monte Ohrt - - * NEWS - libs/Smarty_Compiler.class.php: - remove unnecessary close/open tags from compiled templates - -2003-04-26 Messju Mohr - - * docs/designers.sgml: - added documentation for foreach.property.* - -2003-04-24 Messju Mohr - - * docs/designers.sgml: - fixed example table_attr and tr_attr in html_table-example - -2003-04-21 Greg Beaver - - * libs/Smarty.class.php: - fixed small bug in doc comments - -2003-04-21 Messju Mohr - - * NEWS - libs/plugins/function.html_image.php: - fixed errornous creation of '//' in image_path in html_image - -2003-04-21 Monte Ohrt - - * libs/plugins/modifier.debug_print_var.php: - fix htmlspecialchars() conflict - - * NEWS - libs/plugins/modifier.debug_print_var.php: - fix escapement of special chars in key values of debug console - - * NEWS - libs/plugins/function.config_load.php: - fixed debug timing logic for config_load - - * docs/designers.sgml: - fix example text - - -2003-04-20 Greg Beaver - * plugins/* - Smarty.class.php - Smarty_Compiler.class.php - Config_File.class.php: - updated all doc comments to phpDocumentor format (whew!) - -2003-04-06 Messju Mohr - - * libs/plugins/function.math.php: - allowed "_" in the name of variable-parameters to {math}-function - -2003-04-04 Monte Ohrt - - * NEWS - docs/designers.sgml - libs/Smarty_Compiler.class.php: - change backtic syntax from $`foo` to `$foo` - - * NEWS - libs/Smarty_Compiler.class.php: - recognize $foo[][] syntax in embedded quotes without backticks - -2003-04-03 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - name=123 is passed as an integer (not a string) to plugins now - -2003-04-01 Messju Mohr - - * libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - added CVS $Id: ChangeLog 4660 2012-09-24 20:05:15Z uwe.tews@googlemail.com $ - -2003-03-31 Messju Mohr - - * libs/Smarty.class.php: - added missing compile_id inside Smarty_Compiler - - * libs/Smarty_Compiler.class.php: - fixed flaw when generating an error for missing postfilter - -2003-03-31 Monte Ohrt - - * docs/getting-started.sgml - docs/programmers.sgml: - fix typos - -2003-03-27 Messju Mohr - - * NEWS - libs/plugins/modifier.debug_print_var.php: - $length is now propagated to sub-values in debug_print_var - -2003-03-26 Monte Ohrt - - * NEWS: - update header - - * RELEASE_NOTES: - commit changes to release notes - - * (Smarty_2_5_0_RC2) - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - committing RC2 - -2003-03-24 Messju Mohr - - * NEWS - libs/Smarty.class.php: - made clear_cache() ignore compile_id when clearing cache_groups - - * libs/plugins/function.popup.php: - made onmouseout XHTML-compatible in function.popup.php - -2003-03-21 Messju Mohr - - * NEWS - libs/Smarty.class.php: - applied new var-names to fetch() - - * NEWS - libs/Smarty.class.php: - renamed $localvars to $_localvars in cache-file-handling-functions, - added _get_auto_id()-function - -2003-03-21 Monte Ohrt - - * libs/plugins/function.mailto.php - libs/plugins/function.popup.php: - update functions for XHTML compatability - -2003-03-21 Messju Mohr - - * libs/Smarty.class.php: - fixed wrong $auto_id in _read_cache_file() - - * NEWS - libs/Smarty.class.php: - swapped compile_id and cache_id in read_cache_file and write_cache_file - - * libs/Smarty.class.php: - reverted patch for ignoring compile-id back to -r1.364, due to problems - - * NEWS - libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_radios.php: - html_radios and html_checkboxes accept "selected" instead of "checked" - optionally now - - * NEWS - libs/Smarty.class.php: - swapped compile_id and cache_id for cache-file-handling again - -2003-03-20 Monte Ohrt - - * libs/Smarty_Compiler.class.php: - fix notice when no parameter is passed to default - -2003-03-20 Messju Mohr - - * NEWS - libs/Smarty.class.php: - removed notice of undefined var in _rm_auto() - -2003-03-19 Monte Ohrt - - * libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_radios.php - libs/plugins/function.html_table.php: - fix a few error messages, follow consistancy format plugin_name: errormsg - - * libs/plugins/function.html_radios.php: - update error messages - - * NEWS - libs/plugins/function.html_radios.php: - add a warning when an array is passed as the 'checked' value of html_radios - -2003-03-19 Messju Mohr - - * NEWS - libs/Smarty_Compiler.class.php: - fixed errormessage in _compile_smarty_ref() - - * NEWS - docs/designers.sgml: - updated docs for html_image - -2003-03-18 Messju Mohr - - * NEWS - libs/Smarty.class.php: - cleaned up calls to readdir() - - * libs/plugins/function.html_options.php: - fixed label for optgroup in html_options - -2003-03-18 Monte Ohrt - - * NEWS - libs/Smarty_Compiler.class.php: - fix (newly introduced) bug with passing multiple modifiers to a parameter - -2003-03-18 Messju Mohr - - * NEWS - docs/designers.sgml: - updated docs for html_checkboxes, html_options and html_radios - - * libs/plugins/function.html_options.php: - fixed wrong default-"name" in function.html_options.php - - * NEWS - libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_radios.php: - renamed "checkbox" and "radios" to "options" in {html_checkboxes} and - {html_radios} - - * libs/plugins/outputfilter.trimwhitespace.php: - tried to optimize re-replacement in outputfilter.trimwhitespace.php a - little - - * libs/plugins/outputfilter.trimwhitespace.php: - fixed greedy str_replace in outputfilter.trimwhitespace.php - - * NEWS - libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_options.php - libs/plugins/function.html_radios.php: - html_options, html_checkboxes and html_radios now pass-thru all unknown - paramters - -2003-03-17 Messju Mohr - - * NEWS - libs/plugins/function.html_options.php: - html_options passthru all unknown paramters now - -2003-03-17 Monte Ohrt - - * NEWS - libs/plugins/function.html_image.php: - Fix link bug in html_image function, also make output XHTML compatible - - * libs/Smarty_Compiler.class.php: - fix issue of embedded var and escaped double quotes - -2003-03-15 Monte Ohrt - - * NEWS - libs/Smarty_Compiler.class.php: - back out "@" logic, apply only to default modifier special case - - * libs/Smarty_Compiler.class.php: - fix @ logic, only use upon an echo - - * NEWS - libs/Smarty_Compiler.class.php: - append "@" to template var echoes to supress possible notices - - * NEWS - libs/Smarty_Compiler.class.php: - append "@" to _run_mod_handler to supress warnings - -2003-03-14 Monte Ohrt - - * NEWS - libs/Smarty_Compiler.class.php: - fix problem with escaped double quotes - - * NEWS - libs/plugins/function.html_radios.php: - fixed html_options to not return an array - -2003-03-12 Messju Mohr - - * NEWS - libs/plugins/modifier.truncate.php: - fixed length in modifier.truncate.php - - * NEWS - libs/plugins/outputfilter.trimwhitespace.php: - fixed handling of '$'-signs in trimwhitespace outputfilter (messju) - -2003-03-12 Monte Ohrt - - * docs/programmers.sgml: - update technical explanation of assign_by_ref and append_by_ref - -2003-03-11 Monte Ohrt - - * NEWS - libs/Smarty.class.php: - fix config file recompiling code - -2003-03-07 Monte Ohrt - - * libs/plugins/function.html_image.php: - change E_USER_ERROR to E_USER_NOTICE - - * libs/plugins/function.html_image.php: - suppress warning in html_image - - * NEWS - libs/plugins/function.html_image.php: - update changes to html_image - -2003-03-06 Monte Ohrt - - * docs/designers.sgml - docs/de/appendixes.sgml - docs/de/common.dsl - docs/de/designers.sgml - docs/de/getting-started.sgml - docs/de/html-common.dsl - docs/de/html.dsl - docs/de/manual.sgml - docs/de/preface.sgml - docs/de/programmers.sgml: - add german docs to dist - - * NEWS: - update news file - - * libs/plugins/function.html_image.php: - fix width/height parameter index - - * NEWS - libs/Smarty.class.php: - get rid of unsetting name and script attributes to insert tags - -2003-03-05 Monte Ohrt - - * NEWS - RELEASE_NOTES: - update NEWS file - - * libs/plugins/modifier.string_format.php: - fix argument order, erroneously swapped a while back - - * (Smarty_2_5_0_RC1) - NEWS - README - RELEASE_NOTES - libs/Config_File.class.php - libs/Smarty.class.php - libs/Smarty_Compiler.class.php: - commit final changes for 2.5.0-RC1 - -2003-03-04 Monte Ohrt - - * docs/programmers.sgml: - remove $show_info_header and $show_info_include property vars from docs - -2003-03-03 Monte Ohrt - - * NEWS - libs/plugins/function.popup.php: - fixed PHP notice - -2003-02-28 Monte Ohrt - - * libs/Smarty_Compiler.class.php: - simplify smarty.const.foo and smarty.const.$foo logic - - * libs/Smarty_Compiler.class.php: - only allow $foo syntax in embedded quotes, unless escaped with backticks - then allow any dollar var - - * NEWS - libs/Smarty_Compiler.class.php: - fix "once" var compiling to work with new attr compiling methods for - include_php - - * FAQ - NEWS - README - docs/designers.sgml - docs/getting-started.sgml - libs/Smarty_Compiler.class.php - libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_image.php - libs/plugins/function.html_options.php - libs/plugins/function.html_radios.php - libs/plugins/function.html_select_date.php - libs/plugins/function.html_select_time.php - libs/plugins/function.html_table.php: - fix $smarty.const.foo compiling, clean up double quoted strings, - allow full dollar var syntax in quotes again - -2003-02-27 Monte Ohrt - - * docs/designers.sgml - docs/programmers.sgml - libs/Smarty_Compiler.class.php: - update docs, fix smarty var compiling, allow any $smarty.*.$foo syntax, - add $`foobar` for embedded variables - - * libs/plugins/function.html_image.php: - update functionality - -2003-02-26 Monte Ohrt - - * NEWS - libs/plugins/modifier.nl2br.php: - add nl2br modifier - - * libs/plugins/function.html_image.php: - add link parameter - -2003-02-24 Monte Ohrt - - * libs/Smarty.class.php - libs/plugins/function.html_image.php: - fix rename problem in windows, unlink first - - * libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_image.php - libs/plugins/function.html_options.php - libs/plugins/function.html_radios.php - libs/plugins/shared.escape_special_chars.php: - update functions with separate escape_special_chars routine - - * NEWS - libs/plugins/function.html_checkboxes.php - libs/plugins/function.html_radios.php: - commit checkboxes, update radios - - * NEWS - libs/Smarty.class.php - libs/plugins/function.html_image.php: - fix bug with get_registered_object - - * NEWS - libs/plugins/modifier.cat.php: - added cat modifier to distribution - - * NEWS - libs/Smarty_Compiler.class.php: - added << >> <> support to IF statements - - * libs/plugins/function.html_radios.php: - apply patch to initial html_radios function - - * NEWS - libs/Smarty.class.php: - fix _assign_smarty_interface to not overwrite keys other than 'request' - - * NEWS - libs/plugins/function.html_radios.php: - added html_radios to distribution - - * NEWS - libs/plugins/modifier.string_format.php: - fixed arg order of string_format - - * NEWS - libs/Smarty.class.php: - use tmp file for file writes, avoid race condition - - * NEWS - libs/Smarty_Compiler.class.php: - add $smarty.config.foo var, handle embedded smarty var correctly - - * NEWS - libs/plugins/function.fetch.php: - silence warnings in fetch plugin - -2003-02-21 Monte Ohrt - - * INSTALL: - update wording - - * INSTALL: - update install instructions - - * AUTHORS - BUGS - CREDITS - QUICKSTART - README - RESOURCES - TESTIMONIALS: - remove some files already in docs or elsewhere - - * demo/index.php: - add templates_c to repository - - * index.php: - move demo files to demo directory - - * Config_File.class.php - Smarty.class.php - Smarty_Compiler.class.php - debug.tpl: - moved lib files under libs directory - -2003-02-20 Monte Ohrt - - * NEWS - Smarty.class.php: - add get_config_vars() method, update get_template_vars() functionality - - * NEWS - Smarty.class.php: - fix minor logic in _fetch_template_info() - - * NEWS - Smarty.class.php: - support merging appended vars - - * NEWS - Smarty.class.php: - fix cache groups behavior with compile_id set - -2003-02-19 Monte Ohrt - - * Smarty.class.php: - back out third parameter, extend functionality of append - - * NEWS - Smarty_Compiler.class.php: - update imbedded vars, allow special $smarty vars - - * plugins/function.html_table.php: - add plugin html_table - - * NEWS - Smarty.class.php: - support appending key=>val pairs - - * NEWS - Smarty_Compiler.class.php: - change embedded variable logic to only recognize $foo and $foo[0][bar] - syntax - - * NEWS - Smarty_Compiler.class.php: - allow null as function attribute value - -2003-02-18 Monte Ohrt - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - support foo->bar[index] syntax - - * Smarty_Compiler.class.php: - allow $foo->bar[0] syntax - -2003-02-17 Monte Ohrt - - * plugins/modifier.escape.php: - fix syntax error from previous commit - - * NEWS - Smarty.class.php: - add error msgs to get_registered_object - - * Smarty.class.php: - add function for getting reference to registered object - - * Smarty_Compiler.class.php: - back out patches for object and objref calls on $smarty var - - * NEWS - Smarty_Compiler.class.php: - treat unrecognized param attribute syntax as a string - - * NEWS - Smarty_Compiler.class.php: - support $smarty.const.$foo syntax - - * NEWS - debug.tpl - plugins/modifier.count_words.php - plugins/modifier.escape.php: - fix E_NOTICE messages - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - add @ and === to if tokens, few param cleanups - -2003-02-16 Greg Beaver - - * ChangeLog - Smarty.class.php - Smarty_Compiler.class.php: - many more phpdoc comment upgrades - -2003-02-15 Greg Beaver - * Smarty.class.php - Smarty_Compiler.class.php - continue cleaning of phpdoc comments. All that is needed is the - addition of @return tags and perhaps a bit more verbose comments - and they are finished. - -2003-02-14 Monte Ohrt - - * NEWS - Smarty.class.php: - enable config_load error messages - - * NEWS - plugins/function.html_options.php: - fix html_options to not escape already escaped entities - - * NEWS - Smarty.class.php: - send Last-Modified header on cache creation, misc tab/spacing cleanup - -2003-02-13 Monte Ohrt - - * Smarty_Compiler.class.php - docs/designers.sgml: - allow dash in plain text - - * NEWS - Smarty_Compiler.class.php: - check strict syntax of function attributes - -2003-02-12 Monte Ohrt - - * NEWS - Smarty_Compiler.class.php: - dropped support for modifiers on object parameters, - added support for objects as modifier parameters - - * NEWS - Smarty_Compiler.class.php - docs/designers.sgml: - fix bug with decimal numbers in if statements, misc doc updates - -2003-02-11 Monte Ohrt - - * (Smarty_2_4_2) - Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.class.php - Smarty_Compiler.class.php: - update version numbers - -2003-02-10 Monte Ohrt - - * NEWS - Smarty_Compiler.class.php: - add support for $foo->$bar syntax - - * NEWS: - update NEWS file - - * NEWS - Smarty_Compiler.class.php: - support full var syntax in quoted text, fix problem with const var access, - clean up some more regex code, fix object problem with no properties - -2003-02-06 Monte Ohrt - - * (Smarty_2_4_1) - Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.class.php - Smarty_Compiler.class.php: - committed 2.4.1 changes - - * NEWS - Smarty_Compiler.class.php: - ignore case in IF statements - -2003-02-05 Monte Ohrt - - * NEWS - Smarty_Compiler.class.php: - treat undefined constants as null - - * NEWS - Smarty.class.php: - fix problem with inserts and nested fetches - - * Smarty_Compiler.class.php: - fix "if" regex for math tokens - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php - docs/getting-started.sgml: - added support for extracting params to include_php - -2003-02-04 Monte Ohrt - - * RELEASE_NOTES: - reformat text - -2003-02-03 Monte Ohrt - - * NEWS: - update news file - -2003-02-03 Greg Beaver - - * ChangeLog - Smarty.class.php: - begin fixing phpdoc comments in Smarty.class.php - - * ChangeLog - Config_File.class.php: - fixed phpdoc comments - -2003-02-03 Monte Ohrt - - * Smarty_Compiler.class.php: - allow $foo->bar[$x].foo syntax - - * Smarty_Compiler.class.php - index.php - configs/test.conf - templates/index.tpl: - fix accidental commit - - * index.php - configs/test.conf - templates/index.tpl: - allow $foo->bar[$j].blah type of syntax - -2003-02-02 Greg Beaver - - * Smarty.class.php - begin fixing of phpdoc comments - - * Config_File.class.php - fix phpdoc comments, add phpDocumentor docblock templates - -2003-02-02 Monte Ohrt - - * Smarty.class.php - docs/html.dsl - docs/php.dsl: - fix version number - - * (Smarty_2_4_0) - Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.class.php - Smarty_Compiler.class.php - docs/appendixes.sgml - docs/designers.sgml - docs/programmers.sgml: - update Smarty version numbers - -2003-01-30 Monte Ohrt - - * NEWS - Smarty_Compiler.class.php - TODO: - fix order of php tag comparisons - - * NEWS - Smarty_Compiler.class.php: - fix known php tag handling problems - -2003-01-29 Monte Ohrt - - * Smarty.class.php - Smarty_Compiler.class.php: - change comments to phpdoc style - -2003-01-28 Monte Ohrt - - * Smarty.class.php - docs/programmers.sgml: - make separate var for compiler file - - * plugins/function.fetch.php: - fix error call - -2003-01-25 Monte Ohrt - - * Smarty.class.php - Smarty_Compiler.class.php: - add support for restriction to registered methods - - * plugins/outputfilter.trimwhitespace.php: - update with textarea support - -2003-01-24 Monte Ohrt - - * Smarty_Compiler.class.php: - fix compiling problem with {foreach} tags - - * Smarty.class.php - Smarty_Compiler.class.php: - put objects in own array, add object param format support, change - object syntax from foo.bar to foo->bar - -2003-01-23 Monte Ohrt - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - add support for object registration - -2003-01-22 Monte Ohrt - - * Smarty.class.php: - add file & line number of calling error to error message - -2003-01-21 Monte Ohrt - - * Smarty_Compiler.class.php: - put php style object syntax back in - -2003-01-20 Monte Ohrt - - * Smarty.class.php: - move security settings to fetch function for template_dir - - * NEWS - Smarty.class.php: - fix debug template and security, add template_dir to secure_dir at runtime - -2003-01-17 Monte Ohrt - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - added new object support without new template syntax - -2003-01-15 Monte Ohrt - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - fix if statement syntax for negative integers, fix issue with directories - named '0' - -2003-01-08 Monte Ohrt - - * Smarty.class.php - plugins/function.counter.php - plugins/function.cycle.php - plugins/function.debug.php - plugins/function.eval.php - plugins/function.fetch.php - plugins/function.html_options.php - plugins/function.html_select_date.php - plugins/function.html_select_time.php - plugins/function.mailto.php - plugins/function.math.php - plugins/function.popup.php - plugins/function.popup_init.php: - update plugins to return values instead of echo, fix config file cache - to include global config variables in cache file - - * Smarty_Compiler.class.php: - fix bug with >= tests in if statements, comment out full object support - -2003-01-06 Monte Ohrt - - * NEWS - docs/html.dsl - plugins/modifier.escape.php: - add javascript escape parameter to escape modifier - -2003-01-02 Monte Ohrt - - * templates/header.tpl: - move the title into head where it should be - -2002-12-24 Monte Ohrt - - * Smarty_Compiler.class.php: - added correct line numbers to smarty syntax error messages - - * docs/programmers.sgml: - update append documentation, make more clear on its function - - * Smarty_Compiler.class.php: - fix modifier matching regexp - -2002-12-23 Monte Ohrt - - * Smarty_Compiler.class.php: - support nested function calls in IF statements - -2002-12-20 Monte Ohrt - - * Smarty_Compiler.class.php: - few more fixes, spaces around function parameters - - * Smarty_Compiler.class.php: - fix misc syntax issues with {if} tags - -2002-12-20 Monte Ohrt - - * Smarty_Compiler.class.php: - fix misc syntax issues with {if} tags - -2002-12-19 Monte Ohrt - - * Smarty_Compiler.class.php: - commit updates, passes all smoke tests - - * NEWS: - update NEWS file - - * Smarty_Compiler.class.php: - fixed literal string not in quotes as parameters - - * NEWS - Smarty_Compiler.class.php: - fix misc syntax issues, add ability to pass modifiers to functions - -2002-12-18 Monte Ohrt - - * NEWS: - update NEWS - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - update compiler code, clean up regex, add new syntax features - -2002-12-16 Monte Ohrt - - * NEWS: - update NEWS file - - * Smarty_Compiler.class.php: - commit updates for objects - -2002-12-14 Monte Ohrt - - * Smarty.class.php - Smarty_Compiler.class.php: - fix bug with compiling config files with caching on - -2002-12-13 Monte Ohrt - - * Smarty_Compiler.class.php: - fix problem with matching single quoted strings - - * Smarty_Compiler.class.php: - update embedded variable logic, get rid of ."" at end of output - - * NEWS - docs/designers.sgml - plugins/function.html_select_date.php: - add day_value_format to html_select_date - -2002-12-12 Monte Ohrt - - * plugins/modifier.debug_print_var.php: - fix bug, double escaped values in display - - * Smarty.class.php: - move debug test back into fetch() - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php - plugins/outputfilter.trimwhitespace.php: - assigned vars are no longer in global name space, few debug cleanups - -2002-12-11 Monte Ohrt - - * plugins/function.popup.php: - fix error in newline code - - * plugins/function.popup.php: - fix popup to allow newlines in text data - -2002-12-10 Monte Ohrt - - * Smarty.class.php: - fix plugin error logic - - * docs/designers.sgml - docs/programmers.sgml: - edit examples, make more verbose - - * NEWS - plugins/function.html_options.php: - escape html entities in the option values and output - - * NEWS - plugins/function.html_options.php: - fixed bug with label of html_options - -2002-12-09 Monte Ohrt - - * Smarty.class.php: - add support for var_export() - - * Config_File.class.php - Smarty.class.php: - clean up code, respect force_compile and compile_check flags - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php - docs/designers.sgml - plugins/function.mailto.php: - add caching feature to config loading, document update, add mailto plugin - -2002-12-08 Monte Ohrt - - * plugins/function.fetch.php: - fix query part of URL - -2002-12-05 Monte Ohrt - - * docs/designers.sgml: - fix typos - -2002-11-22 Monte Ohrt - - * Smarty_Compiler.class.php: - patch for warning message - -2002-11-21 Monte Ohrt - - * RELEASE_NOTES - Smarty.class.php: - get rid of testing for a set value with assign function, just set to - whatever is passed into the template - - * docs/programmers.sgml: - fix typo - -2002-11-19 Monte Ohrt - - * Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.class.php - Smarty_Compiler.class.php: - commit changes, ready for 2.3.1 release - -2002-11-01 Monte Ohrt - - * plugins/function.html_options.php: - added label attribute to all option outputs, cover w3c spec. - - * NEWS: update NEWS file - - * docs/designers.sgml: update docs for optgroup output - - * plugins/function.html_options.php: - make html_options work with optgroup, make func modular and recursive. - -2002-10-29 Monte Ohrt - - * NEWS - Smarty.class.php: set mtime on compile files so they match source files - -2002-10-18 Monte Ohrt - - * NEWS - Smarty.class.php: added proper support for open_basedir setting - - * docs/designers.sgml: clear up docs on index, iteration and rownum - -2002-10-16 Monte Ohrt - - * plugins/modifier.default.php: fix warning message in default modifier - -2002-09-25 Monte Ohrt - - * docs/designers.sgml - plugins/modifier.strip.php - NEWS: added strip variable modifier - -2002-09-24 Andrei Zmievski - - * NEWS: *** empty log message *** - - * Smarty_Compiler.class.php: - Fix to be able to use $smarty.x variables as arrays. - -2002-09-23 Monte Ohrt - - * Config_File.class.php: - add support for mac/dos formatted config files (fix newlines) - - * docs/programmers.sgml: add optional tags to clear_cache parameters - - * docs/designers.sgml: - fix error with include_php description, add $this to description - -2002-09-20 Monte Ohrt - - * NEWS - docs/getting-started.sgml: fixed errors with example setup docs - -2002-09-16 Monte Ohrt - - * plugins/block.textformat.php - docs/designers.sgml - NEWS: add textformat block function - -2002-09-10 Monte Ohrt - - * docs/designers.sgml: - add assign attribute to cycle function documentation - - * docs/designers.sgml - docs/programmers.sgml: fix typos - -2002-09-09 Monte Ohrt - - * plugins/function.debug.php - templates/header.tpl: - fix header in debug template, fix typo in header.tpl example - -2002-08-15 mohrt - - * docs/programmers.sgml: fix typos - -2002-08-08 mohrt - - * RELEASE_NOTES - Smarty.class.php: - supress warnings from unlink() and is_dir(), let error handler deal with it - -2002-08-07 mohrt - - * docs/appendixes.sgml - docs/designers.sgml - docs/programmers.sgml - Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.class.php - Smarty_Compiler.class.php: update files with new version numbers - -2002-08-02 mohrt - - * NEWS: update NEWS file with credits - - * NEWS - Smarty.class.php: added assign_by_ref() and append_by_ref() functions - -2002-08-01 mohrt - - * TODO - NEWS - Smarty.class.php: - changed default warning type for plugin errors from E_USER_WARNING to E_USER_ERROR - -2002-07-29 mohrt - - * plugins/function.html_select_time.php - docs/designers.sgml - NEWS: added paramters to html_select_time plugin - -2002-07-25 Andrei Zmievski - - * TODO: *** empty log message *** - -2002-07-24 mohrt - - * QUICKSTART: update QUICKSTART guide - - * NEWS - debug.tpl - plugins/modifier.debug_print_var.php: - update debug console to show objects, fix warning in debug.tpl - -2002-07-23 mohrt - - * docs/programmers.sgml: fix load_filter examples - - * Config_File.class.php - NEWS: fix error when there are no sections in config file - -2002-07-19 mohrt - - * docs/getting-started.sgml: fix error in install guide - -2002-07-18 mohrt - - * Smarty_Compiler.class.php: - correct the expression match for smarty:nodefaults - -2002-07-17 mohrt - - * Smarty_Compiler.class.php: fix default modifier to work with config vars - - * Smarty_Compiler.class.php: got args to strstr backwards... - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - change default modifiers to array instead of string - - * Smarty_Compiler.class.php - docs/designers.sgml - Smarty.class.php: add default modifier logic, minor doc updates - - * NEWS - Smarty.class.php - plugins/function.popup_init.php: - make popup_init xhtml compliant, minor variable name changes for consistancy - -2002-07-16 mohrt - - * NEWS: update NEWS file - - * plugins/function.debug.php - Smarty.class.php - debug.tpl - NEWS: - fix problem with filenames on windows, add ability to supply expire time in seconds when clearing cache or compiled files - -2002-07-15 mohrt - - * Smarty.class.php: - fixed problem with insert tags when loading function from script attribute - and caching enabled (Monte) - -2002-07-14 mohrt - - * NEWS - Smarty.class.php: fix bug with debug_tpl file path for Windows - -2002-07-12 Monte Ohrt - - * Smarty.class.php: fix append function with array/string issue - -2002-07-11 Monte Ohrt - - * RELEASE_NOTES: update release notes - - * NEWS - README - RELEASE_NOTES - Smarty.class.php - Smarty_Compiler.class.php - Config_File.class.php: update files to 2.2.0 tags, get ready for release - -2002-07-09 Monte Ohrt - - * NEWS - Smarty.class.php: make debug.tpl work with any delimiter - - * NEWS - Smarty.class.php: - change tests in append and assign to != '' instead of empty(), which is more accurate - -2002-07-08 Monte Ohrt - - * docs/designers.sgml: minor doc update - - * Smarty.class.php: - cast var as an array, simplify and get rid of PHP warning messages - -2002-07-03 Monte Ohrt - - * Smarty.class.php: one more N - - * Smarty.class.php: - prepend "N" to filenames to avoid possible OS issues with dir names starting with "-" - - * Smarty.class.php: only set $debug_tpl in constructor if empty - - * Smarty.class.php - docs/designers.sgml - docs/getting-started.sgml - docs/programmers.sgml: - make use_sub_dirs go back to crc32 for subdir separation - -2002-06-29 Monte Ohrt - - * plugins/function.eval.php: do nothing if $val is empty - - * TODO - plugins/function.eval.php - plugins/function.popup_init.php: - add zindex to popup init, fix error message for eval. - -2002-06-27 Monte Ohrt - - * Smarty.class.php: - only loop through relative paths for PHP include_path, remove $_relative variable - - * Smarty_Compiler.class.php: added {$smarty.version} variable - -2002-06-26 Monte Ohrt - - * docs/appendixes.sgml - docs/designers.sgml - docs/getting-started.sgml - docs/programmers.sgml - Smarty.class.php: - update plugin loading logic, look in SMARTY_DIR, then cwd. If all fail, then retry all with include_path - - * templates/header.tpl - Smarty.class.php: update get_include_path, get _path_array only once - - * Smarty.class.php: fix get_include_path function for windows - - * Smarty.class.php: update plugin search logic - - * Smarty.class.php: only search include_path if relative path - - * plugins/function.html_select_date.php - plugins/function.html_select_time.php - plugins/modifier.date_format.php - Smarty_Compiler.class.php - NEWS - Smarty.class.php: allow plugins_dir to be an array of directories - -2002-06-25 Monte Ohrt - - * docs/programmers.sgml - docs/getting-started.sgml: update installation docs - - * debug.tpl - docs/getting-started.sgml - templates/debug.tpl - NEWS - Smarty.class.php: move debug.tpl to SMARTY_DIR, add to constructor - -2002-06-24 Monte Ohrt - - * plugins/function.assign_debug_info.php - NEWS: fixed warning message in function.assign_debug_info - - * Smarty.class.php: update include_path fixes - - * NEWS: - fixed $template_dir, $compile_dir, $cache_dir, $config_dir to respect include_path - -2002-06-23 Monte Ohrt - - * plugins/shared.make_timestamp.php: - update timestamp plugin to work when passed a timestamp - -2002-06-19 Monte Ohrt - - * NEWS: update NEWS file - - * plugins/modifier.date_format.php - docs/designers.sgml: - update date_format, allow optional 2nd paramater as default date if passed date is empty. update docs. - - * plugins/modifier.date_format.php: - fix date_format modifier, return nothing if given empty string - -2002-06-18 Monte Ohrt - - * NEWS - plugins/function.cycle.php: - gave $reset a default value in cycle function - - * plugins/function.html_select_date.php - plugins/shared.make_timestamp.php - NEWS: - corrected warnings in html_select_time function, made make timestamp always return a timestamp - -2002-06-17 Monte Ohrt - - * Smarty.class.php: swapped around cache_id and compile_id order - -2002-06-14 Monte Ohrt - - * docs/programmers.sgml - plugins/function.popup_init.php - Smarty.class.php: - change directory delimiter to "^" for cache and compile files - -2002-06-13 Andrei Zmievski - - * TODO: done. - - * Smarty_Compiler.class.php: - Optimize the calculation of section 'total' property. - -2002-06-11 Monte Ohrt - - * NEWS - Smarty.class.php: - added support for subdir exclusion, deletion by full or partial cache_id and compile_id, change file format to urlencoded values instead of crc32 - -2002-06-07 Monte Ohrt - - * Smarty.class.php: fix bug with last_modified_check code - - * NEWS - Smarty.class.php: - updated $GLOBALS refererence for HTTP_IF_MODIFIED_SINCE - -2002-06-06 Monte Ohrt - - * docs/designers.sgml - overlib.js: - remove overlib.js file from distribution, update plugin and docs - -2002-06-05 Monte Ohrt - - * docs/designers.sgml - NEWS - Smarty.class.php: fix 304 Not Modified, don't send content - -2002-06-03 Monte Ohrt - - * plugins/function.cycle.php: update version number - - * plugins/function.cycle.php - NEWS: - fixed cycle function to respect delimiter setting after initial setting - - * Smarty.class.php - NEWS: - update $GLOBALS references to work properly with track_globals settings - - * plugins/function.math.php: fixed bug with call $assign - - * docs/appendixes.sgml - docs/designers.sgml - plugins/function.html_options.php - plugins/function.html_select_time.php - NEWS - Smarty.class.php - Smarty_Compiler.class.php: - optimized for loops with count() function calls - -2002-06-01 Andrei Zmievski - - * TODO: *** empty log message *** - -2002-05-21 Monte Ohrt - - * NEWS: update NEWS file - - * plugins/function.html_select_date.php - RESOURCES - docs/designers.sgml - Config_File.class.php: - update html_select_date with month_value_format attribute for controlling the format of the month values. - -2002-05-17 Andrei Zmievski - - * NEWS - Smarty_Compiler.class.php: - Made it possible to use simple variables inside [] for indexing. - -2002-05-16 Monte Ohrt - - * docs/designers.sgml - docs/getting-started.sgml - NEWS - Smarty.class.php - Smarty_Compiler.class.php - TESTIMONIALS: add "once" attribute to php_include, update docs - -2002-05-09 Andrei Zmievski - - * NEWS - TODO: *** empty log message *** - -2002-05-07 Monte Ohrt - - * plugins/function.cycle.php: remove \n from cycle function - - * docs/designers.sgml - plugins/function.cycle.php - README - RELEASE_NOTES - Smarty.class.php - Smarty_Compiler.class.php - NEWS: - update cycle function to handle array as input, update files to 2.1.1 - -2002-05-06 Monte Ohrt - - * plugins/function.fetch.php: - update fetch function with more error checking - -2002-05-03 Monte Ohrt - - * docs/designers.sgml - plugins/function.counter.php: - update counter to use name instead of id (id still works though) - - * plugins/function.cycle.php - docs/designers.sgml: rename id to name for cycle function - - * plugins/function.cycle.php: - update cycle function to allow blank values parameter after initialized - - * plugins/function.cycle.php: fix syntax error - -2002-05-02 Monte Ohrt - - * plugins/function.cycle.php: ugh, another typo - - * plugins/function.cycle.php: update comments - - * docs/designers.sgml - plugins/function.cycle.php - NEWS: added function cycle - - * FAQ - Smarty.class.php: fix register_outputfilter function - -2002-05-01 Monte Ohrt - - * docs/designers.sgml - NEWS - Smarty.class.php: fixed bug with resource testing and include_path - -2002-04-30 Monte Ohrt - - * NEWS - README - RELEASE_NOTES - Smarty.class.php - Smarty_Compiler.class.php: update files for 2.1.0 release - -2002-04-30 Andrei Zmievski - - * plugins/function.fetch.php - docs/programmers.sgml - Smarty.class.php: Fix. - -2002-04-29 Andrei Zmievski - - * docs/programmers.sgml - docs/designers.sgml: A whole bunch of docs. - -2002-04-26 Monte Ohrt - - * FAQ - QUICKSTART - docs/programmers.sgml: update FAQ, QUICKSTART, small doc syntax fix - -2002-04-24 Monte Ohrt - - * docs/programmers.sgml - templates/debug.tpl - Smarty.class.php: changed doc structure a bit - -2002-04-16 Andrei Zmievski - - * Smarty.class.php: Add register/unregister API for output filters. - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php - TODO: - Changed the way filters are loaded, which now has to be done explicitly, - either through load_filter() API or by filling in $autoload_filters variable. - Also renamed internal variable to avoid namespace pollution. - -2002-04-15 Andrei Zmievski - - * Smarty.class.php: - Fixed _get_php_resource() to take include_path into account. - -2002-04-15 Monte Ohrt - - * docs/designers.sgml: - update docs, get modifiers and functions into index for easy access - - * docs/programmers.sgml - NEWS - Smarty.class.php: update caching documentation - -2002-04-15 Andrei Zmievski - - * NEWS: *** empty log message *** - - * Smarty.class.php: Only turn down error notices if $debugging is false. - -2002-04-15 Monte Ohrt - - * NEWS: update NEWS file - - * plugins/function.html_select_date.php: - fixed logic so this works right when field_separator = "/" - - * plugins/function.html_select_date.php: - fix regular expression for matching date - -2002-04-13 Monte Ohrt - - * docs/designers.sgml: updated html_select_date docs to reflect changes - - * NEWS - plugins/function.html_select_date.php: - added YYYY-MM-DD support to html_select_date - -2002-04-12 Andrei Zmievski - - * TESTIMONIALS: New entry. - -2002-04-12 Monte Ohrt - - * plugins/modifier.strip_tags.php: back out changes to strip_tags - - * docs/programmers.sgml: update docs regarding cache_lifetime - - * plugins/modifier.strip_tags.php - Smarty.class.php: - update cache_lifetime logic: -1 = never expire, 0 = always expire - -2002-04-11 Andrei Zmievski - - * BUGS - FAQ - INSTALL - NEWS - Smarty.class.php - Smarty_Compiler.class.php - docs/getting-started.sgml: - Fixed directory separtor issue. Requiring PHP 4.0.6 now. - - * NEWS - Smarty_Compiler.class.php: - Added ability to use simple variables for array indices or object properties. - - * TESTIMONIALS: Another one. - - * TESTIMONIALS: Adding one from Mark P. - -2002-04-05 Andrei Zmievski - - * Smarty_Compiler.class.php - NEWS - Smarty.class.php: Make it possible to unregister pre/postfilter plugins. - -2002-04-05 Monte Ohrt - - * INSTALL: Remove addons file from INSTALL instructions - -2002-04-04 Monte Ohrt - - * docs/designers.sgml: update doc error - - * docs/designers.sgml - plugins/modifier.escape.php - NEWS - Smarty.class.php: added htmlall attribute to escape modifier - -2002-04-03 Andrei Zmievski - - * Smarty_Compiler.class.php: Fixed undefined offset warning in {if} tag. - - * Smarty.class.php - NEWS: Added template_exists() API. - - * Smarty.class.php - Smarty_Compiler.class.php - NEWS: - - Added $smarty.template variable. - - Fixed {include_php} tag when dynamic values were used for 'file' attribute. - - * Config_File.class.php: Separator setting fix. - -2002-03-28 Monte Ohrt - - * FAQ - README: add digest address - - * FAQ - README - Smarty.class.php: update mailing list addresses - -2002-03-28 Andrei Zmievski - - * NEWS: *** empty log message *** - - * plugins/function.html_select_date.php - plugins/function.html_select_time.php - plugins/modifier.date_format.php: - Fix for when plugins directory is not the default one. - -2002-03-28 Andrei Zmievski - - * NEWS: *** empty log message *** - - * plugins/function.html_select_date.php - plugins/function.html_select_time.php - plugins/modifier.date_format.php: - Fix for when plugins directory is not the default one. - -2002-03-27 Monte Ohrt - - * FAQ: update FAQ page - -2002-03-26 Andrei Zmievski - - * CREDITS - NEWS - Smarty.class.php - Smarty_Compiler.class.php - TODO: Block functions changes. - - * Config_File.class.php: *** empty log message *** - -2002-03-25 Andrei Zmievski - - * Smarty.class.php - Smarty_Compiler.class.php: Initial implementation of block functions. - -2002-03-22 Monte Ohrt - - * docs/designers.sgml: fix documentation error in capture - -2002-03-22 Andrei Zmievski - - * Smarty.class.php: *** empty log message *** - - * Smarty.class.php: Turn off notices. - -2002-03-21 Andrei Zmievski - - * Smarty_Compiler.class.php: Make _current_file available to prefilters. - - * NEWS - Smarty.class.php: - Made is possible to assign variables in pre/postfilters. - -2002-03-20 Andrei Zmievski - - * plugins/function.html_select_date.php: Fixed +/- functionality. - - * NEWS: *** empty log message *** - -2002-03-20 Monte Ohrt - - * Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.class.php - Smarty_Compiler.class.php: update version numbers - - * plugins/function.html_select_date.php - plugins/function.html_select_time.php - plugins/modifier.date_format.php: - move .make_timestamp.php to shared.make_timestamp.php - - * NEWS - Smarty.class.php - docs/designers.sgml - plugins/function.fetch.php - plugins/function.html_select_date.php: - update file generation, replace crc32() '-' with 'N' - -2002-03-20 Andrei Zmievski - - * Smarty_Compiler.class.php: *** empty log message *** - -2002-03-19 Andrei Zmievski - - * NEWS: *** empty log message *** - - * Smarty.class.php - Smarty_Compiler.class.php: - Fix plugin behavior for inserts with script attribute. - - * NEWS: *** empty log message *** - - * Smarty_Compiler.class.php: Fix bug with $smarty.cookies. - - * TESTIMONIALS: *** empty log message *** - -2002-03-15 Monte Ohrt - - * NEWS - docs/designers.sgml: update Changelog - - * plugins/modifier.indent.php - plugins/modifier.wordwrap.php: add wordwrap and indent to repository - -2002-03-14 Monte Ohrt - - * Smarty.class.php: - remove show_info_include and show_info_header functions - -2002-03-13 Monte Ohrt - - * plugins/function.fetch.php: update fetch function - - * plugins/function.fetch.php: update fetch function with new parameters - -2002-03-12 Monte Ohrt - - * docs/designers.sgml: update doc tables - - * docs/designers.sgml: update docs columns - - * docs/getting-started.sgml - docs/appendixes.sgml: update docs - - * TESTIMONIALS - docs/appendixes.sgml: update syntax error in docs, add to testimonials - -2002-03-04 Monte Ohrt - - * FAQ - README: update FAQ, README with digest mode info - -2002-03-02 Monte Ohrt - - * QUICKSTART: update quickstart - - * Smarty.class.php: - change behavior so cache_lifetime = 0 never expires (instead of always regenerate) - -2002-03-01 Monte Ohrt - - * docs/designers.sgml: update doc example - -2002-03-01 Andrei Zmievski - - * CREDITS - RELEASE_NOTES - TODO - NEWS: *** empty log message *** - -2002-03-01 Monte Ohrt - - * docs/appendixes.sgml - docs/designers.sgml - docs/getting-started.sgml - docs/programmers.sgml: update document id tags - - * docs.sgml: remove docs.sgml - - * RESOURCES - Smarty.class.php: update resources - -2002-02-28 Andrei Zmievski - - * TESTIMONIALS - docs/appendixes.sgml - docs/designers.sgml - docs/programmers.sgml: *** empty log message *** - -2002-02-27 Andrei Zmievski - - * plugins/function.eval.php - docs/designers.sgml: *** empty log message *** - -2002-02-27 Monte Ohrt - - * plugins/function.eval.php: added eval function to plugin dir - -2002-02-27 Andrei Zmievski - - * NEWS: *** empty log message *** - -2002-02-27 Monte Ohrt - - * docs/designers.sgml: fix syntax error - - * docs/appendixes.sgml - docs/designers.sgml - docs/getting-started.sgml - docs/programmers.sgml: convert technical notes to docbook format - - * NEWS - docs/designers.sgml: added "eval" plugin docs - -2002-02-26 Andrei Zmievski - - * docs/programmers.sgml - docs/designers.sgml - docs/appendixes.sgml - docs/getting-started.sgml - docs/html-common.dsl - docs/.cvsignore: *** empty log message *** - - * docs/appendixes.sgml - docs/common.dsl - docs/designers.sgml - docs/getting-started.sgml - docs/html-common.dsl - docs/html.dsl - docs/manual.sgml - docs/preface.sgml - docs/programmers.sgml: Split up docs. - -2002-02-25 Andrei Zmievski - - * docs.sgml: *** empty log message *** - -2002-02-22 Monte Ohrt - - * docs.sgml: update docs - -2002-02-22 Andrei Zmievski - - * docs.sgml - AUTHORS - NEWS: *** empty log message *** - -2002-02-21 Monte Ohrt - - * Config_File.class.php - NEWS - Smarty.class.php - Smarty_Compiler.class.php - docs.sgml: update misc changes - -2002-02-21 Andrei Zmievski - - * docs.sgml: *** empty log message *** - -2002-02-20 Monte Ohrt - - * docs.sgml: misc updates - -2002-02-20 Andrei Zmievski - - * docs.sgml: *** empty log message *** - - * Smarty.class.php - plugins/function.assign.php - plugins/function.assign_debug_info.php - plugins/function.counter.php - plugins/function.fetch.php - plugins/function.math.php - plugins/function.popup.php - plugins/function.popup_init.php - plugins/modifier.escape.php: Fixup some naming. - -2002-02-20 Monte Ohrt - - * docs.sgml: update docs - -2002-02-20 Andrei Zmievski - - * docs.sgml: *** empty log message *** - -2002-02-20 Monte Ohrt - - * NEWS - docs.sgml - plugins/modifier.escape.php: - removed global vars from fetch function, added attrs to escape modifier - - * docs.sgml: add plugin chapter outline - -2002-02-19 Monte Ohrt - - * README - RELEASE_NOTES - RESOURCES - Smarty.class.php - docs.sgml - BUGS - FAQ - INSTALL - QUICKSTART: update docs - -2002-02-19 Andrei Zmievski - - * docs.sgml: Updated resources docs. - - * README: *** empty log message *** - - * docs.sgml: Updated description of {$smarty} variable. - - * BUGS - FAQ - INSTALL - QUICKSTART - RELEASE_NOTES - docs.sgml: Remove PEAR notes. - -2002-02-18 Andrei Zmievski - - * Config_File.class.php - NEWS: Removed dependency on PEAR. - -2002-02-18 Monte Ohrt - - * NEWS - docs.sgml - plugins/function.popup_init.php: add src attribute to popup_init - -2002-02-15 Andrei Zmievski - - * Smarty_Compiler.class.php - plugins/modifier.debug_print_var.php - NEWS - Smarty.class.php: Performance enhancements. - -2002-02-06 Andrei Zmievski - - * plugins/function.html_options.php: - Fix html_options output to be XHTML compatible. - -2002-02-05 Andrei Zmievski - - * Smarty.class.php - Smarty_Compiler.class.php: Fix up plugin inclusion. - - * Smarty.class.php - Smarty_Compiler.class.php - TODO - plugins/function.html_select_date.php - plugins/function.html_select_time.php - plugins/modifier.date_format.php: Fix plugin directory access. - -2002-02-04 Andrei Zmievski - - * .cvsignore - Smarty_Compiler.class.php: *** empty log message *** - -2002-01-31 Andrei Zmievski - - * NEWS: *** empty log message *** - - * Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php - TODO - plugins/function.assign.php - plugins/function.assign_debug_info.php - plugins/function.counter.php - plugins/function.fetch.php - plugins/function.html_options.php - plugins/function.html_select_date.php - plugins/function.html_select_time.php - plugins/function.math.php - plugins/function.popup.php - plugins/function.popup_init.php - plugins/modifier.capitalize.php - plugins/modifier.count_characters.php - plugins/modifier.count_paragraphs.php - plugins/modifier.count_sentences.php - plugins/modifier.count_words.php - plugins/modifier.date_format.php - plugins/modifier.debug_print_var.php - plugins/modifier.default.php - plugins/modifier.escape.php - plugins/modifier.lower.php - plugins/modifier.regex_replace.php - plugins/modifier.replace.php - plugins/modifier.spacify.php - plugins/modifier.string_format.php - plugins/modifier.strip_tags.php - plugins/modifier.truncate.php - plugins/modifier.upper.php - plugins/shared.make_timestamp.php - templates/index.tpl - AUTHORS - CREDITS - Config_File.class.php - README: Implemented plugin architecture. - - * NEWS: *** empty log message *** - -2002-01-30 Monte Ohrt - - * NEWS - Smarty.addons.php - Smarty.class.php - docs.sgml: added modifiers wordwrap and indent - -2002-01-28 Monte Ohrt - - * Smarty.class.php - docs.sgml: - add support for is-modified-since headers, adjust a doc example - -2002-01-24 Monte Ohrt - - * Smarty.class.php: cleanup formatting - - * NEWS - Smarty.class.php - docs.sgml: update ChangeLog, remove insert_tag_check parameter - -2002-01-24 Andrei Zmievski - - * plugins/standard.plugin.php: *** empty log message *** - -2002-01-24 Monte Ohrt - - * Smarty.class.php: fix syntax error - - * Smarty.class.php: removed unneccesary test from fetch() - -2002-01-23 Monte Ohrt - - * Smarty.addons.php: update overlib fixes - - * NEWS: update changelog - - * FAQ - NEWS - RESOURCES - Smarty.addons.php: updated overlib fixes - -2001-12-31 Andrei Zmievski - - * NEWS - Smarty.class.php: Fixed compile_id problem. - -2001-12-28 Monte Ohrt - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - fixed problem with using assigned var with include_php filepath - -2001-12-21 Monte Ohrt - - * RESOURCES: update RESOURCES - -2001-12-20 Monte Ohrt - - * FAQ - README: update FAQ - -2001-12-18 Monte Ohrt - - * Smarty_Compiler.class.php - docs.sgml - Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php: update version numbers - -2001-12-18 Andrei Zmievski - - * NEWS - Smarty.class.php: Fixed clear_cache(). - -2001-12-14 Monte Ohrt - - * NEWS - Smarty.addons.php: - fixed bug in smarty_make_timestamp introduced in PHP 4.1.0 - -2001-12-13 Monte Ohrt - - * NEWS - Smarty.class.php - docs.sgml: update default function args, fix cached insert debug timing - -2001-12-12 Monte Ohrt - - * docs.sgml: fix syntax error in documentation - - * Smarty.class.php: update default template handling functionality - -2001-12-11 Monte Ohrt - - * Smarty.class.php - Smarty_Compiler.class.php: update file fetching logic - -2001-12-11 Andrei Zmievski - - * NEWS - Smarty.class.php: Added 'script' attribute to {insert..}. - -2001-12-10 Monte Ohrt - - * NEWS - Smarty.class.php: added default template function handler - - * Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php: update version numbers in files to 1.5.1 - -2001-12-10 Andrei Zmievski - - * NEWS - Smarty.class.php: Removed error message from the _read_file() method. - - * Smarty.class.php: Fix check for compile and cache IDs. - -2001-12-06 Monte Ohrt - - * QUICKSTART: fix spelling error in QUICKSTART - - * docs.sgml: fixed spelling errors in documenation - - * Smarty_Compiler.class.php - docs.sgml - Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php: commit 1.5.0 release - - * RESOURCES - docs.sgml: added RESOURCES file - -2001-12-05 Andrei Zmievski - - * Smarty_Compiler.class.php: Refactor. - -2001-12-05 Monte Ohrt - - * NEWS - Smarty_Compiler.class.php - docs.sgml: added assign to include and php_include - - * Smarty.class.php - Smarty_Compiler.class.php - docs.sgml: *** empty log message *** - -2001-12-04 Andrei Zmievski - - * NEWS - Smarty_Compiler.class.php: Formatting. - -2001-12-04 Monte Ohrt - - * Smarty_Compiler.class.php - NEWS - Smarty.class.php: update ChangeLog - -2001-12-04 Andrei Zmievski - - * NEWS - Smarty.class.php: Formatting. - -2001-12-04 Monte Ohrt - - * Smarty.class.php: removed SMARTY_DIR setting in constructor - - * Smarty.class.php: fix Smarty.class.php indention error - - * Smarty.class.php: update trusted logic - -2001-12-03 Monte Ohrt - - * Smarty.class.php: - fix up is_secure, is_trusted, make _parse_tpl_path function - - * Smarty.class.php: fix problem with testing SMARTY_DIR as empty - - * NEWS - docs.sgml: update documentation, change log - - * Smarty.class.php: - update constructor to check for SMARTY_DIR before assigning - -2001-12-03 Andrei Zmievski - - * NEWS - Smarty.class.php: *** empty log message *** - -2001-12-03 Monte Ohrt - - * FAQ - INSTALL - RELEASE_NOTES: update a few files - - * NEWS - QUICKSTART - Smarty.class.php - docs.sgml: added trusted_dir functionality, cleaned up secure_dir logic - -2001-12-03 Andrei Zmievski - - * NEWS: *** empty log message *** - - * NEWS - Smarty.class.php: - Introduced $compile_id class variable. - - Fixed a situation where if $cache_id and $compile_id were both null - they were passed to auto functions as empty string instead of null. - -2001-11-30 Monte Ohrt - - * NEWS - Smarty.class.php: - change variable names in fetch() fuction to smarty_* to avoid namespace conflicts - - * NEWS - Smarty.class.php: fixed bug in _rm_auto with catenated null values - -2001-11-29 Andrei Zmievski - - * NEWS - Smarty_Compiler.class.php: Added $smarty.section.* syntax. - - * Smarty_Compiler.class.php: Made 'name' attribute optional for {foreach}. - -2001-11-29 Monte Ohrt - - * Smarty.class.php - index.php: remove assign "now" in index.tpl - -2001-11-29 Andrei Zmievski - - * NEWS - Smarty.addons.php - Smarty.class.php: Fix formatting. - -2001-11-28 Monte Ohrt - - * NEWS - Smarty.class.php - docs.sgml: - removed return statements from _read_cache_file (how did they get in there?) - -2001-11-27 Monte Ohrt - - * docs.sgml - NEWS - Smarty.addons.php - Smarty.class.php: - fixed bugs and added assign attribute to several functions - -2001-11-27 Andrei Zmievski - - * NEWS: Some rewording. - - * Smarty_Compiler.class.php: Fix $smarty.capture access. - - * TODO: *** empty log message *** - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - Made {config_load ..} merge globals from each config file only once per scope. - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - Added {foreach ...}. - - Made certain $smarty.* references handled at compilation time. - -2001-11-26 Monte Ohrt - - * Config_File.class.php - NEWS - Smarty.class.php - Smarty_Compiler.class.php - docs.sgml: commit cache handler functionality - -2001-11-20 Andrei Zmievski - - * NEWS - Smarty.addons.php - Smarty_Compiler.class.php: Various fixes and additions. - - * NEWS - index.php: *** empty log message *** - -2001-11-05 Monte Ohrt - - * Smarty.class.php: changed _read_file parameter from $end to $lines - - * NEWS - Smarty.class.php: fixed is_cache, make cache reading more efficient - -2001-11-02 Monte Ohrt - - * FAQ - NEWS: update FAQ with mailing list Reply-To header FAQ - - * NEWS - Smarty.class.php - index.php: supress fopen errors, return false if cache file won't load - -2001-11-01 Monte Ohrt - - * QUICKSTART - docs.sgml - index.php: update QUICKSTART guide with index key example - - * Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php - docs.sgml: commit all updates for 1.4.6 - -2001-11-01 Andrei Zmievski - - * NEWS: *** empty log message *** - -2001-10-30 Monte Ohrt - - * Smarty.addons.php: fix assign function problem with empty value passed - - * NEWS - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php - templates/debug.tpl: - fixed bug in assign function when passing an empty value - -2001-10-26 Monte Ohrt - - * Smarty.addons.php - Smarty.class.php - index.php: fix minor typo in debug code - -2001-10-26 Andrei Zmievski - - * Smarty.class.php: Typo. - -2001-10-26 Monte Ohrt - - * Smarty.addons.php: - update debug console output, handle html encoding correctly - -2001-10-26 Andrei Zmievski - - * Smarty.addons.php - templates/debug.tpl: Debug formatting. - - * Smarty.class.php: Disable rmdir warning. - -2001-10-26 Monte Ohrt - - * Smarty.addons.php - Smarty.class.php - templates/debug.tpl: update debugging to expand array variables - - * Smarty.class.php - docs.sgml: - update docs for fetching only timestamp with custom template source functions - - * Smarty.addons.php: fix debug console error - -2001-10-26 Andrei Zmievski - - * docs.sgml: Typos. - - * Smarty.addons.php: Cleanup whitespace. - - * Smarty_Compiler.class.php: Clean up whitespace. - - * Smarty.class.php: Cleaning up code, formatting mostly. - - * NEWS: *** empty log message *** - -2001-10-25 Monte Ohrt - - * NEWS - docs.sgml: update documentation to current version - - * NEWS - Smarty.addons.php: - updated fetch to give proper warning when fetching unreadable or nonexistant files - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - fixed problem with newline at the end of compiled templates - - * NEWS - Smarty.class.php: recompile cache if config file gets modified too. - - * NEWS - Smarty.class.php: - added feature to regenerate cache if compile_check is enabled and an - involved template is modified - -2001-10-23 Monte Ohrt - - * Smarty.class.php: fix indent for insert tags in debug console - - * templates/debug.tpl: update debug.tpl file format - - * NEWS - Smarty.addons.php - Smarty.class.php - templates/debug.tpl: - update execution time debugging, move into include list - -2001-10-10 Monte Ohrt - - * NEWS - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php: - fixed up execution time output in debug console - -2001-10-09 Andrei Zmievski - - * Config_File.class.php - NEWS - Smarty.class.php - TODO: Added support for hidden config vars. - -2001-10-04 Monte Ohrt - - * NEWS - Smarty.addons.php - Smarty.class.php - templates/debug.tpl: added execution times to debug console - -2001-10-02 Andrei Zmievski - - * Smarty_Compiler.class.php: Add space. - -2001-10-01 Andrei Zmievski - - * Smarty.class.php: Fix reference to compile_id. - -2001-09-28 Andrei Zmievski - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: Added postfilter functions. - -2001-09-26 Andrei Zmievski - - * NEWS - Smarty.class.php - docs.sgml: Rename to clear_compiled_tpl(). - -2001-09-25 Andrei Zmievski - - * NEWS - Smarty_Compiler.class.php: - Fixed line number reporting when removing comments. - -2001-09-20 Monte Ohrt - - * NEWS - RELEASE_NOTES - Smarty.addons.php: made html_options output xhtml compatible - -2001-09-19 Monte Ohrt - - * Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php - templates/debug.tpl: updated version numbers - -2001-09-16 Monte Ohrt - - * FAQ - NEWS - docs.sgml: fix doc error with insert function - -2001-09-06 Andrei Zmievski - - * NEWS: *** empty log message *** - -2001-08-31 Monte Ohrt - - * NEWS: update ChangeLog - - * overlib.js - Smarty.addons.php - Smarty.class.php - docs.sgml: - update overlib to 3.50, adjust addon code so that the overlib.js file isn't modified - -2001-08-31 Andrei Zmievski - - * Smarty.class.php: - compile_id changes - - * NEWS - Smarty.addons.php: - compile_id support - - new options for html_select_date - -2001-08-23 Andrei Zmievski - - * TODO: *** empty log message *** - -2001-08-10 Andrei Zmievski - - * NEWS - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php: - Modified to pass Smarty object as second parameter to insert functions. - Also moved _smarty_mod_handler() and _smarty_insert_handler() into the class. - - * NEWS - Smarty_Compiler.class.php: - Passing Smarty as second parameter to prefilter functions. - -2001-08-09 Andrei Zmievski - - * NEWS: *** empty log message *** - -2001-08-09 Monte Ohrt - - * templates/index.tpl - Smarty.class.php: add smarty.now variable to template - -2001-08-06 Monte Ohrt - - * templates/index.tpl: change config_load section back to setup - -2001-08-06 Andrei Zmievski - - * Smarty.addons.php: Optimize a bit. - -2001-08-04 Monte Ohrt - - * docs.sgml: update capture documentation - -2001-08-03 Monte Ohrt - - * FAQ - NEWS - Smarty.class.php: - fix bug with URL controlled debugging, works now (Monte) - -2001-08-01 Andrei Zmievski - - * Config_File.class.php: *** empty log message *** - - * Smarty_Compiler.class.php - Smarty.class.php: - Fixed some E_NOTICE stuff in compiler. - - Generalized assign_smarty_interface() a bit. - -2001-07-24 Andrei Zmievski - - * NEWS - Smarty_Compiler.class.php - TODO: See ChangeLog for details. - -2001-07-20 Andrei Zmievski - - * Config_File.class.php: Booleanize case-insensitively. - -2001-07-17 Monte Ohrt - - * NEWS: update ChangeLog - - * Smarty.class.php - docs.sgml: put SMARTY_DIR on Config_File require - -2001-07-11 Monte Ohrt - - * docs.sgml - FAQ - NEWS - Smarty.class.php: - updated security to not include insecure docs, only warning - -2001-07-10 Andrei Zmievski - - * Smarty.class.php: Adding 'sizeof' as an allowed {if} function. - -2001-07-06 Andrei Zmievski - - * NEWS: *** empty log message *** - -2001-07-06 Monte Ohrt - - * Config_File.class.php - NEWS - README - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php: update version number to 1.4.4 - - * NEWS - Smarty.addons.php - Smarty_Compiler.class.php - docs.sgml - templates/header.tpl - templates/index.tpl: update documenatation, template examples - -2001-07-03 Andrei Zmievski - - * NEWS - Smarty.class.php: Implemented access to request vars via $smarty var. - - * NEWS - Smarty_Compiler.class.php: - Fixed a bug with parsing function arguments in {if} tags. - -2001-06-30 Monte Ohrt - - * NEWS: update ChangeLog - -2001-06-29 Monte Ohrt - - * Smarty.addons.php - Smarty.class.php - docs.sgml - overlib.js: - moved overlib to separate file, added SMARTY_DIR, documented. added much documentation - -2001-06-29 Andrei Zmievski - - * NEWS - RELEASE_NOTES - TODO: *** empty log message *** - -2001-06-29 Monte Ohrt - - * NEWS - README - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php - docs.sgml - index.php - templates/debug.tpl - templates/header.tpl - templates/index.tpl: update release notes - -2001-06-27 Andrei Zmievski - - * Smarty_Compiler.class.php: *** empty log message *** - - * NEWS - Smarty_Compiler.class.php: Implemented 'step' section attribute. - - * Smarty_Compiler.class.php: Negative values of 'max' will mean no max. - - * AUTHORS - NEWS: *** empty log message *** - -2001-06-26 Andrei Zmievski - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php - index.php: Added 'max' and 'start' section attributes. - Added 'total' and 'iteration' section properties. - -2001-06-25 Andrei Zmievski - - * Config_File.class.php - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php: Update version numbers. - -2001-06-23 Andrei Zmievski - - * TODO: *** empty log message *** - -2001-06-21 Andrei Zmievski - - * Config_File.class.php - NEWS: Fixed booleanization bug. - -2001-06-20 Monte Ohrt - - * docs.sgml: - update documents to reflect changes to cached content & debugging - -2001-06-20 Andrei Zmievski - - * Smarty.addons.php - Smarty.class.php: Remove debug output for cached and fetched cases. - -2001-06-20 Monte Ohrt - - * Smarty.class.php: update include_info to false - - * Smarty.class.php - docs.sgml - index.php - templates/footer.tpl: - moved debug logic into Smarty completely, created flags for it - -2001-06-19 Andrei Zmievski - - * Smarty.addons.php - Smarty.class.php - templates/debug.tpl: *** empty log message *** - - * NEWS - Smarty.class.php: Remove unneeded debug functions. - -2001-06-19 Monte Ohrt - - * NEWS - Smarty.addons.php - Smarty.class.php - docs.sgml - templates/debug.tpl - templates/footer.tpl: commit updates, add debug template - -2001-06-19 Andrei Zmievski - - * Smarty.class.php - Smarty_Compiler.class.php - TODO: - Moved config loading code inside main class, the compiled template now - simply calls that method. - -2001-06-15 Andrei Zmievski - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php - templates/index.tpl: * moved config array into class itself - * added 'scope' attribute for config_load - - * Smarty_Compiler.class.php - Smarty.addons.php - Smarty.class.php: Finishing up secure mode. - -2001-06-15 Monte Ohrt - - * NEWS: update ChangeLog - - * Smarty_Compiler.class.php: cleaned up logic of if statement security - - * Smarty_Compiler.class.php: update if logic to cover more situations - - * Smarty_Compiler.class.php - docs.sgml: update if statement security feature - -2001-06-14 Andrei Zmievski - - * Smarty.addons.php - Smarty.class.php: *** empty log message *** - - * NEWS - Smarty_Compiler.class.php: - Fixed a bug with quoted strings inside if statements. - -2001-06-13 Monte Ohrt - - * Smarty.addons.php - Smarty.class.php: added secure_dir array for multiple secure directories - - * Smarty.addons.php: update fetch funtion to respect security setting - - * NEWS - Smarty.addons.php - Smarty.class.php - docs.sgml: update documentation, changelog - - * Smarty.addons.php - Smarty.class.php: moved _extract setting to assign functions - - * Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php: - added assign/unassign custom functions, ability to re-extract tpl_vars - - * Smarty.class.php - Smarty_Compiler.class.php - docs.sgml - index.php: commit security features - -2001-06-11 Andrei Zmievski - - * Smarty.class.php: Version variable typo. - -2001-06-05 Andrei Zmievski - - * Smarty.class.php: - Create config object in fetch() or just set the config path if it already - exists. - -2001-06-04 Andrei Zmievski - - * Smarty.class.php: *** empty log message *** - - * NEWS - Smarty_Compiler.class.php: - Fixed a problem with $ inside strip tags. - -2001-05-31 Andrei Zmievski - - * NEWS: *** empty log message *** - - * Config_File.class.php: Allow empty config_path. - -2001-05-29 Monte Ohrt - - * Smarty_Compiler.class.php - docs.sgml - NEWS - README - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php: update version numbers - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php - docs.sgml: moved version variable to internal variable - -2001-05-22 Andrei Zmievski - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php: - Moved $_smarty_sections and $_smarty_conf_obj into Smarty class. - -2001-05-18 Monte Ohrt - - * NEWS: update ChangeLog - - * FAQ - QUICKSTART: update FAQ, QUICKSTART for windows include_path setup - - * configs/test.conf: added configs directory to cvs - -2001-05-18 Andrei Zmievski - - * Smarty.class.php: Use compiler_class for including the file. - -2001-05-18 Monte Ohrt - - * docs.sgml: fix typo - -2001-05-16 Monte Ohrt - - * README - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php: update files to version 1.4.1 - - * NEWS: update ChangeLog - -2001-05-15 Andrei Zmievski - - * NEWS: *** empty log message *** - - * index.php: forget that! - - * NEWS - Smarty_Compiler.class.php - index.php: Fixed a few E_NOTICE warnings. - -2001-05-09 Monte Ohrt - - * NEWS - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php - docs.sgml: update dates versions - -2001-05-09 Andrei Zmievski - - * NEWS: *** empty log message *** - - * Smarty.class.php: - Use absolute paths when requiring/including Smart components. - - * NEWS: *** empty log message *** - - * Smarty.class.php: Use write mode instead of append. - -2001-05-02 Andrei Zmievski - - * NEWS - Smarty_Compiler.class.php: Fix indexing by section properties. - -2001-05-02 Monte Ohrt - - * NEWS: update changelog - - * Smarty.class.php: remove period from syntax error - -2001-05-02 Andrei Zmievski - - * Smarty_Compiler.class.php: Double-quote the attribute values by default. - -2001-04-30 Monte Ohrt - - * Smarty_Compiler.class.php - NEWS: added simple {capture} logic - -2001-04-30 Andrei Zmievski - - * TODO: *** empty log message *** - - * Smarty_Compiler.class.php - Smarty.class.php: Fix passing config vars to included files. - - * Smarty.class.php - Smarty_Compiler.class.php: Fix inclusion again. - -2001-04-30 Monte Ohrt - - * FAQ - RELEASE_NOTES - Smarty.class.php - misc/fix_vars.php - NEWS: update paths for windows (c:) - -2001-04-28 Andrei Zmievski - - * Smarty.class.php - Smarty_Compiler.class.php: Fix passing variables to included files. - - * templates/index.tpl: *** empty log message *** - -2001-04-27 Andrei Zmievski - - * Smarty_Compiler.class.php: Fix includes. - -2001-04-26 Andrei Zmievski - - * Smarty_Compiler.class.php - docs.sgml - Smarty.class.php: Formatting mostly. - - * Smarty_Compiler.class.php - Config_File.class.php: *** empty log message *** - -2001-04-26 Monte Ohrt - - * Smarty_Compiler.class.php - docs.sgml - FAQ - NEWS - QUICKSTART - RELEASE_NOTES - Smarty.class.php: update docs with new changes - -2001-04-26 Andrei Zmievski - - * RELEASE_NOTES: *** empty log message *** - - * docs.sgml - templates/index.tpl - NEWS - Smarty_Compiler.class.php: Added ability to reference object properties. - -2001-04-25 Andrei Zmievski - - * README - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php - docs.sgml - AUTHORS - Config_File.class.php - CREDITS - RELEASE_NOTES - NEWS: *** empty log message *** - - * docs.sgml: Docs on new parameter to custom functions. - - * NEWS: *** empty log message *** - - * Smarty_Compiler.class.php: - Changing the way tpl vars are referenced and passing smarty object - to custom functions. - - * RELEASE_NOTES - docs.sgml: Fixing docs a bit. - -2001-04-24 Andrei Zmievski - - * docs.sgml: Docs for $compiler_class and compiler functions. - - * templates/index.tpl: *** empty log message *** - - * Smarty_Compiler.class.php: Remove debugging. - -2001-04-24 Monte Ohrt - - * docs.sgml: update compiler function docs - -2001-04-24 Andrei Zmievski - - * NEWS - Smarty.class.php - Smarty_Compiler.class.php - templates/index.tpl: Added compiler function support. - -2001-04-24 Monte Ohrt - - * RELEASE_NOTES - Smarty.class.php: - update notes, change show_info_header to false by default - - * Smarty.class.php - Smarty_Compiler.class.php - docs.sgml - CREDITS - FAQ - NEWS - README - RELEASE_NOTES: update documenation, bug fixes - -2001-04-24 Andrei Zmievski - - * misc/fix_vars.php: Hopefully fix for sure. - -2001-04-23 Monte Ohrt - - * misc/fix_vars.php: uncomment copy/unlink - -2001-04-23 Andrei Zmievski - - * misc/fix_vars.php: Do it more thoroughly. - - * misc/fix_vars.php: check for } - -2001-04-22 Andrei Zmievski - - * misc/fix_vars.php: Fix variable parsing. - -2001-04-20 Monte Ohrt - - * misc/fix_vars.php: fix problem with 4.0.5-dev and preg_replace_callback - -2001-04-19 Monte Ohrt - - * Smarty_Compiler.class.php - docs.sgml - misc/fix_vars.php - NEWS - RELEASE_NOTES - Smarty.class.php: update notes/documentation - - * NEWS - README - RELEASE_NOTES - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php - docs.sgml: update files for 1.4.0 release - -2001-04-16 Andrei Zmievski - - * misc/fix_vars.php: Added fix_vars.php script. - -2001-04-16 Monte Ohrt - - * QUICKSTART - RELEASE_NOTES - docs.sgml - templates/index.tpl: - update RELEASE_NOTES & scripts with new section var syntax - -2001-04-13 Andrei Zmievski - - * Smarty_Compiler.class.php: * Implement new variable format parser. - * Optimizing config load a bit. - -2001-04-13 Monte Ohrt - - * FAQ - NEWS - RELEASE_NOTES - Smarty.class.php: - added $check_cached_insert_tags to speed up cached pages if - {insert ...} is not used (Monte) - -2001-04-12 Andrei Zmievski - - * NEWS - Smarty.class.php - RELEASE_NOTES: *** empty log message *** - - * Smarty_Compiler.class.php: Remove redundant functions. - - * Smarty.class.php: Formatting. - -2001-04-12 Monte Ohrt - - * Smarty.class.php: update file: parsing - - * Smarty.class.php - docs.sgml: update documentation - -2001-04-12 Andrei Zmievski - - * Smarty.class.php - Smarty_Compiler.class.php - TODO: *** empty log message *** - -2001-04-11 Monte Ohrt - - * FAQ - QUICKSTART - RELEASE_NOTES: added RELEASE_NOTES file to cvs - - * NEWS - docs.sgml: update ChangeLog, update documentation - - * Smarty.class.php - Smarty_Compiler.class.php - templates/index.tpl: - update Smarty to compile at run-time. added ability to get files from - absolute paths, added work around for LOCK_EX and windows, changed a few - file permissions to be more secure. - -2001-03-29 Monte Ohrt - - * NEWS - Smarty.addons.php: - allow arbitrary date strings instead of just timestamps - -2001-03-28 Monte Ohrt - - * Smarty.class.php - Smarty_Compiler.class.php - docs.sgml - FAQ - NEWS - README - Smarty.addons.php: - update version in class, update docs for count_ and new vars - - * templates/index.tpl - docs.sgml: update docs, example template - -2001-03-28 Andrei Zmievski - - * Smarty_Compiler.class.php: Some variable renaming. - -2001-03-23 Andrei Zmievski - - * Smarty_Compiler.class.php - NEWS: Fixed nested include infinite repeat bug. - -2001-03-23 Monte Ohrt - - * Smarty.class.php: fix version number - - * Smarty.class.php - NEWS: added optional HTML header to output - -2001-03-22 Andrei Zmievski - - * Smarty_Compiler.class.php: Fixed inclusion of dynamic files. - -2001-03-16 Andrei Zmievski - - * Smarty_Compiler.class.php: Fixing the config_load scoping. - - * Smarty_Compiler.class.php: making config variables global for now. - -2001-03-15 Andrei Zmievski - - * NEWS: *** empty log message *** - - * Smarty_Compiler.class.php: - * Includes are now always done via generated function call to protect - namespace. - * config_load now always uses global config object to improve - performance. - -2001-03-13 Monte Ohrt - - * docs.sgml: update math documentation with format attribute - -2001-03-11 Monte Ohrt - - * docs.sgml - NEWS - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php: update math function with format attribute - -2001-03-10 Andrei Zmievski - - * Smarty.addons.php: *** empty log message *** - - * NEWS - Smarty.addons.php - Smarty.class.php: Added html_select_time custom function. - -2001-03-08 Monte Ohrt - - * Smarty.class.php - Smarty_Compiler.class.php - NEWS - README - Smarty.addons.php: rename 1.3.1b to 1.3.1pl1 - - * NEWS - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php: update version numbers, changelog - - * Smarty.class.php - Smarty_Compiler.class.php: - moved _syntax_error to Smarty_Compiler.class.php - - * Smarty.class.php - docs.sgml: - missing _syntax_error function recovered. fixed minor syntax in docs - -2001-03-07 Monte Ohrt - - * QUICKSTART - README - Smarty.addons.php - Smarty.class.php - Smarty_Compiler.class.php - BUGS - INSTALL - NEWS: update everything to 1.3.1 - -2001-03-03 Monte Ohrt - - * Smarty_Compiler.class.php - Smarty.class.php: fixed bug with cached insert tags - -2001-03-02 Monte Ohrt - - * Smarty.class.php - Smarty_Compiler.class.php: - fix cache fuctions with separated compiled class - - * FAQ - NEWS - docs.sgml: update changelog - -2001-03-02 Andrei Zmievski - - * NEWS - Smarty_Compiler.class.php: Added 'first' and 'last' section properties. - -2001-03-02 Monte Ohrt - - * TODO: remove compiling separation TODO - - * Smarty_Compiler.class.php - Smarty.addons.php - Smarty.class.php: update function headers - - * templates/index.tpl - NEWS - Smarty.class.php - Smarty_Compiler.class.php - index.php: split out compiling code for faster execution - - * Smarty.class.php: fixed a few warning messages - - * Smarty.addons.php - Smarty.class.php - docs.sgml - NEWS: added fetch, unregister mod/fun, updated docs - -2001-03-01 Monte Ohrt - - * Smarty.addons.php: added "int" to available list - - * docs.sgml - FAQ - Smarty.class.php: update FAQ, add math functions & update documetation - - * index.php - Smarty.addons.php - Smarty.class.php - docs.sgml: fixed literal tags and other optional delimiters - -2001-02-26 Andrei Zmievski - - * NEWS - Smarty.class.php: - Added index_prev, index_next section properties and ability to - index by them. - - * NEWS - Smarty.addons.php - Smarty.class.php: Reverting the plugins patch - needs more thought. - - * Smarty.class.php: Fixing plugin loading. - -2001-02-23 Andrei Zmievski - - * Smarty.addons.php - Smarty.class.php - plugins/standard.plugin.php - NEWS: Added plugin functionality. - -2001-02-22 Monte Ohrt - - * docs.sgml - templates/index.tpl - NEWS - README - Smarty.class.php: fixed issue with php tags executed in literal blocks - -2001-02-21 Monte Ohrt - - * NEWS: update changelog for LGPL change - - * Smarty.class.php - docs.sgml - README - Smarty.addons.php: updated version numbers to 1.3.0 - - * NEWS - templates/index.tpl: update changelog, rearrange index.tpl file - -2001-02-21 Andrei Zmievski - - * NEWS - Smarty.class.php: *** empty log message *** - -2001-02-21 Monte Ohrt - - * docs.sgml: update parameters for is_cached and fetch - -2001-02-21 Andrei Zmievski - - * NEWS - Smarty.class.php: *** empty log message *** - -2001-02-21 Monte Ohrt - - * NEWS - Smarty.addons.php - docs.sgml: update docs, remove header function from addons - -2001-02-20 Monte Ohrt - - * FAQ - NEWS: update changelog - - * TODO: update todo - - * TODO: update todo list - - * Smarty.class.php: update php tag handling logic - -2001-02-19 Monte Ohrt - - * index.php - Config_File.class.php - FAQ - Smarty.class.php - docs.sgml: fixed - - * Smarty.addons.php: *** empty log message *** - -2001-02-13 Andrei Zmievski - - * TODO: *** empty log message *** - -2001-02-12 Andrei Zmievski - - * templates/index.tpl - Smarty.class.php: *** empty log message *** - -2001-02-10 Monte Ohrt - - * Smarty.class.php: remove unneeded preg_match - - * Smarty.class.php: remove comment - - * Smarty.class.php: updated php escape to handle -{/if} \ No newline at end of file diff --git a/data/module/Smarty/libs/internals/core.assemble_plugin_filepath.php b/data/module/Smarty/libs/internals/core.assemble_plugin_filepath.php deleted file mode 100644 index 690d3ddbc24..00000000000 --- a/data/module/Smarty/libs/internals/core.assemble_plugin_filepath.php +++ /dev/null @@ -1,67 +0,0 @@ -plugins_dir as $_plugin_dir) { - - $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; - - // see if path is relative - if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) { - $_relative_paths[] = $_plugin_dir; - // relative path, see if it is in the SMARTY_DIR - if (@is_readable(SMARTY_DIR . $_plugin_filepath)) { - $_return = SMARTY_DIR . $_plugin_filepath; - break; - } - } - // try relative to cwd (or absolute) - if (@is_readable($_plugin_filepath)) { - $_return = $_plugin_filepath; - break; - } - } - - if($_return === false) { - // still not found, try PHP include_path - if(isset($_relative_paths)) { - foreach ((array)$_relative_paths as $_plugin_dir) { - - $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; - - $_params = array('file_path' => $_plugin_filepath); - require_once(SMARTY_CORE_DIR . 'core.get_include_path.php'); - if(smarty_core_get_include_path($_params, $smarty)) { - $_return = $_params['new_file_path']; - break; - } - } - } - } - $_filepaths_cache[$_plugin_filename] = $_return; - return $_return; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.assign_smarty_interface.php b/data/module/Smarty/libs/internals/core.assign_smarty_interface.php deleted file mode 100644 index 7e65a73ec27..00000000000 --- a/data/module/Smarty/libs/internals/core.assign_smarty_interface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * Name: assign_smarty_interface
- * Purpose: assign the $smarty interface variable - * @param array Format: null - * @param Smarty - */ -function smarty_core_assign_smarty_interface($params, &$smarty) -{ - if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) { - return; - } - - $_globals_map = array('g' => 'HTTP_GET_VARS', - 'p' => 'HTTP_POST_VARS', - 'c' => 'HTTP_COOKIE_VARS', - 's' => 'HTTP_SERVER_VARS', - 'e' => 'HTTP_ENV_VARS'); - - $_smarty_vars_request = array(); - - foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) { - if (isset($_globals_map[$_c])) { - $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]); - } - } - $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']); - - $smarty->_smarty_vars['request'] = $_smarty_vars_request; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.create_dir_structure.php b/data/module/Smarty/libs/internals/core.create_dir_structure.php deleted file mode 100644 index 3eecc49723c..00000000000 --- a/data/module/Smarty/libs/internals/core.create_dir_structure.php +++ /dev/null @@ -1,79 +0,0 @@ -_dir_perms) && !is_dir($_new_dir)) { - $smarty->trigger_error("problem creating directory '" . $_new_dir . "'"); - return false; - } - $_new_dir .= '/'; - } - } -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.display_debug_console.php b/data/module/Smarty/libs/internals/core.display_debug_console.php deleted file mode 100644 index 1a80f39096a..00000000000 --- a/data/module/Smarty/libs/internals/core.display_debug_console.php +++ /dev/null @@ -1,61 +0,0 @@ - - * Name: display_debug_console
- * Purpose: display the javascript debug console window - * @param array Format: null - * @param Smarty - */ -function smarty_core_display_debug_console($params, &$smarty) -{ - // we must force compile the debug template in case the environment - // changed between separate applications. - - if(empty($smarty->debug_tpl)) { - // set path to debug template from SMARTY_DIR - $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl'; - if($smarty->security && is_file($smarty->debug_tpl)) { - $smarty->secure_dir[] = realpath($smarty->debug_tpl); - } - $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl'; - } - - $_ldelim_orig = $smarty->left_delimiter; - $_rdelim_orig = $smarty->right_delimiter; - - $smarty->left_delimiter = '{'; - $smarty->right_delimiter = '}'; - - $_compile_id_orig = $smarty->_compile_id; - $smarty->_compile_id = null; - - $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl); - if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) - { - ob_start(); - $smarty->_include($_compile_path); - $_results = ob_get_contents(); - ob_end_clean(); - } else { - $_results = ''; - } - - $smarty->_compile_id = $_compile_id_orig; - - $smarty->left_delimiter = $_ldelim_orig; - $smarty->right_delimiter = $_rdelim_orig; - - return $_results; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.get_include_path.php b/data/module/Smarty/libs/internals/core.get_include_path.php deleted file mode 100644 index 43432412b80..00000000000 --- a/data/module/Smarty/libs/internals/core.get_include_path.php +++ /dev/null @@ -1,44 +0,0 @@ - diff --git a/data/module/Smarty/libs/internals/core.get_microtime.php b/data/module/Smarty/libs/internals/core.get_microtime.php deleted file mode 100644 index f1a28e04256..00000000000 --- a/data/module/Smarty/libs/internals/core.get_microtime.php +++ /dev/null @@ -1,23 +0,0 @@ - diff --git a/data/module/Smarty/libs/internals/core.get_php_resource.php b/data/module/Smarty/libs/internals/core.get_php_resource.php deleted file mode 100644 index 786d4e78e88..00000000000 --- a/data/module/Smarty/libs/internals/core.get_php_resource.php +++ /dev/null @@ -1,80 +0,0 @@ -trusted_dir; - $smarty->_parse_resource_name($params, $smarty); - - /* - * Find out if the resource exists. - */ - - if ($params['resource_type'] == 'file') { - $_readable = false; - if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) { - $_readable = true; - } else { - // test for file in include_path - $_params = array('file_path' => $params['resource_name']); - require_once(SMARTY_CORE_DIR . 'core.get_include_path.php'); - if(smarty_core_get_include_path($_params, $smarty)) { - $_include_path = $_params['new_file_path']; - $_readable = true; - } - } - } else if ($params['resource_type'] != 'file') { - $_template_source = null; - $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0]) - && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0], - array($params['resource_name'], &$_template_source, &$smarty)); - } - - /* - * Set the error function, depending on which class calls us. - */ - if (method_exists($smarty, '_syntax_error')) { - $_error_funcc = '_syntax_error'; - } else { - $_error_funcc = 'trigger_error'; - } - - if ($_readable) { - if ($smarty->security) { - require_once(SMARTY_CORE_DIR . 'core.is_trusted.php'); - if (!smarty_core_is_trusted($params, $smarty)) { - $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted'); - return false; - } - } - } else { - $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable'); - return false; - } - - if ($params['resource_type'] == 'file') { - $params['php_resource'] = $params['resource_name']; - } else { - $params['php_resource'] = $_template_source; - } - return true; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.is_secure.php b/data/module/Smarty/libs/internals/core.is_secure.php deleted file mode 100644 index d54abd43227..00000000000 --- a/data/module/Smarty/libs/internals/core.is_secure.php +++ /dev/null @@ -1,59 +0,0 @@ -security || $smarty->security_settings['INCLUDE_ANY']) { - return true; - } - - if ($params['resource_type'] == 'file') { - $_rp = realpath($params['resource_name']); - if (isset($params['resource_base_path'])) { - foreach ((array)$params['resource_base_path'] as $curr_dir) { - if ( ($_cd = realpath($curr_dir)) !== false && - strncmp($_rp, $_cd, strlen($_cd)) == 0 && - substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { - return true; - } - } - } - if (!empty($smarty->secure_dir)) { - foreach ((array)$smarty->secure_dir as $curr_dir) { - if ( ($_cd = realpath($curr_dir)) !== false) { - if($_cd == $_rp) { - return true; - } elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 && - substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) { - return true; - } - } - } - } - } else { - // resource is not on local file system - return call_user_func_array( - $smarty->_plugins['resource'][$params['resource_type']][0][2], - array($params['resource_name'], &$smarty)); - } - - return false; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.is_trusted.php b/data/module/Smarty/libs/internals/core.is_trusted.php deleted file mode 100644 index 429973158d6..00000000000 --- a/data/module/Smarty/libs/internals/core.is_trusted.php +++ /dev/null @@ -1,47 +0,0 @@ -trusted_dir)) { - $_rp = realpath($params['resource_name']); - foreach ((array)$smarty->trusted_dir as $curr_dir) { - if (!empty($curr_dir) && is_readable ($curr_dir)) { - $_cd = realpath($curr_dir); - if (strncmp($_rp, $_cd, strlen($_cd)) == 0 - && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { - $_smarty_trusted = true; - break; - } - } - } - } - - } else { - // resource is not on local file system - $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3], - array($params['resource_name'], $smarty)); - } - - return $_smarty_trusted; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.load_plugins.php b/data/module/Smarty/libs/internals/core.load_plugins.php deleted file mode 100644 index 6db1dc51d2f..00000000000 --- a/data/module/Smarty/libs/internals/core.load_plugins.php +++ /dev/null @@ -1,125 +0,0 @@ -_plugins[$_type][$_name]; - - /* - * We do not load plugin more than once for each instance of Smarty. - * The following code checks for that. The plugin can also be - * registered dynamically at runtime, in which case template file - * and line number will be unknown, so we fill them in. - * - * The final element of the info array is a flag that indicates - * whether the dynamically registered plugin function has been - * checked for existence yet or not. - */ - if (isset($_plugin)) { - if (empty($_plugin[3])) { - if (!is_callable($_plugin[0])) { - $smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__); - } else { - $_plugin[1] = $_tpl_file; - $_plugin[2] = $_tpl_line; - $_plugin[3] = true; - if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */ - } - } - continue; - } else if ($_type == 'insert') { - /* - * For backwards compatibility, we check for insert functions in - * the symbol table before trying to load them as a plugin. - */ - $_plugin_func = 'insert_' . $_name; - if (function_exists($_plugin_func)) { - $_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false); - continue; - } - } - - $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name); - - if (! $_found = ($_plugin_file != false)) { - $_message = "could not load plugin file '$_type.$_name.php'\n"; - } - - /* - * If plugin file is found, it -must- provide the properly named - * plugin function. In case it doesn't, simply output the error and - * do not fall back on any other method. - */ - if ($_found) { - include_once $_plugin_file; - - $_plugin_func = 'smarty_' . $_type . '_' . $_name; - if (!function_exists($_plugin_func)) { - $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__); - continue; - } - } - /* - * In case of insert plugins, their code may be loaded later via - * 'script' attribute. - */ - else if ($_type == 'insert' && $_delayed_loading) { - $_plugin_func = 'smarty_' . $_type . '_' . $_name; - $_found = true; - } - - /* - * Plugin specific processing and error checking. - */ - if (!$_found) { - if ($_type == 'modifier') { - /* - * In case modifier falls back on using PHP functions - * directly, we only allow those specified in the security - * context. - */ - if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) { - $_message = "(secure mode) modifier '$_name' is not allowed"; - } else { - if (!function_exists($_name)) { - $_message = "modifier '$_name' is not implemented"; - } else { - $_plugin_func = $_name; - $_found = true; - } - } - } else if ($_type == 'function') { - /* - * This is a catch-all situation. - */ - $_message = "unknown tag - '$_name'"; - } - } - - if ($_found) { - $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true); - } else { - // output error - $smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__); - } - } -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.load_resource_plugin.php b/data/module/Smarty/libs/internals/core.load_resource_plugin.php deleted file mode 100644 index a7d37d1afc1..00000000000 --- a/data/module/Smarty/libs/internals/core.load_resource_plugin.php +++ /dev/null @@ -1,74 +0,0 @@ -_plugins['resource'][$params['type']]; - if (isset($_plugin)) { - if (!$_plugin[1] && count($_plugin[0])) { - $_plugin[1] = true; - foreach ($_plugin[0] as $_plugin_func) { - if (!is_callable($_plugin_func)) { - $_plugin[1] = false; - break; - } - } - } - - if (!$_plugin[1]) { - $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__); - } - - return; - } - - $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']); - $_found = ($_plugin_file != false); - - if ($_found) { /* - * If the plugin file is found, it -must- provide the properly named - * plugin functions. - */ - include_once($_plugin_file); - - /* - * Locate functions that we require the plugin to provide. - */ - $_resource_ops = array('source', 'timestamp', 'secure', 'trusted'); - $_resource_funcs = array(); - foreach ($_resource_ops as $_op) { - $_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op; - if (!function_exists($_plugin_func)) { - $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__); - return; - } else { - $_resource_funcs[] = $_plugin_func; - } - } - - $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true); - } -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.process_cached_inserts.php b/data/module/Smarty/libs/internals/core.process_cached_inserts.php deleted file mode 100644 index 1d78edd937a..00000000000 --- a/data/module/Smarty/libs/internals/core.process_cached_inserts.php +++ /dev/null @@ -1,71 +0,0 @@ -_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis', - $params['results'], $match); - list($cached_inserts, $insert_args) = $match; - - for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { - if ($smarty->debugging) { - $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $debug_start_time = smarty_core_get_microtime($_params, $smarty); - } - - $args = unserialize($insert_args[$i]); - $name = $args['name']; - - if (isset($args['script'])) { - $_params = array('resource_name' => $smarty->_dequote($args['script'])); - require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); - if(!smarty_core_get_php_resource($_params, $smarty)) { - return false; - } - $resource_type = $_params['resource_type']; - $php_resource = $_params['php_resource']; - - - if ($resource_type == 'file') { - $smarty->_include($php_resource, true); - } else { - $smarty->_eval($php_resource); - } - } - - $function_name = $smarty->_plugins['insert'][$name][0]; - if (empty($args['assign'])) { - $replace = $function_name($args, $smarty); - } else { - $smarty->assign($args['assign'], $function_name($args, $smarty)); - $replace = ''; - } - - $params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i])); - if ($smarty->debugging) { - $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $smarty->_smarty_debug_info[] = array('type' => 'insert', - 'filename' => 'insert_'.$name, - 'depth' => $smarty->_inclusion_depth, - 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time); - } - } - - return $params['results']; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.process_compiled_include.php b/data/module/Smarty/libs/internals/core.process_compiled_include.php deleted file mode 100644 index 904d5974528..00000000000 --- a/data/module/Smarty/libs/internals/core.process_compiled_include.php +++ /dev/null @@ -1,37 +0,0 @@ -_cache_including; - $smarty->_cache_including = true; - - $_return = $params['results']; - - foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) { - $smarty->_include($_include_file_path, true); - } - - foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) { - $_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s', - array(&$smarty, '_process_compiled_include_callback'), - $_return); - } - $smarty->_cache_including = $_cache_including; - return $_return; -} - -?> diff --git a/data/module/Smarty/libs/internals/core.read_cache_file.php b/data/module/Smarty/libs/internals/core.read_cache_file.php deleted file mode 100644 index c60e113a71a..00000000000 --- a/data/module/Smarty/libs/internals/core.read_cache_file.php +++ /dev/null @@ -1,101 +0,0 @@ -force_compile) { - // force compile enabled, always regenerate - return false; - } - - if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) { - list($params['results'], $smarty->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']]; - return true; - } - - if (!empty($smarty->cache_handler_func)) { - // use cache_handler function - call_user_func_array($smarty->cache_handler_func, - array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null)); - } else { - // use local cache file - $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']); - $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id); - $params['results'] = $smarty->_read_file($_cache_file); - } - - if (empty($params['results'])) { - // nothing to parse (error?), regenerate cache - return false; - } - - $_contents = $params['results']; - $_info_start = strpos($_contents, "\n") + 1; - $_info_len = (int)substr($_contents, 0, $_info_start - 1); - $_cache_info = unserialize(substr($_contents, $_info_start, $_info_len)); - $params['results'] = substr($_contents, $_info_start + $_info_len); - - if ($smarty->caching == 2 && isset ($_cache_info['expires'])){ - // caching by expiration time - if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) { - // cache expired, regenerate - return false; - } - } else { - // caching by lifetime - if ($smarty->cache_lifetime > -1 && (time() - $_cache_info['timestamp'] > $smarty->cache_lifetime)) { - // cache expired, regenerate - return false; - } - } - - if ($smarty->compile_check) { - $_params = array('get_source' => false, 'quiet'=>true); - foreach (array_keys($_cache_info['template']) as $_template_dep) { - $_params['resource_name'] = $_template_dep; - if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) { - // template file has changed, regenerate cache - return false; - } - } - - if (isset($_cache_info['config'])) { - $_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false, 'quiet'=>true); - foreach (array_keys($_cache_info['config']) as $_config_dep) { - $_params['resource_name'] = $_config_dep; - if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) { - // config file has changed, regenerate cache - return false; - } - } - } - } - - $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info); - - $smarty->_cache_info = $_cache_info; - return true; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.rm_auto.php b/data/module/Smarty/libs/internals/core.rm_auto.php deleted file mode 100644 index b251f649111..00000000000 --- a/data/module/Smarty/libs/internals/core.rm_auto.php +++ /dev/null @@ -1,71 +0,0 @@ - $params['auto_base'], - 'level' => 0, - 'exp_time' => $params['exp_time'] - ); - require_once(SMARTY_CORE_DIR . 'core.rmdir.php'); - $_res = smarty_core_rmdir($_params, $smarty); - } else { - $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']); - - if(isset($params['auto_source'])) { - if (isset($params['extensions'])) { - $_res = false; - foreach ((array)$params['extensions'] as $_extension) - $_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']); - } else { - $_res = $smarty->_unlink($_tname, $params['exp_time']); - } - } elseif ($smarty->use_sub_dirs) { - $_params = array( - 'dirname' => $_tname, - 'level' => 1, - 'exp_time' => $params['exp_time'] - ); - require_once(SMARTY_CORE_DIR . 'core.rmdir.php'); - $_res = smarty_core_rmdir($_params, $smarty); - } else { - // remove matching file names - $_handle = opendir($params['auto_base']); - $_res = true; - while (false !== ($_filename = readdir($_handle))) { - if($_filename == '.' || $_filename == '..') { - continue; - } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) { - $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']); - } - } - } - } - - return $_res; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.rmdir.php b/data/module/Smarty/libs/internals/core.rmdir.php deleted file mode 100644 index 2166c44d28a..00000000000 --- a/data/module/Smarty/libs/internals/core.rmdir.php +++ /dev/null @@ -1,54 +0,0 @@ - keep root) - * WARNING: no tests, it will try to remove what you tell it! - * - * @param string $dirname - * @param integer $level - * @param integer $exp_time - * @return boolean - */ - -// $dirname, $level = 1, $exp_time = null - -function smarty_core_rmdir($params, &$smarty) -{ - if(!isset($params['level'])) { $params['level'] = 1; } - if(!isset($params['exp_time'])) { $params['exp_time'] = null; } - - if($_handle = @opendir($params['dirname'])) { - - while (false !== ($_entry = readdir($_handle))) { - if ($_entry != '.' && $_entry != '..') { - if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) { - $_params = array( - 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry, - 'level' => $params['level'] + 1, - 'exp_time' => $params['exp_time'] - ); - smarty_core_rmdir($_params, $smarty); - } - else { - $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']); - } - } - } - closedir($_handle); - } - - if ($params['level']) { - return @rmdir($params['dirname']); - } - return (bool)$_handle; - -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.run_insert_handler.php b/data/module/Smarty/libs/internals/core.run_insert_handler.php deleted file mode 100644 index 71c3845080c..00000000000 --- a/data/module/Smarty/libs/internals/core.run_insert_handler.php +++ /dev/null @@ -1,71 +0,0 @@ -debugging) { - $_params = array(); - $_debug_start_time = smarty_core_get_microtime($_params, $smarty); - } - - if ($smarty->caching) { - $_arg_string = serialize($params['args']); - $_name = $params['args']['name']; - if (!isset($smarty->_cache_info['insert_tags'][$_name])) { - $smarty->_cache_info['insert_tags'][$_name] = array('insert', - $_name, - $smarty->_plugins['insert'][$_name][1], - $smarty->_plugins['insert'][$_name][2], - !empty($params['args']['script']) ? true : false); - } - return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5; - } else { - if (isset($params['args']['script'])) { - $_params = array('resource_name' => $smarty->_dequote($params['args']['script'])); - require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); - if(!smarty_core_get_php_resource($_params, $smarty)) { - return false; - } - - if ($_params['resource_type'] == 'file') { - $smarty->_include($_params['php_resource'], true); - } else { - $smarty->_eval($_params['php_resource']); - } - unset($params['args']['script']); - } - - $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0]; - $_content = $_funcname($params['args'], $smarty); - if ($smarty->debugging) { - $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $smarty->_smarty_debug_info[] = array('type' => 'insert', - 'filename' => 'insert_'.$params['args']['name'], - 'depth' => $smarty->_inclusion_depth, - 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); - } - - if (!empty($params['args']["assign"])) { - $smarty->assign($params['args']["assign"], $_content); - } else { - return $_content; - } - } -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.smarty_include_php.php b/data/module/Smarty/libs/internals/core.smarty_include_php.php deleted file mode 100644 index 30c6e76549d..00000000000 --- a/data/module/Smarty/libs/internals/core.smarty_include_php.php +++ /dev/null @@ -1,50 +0,0 @@ - $params['smarty_file']); - require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); - smarty_core_get_php_resource($_params, $smarty); - $_smarty_resource_type = $_params['resource_type']; - $_smarty_php_resource = $_params['php_resource']; - - if (!empty($params['smarty_assign'])) { - ob_start(); - if ($_smarty_resource_type == 'file') { - $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); - } else { - $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); - } - $smarty->assign($params['smarty_assign'], ob_get_contents()); - ob_end_clean(); - } else { - if ($_smarty_resource_type == 'file') { - $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); - } else { - $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); - } - } -} - - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.write_cache_file.php b/data/module/Smarty/libs/internals/core.write_cache_file.php deleted file mode 100644 index fa3cdd746d7..00000000000 --- a/data/module/Smarty/libs/internals/core.write_cache_file.php +++ /dev/null @@ -1,96 +0,0 @@ -_cache_info['timestamp'] = time(); - if ($smarty->cache_lifetime > -1){ - // expiration set - $smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime; - } else { - // cache will never expire - $smarty->_cache_info['expires'] = -1; - } - - // collapse nocache.../nocache-tags - if (preg_match_all('!\{(/?)nocache\:[0-9a-f]{32}#\d+\}!', $params['results'], $match, PREG_PATTERN_ORDER)) { - // remove everything between every pair of outermost noache.../nocache-tags - // and replace it by a single nocache-tag - // this new nocache-tag will be replaced by dynamic contents in - // smarty_core_process_compiled_includes() on a cache-read - - $match_count = count($match[0]); - $results = preg_split('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!', $params['results'], -1, PREG_SPLIT_DELIM_CAPTURE); - - $level = 0; - $j = 0; - for ($i=0, $results_count = count($results); $i < $results_count && $j < $match_count; $i++) { - if ($results[$i] == $match[0][$j]) { - // nocache tag - if ($match[1][$j]) { // closing tag - $level--; - unset($results[$i]); - } else { // opening tag - if ($level++ > 0) unset($results[$i]); - } - $j++; - } elseif ($level > 0) { - unset($results[$i]); - } - } - $params['results'] = implode('', $results); - } - $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials; - - // prepend the cache header info into cache file - $_cache_info = serialize($smarty->_cache_info); - $params['results'] = strlen($_cache_info) . "\n" . $_cache_info . $params['results']; - - if (!empty($smarty->cache_handler_func)) { - // use cache_handler function - call_user_func_array($smarty->cache_handler_func, - array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], $smarty->_cache_info['expires'])); - } else { - // use local cache file - - if(!@is_writable($smarty->cache_dir)) { - // cache_dir not writable, see if it exists - if(!@is_dir($smarty->cache_dir)) { - $smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); - return false; - } - $smarty->trigger_error('unable to write to $cache_dir \'' . realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR); - return false; - } - - $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']); - $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id); - $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true); - require_once(SMARTY_CORE_DIR . 'core.write_file.php'); - smarty_core_write_file($_params, $smarty); - return true; - } -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.write_compiled_include.php b/data/module/Smarty/libs/internals/core.write_compiled_include.php deleted file mode 100644 index c14adb5f42a..00000000000 --- a/data/module/Smarty/libs/internals/core.write_compiled_include.php +++ /dev/null @@ -1,91 +0,0 @@ -caching && \!\$this->_cache_including\)\: echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; endif;'; - $_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{/nocache\:(\\2)#(\\3)\}\'; endif;'; - - preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us', - $params['compiled_content'], $_match_source, PREG_SET_ORDER); - - // no nocache-parts found: done - if (count($_match_source)==0) return; - - // convert the matched php-code to functions - $_include_compiled = "_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n"; - $_include_compiled .= " compiled from " . strtr(urlencode($params['resource_name']), array('%2F'=>'/', '%3A'=>':')) . " */\n\n"; - - $_compile_path = $params['include_file_path']; - - $smarty->_cache_serials[$_compile_path] = $params['cache_serial']; - $_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>"; - - $_include_compiled .= $params['plugins_code']; - $_include_compiled .= "= 5.0) ? '_smarty' : 'this'; - for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) { - $_match =& $_match_source[$_i]; - $source = $_match[4]; - if ($this_varname == '_smarty') { - /* rename $this to $_smarty in the sourcecode */ - $tokens = token_get_all('\n"; - - $_params = array('filename' => $_compile_path, - 'contents' => $_include_compiled, 'create_dirs' => true); - - require_once(SMARTY_CORE_DIR . 'core.write_file.php'); - smarty_core_write_file($_params, $smarty); - return true; -} - - -?> diff --git a/data/module/Smarty/libs/internals/core.write_compiled_resource.php b/data/module/Smarty/libs/internals/core.write_compiled_resource.php deleted file mode 100644 index b902eff3cb4..00000000000 --- a/data/module/Smarty/libs/internals/core.write_compiled_resource.php +++ /dev/null @@ -1,35 +0,0 @@ -compile_dir)) { - // compile_dir not writable, see if it exists - if(!@is_dir($smarty->compile_dir)) { - $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); - return false; - } - $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); - return false; - } - - $_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true); - require_once(SMARTY_CORE_DIR . 'core.write_file.php'); - smarty_core_write_file($_params, $smarty); - return true; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/internals/core.write_file.php b/data/module/Smarty/libs/internals/core.write_file.php deleted file mode 100644 index 8a3a3b39843..00000000000 --- a/data/module/Smarty/libs/internals/core.write_file.php +++ /dev/null @@ -1,54 +0,0 @@ - $_dirname); - require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php'); - smarty_core_create_dir_structure($_params, $smarty); - } - - // write to tmp file, then rename it to avoid file locking race condition - $_tmp_file = tempnam($_dirname, 'wrt'); - - if (!($fd = @fopen($_tmp_file, 'wb'))) { - $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt'); - if (!($fd = @fopen($_tmp_file, 'wb'))) { - $smarty->trigger_error("problem writing temporary file '$_tmp_file'"); - return false; - } - } - - fwrite($fd, $params['contents']); - fclose($fd); - - if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) { - // On platforms and filesystems that cannot overwrite with rename() - // delete the file before renaming it -- because windows always suffers - // this, it is short-circuited to avoid the initial rename() attempt - @unlink($params['filename']); - @rename($_tmp_file, $params['filename']); - } - @chmod($params['filename'], $smarty->_file_perms); - - return true; -} - -/* vim: set expandtab: */ - -?> \ No newline at end of file diff --git a/data/module/Smarty/libs/plugins/block.textformat.php b/data/module/Smarty/libs/plugins/block.textformat.php deleted file mode 100644 index 8cd010acb4e..00000000000 --- a/data/module/Smarty/libs/plugins/block.textformat.php +++ /dev/null @@ -1,103 +0,0 @@ - - * Name: textformat
- * Purpose: format text a certain way with preset styles - * or custom wrap/indent settings
- * @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} - * (Smarty online manual) - * @param array - *
- * Params:   style: string (email)
- *           indent: integer (0)
- *           wrap: integer (80)
- *           wrap_char string ("\n")
- *           indent_char: string (" ")
- *           wrap_boundary: boolean (true)
- * 
- * @author Monte Ohrt - * @param string contents of the block - * @param Smarty clever simulation of a method - * @return string string $content re-formatted - */ -function smarty_block_textformat($params, $content, &$smarty) -{ - if (is_null($content)) { - return; - } - - $style = null; - $indent = 0; - $indent_first = 0; - $indent_char = ' '; - $wrap = 80; - $wrap_char = "\n"; - $wrap_cut = false; - $assign = null; - - foreach ($params as $_key => $_val) { - switch ($_key) { - case 'style': - case 'indent_char': - case 'wrap_char': - case 'assign': - $$_key = (string)$_val; - break; - - case 'indent': - case 'indent_first': - case 'wrap': - $$_key = (int)$_val; - break; - - case 'wrap_cut': - $$_key = (bool)$_val; - break; - - default: - $smarty->trigger_error("textformat: unknown attribute '$_key'"); - } - } - - if ($style == 'email') { - $wrap = 72; - } - - // split into paragraphs - $_paragraphs = preg_split('![\r\n][\r\n]!',$content); - $_output = ''; - - for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) { - if ($_paragraphs[$_x] == '') { - continue; - } - // convert mult. spaces & special chars to single space - $_paragraphs[$_x] = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'), array(' ',''), $_paragraphs[$_x]); - // indent first line - if($indent_first > 0) { - $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x]; - } - // wordwrap sentences - $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut); - // indent lines - if($indent > 0) { - $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]); - } - } - $_output = implode($wrap_char . $wrap_char, $_paragraphs); - - return $assign ? $smarty->assign($assign, $_output) : $_output; - -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/plugins/compiler.assign.php b/data/module/Smarty/libs/plugins/compiler.assign.php deleted file mode 100644 index abef377f8c4..00000000000 --- a/data/module/Smarty/libs/plugins/compiler.assign.php +++ /dev/null @@ -1,40 +0,0 @@ - - * Name: assign
- * Purpose: assign a value to a template variable - * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign} - * (Smarty online manual) - * @author Monte Ohrt (initial author) - * @author messju mohr (conversion to compiler function) - * @param string containing var-attribute and value-attribute - * @param Smarty_Compiler - */ -function smarty_compiler_assign($tag_attrs, &$compiler) -{ - $_params = $compiler->_parse_attrs($tag_attrs); - - if (!isset($_params['var'])) { - $compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING); - return; - } - - if (!isset($_params['value'])) { - $compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING); - return; - } - - return "\$this->assign({$_params['var']}, {$_params['value']});"; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/plugins/function.assign_debug_info.php b/data/module/Smarty/libs/plugins/function.assign_debug_info.php deleted file mode 100644 index 654049876a9..00000000000 --- a/data/module/Smarty/libs/plugins/function.assign_debug_info.php +++ /dev/null @@ -1,40 +0,0 @@ - - * Name: assign_debug_info
- * Purpose: assign debug info to the template
- * @author Monte Ohrt - * @param array unused in this plugin, this plugin uses {@link Smarty::$_config}, - * {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info} - * @param Smarty - */ -function smarty_function_assign_debug_info($params, &$smarty) -{ - $assigned_vars = $smarty->_tpl_vars; - ksort($assigned_vars); - if (@is_array($smarty->_config[0])) { - $config_vars = $smarty->_config[0]; - ksort($config_vars); - $smarty->assign("_debug_config_keys", array_keys($config_vars)); - $smarty->assign("_debug_config_vals", array_values($config_vars)); - } - - $included_templates = $smarty->_smarty_debug_info; - - $smarty->assign("_debug_keys", array_keys($assigned_vars)); - $smarty->assign("_debug_vals", array_values($assigned_vars)); - - $smarty->assign("_debug_tpls", $included_templates); -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/plugins/function.config_load.php b/data/module/Smarty/libs/plugins/function.config_load.php deleted file mode 100644 index db89f638c28..00000000000 --- a/data/module/Smarty/libs/plugins/function.config_load.php +++ /dev/null @@ -1,142 +0,0 @@ - - * Name: config_load
- * Purpose: load config file vars - * @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load} - * (Smarty online manual) - * @author Monte Ohrt - * @author messju mohr (added use of resources) - * @param array Format: - *
- * array('file' => required config file name,
- *       'section' => optional config file section to load
- *       'scope' => local/parent/global
- *       'global' => overrides scope, setting to parent if true)
- * 
- * @param Smarty - */ -function smarty_function_config_load($params, &$smarty) -{ - if ($smarty->debugging) { - $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $_debug_start_time = smarty_core_get_microtime($_params, $smarty); - } - - $_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null; - $_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null; - $_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global'; - $_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false; - - if (!isset($_file) || strlen($_file) == 0) { - $smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__); - } - - if (isset($_scope)) { - if ($_scope != 'local' && - $_scope != 'parent' && - $_scope != 'global') { - $smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__); - } - } else { - if ($_global) { - $_scope = 'parent'; - } else { - $_scope = 'local'; - } - } - - $_params = array('resource_name' => $_file, - 'resource_base_path' => $smarty->config_dir, - 'get_source' => false); - $smarty->_parse_resource_name($_params); - $_file_path = $_params['resource_type'] . ':' . $_params['resource_name']; - if (isset($_section)) - $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section); - else - $_compile_file = $smarty->_get_compile_path($_file_path); - - if($smarty->force_compile || !file_exists($_compile_file)) { - $_compile = true; - } elseif ($smarty->compile_check) { - $_params = array('resource_name' => $_file, - 'resource_base_path' => $smarty->config_dir, - 'get_source' => false); - $_compile = $smarty->_fetch_resource_info($_params) && - $_params['resource_timestamp'] > filemtime($_compile_file); - } else { - $_compile = false; - } - - if($_compile) { - // compile config file - if(!is_object($smarty->_conf_obj)) { - require_once SMARTY_DIR . $smarty->config_class . '.class.php'; - $smarty->_conf_obj = new $smarty->config_class(); - $smarty->_conf_obj->overwrite = $smarty->config_overwrite; - $smarty->_conf_obj->booleanize = $smarty->config_booleanize; - $smarty->_conf_obj->read_hidden = $smarty->config_read_hidden; - $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines; - } - - $_params = array('resource_name' => $_file, - 'resource_base_path' => $smarty->config_dir, - $_params['get_source'] = true); - if (!$smarty->_fetch_resource_info($_params)) { - return; - } - $smarty->_conf_obj->set_file_contents($_file, $_params['source_content']); - $_config_vars = array_merge($smarty->_conf_obj->get($_file), - $smarty->_conf_obj->get($_file, $_section)); - if(function_exists('var_export')) { - $_output = ''; - } else { - $_output = ''\\\'', '\\'=>'\\\\')) . '\'); ?>'; - } - $_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp'])); - require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php'); - smarty_core_write_compiled_resource($_params, $smarty); - } else { - include($_compile_file); - } - - if ($smarty->caching) { - $smarty->_cache_info['config'][$_file] = true; - } - - $smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars); - $smarty->_config[0]['files'][$_file] = true; - - if ($_scope == 'parent') { - $smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars); - $smarty->_config[1]['files'][$_file] = true; - } else if ($_scope == 'global') { - for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) { - $smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars); - $smarty->_config[$i]['files'][$_file] = true; - } - } - - if ($smarty->debugging) { - $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $smarty->_smarty_debug_info[] = array('type' => 'config', - 'filename' => $_file.' ['.$_section.'] '.$_scope, - 'depth' => $smarty->_inclusion_depth, - 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); - } - -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/plugins/function.counter.php b/data/module/Smarty/libs/plugins/function.counter.php deleted file mode 100644 index 1f26db5fb63..00000000000 --- a/data/module/Smarty/libs/plugins/function.counter.php +++ /dev/null @@ -1,80 +0,0 @@ - - * Name: counter
- * Purpose: print out a counter value - * @author Monte Ohrt - * @link http://smarty.php.net/manual/en/language.function.counter.php {counter} - * (Smarty online manual) - * @param array parameters - * @param Smarty - * @return string|null - */ -function smarty_function_counter($params, &$smarty) -{ - static $counters = array(); - - $name = (isset($params['name'])) ? $params['name'] : 'default'; - if (!isset($counters[$name])) { - $counters[$name] = array( - 'start'=>1, - 'skip'=>1, - 'direction'=>'up', - 'count'=>1 - ); - } - $counter =& $counters[$name]; - - if (isset($params['start'])) { - $counter['start'] = $counter['count'] = (int)$params['start']; - } - - if (!empty($params['assign'])) { - $counter['assign'] = $params['assign']; - } - - if (isset($counter['assign'])) { - $smarty->assign($counter['assign'], $counter['count']); - } - - if (isset($params['print'])) { - $print = (bool)$params['print']; - } else { - $print = empty($counter['assign']); - } - - if ($print) { - $retval = $counter['count']; - } else { - $retval = null; - } - - if (isset($params['skip'])) { - $counter['skip'] = $params['skip']; - } - - if (isset($params['direction'])) { - $counter['direction'] = $params['direction']; - } - - if ($counter['direction'] == "down") - $counter['count'] -= $counter['skip']; - else - $counter['count'] += $counter['skip']; - - return $retval; - -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/plugins/function.cycle.php b/data/module/Smarty/libs/plugins/function.cycle.php deleted file mode 100644 index 80378b7f96c..00000000000 --- a/data/module/Smarty/libs/plugins/function.cycle.php +++ /dev/null @@ -1,106 +0,0 @@ - - * Name: cycle
- * Date: May 3, 2002
- * Purpose: cycle through given values
- * Input: - * - name = name of cycle (optional) - * - values = comma separated list of values to cycle, - * or an array of values to cycle - * (this can be left out for subsequent calls) - * - reset = boolean - resets given var to true - * - print = boolean - print var or not. default is true - * - advance = boolean - whether or not to advance the cycle - * - delimiter = the value delimiter, default is "," - * - assign = boolean, assigns to template var instead of - * printed. - * - * Examples:
- *
- * {cycle values="#eeeeee,#d0d0d0d"}
- * {cycle name=row values="one,two,three" reset=true}
- * {cycle name=row}
- * 
- * @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle} - * (Smarty online manual) - * @author Monte Ohrt - * @author credit to Mark Priatel - * @author credit to Gerard - * @author credit to Jason Sweat - * @version 1.3 - * @param array - * @param Smarty - * @return string|null - */ -function smarty_function_cycle($params, &$smarty) -{ - static $cycle_vars; - - $name = (empty($params['name'])) ? 'default' : $params['name']; - $print = (isset($params['print'])) ? (bool)$params['print'] : true; - $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true; - $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false; - - if (!in_array('values', array_keys($params))) { - if(!isset($cycle_vars[$name]['values'])) { - $smarty->trigger_error("cycle: missing 'values' parameter"); - return; - } - } else { - if(isset($cycle_vars[$name]['values']) - && $cycle_vars[$name]['values'] != $params['values'] ) { - $cycle_vars[$name]['index'] = 0; - } - $cycle_vars[$name]['values'] = $params['values']; - } - - if (isset($params['delimiter'])) { - $cycle_vars[$name]['delimiter'] = $params['delimiter']; - } elseif (!isset($cycle_vars[$name]['delimiter'])) { - $cycle_vars[$name]['delimiter'] = ','; - } - - if(is_array($cycle_vars[$name]['values'])) { - $cycle_array = $cycle_vars[$name]['values']; - } else { - $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']); - } - - if(!isset($cycle_vars[$name]['index']) || $reset ) { - $cycle_vars[$name]['index'] = 0; - } - - if (isset($params['assign'])) { - $print = false; - $smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); - } - - if($print) { - $retval = $cycle_array[$cycle_vars[$name]['index']]; - } else { - $retval = null; - } - - if($advance) { - if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) { - $cycle_vars[$name]['index'] = 0; - } else { - $cycle_vars[$name]['index']++; - } - } - - return $retval; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/plugins/function.debug.php b/data/module/Smarty/libs/plugins/function.debug.php deleted file mode 100644 index 43452307bcb..00000000000 --- a/data/module/Smarty/libs/plugins/function.debug.php +++ /dev/null @@ -1,35 +0,0 @@ - - * Name: debug
- * Date: July 1, 2002
- * Purpose: popup debug window - * @link http://smarty.php.net/manual/en/language.function.debug.php {debug} - * (Smarty online manual) - * @author Monte Ohrt - * @version 1.0 - * @param array - * @param Smarty - * @return string output from {@link Smarty::_generate_debug_output()} - */ -function smarty_function_debug($params, &$smarty) -{ - if (isset($params['output'])) { - $smarty->assign('_smarty_debug_output', $params['output']); - } - require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php'); - return smarty_core_display_debug_console(null, $smarty); -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/plugins/function.eval.php b/data/module/Smarty/libs/plugins/function.eval.php deleted file mode 100644 index ff0472de250..00000000000 --- a/data/module/Smarty/libs/plugins/function.eval.php +++ /dev/null @@ -1,49 +0,0 @@ - - * Name: eval
- * Purpose: evaluate a template variable as a template
- * @link http://smarty.php.net/manual/en/language.function.eval.php {eval} - * (Smarty online manual) - * @author Monte Ohrt - * @param array - * @param Smarty - */ -function smarty_function_eval($params, &$smarty) -{ - - if (!isset($params['var'])) { - $smarty->trigger_error("eval: missing 'var' parameter"); - return; - } - - if($params['var'] == '') { - return; - } - - $smarty->_compile_source('evaluated template', $params['var'], $_var_compiled); - - ob_start(); - $smarty->_eval('?>' . $_var_compiled); - $_contents = ob_get_contents(); - ob_end_clean(); - - if (!empty($params['assign'])) { - $smarty->assign($params['assign'], $_contents); - } else { - return $_contents; - } -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/plugins/function.fetch.php b/data/module/Smarty/libs/plugins/function.fetch.php deleted file mode 100644 index d72c7b1f9e8..00000000000 --- a/data/module/Smarty/libs/plugins/function.fetch.php +++ /dev/null @@ -1,221 +0,0 @@ - - * Name: fetch
- * Purpose: fetch file, web or ftp data and display results - * @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch} - * (Smarty online manual) - * @author Monte Ohrt - * @param array - * @param Smarty - * @return string|null if the assign parameter is passed, Smarty assigns the - * result to a template variable - */ -function smarty_function_fetch($params, &$smarty) -{ - if (empty($params['file'])) { - $smarty->_trigger_fatal_error("[plugin] parameter 'file' cannot be empty"); - return; - } - - $content = ''; - if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) { - $_params = array('resource_type' => 'file', 'resource_name' => $params['file']); - require_once(SMARTY_CORE_DIR . 'core.is_secure.php'); - if(!smarty_core_is_secure($_params, $smarty)) { - $smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed'); - return; - } - - // fetch the file - if($fp = @fopen($params['file'],'r')) { - while(!feof($fp)) { - $content .= fgets ($fp,4096); - } - fclose($fp); - } else { - $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] . '\''); - return; - } - } else { - // not a local file - if(preg_match('!^http://!i',$params['file'])) { - // http fetch - if($uri_parts = parse_url($params['file'])) { - // set defaults - $host = $server_name = $uri_parts['host']; - $timeout = 30; - $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; - $agent = "Smarty Template Engine ".$smarty->_version; - $referer = ""; - $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; - $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; - $_is_proxy = false; - if(empty($uri_parts['port'])) { - $port = 80; - } else { - $port = $uri_parts['port']; - } - if(!empty($uri_parts['user'])) { - $user = $uri_parts['user']; - } - if(!empty($uri_parts['pass'])) { - $pass = $uri_parts['pass']; - } - // loop through parameters, setup headers - foreach($params as $param_key => $param_value) { - switch($param_key) { - case "file": - case "assign": - case "assign_headers": - break; - case "user": - if(!empty($param_value)) { - $user = $param_value; - } - break; - case "pass": - if(!empty($param_value)) { - $pass = $param_value; - } - break; - case "accept": - if(!empty($param_value)) { - $accept = $param_value; - } - break; - case "header": - if(!empty($param_value)) { - if(!preg_match('![\w\d-]+: .+!',$param_value)) { - $smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'"); - return; - } else { - $extra_headers[] = $param_value; - } - } - break; - case "proxy_host": - if(!empty($param_value)) { - $proxy_host = $param_value; - } - break; - case "proxy_port": - if(!preg_match('!\D!', $param_value)) { - $proxy_port = (int) $param_value; - } else { - $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'"); - return; - } - break; - case "agent": - if(!empty($param_value)) { - $agent = $param_value; - } - break; - case "referer": - if(!empty($param_value)) { - $referer = $param_value; - } - break; - case "timeout": - if(!preg_match('!\D!', $param_value)) { - $timeout = (int) $param_value; - } else { - $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'"); - return; - } - break; - default: - $smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'"); - return; - } - } - if(!empty($proxy_host) && !empty($proxy_port)) { - $_is_proxy = true; - $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); - } else { - $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); - } - - if(!$fp) { - $smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)"); - return; - } else { - if($_is_proxy) { - fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n"); - } else { - fputs($fp, "GET $uri HTTP/1.0\r\n"); - } - if(!empty($host)) { - fputs($fp, "Host: $host\r\n"); - } - if(!empty($accept)) { - fputs($fp, "Accept: $accept\r\n"); - } - if(!empty($agent)) { - fputs($fp, "User-Agent: $agent\r\n"); - } - if(!empty($referer)) { - fputs($fp, "Referer: $referer\r\n"); - } - if(isset($extra_headers) && is_array($extra_headers)) { - foreach($extra_headers as $curr_header) { - fputs($fp, $curr_header."\r\n"); - } - } - if(!empty($user) && !empty($pass)) { - fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n"); - } - - fputs($fp, "\r\n"); - while(!feof($fp)) { - $content .= fgets($fp,4096); - } - fclose($fp); - $csplit = preg_split("!\r\n\r\n!",$content,2); - - $content = $csplit[1]; - - if(!empty($params['assign_headers'])) { - $smarty->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0])); - } - } - } else { - $smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax"); - return; - } - } else { - // ftp fetch - if($fp = @fopen($params['file'],'r')) { - while(!feof($fp)) { - $content .= fgets ($fp,4096); - } - fclose($fp); - } else { - $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] .'\''); - return; - } - } - - } - - - if (!empty($params['assign'])) { - $smarty->assign($params['assign'],$content); - } else { - return $content; - } -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/plugins/function.html_checkboxes.php b/data/module/Smarty/libs/plugins/function.html_checkboxes.php deleted file mode 100644 index ed8ad7f33db..00000000000 --- a/data/module/Smarty/libs/plugins/function.html_checkboxes.php +++ /dev/null @@ -1,143 +0,0 @@ - - * Type: function
- * Name: html_checkboxes
- * Date: 24.Feb.2003
- * Purpose: Prints out a list of checkbox input types
- * Input:
- * - name (optional) - string default "checkbox" - * - values (required) - array - * - options (optional) - associative array - * - checked (optional) - array default not set - * - separator (optional) - ie
or   - * - output (optional) - the output next to each checkbox - * - assign (optional) - assign the output as an array to this variable - * Examples: - *
- * {html_checkboxes values=$ids output=$names}
- * {html_checkboxes values=$ids name='box' separator='
' output=$names} - * {html_checkboxes values=$ids checked=$checked separator='
' output=$names} - *
- * @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} - * (Smarty online manual) - * @author Christopher Kvarme - * @author credits to Monte Ohrt - * @version 1.0 - * @param array - * @param Smarty - * @return string - * @uses smarty_function_escape_special_chars() - */ -function smarty_function_html_checkboxes($params, &$smarty) -{ - require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); - - $name = 'checkbox'; - $values = null; - $options = null; - $selected = null; - $separator = ''; - $labels = true; - $output = null; - - $extra = ''; - - foreach($params as $_key => $_val) { - switch($_key) { - case 'name': - case 'separator': - $$_key = $_val; - break; - - case 'labels': - $$_key = (bool)$_val; - break; - - case 'options': - $$_key = (array)$_val; - break; - - case 'values': - case 'output': - $$_key = array_values((array)$_val); - break; - - case 'checked': - case 'selected': - $selected = array_map('strval', array_values((array)$_val)); - break; - - case 'checkboxes': - $smarty->trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING); - $options = (array)$_val; - break; - - case 'assign': - break; - - default: - if(!is_array($_val)) { - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; - } else { - $smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - } - } - - if (!isset($options) && !isset($values)) - return ''; /* raise error here? */ - - settype($selected, 'array'); - $_html_result = array(); - - if (isset($options)) { - - foreach ($options as $_key=>$_val) - $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); - - - } else { - foreach ($values as $_i=>$_key) { - $_val = isset($output[$_i]) ? $output[$_i] : ''; - $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); - } - - } - - if(!empty($params['assign'])) { - $smarty->assign($params['assign'], $_html_result); - } else { - return implode("\n",$_html_result); - } - -} - -function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) { - $_output = ''; - if ($labels) $_output .= ''; - $_output .= $separator; - - return $_output; -} - -?> diff --git a/data/module/Smarty/libs/plugins/function.html_image.php b/data/module/Smarty/libs/plugins/function.html_image.php deleted file mode 100644 index 9abae72ef76..00000000000 --- a/data/module/Smarty/libs/plugins/function.html_image.php +++ /dev/null @@ -1,142 +0,0 @@ - - * Name: html_image
- * Date: Feb 24, 2003
- * Purpose: format HTML tags for the image
- * Input:
- * - file = file (and path) of image (required) - * - height = image height (optional, default actual height) - * - width = image width (optional, default actual width) - * - basedir = base directory for absolute paths, default - * is environment variable DOCUMENT_ROOT - * - path_prefix = prefix for path output (optional, default empty) - * - * Examples: {html_image file="/images/masthead.gif"} - * Output: - * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image} - * (Smarty online manual) - * @author Monte Ohrt - * @author credits to Duda - wrote first image function - * in repository, helped with lots of functionality - * @version 1.0 - * @param array - * @param Smarty - * @return string - * @uses smarty_function_escape_special_chars() - */ -function smarty_function_html_image($params, &$smarty) -{ - require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); - - $alt = ''; - $file = ''; - $height = ''; - $width = ''; - $extra = ''; - $prefix = ''; - $suffix = ''; - $path_prefix = ''; - $server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; - $basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : ''; - foreach($params as $_key => $_val) { - switch($_key) { - case 'file': - case 'height': - case 'width': - case 'dpi': - case 'path_prefix': - case 'basedir': - $$_key = $_val; - break; - - case 'alt': - if(!is_array($_val)) { - $$_key = smarty_function_escape_special_chars($_val); - } else { - $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - - case 'link': - case 'href': - $prefix = ''; - $suffix = ''; - break; - - default: - if(!is_array($_val)) { - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; - } else { - $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - } - } - - if (empty($file)) { - $smarty->trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); - return; - } - - if (substr($file,0,1) == '/') { - $_image_path = $basedir . $file; - } else { - $_image_path = $file; - } - - if(!isset($params['width']) || !isset($params['height'])) { - if(!$_image_data = @getimagesize($_image_path)) { - if(!file_exists($_image_path)) { - $smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); - return; - } else if(!is_readable($_image_path)) { - $smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); - return; - } else { - $smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); - return; - } - } - if ($smarty->security && - ($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) && - (require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) && - (!smarty_core_is_secure($_params, $smarty)) ) { - $smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE); - } - - if(!isset($params['width'])) { - $width = $_image_data[0]; - } - if(!isset($params['height'])) { - $height = $_image_data[1]; - } - - } - - if(isset($params['dpi'])) { - if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) { - $dpi_default = 72; - } else { - $dpi_default = 96; - } - $_resize = $dpi_default/$params['dpi']; - $width = round($width * $_resize); - $height = round($height * $_resize); - } - - return $prefix . ''.$alt.'' . $suffix; -} - -/* vim: set expandtab: */ - -?> diff --git a/data/module/Smarty/libs/plugins/function.html_options.php b/data/module/Smarty/libs/plugins/function.html_options.php deleted file mode 100644 index cebadde4794..00000000000 --- a/data/module/Smarty/libs/plugins/function.html_options.php +++ /dev/null @@ -1,122 +0,0 @@ - - * Name: html_options
- * Input:
- * - name (optional) - string default "select" - * - values (required if no options supplied) - array - * - options (required if no values supplied) - associative array - * - selected (optional) - string default not set - * - output (required if not options supplied) - array - * Purpose: Prints the list of