package.xml0000664000175000017500000005361212654071112011305 0ustar janjan Horde_SessionHandler pear.horde.org Horde Session Handler API Horde_SessionHandler defines an API for implementing custom session handlers for PHP. Chuck Hagenbuch chuck chuck@horde.org yes Jan Schneider jan jan@horde.org yes Michael Slusarz slusarz slusarz@horde.org yes 2016-02-02 2.2.7 2.2.0 stable stable LGPL-2.1 * [jan] Mark PHP 7 as supported. 5.3.0 8.0.0alpha1 8.0.0alpha1 1.7.0 Horde_Exception pear.horde.org 2.0.0 3.0.0alpha1 3.0.0alpha1 Horde_Support pear.horde.org 2.0.0 3.0.0alpha1 3.0.0alpha1 Horde_Db pear.horde.org 2.2.0 3.0.0alpha1 3.0.0alpha1 Horde_HashTable pear.horde.org 1.1.0 2.0.0alpha1 2.0.0alpha1 Horde_Log pear.horde.org 2.0.0 3.0.0alpha1 3.0.0alpha1 Horde_Mongo pear.horde.org 1.0.0 2.0.0alpha1 2.0.0alpha1 Horde_Test pear.horde.org 2.1.0 3.0.0alpha1 3.0.0alpha1 0.0.1 0.0.1 alpha alpha 2003-07-03 LGPL-2.1 Initial release as a PEAR package 0.0.2 0.0.2 alpha alpha 2004-01-01 LGPL-2.1 * Renamed memcached.php to memcache.php for consistency with other drivers and applications. * Add support for separate read and write DB servers for the sql driver. * Add support for locking in the memcache driver (Bug #2913). 2006-05-08 0.0.3 0.0.3 alpha alpha LGPL-2.1 * Fixed garbage collection checking for SQL backends. * Memcache driver no longer uses value in session.gc_maxlifetime as the lifetime value. * Add memcache caching support to all other backends. * Only write to backend if session data has changed * Locking in memcache driver implemented via memcache itself * Support LDAPv3 in the LDAP backend (Bug #5864) * Converted to package.xml 2.0 for pear.horde.org 1.0.0alpha1 1.0.0 alpha alpha 2011-03-08 LGPL-2.1 * First alpha release for Horde 4. * Added 'File' driver. * Abstracted storage-specific code into 'Storage' drivers. * Removed LDAP driver * Abstracted memcache persistent-backend code into 'Stack' driver. * Renamed 'none' driver to 'Builtin'. * Now throws Horde_SessionHandler_Exception. * Split driver code into abstract class. * Use horde/Db to access SQL databases. * Do not rely on Horde::logMessage(). * Removed Horde-specific session counting script. 1.0.0beta1 1.0.0 beta beta 2011-03-16 LGPL-2.1 * Workaround PHP < 5.2.6 (broken stream handling) (Bug #9644). 1.0.0RC1 1.0.0 beta beta 2011-03-22 LGPL-2.1 * First release candidate for Horde 4. 1.0.0RC2 1.0.0 beta beta 2011-03-29 LGPL-2.1 * Second release candidate for Horde 4. 1.0.0 1.0.0 stable stable 2011-04-06 LGPL-2.1 * First stable release for Horde 4. 1.0.1 1.0.0 stable stable 2011-09-20 LGPL-2.1 * [mms] Call garbage collection before grabbing list of active sessions. * [mms] Fix obtaining session information from more than one session. 1.0.2 1.0.0 stable stable 2011-10-11 LGPL-2.1 * [jan] Use portable queries in SQL session handler (Bug #10574). 1.0.3 1.0.0 stable stable 2012-01-31 LGPL-2.1 * [jan] Fix transaction error when reconnecting to database during session writing (Bug #10906). 1.0.4 1.0.0 stable stable 2012-02-22 LGPL-2.1 * [jan] Don't start transaction more than once in SQL driver (Bug #10978). 1.0.5 1.0.0 stable stable 2012-04-10 LGPL-2.1 * [jan] Fix SQL driver with PostgreSQL. * [jan] Fix reading sessions with the External driver. * [jan] Add test suite. 2.0.0alpha1 1.0.0 alpha stable 2012-07-06 LGPL-2.1 * First alpha release for Horde 5. 2.0.0beta1 1.0.0 beta stable 2012-07-19 LGPL-2.1 * First beta release for Horde 5. 2.0.0beta2 1.0.0 beta stable 2012-10-12 LGPL-2.1 * [jan] Fix track_lifetime setting for Memcache driver (Bug #11444). 2.0.0 1.0.0 stable stable 2012-10-30 LGPL-2.1 * First stable release for Horde 5. 2.0.1 1.0.0 stable stable 2012-11-19 LGPL-2.1 * [mms] Use new Horde_Test layout. 2.0.2 1.0.0 stable stable 2013-03-05 LGPL-2.1 * [jan] Fix unit tests. 2.1.0 1.0.0 stable stable 2013-05-06 LGPL-2.1 * [mms] Add MongoDB driver. 2.2.0 2.2.0 stable stable 2013-06-04 LGPL-2.1 * [mms] Horde_Memcache driver is now deprecated in favor of the Horde_HashTable driver. * [mms] Added Horde_HashTable driver. * [mms] Implement logging for all storage drivers. 2.2.1 2.2.0 stable stable 2013-07-23 LGPL-2.1 * [mms] More robust way of checking for locking in a HashTable instance. 2.2.2 2.2.0 stable stable 2013-08-22 LGPL-2.1 * [mms] Fix rare race condition when creating file-based session data for the first time (Thomas Jarosch <thomas.jarosch@intra2net.com; Bug #12557). 2.2.3 2.2.0 stable stable 2013-08-27 LGPL-2.1 * [mms] Fix session ID tracking for the Hashtable driver. 2.2.4 2.2.0 stable stable 2014-03-03 LGPL-2.1 * [mms] More efficient reading of session data from filesystem in file driver. 2.2.5 2.2.0 stable stable 2015-10-20 LGPL-2.1 * [jan] Catch possible exceptions in shutdown methods. * [jan] Test environment improvements. 2.2.6 2.2.0 stable stable 2016-01-05 LGPL-2.1 * [jan] Fix updating large files in Oracle backends. * [jan] Fix writing big session data to Oracle (Bug #14175). 2.2.7 2.2.0 stable stable 2016-02-02 LGPL-2.1 * [jan] Mark PHP 7 as supported. Horde_SessionHandler-2.2.7/doc/Horde/SessionHandler/COPYING0000664000175000017500000005764612654071111021472 0ustar janjan GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler/Storage/Builtin.php0000664000175000017500000000420612654071111024143 0ustar janjan * @category Horde * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @package SessionHandler */ class Horde_SessionHandler_Storage_Builtin extends Horde_SessionHandler_Storage { /** * Directory with session files. * * @var string */ protected $_path; /** */ public function __construct(array $params = array()) { parent::__construct($params); $this->_path = session_save_path(); if (!$this->_path) { $this->_path = sys_get_temp_dir(); } } /** */ public function open($save_path = null, $session_name = null) { } /** */ public function close() { } /** */ public function read($id) { return strval(@file_get_contents($this->_path . '/sess_' . $id)); } /** */ public function write($id, $session_data) { return false; } /** */ public function destroy($id) { return false; } /** */ public function gc($maxlifetime = 300) { return false; } /** */ public function getSessionIDs() { $sessions = array(); try { $di = new DirectoryIterator($this->_path); } catch (UnexpectedValueException $e) { return $sessions; } foreach ($di as $val) { /* Make sure we're dealing with files that start with sess_. */ if ($val->isFile() && (strpos($val->getFilename(), 'sess_') === 0)) { $sessions[] = substr($val->getFilename(), strlen('sess_')); } } return $sessions; } } Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler/Storage/External.php0000664000175000017500000000473012654071111024321 0ustar janjan * @category Horde * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @package SessionHandler */ class Horde_SessionHandler_Storage_External extends Horde_SessionHandler_Storage { /** * Constructor. * * @param array $params Required parameters: *
     * close - (callback) See session_set_save_handler().
     * destroy - (callback) See session_set_save_handler().
     * gc - (callback) See session_set_save_handler().
     * open - (callback) See session_set_save_handler().
     * read - (callback) See session_set_save_handler().
     * write - (callback) See session_set_save_handler().
     * 
* * @throws InvalidArgumentException */ public function __construct(array $params = array()) { foreach (array('open', 'close', 'read', 'write', 'destroy', 'gc') as $val) { if (!isset($params[$val])) { throw new InvalidArgumentException('Missing parameter: ' . $val); } } parent::__construct($params); } /** */ public function open($save_path = null, $session_name = null) { return call_user_func($this->_params['open'], $save_path, $session_name); } /** */ public function close() { return call_user_func($this->_params['close']); } /** */ public function read($id) { return call_user_func($this->_params['read'], $id); } /** */ public function write($id, $session_data) { return call_user_func($this->_params['write'], $id, $session_data); } /** */ public function destroy($id) { return call_user_func($this->_params['destroy'], $id); } /** */ public function gc($maxlifetime = 300) { return call_user_func($this->_params['gc'], $maxlifetime); } /** * Get a list of the valid session identifiers. * * @throws Horde_SessionHandler_Exception */ public function getSessionIDs() { throw new Horde_SessionHandler_Exception('Driver does not support listing session IDs.'); } } Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler/Storage/File.php0000664000175000017500000000761312654071111023421 0ustar janjan * @category Horde * @copyright 2010-2016 Horde LLC * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @package SessionHandler */ class Horde_SessionHandler_Storage_File extends Horde_SessionHandler_Storage { /* File prefix. */ const PREFIX = 'horde_sh_'; /** * File stream. * * @var resource */ protected $_fp; /** * Constructor. * * @param array $params Parameters: *
     * path - (string) [REQUIRED] The path to save the files.
     * 
* * @throws InvalidArgumentException */ public function __construct(array $params = array()) { if (!isset($params['path'])) { throw new InvalidArgumentException('Missing path parameter.'); } $params['path'] = rtrim($params['path'], '/'); parent::__construct($params); } /** */ public function open($save_path = null, $session_name = null) { return true; } /** * Open the file stream connection. * * @param string $id The session ID. */ protected function _open($id) { if (!empty($this->_fp)) { return; } $filename = $this->_params['path'] . '/' . self::PREFIX . $id; $this->_fp = fopen($filename, 'c+'); if ($this->_fp) { flock($this->_fp, LOCK_EX); } } /** */ public function close() { if (!empty($this->_fp)) { flock($this->_fp, LOCK_UN); fclose($this->_fp); unset($this->_fp); } return true; } /** */ public function read($id) { $this->_open($id); if (!$this->_fp) { return false; } $data = ''; rewind($this->_fp); while (!feof($this->_fp)) { $data .= fread($this->_fp, 16384); } return $data; } /** */ public function write($id, $session_data) { $this->_open($id); if (!$this->_fp) { return false; } fseek($this->_fp, 0); ftruncate($this->_fp, 0); fwrite($this->_fp, $session_data); return true; } /** */ public function destroy($id) { $this->close(); $filename = $this->_params['path'] . '/' . self::PREFIX . $id; return @unlink($filename); } /** */ public function gc($maxlifetime = 300) { try { $di = new DirectoryIterator($this->_params['path']); } catch (UnexpectedValueException $e) { return false; } $expire_time = time() - $maxlifetime; foreach ($di as $val) { if ($val->isFile() && (strpos($val->getFilename(), self::PREFIX) === 0) && ($val->getMTime() < $expire_time)) { @unlink($val->getPathname()); } } return true; } /** */ public function getSessionIDs() { $ids = array(); try { $di = new DirectoryIterator($this->_params['path']); foreach ($di as $val) { if ($val->isFile() && (strpos($val->getFilename(), self::PREFIX) === 0)) { $ids[] = substr($val->getFilename(), strlen(self::PREFIX)); } } } catch (UnexpectedValueException $e) {} return $ids; } } Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler/Storage/Hashtable.php0000664000175000017500000001275012654071111024433 0ustar janjan * @category Horde * @copyright 2013-2016 Horde LLC * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @package SessionHandler * @since 2.2.0 */ class Horde_SessionHandler_Storage_Hashtable extends Horde_SessionHandler_Storage { /** * HashTable object. * * @var Horde_HashTable */ protected $_hash; /** * Current session ID. * * @var string */ protected $_id; /** * The ID used for session tracking. * * @var string */ protected $_trackID = 'horde_sessions_track_ht'; /** * Constructor. * * @param array $params Parameters: *
     *   - hashtable: (Horde_HashTable) [REQUIRED] A Horde_HashTable object.
     *   - track: (boolean) Track active sessions?
     * 
*/ public function __construct(array $params = array()) { if (empty($params['hashtable'])) { throw new InvalidArgumentException('Missing hashtable parameter.'); } if (!$params['hashtable']->locking) { throw new InvalidArgumentException('HashTable object must support locking.'); } $this->_hash = $params['hashtable']; unset($params['hashtable']); parent::__construct($params); if (!empty($this->_params['track']) && (!rand(0, 999))) { register_shutdown_function(array($this, 'trackGC')); } } /** */ public function open($save_path = null, $session_name = null) { } /** */ public function close() { if (isset($this->_id)) { $this->_hash->unlock($this->_id); } } /** */ public function read($id) { if (!$this->readonly) { $this->_hash->lock($id); } if (($result = $this->_hash->get($id)) === false) { if (!$this->readonly) { $this->_hash->unlock($id); } $result = ''; } elseif (!$this->readonly) { $this->_id = $id; } return $result; } /** */ public function write($id, $session_data) { $base = array_filter(array( 'timeout' => ini_get('session.gc_maxlifetime') )); if (!empty($this->_params['track'])) { // Do a replace - the only time it should fail is if we are // writing a session for the first time. If that is the case, // update the session tracker. $res = $this->_hash->set($id, $session_data, array_merge($base, array( 'replace' => true, ))); $track = !$res; } else { $res = $track = false; } if (!$res && !$this->_hash->set($id, $session_data, $base)) { return false; } if ($track) { $this->_hash->lock($this->_trackID); $ids = $this->_getTrackIds(); $ids[$id] = 1; $this->_hash->set($this->_trackID, json_encode($ids)); $this->_hash->unlock($this->_trackID); } return true; } /** */ public function destroy($id) { $res = $this->_hash->delete($id); $this->_hash->unlock($id); if ($res === false) { return false; } if (!empty($this->_params['track'])) { $this->_hash->lock($this->_trackID); if ($ids = $this->_getTrackIds()) { unset($ids[$id]); $this->_hash->set($this->_trackID, json_encode($ids)); } $this->_hash->unlock($this->_trackID); } return true; } /** */ public function gc($maxlifetime = 300) { return true; } /** */ public function getSessionIDs() { if (empty($this->_params['track'])) { throw new Horde_SessionHandler_Exception('Memcache session tracking not enabled.'); } $this->trackGC(); return array_keys($this->_getTrackIds()); } /** * Do garbage collection for session tracking information. */ public function trackGC() { try { $this->_hash->lock($this->_trackID); if ($ids = $this->_getTrackIds()) { $alter = false; foreach (array_keys($ids) as $key) { if (!$this->_hash->exists($key)) { unset($ids[$key]); $alter = true; } } if ($alter) { $this->_hash->set($this->_trackID, json_encode($ids)); } } $this->_hash->unlock($this->_trackID); } catch (Horde_HashTable_Exception $e) { } } /** * Get the tracking IDs. * * @return array Tracking IDs. */ protected function _getTrackIds() { if ((($ids = $this->_hash->get($this->_trackID)) === false) || !($ids = json_decode($ids, true))) { $ids = array(); } return $ids; } } Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler/Storage/Memcache.php0000664000175000017500000001320412654071111024235 0ustar janjan * @author Michael Slusarz * @category Horde * @copyright 2005-2016 Horde LLC * @deprecated Use HashTable driver instead * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @package SessionHandler */ class Horde_SessionHandler_Storage_Memcache extends Horde_SessionHandler_Storage { /** * Memcache object. * * @var Horde_Memcache */ protected $_memcache; /** * Current session ID. * * @var string */ protected $_id; /** * The ID used for session tracking. * * @var string */ protected $_trackID = 'horde_memcache_sessions_track'; /** * Constructor. * * @param array $params Parameters: *
     * 'memcache' - (Horde_Memcache) [REQUIRED] A memcache object.
     * 'track' - (boolean) Track active sessions?
     * 'track_lifetime' - (integer) The number of seconds after which tracked
     *                    sessions will be treated as expired.
     * 
* * @throws InvalidArgumentException */ public function __construct(array $params = array()) { if (empty($params['memcache'])) { throw new InvalidArgumentException('Missing memcache argument.'); } $this->_memcache = $params['memcache']; unset($params['memcache']); parent::__construct($params); if (empty($this->_params['track_lifetime'])) { $this->_params['track_lifetime'] = ini_get('session.gc_maxlifetime'); } if (!empty($this->_params['track']) && (substr(time(), -3) === '000')) { register_shutdown_function(array($this, 'trackGC')); } } /** */ public function open($save_path = null, $session_name = null) { return true; } /** */ public function close() { if (isset($this->_id)) { $this->_memcache->unlock($this->_id); } return true; } /** */ public function read($id) { if (!$this->readonly) { $this->_memcache->lock($id); } $result = $this->_memcache->get($id); if ($result === false) { if (!$this->readonly) { $this->_memcache->unlock($id); } $result = ''; } elseif (!$this->readonly) { $this->_id = $id; } return $result; } /** */ public function write($id, $session_data) { if (!empty($this->_params['track'])) { // Do a replace - the only time it should fail is if we are // writing a session for the first time. If that is the case, // update the session tracker. $res = $this->_memcache->replace($id, $session_data); $track = !$res; } else { $res = $track = false; } if (!$res && !$this->_memcache->set($id, $session_data)) { return false; } if ($track) { $this->_memcache->lock($this->_trackID); $ids = $this->_memcache->get($this->_trackID); if ($ids === false) { $ids = array(); } $ids[$id] = time(); $this->_memcache->set($this->_trackID, $ids); $this->_memcache->unlock($this->_trackID); } return true; } /** */ public function destroy($id) { $result = $this->_memcache->delete($id); $this->_memcache->unlock($id); if ($result === false) { return false; } if (!empty($this->_params['track'])) { $this->_memcache->lock($this->_trackID); $ids = $this->_memcache->get($this->_trackID); if ($ids !== false) { unset($ids[$id]); $this->_memcache->set($this->_trackID, $ids); } $this->_memcache->unlock($this->_trackID); } return true; } /** */ public function gc($maxlifetime = 300) { // Memcache does its own garbage collection. return true; } /** */ public function getSessionIDs() { if (empty($this->_params['track'])) { throw new Horde_SessionHandler_Exception('Memcache session tracking not enabled.'); } $this->trackGC(); $ids = $this->_memcache->get($this->_trackID); return ($ids === false) ? array() : array_keys($ids); } /** * Do garbage collection for session tracking information. */ public function trackGC() { $this->_memcache->lock($this->_trackID); $ids = $this->_memcache->get($this->_trackID); if (empty($ids)) { $this->_memcache->unlock($this->_trackID); return; } $tstamp = time() - $this->_params['track_lifetime']; $alter = false; foreach ($ids as $key => $val) { if ($tstamp > $val) { unset($ids[$key]); $alter = true; } } if ($alter) { $this->_memcache->set($this->_trackID, $ids); } $this->_memcache->unlock($this->_trackID); } } Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler/Storage/Mongo.php0000664000175000017500000001534712654071111023624 0ustar janjan * @category Horde * @copyright 2013-2016 Horde LLC * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @package SessionHandler */ class Horde_SessionHandler_Storage_Mongo extends Horde_SessionHandler_Storage implements Horde_Mongo_Collection_Index { /* Field names. */ const DATA = 'data'; const LOCK = 'lock'; const MODIFIED = 'ts'; const SID = 'sid'; /** * MongoCollection object for the storage table. * * @var MongoCollection */ protected $_db; /** * Is the session locked. * * @var boolean */ protected $_locked = false; /** * Indices list. * * @var array */ protected $_indices = array( 'index_ts' => array( self::MODIFIED => 1 ) ); /** * Constructor. * * @param array $params Parameters: *
     * collection: (string) The collection to store data in.
     * mongo_db: (Horde_Mongo_Client) [REQUIRED] The Mongo client object.
     * 
*/ public function __construct(array $params = array()) { if (!isset($params['mongo_db'])) { throw new InvalidArgumentException('Missing mongo_db parameter.'); } parent::__construct(array_merge(array( 'collection' => 'horde_sessionhandler' ), $params)); $this->_db = $this->_params['mongo_db']->selectCollection(null, $this->_params['collection']); } /** */ public function open($save_path = null, $session_name = null) { return true; } /** */ public function close() { if ($this->_locked) { try { $this->_db->update(array( self::SID => $this->_locked ), array( '$unset' => array(self::LOCK => '') )); } catch (MongoException $e) {} $this->_locked = false; } return true; } /** */ public function read($id) { /* Check for session existence. Unfortunately needed because * we need findAndModify() for its atomicity for locking, but this * atomicity means we can't tell the difference between a * non-existent session and a locked session. */ $exists = $this->_db->count(array( self::SID => $id )); $exist_check = false; $i = 0; /* Set a maximum unlocking time, to prevent runaway PHP processes. */ $max = ini_get('max_execution_time') * 10; while (true) { $data = array( self::LOCK => time(), self::SID => $id ); /* This call will either create the session if it doesn't exist, * or will update the current session and lock it if not already * locked. If a session exists, and is locked, $res will contain * an empty set and we need to sleep and wait for lock to be * removed. */ $res = $this->_db->findAndModify(array( self::SID => $id, self::LOCK => array( '$exists' => $exist_check ) ), array($data), array( self::DATA => true ), array( 'update' => array( '$set' => $data ), 'upsert' => !$exists )); if (!$exists || isset($res[self::DATA])) { break; } /* After a second, check the timestamp to determine if this is * a stale session. This can prevent long waits on a busted PHP * process. */ if ($i == 10) { $res = $this->_db->findOne(array( self::SID => $id ), array( self::LOCK => true )); $max = isset($res[self::LOCK]) ? ((time() - $res[self::LOCK]) * 10) : $i; } if (++$i >= $max) { $exist_check = true; } else { /* Sleep for 0.1 second before trying again. */ usleep(100000); } } $this->_locked = $id; return isset($res[self::DATA]) ? $res[self::DATA]->bin : ''; } /** */ public function write($id, $session_data) { /* Update/insert session data. */ try { $this->_db->update(array( self::SID => $id ), array( self::DATA => new MongoBinData($session_data, MongoBinData::BYTE_ARRAY), self::MODIFIED => time(), self::SID => $id ), array( 'upsert' => true )); $this->_locked = false; } catch (MongoException $e) { return false; } return true; } /** */ public function destroy($id) { try { $this->_db->remove(array( self::SID => $id )); return true; } catch (MongoException $e) {} return false; } /** */ public function gc($maxlifetime = 300) { try { $this->_db->remove(array( self::MODIFIED => array( '$lt' => (time() - $maxlifetime) ) )); return true; } catch (MongoException $e) {} return false; } /** */ public function getSessionIDs() { $ids = array(); try { $cursor = $this->_db->find(array( self::MODIFIED => array( '$gte' => (time() - ini_get('session.gc_maxlifetime')) ) ), array(self::SID)); foreach ($cursor as $val) { $ids[] = $val[self::SID]; } } catch (MongoException $e) {} return $ids; } /* Horde_Mongo_Collection_Index methods. */ /** */ public function checkMongoIndices() { return $this->_params['mongo_db']->checkIndices($this->_db, $this->_indices); } /** */ public function createMongoIndices() { $this->_params['mongo_db']->createIndices($this->_db, $this->_indices); } } Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler/Storage/Sql.php0000664000175000017500000001343412654071111023277 0ustar janjan * CREATE TABLE horde_sessionhandler ( * VARCHAR(32) NOT NULL, * session_lastmodified INT NOT NULL, * session_data LONGBLOB, * -- Or, on some DBMS systems: * -- session_data IMAGE, * * PRIMARY KEY (session_id) * ); * * CREATE INDEX session_lastmodified_idx ON horde_sessionhandler (session_lastmodified); * * * Copyright 2002-2016 Horde LLC (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you * did not receive this file, see http://www.horde.org/licenses/lgpl21. * * @author Mike Cochrane * @category Horde * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @package SessionHandler */ class Horde_SessionHandler_Storage_Sql extends Horde_SessionHandler_Storage { /** * Handle for the current database connection. * * @var Horde_Db_Adapter */ protected $_db; /** * Constructor. * * @param array $params Parameters: *
     * 'db' - (Horde_Db_Adapter) [REQUIRED] The DB instance.
     * 'table' - (string) The name of the sessions table.
     *           DEFAULT: 'horde_sessionhandler'
     * 
* * @throws InvalidArgumentException */ public function __construct(array $params = array()) { if (!isset($params['db'])) { throw new InvalidArgumentException('Missing db parameter.'); } $this->_db = $params['db']; unset($params['db']); parent::__construct(array_merge(array( 'table' => 'horde_sessionhandler' ), $params)); } /** */ public function open($save_path = null, $session_name = null) { return true; } /** */ public function close() { /* Close any open transactions. */ if ($this->_db->transactionStarted()) { try { $this->_db->commitDbTransaction(); } catch (Horde_Db_Exception $e) { return false; } } return true; } /** */ public function read($id) { /* Begin a transaction. */ // TODO: Rowlocking in Mysql if (!$this->_db->transactionStarted()) { $this->_db->beginDbTransaction(); } /* Build query. */ $query = sprintf('SELECT session_data FROM %s WHERE session_id = ?', $this->_params['table']); $values = array($id); /* Execute the query. */ try { $columns = $this->_db->columns($this->_params['table']); return $columns['session_data']->binaryToString( $this->_db->selectValue($query, $values)); } catch (Horde_Db_Exception $e) { return ''; } } /** */ public function write($id, $session_data) { if (!$this->_db->isActive()) { $this->_db->reconnect(); $this->_db->beginDbTransaction(); } /* Check if session exists. */ try { $exists = $this->_db->selectValue( sprintf('SELECT 1 FROM %s WHERE session_id = ?', $this->_params['table']), array($id)); } catch (Horde_Db_Exception $e) { return false; } /* Update or insert session data. */ $values = array( 'session_data' => new Horde_Db_Value_Binary($session_data), 'session_lastmodified' => time() ); try { if ($exists) { $this->_db->updateBlob( $this->_params['table'], $values, array('session_id = ?', array($id)) ); } else { $this->_db->insertBlob( $this->_params['table'], array_merge(array('session_id' => $id), $values) ); } $this->_db->commitDbTransaction(); } catch (Horde_Db_Exception $e) { try { $this->_db->rollbackDbTransaction(); } catch (Horde_Db_Exception $e) { } return false; } return true; } /** */ public function destroy($id) { /* Build the SQL query. */ $query = sprintf('DELETE FROM %s WHERE session_id = ?', $this->_params['table']); $values = array($id); /* Execute the query. */ try { $this->_db->delete($query, $values); $this->_db->commitDbTransaction(); } catch (Horde_Db_Exception $e) { return false; } return true; } /** */ public function gc($maxlifetime = 300) { /* Build the SQL query. */ $query = sprintf('DELETE FROM %s WHERE session_lastmodified < ?', $this->_params['table']); $values = array(time() - $maxlifetime); /* Execute the query. */ try { $this->_db->delete($query, $values); } catch (Horde_Db_Exception $e) { return false; } return true; } /** */ public function getSessionIDs() { $this->open(); /* Build the SQL query. */ $query = sprintf('SELECT session_id FROM %s' . ' WHERE session_lastmodified >= ?', $this->_params['table']); $values = array(time() - ini_get('session.gc_maxlifetime')); /* Execute the query. */ try { return $this->_db->selectValues($query, $values); } catch (Horde_Db_Exception $e) { return array(); } } } Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler/Storage/Stack.php0000664000175000017500000000706412654071111023607 0ustar janjan * @category Horde * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @package SessionHandler */ class Horde_SessionHandler_Storage_Stack extends Horde_SessionHandler_Storage { /** * Stack of storage objects. * * @var array */ protected $_stack = array(); /** * Constructor. * * @param array $params Parameters: *
     * stack - (array) [REQUIRED] A list of storage objects to loop
     *         through, in order of priority. The last entry is considered
     *         the "master" server.
     * 
* * @throws InvalidArgumentException */ public function __construct(array $params = array()) { if (!isset($params['stack'])) { throw new InvalidArgumentException('Missing stack parameter.'); } $this->_stack = $params['stack']; unset($params['stack']); parent::__construct($params); } /** */ public function open($save_path = null, $session_name = null) { foreach ($this->_stack as $val) { if (!$val->open($save_path, $session_name)) { return false; } } return true; } /** */ public function close() { foreach ($this->_stack as $val) { if (!$val->close()) { return false; } } return true; } /** */ public function read($id) { foreach ($this->_stack as $val) { $result = $val->read($id); if ($result === false) { break; } } return $result; } /** */ public function write($id, $session_data) { /* Do writes in *reverse* order - it is OK if a write to one of the * non-master backends fails. */ $master = true; foreach (array_reverse($this->_stack) as $val) { $result = $val->write($id, $session_data); if ($result === false) { if ($master) { return false; } /* Attempt to invalidate cache if write failed. */ $val->destroy($id); } $master = false; } return true; } /** */ public function destroy($id) { /* Only report success from master. */ $master = $success = true; foreach (array_reverse($this->_stack) as $val) { $result = $val->destroy($id); if ($master && ($result === false)) { $success = false; } $master = false; } return $success; } /** */ public function gc($maxlifetime = 300) { /* Only report GC results from master. */ foreach ($this->_stack as $val) { $result = $val->gc($maxlifetime); } return $result; } /** */ public function getSessionIDs() { /* Grab session ID list from the master. */ $ob = end($this->_stack); return $ob->getSessionIDs(); } } Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler/Exception.php0000664000175000017500000000067612654071111023076 0ustar janjan * @category Horde * @package SessionHandler */ class Horde_SessionHandler_Exception extends Horde_Exception_Wrapped { } Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler/Storage.php0000664000175000017500000000664312654071111022544 0ustar janjan * @category Horde * @copyright 2002-2016 Horde LLC * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @package SessionHandler */ abstract class Horde_SessionHandler_Storage { /** * Access session read-only? * * @var boolean */ public $readonly = false; /** * Hash containing connection parameters. * * @var array */ protected $_params = array(); /** * Constructor. * * @param array $params Configuration parameters. */ public function __construct(array $params = array()) { $this->_params = array_merge($this->_params, $params); } /** * Storage objects do not support serialization. */ public function __sleep() { throw new LogicException('SessionHandler storage objects do not support serialization.'); } /** * Set the logger object. * * @deprecated */ public function setLogger(Horde_Log_Logger $log) { } /** * Open the backend. * * @param string $save_path The path to the session object. * @param string $session_name The name of the session. * * @throws Horde_SessionHandler_Exception */ abstract public function open($save_path = null, $session_name = null); /** * Close the backend. * * @throws Horde_SessionHandler_Exception */ abstract public function close(); /** * Read the data for a particular session identifier from the backend. * * @param string $id The session identifier. * * @return string The session data. */ abstract public function read($id); /** * Write session data to the backend. * * @param string $id The session identifier. * @param string $session_data The session data. * * @return boolean True on success, false otherwise. */ abstract public function write($id, $session_data); /** * Destroy the data for a particular session identifier in the backend. * This method should only be called internally by PHP via * session_set_save_handler(). * * @param string $id The session identifier. * * @return boolean True on success, false otherwise. */ abstract public function destroy($id); /** * Garbage collect stale sessions from the backend. * This method should only be called internally by PHP via * session_set_save_handler(). * * @param integer $maxlifetime The maximum age of a session. * * @return boolean True on success, false otherwise. */ abstract public function gc($maxlifetime = 300); /** * Get a list of the valid session identifiers. * * @return array A list of valid session identifiers. * @throws Horde_SessionHandler_Exception */ abstract public function getSessionIDs(); } Horde_SessionHandler-2.2.7/lib/Horde/SessionHandler.php0000664000175000017500000002043212654071111021130 0ustar janjan * @category Horde * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @package SessionHandler */ class Horde_SessionHandler { /** * If true, indicates the session data has changed. * * @var boolean */ public $changed = false; /** * Has a connection been made to the backend? * * @var boolean */ protected $_connected = false; /** * A logger instance. * * @var Horde_Log_Logger */ protected $_logger; /** * Configuration parameters. * * @var array */ protected $_params = array(); /** * Initial session data signature. * * @var string */ protected $_sig; /** * The storage object. * * @var Horde_SessionHandler_Storage */ protected $_storage; /** * Constructor. * * @param Horde_SessionHandler_Storage $storage The storage object. * @param array $params Configuration parameters: *
     *   - logger: (Horde_Log_Logger) A logger instance.
     *             DEFAULT: No logging
     *   - no_md5: (boolean) If true, does not do MD5 signatures of the
     *             session to determine if the session has changed (calling
     *             code is responsible for marking $changed as true when the
     *             session data has changed).
     *             DEFAULT: false
     *   - noset: (boolean) If true, don't set the save handler.
     *            DEFAULT: false
     *   - parse: (callback) A callback function that parses session
     *            information into an array. Is passed the raw session data
     *            as the only argument; expects either false or an array of
     *            session data as a return.
     *            DEFAULT: No
     * 
*/ public function __construct(Horde_SessionHandler_Storage $storage, array $params = array()) { $params = array_merge($this->_params, $params); $this->_logger = isset($params['logger']) ? $params['logger'] : new Horde_Support_Stub(); unset($params['logger']); $this->_params = $params; $this->_storage = $storage; if (empty($this->_params['noset'])) { ini_set('session.save_handler', 'user'); session_set_save_handler( array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc') ); } } /** * Destructor. */ public function __destruct() { /* This is necessary as of PHP 5.0.5 because objects are not available * when the write() handler is called at the end of a session * access. */ session_write_close(); } /** * Open the backend. * * @param string $save_path The path to the session object. * @param string $session_name The name of the session. * * @return boolean True on success, false otherwise. */ public function open($save_path = null, $session_name = null) { if (!$this->_connected) { try { $this->_storage->open($save_path, $session_name); } catch (Horde_SessionHandler_Exception $e) { $this->_logger->log($e, 'ERR'); return false; } $this->_connected = true; } return true; } /** * Close the backend. * * @return boolean True on success, false otherwise. */ public function close() { try { $this->_storage->close(); } catch (Horde_SessionHandler_Exception $e) { $this->_logger->log($e, 'ERR'); } $this->_connected = false; return true; } /** * Read the data for a particular session identifier from the backend. * This method should only be called internally by PHP via * session_set_save_handler(). * * @param string $id The session identifier. * * @return string The session data. */ public function read($id) { if (($result = $this->_storage->read($id)) == '') { $this->_logger->log('Error retrieving session data (' . $id . ')', 'DEBUG'); } else { $this->_logger->log('Read session data (' . $id . ')', 'DEBUG'); } if (empty($this->_params['no_md5'])) { $this->_sig = md5($result); } return $result; } /** * Write session data to the backend. * This method should only be called internally by PHP via * session_set_save_handler(). * * @param string $id The session identifier. * @param string $session_data The session data. * * @return boolean True on success, false otherwise. */ public function write($id, $session_data) { if ($this->changed || (empty($this->_params['no_md5']) && ($this->_sig != md5($session_data)))) { if (!$this->_storage->write($id, $session_data)) { $this->_logger->log('Failed to write session data (' . $id . ')', 'DEBUG'); return false; } $this->_logger->log('Wrote session data (' . $id . ')', 'DEBUG'); } return true; } /** * Destroy the data for a particular session identifier in the backend. * This method should only be called internally by PHP via * session_set_save_handler(). * * @param string $id The session identifier. * * @return boolean True on success, false otherwise. */ public function destroy($id) { if ($this->_storage->destroy($id)) { $this->_logger->log('Session data destroyed (' . $id . ')', 'DEBUG'); return true; } $this->_logger->log('Failed to destroy session data (' . $id . ')', 'DEBUG'); return false; } /** * Garbage collect stale sessions from the backend. * This method should only be called internally by PHP via * session_set_save_handler(). * * @param integer $maxlifetime The maximum age of a session. * * @return boolean True on success, false otherwise. */ public function gc($maxlifetime = 300) { return $this->_storage->gc($maxlifetime); } /** * Get a list of the valid session identifiers. * * @return array A list of valid session identifiers. * @throws Horde_SessionHandler_Exception */ public function getSessionIDs() { return $this->_storage->getSessionIDs(); } /** * Returns a list of authenticated users and data about their session. * * @return array For authenticated users, the sessionid as a key and the * session information as value. If no parsing function * was provided, will always return an empty array. * @throws Horde_SessionHandler_Exception */ public function getSessionsInfo() { $info = array(); if (empty($this->_params['parse']) || !is_callable($this->_params['parse'])) { return $info; } /* Explicitly do garbage collection call here to make sure session * data is correct. */ $this->gc(ini_get('session.gc_maxlifetime')); $sessions = $this->getSessionIDs(); $this->_storage->readonly = true; foreach ($sessions as $id) { try { $data = $this->read($id); $this->close(); } catch (Horde_SessionHandler_Exception $e) { continue; } $data = call_user_func($this->_params['parse'], $data); if ($data !== false) { $info[$id] = $data; } } $this->_storage->readonly = false; return $info; } } Horde_SessionHandler-2.2.7/migration/Horde/SessionHandler/1_horde_sessionhandler_base_tables.php0000664000175000017500000000136212654071111031322 0ustar janjantables())) { $t = $this->createTable('horde_sessionhandler', array('autoincrementKey' => false)); $t->column('session_id', 'string', array('limit' => 32, 'null' => false)); $t->column('session_lastmodified', 'integer', array('null' => false)); $t->column('session_data', 'binary'); $t->primaryKey(array('session_id')); $t->end(); $this->addIndex('horde_sessionhandler', array('session_lastmodified')); } } public function down() { $this->dropTable('horde_sessionhandler'); } } ././@LongLink000 144 0003735 LHorde_SessionHandler-2.2.7/migration/Horde/SessionHandler/2_horde_sessionhandler_fix_blob_length.phpHorde_SessionHandler-2.2.7/migration/Horde/SessionHandler/2_horde_sessionhandler_fix_blob_length.php0000664000175000017500000000035512654071111032205 0ustar janjanchangeColumn('horde_sessionhandler', 'session_data', 'binary'); } public function down() { } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/Sql/Pdo/MysqlTest.php0000664000175000017500000000221112654071112026167 0ustar janjan * @category Horde * @package SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_Sql_Pdo_MysqlTest extends Horde_SessionHandler_Storage_Sql_Base { public static function setUpBeforeClass() { if (!extension_loaded('pdo') || !in_array('mysql', PDO::getAvailableDrivers())) { self::$reason = 'No mysql extension or no mysql PDO driver'; return; } $config = self::getConfig('SESSIONHANDLER_SQL_PDO_MYSQL_TEST_CONFIG', dirname(__FILE__) . '/../../..'); if ($config && !empty($config['sessionhandler']['sql']['pdo_mysql'])) { self::$db = new Horde_Db_Adapter_Pdo_Mysql($config['sessionhandler']['sql']['pdo_mysql']); parent::setUpBeforeClass(); } else { self::$reason = 'No pdo_mysql configuration'; } } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/Sql/Pdo/PgsqlTest.php0000664000175000017500000000221112654071112026150 0ustar janjan * @category Horde * @package SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_Sql_Pdo_PgsqlTest extends Horde_SessionHandler_Storage_Sql_Base { public static function setUpBeforeClass() { if (!extension_loaded('pdo') || !in_array('pgsql', PDO::getAvailableDrivers())) { self::$reason = 'No pgsql extension or no pgsql PDO driver'; return; } $config = self::getConfig('SESSIONHANDLER_SQL_PDO_PGSQL_TEST_CONFIG', dirname(__FILE__) . '/../../..'); if ($config && !empty($config['sessionhandler']['sql']['pdo_pgsql'])) { self::$db = new Horde_Db_Adapter_Pdo_Pgsql($config['sessionhandler']['sql']['pdo_pgsql']); parent::setUpBeforeClass(); } else { self::$reason = 'No pdo_pgsql configuration'; } } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/Sql/Pdo/SqliteTest.php0000664000175000017500000000137112654071112026331 0ustar janjan * @category Horde * @package SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_Sql_Pdo_SqliteTest extends Horde_SessionHandler_Storage_Sql_Base { public static function setUpBeforeClass() { $factory_db = new Horde_Test_Factory_Db(); try { self::$db = $factory_db->create(); parent::setUpBeforeClass(); } catch (Horde_Test_Exception $e) { self::$reason = 'Sqlite not available'; } } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/Sql/Base.php0000664000175000017500000000470312654071112024362 0ustar janjan * @category Horde * @package Horde_SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_Sql_Base extends Horde_SessionHandler_Storage_Base { protected static $db; protected static $migrator; protected static $reason; public function testWrite() { $this->_write(); } /** * @depends testWrite */ public function testRead() { $this->_read(); } /** * @depends testWrite */ public function testReopen() { $this->_reopen(); } /** * @depends testWrite */ public function testList() { $this->_list(); } /** * @depends testList */ public function testDestroy() { $this->_destroy(); } /** * @depends testDestroy */ public function testGc() { $this->_gc(); } public static function setUpBeforeClass() { parent::setUpBeforeClass(); $logger = new Horde_Log_Logger(new Horde_Log_Handler_Cli()); //self::$db->setLogger($logger); $dir = dirname(__FILE__) . '/../../../../../migration/Horde/SessionHandler'; if (!is_dir($dir)) { error_reporting(E_ALL & ~E_DEPRECATED); $dir = PEAR_Config::singleton() ->get('data_dir', null, 'pear.horde.org') . '/Horde_SessionHandler/migration'; error_reporting(E_ALL | E_STRICT); } self::$migrator = new Horde_Db_Migration_Migrator( self::$db, null,//$logger, array('migrationsPath' => $dir, 'schemaTableName' => 'horde_sh_schema_info')); self::$migrator->up(); self::$handler = new Horde_SessionHandler_Storage_Sql(array('db' => self::$db)); } public static function tearDownAfterClass() { if (self::$migrator) { self::$migrator->down(); } if (self::$db) { self::$db->disconnect(); } self::$db = self::$migrator = null; parent::tearDownAfterClass(); } public function setUp() { if (!self::$db) { $this->markTestSkipped(self::$reason); } } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/Sql/MysqliTest.php0000664000175000017500000000203312654071112025620 0ustar janjan * @category Horde * @package SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_Sql_MysqliTest extends Horde_SessionHandler_Storage_Sql_Base { public static function setUpBeforeClass() { if (!extension_loaded('mysqli')) { self::$reason = 'No mysqli extension'; return; } $config = self::getConfig('SESSIONHANDLER_SQL_MYSQLI_TEST_CONFIG', dirname(__FILE__) . '/../..'); if (!$config || empty($config['sessionhandler']['sql']['mysqli'])) { self::$reason = 'No mysqli configuration'; return; } self::$db = new Horde_Db_Adapter_Mysqli($config['sessionhandler']['sql']['mysqli']); parent::setUpBeforeClass(); } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/Sql/MysqlTest.php0000664000175000017500000000202312654071112025446 0ustar janjan * @category Horde * @package SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_Sql_MysqlTest extends Horde_SessionHandler_Storage_Sql_Base { public static function setUpBeforeClass() { if (!extension_loaded('mysql')) { self::$reason = 'No mysql extension'; return; } $config = self::getConfig('SESSIONHANDLER_SQL_MYSQL_TEST_CONFIG', dirname(__FILE__) . '/../..'); if (!$config || empty($config['sessionhandler']['sql']['mysql'])) { self::$reason = 'No mysql configuration'; return; } self::$db = new Horde_Db_Adapter_Mysql($config['sessionhandler']['sql']['mysql']); parent::setUpBeforeClass(); } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/Sql/Oci8Test.php0000664000175000017500000000275712654071112025161 0ustar janjan * @category Horde * @package SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_Sql_Oci8Test extends Horde_SessionHandler_Storage_Sql_Base { public static function setUpBeforeClass() { if (!extension_loaded('oci8')) { self::$reason = 'No oci8 extension'; return; } $config = self::getConfig('SESSIONHANDLER_SQL_OCI8_TEST_CONFIG', dirname(__FILE__) . '/../..'); if (!$config || empty($config['sessionhandler']['sql']['oci8'])) { self::$reason = 'No oci8 configuration'; return; } self::$db = new Horde_Db_Adapter_Oci8($config['sessionhandler']['sql']['oci8']); parent::setUpBeforeClass(); } public function testLargeWrite() { $this->assertTrue(self::$handler->open(self::$dir, 'sessiondata')); $this->assertSame('', self::$handler->read('largedata')); // Write twice to test both INSERT and UPDATE. $this->assertTrue(self::$handler->write('largedata', str_repeat('x', 4001))); $this->assertTrue(self::$handler->write('largedata', str_repeat('x', 4001))); $this->assertTrue(self::$handler->destroy('largedata')); } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/Base.php0000664000175000017500000000516212654071112023623 0ustar janjan * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 * @category Horde * @package Horde_SessionHandler * @subpackage UnitTests */ class Horde_SessionHandler_Storage_Base extends Horde_Test_Case { protected static $handler; protected static $dir; protected function _write() { $this->assertTrue(self::$handler->open(self::$dir, 'sessionname')); $this->assertSame('', self::$handler->read('sessionid')); $this->assertTrue(self::$handler->write('sessionid', 'sessiondata')); } protected function _read() { $this->assertEquals('sessiondata', self::$handler->read('sessionid')); } protected function _reopen() { $this->assertTrue(self::$handler->close()); $this->assertTrue(self::$handler->open(self::$dir, 'sessionname')); $this->assertEquals('sessiondata', self::$handler->read('sessionid')); $this->assertTrue(self::$handler->close()); } protected function _list() { $this->assertTrue(self::$handler->close()); $this->assertTrue(self::$handler->open(self::$dir, 'sessionname')); self::$handler->read('sessionid2'); $this->assertTrue(self::$handler->write('sessionid2', 'sessiondata2')); /* List while session is active. */ $ids = self::$handler->getSessionIDs(); sort($ids); $this->assertEquals(array('sessionid', 'sessionid2'), $ids); $this->assertTrue(self::$handler->close()); /* List while session is inactive. */ $this->assertTrue(self::$handler->open(self::$dir, 'sessionname')); $ids = self::$handler->getSessionIDs(); sort($ids); $this->assertEquals(array('sessionid', 'sessionid2'), $ids); $this->assertTrue(self::$handler->close()); } protected function _destroy() { $this->assertTrue(self::$handler->open(self::$dir, 'sessionname')); self::$handler->read('sessionid2'); $this->assertTrue(self::$handler->destroy('sessionid2')); $this->assertEquals(array('sessionid'), self::$handler->getSessionIDs()); } protected function _gc() { $this->assertTrue(self::$handler->open(self::$dir, 'sessionname')); $this->assertTrue(self::$handler->gc(-1)); $this->assertEquals(array(), self::$handler->getSessionIDs()); } public static function setUpBeforeClass() { self::$dir = Horde_Util::createTempDir(); } public static function tearDownAfterClass() { self::$handler = null; } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/BuiltinTest.php0000664000175000017500000000657212654071112025225 0ustar janjan * @category Horde * @package Horde_SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_BuiltinTest extends Horde_SessionHandler_Storage_Base { public function testWrite() { session_name('sessionname'); session_id('sessionid'); @session_start(); $this->assertEmpty($_SESSION); $_SESSION['sessiondata'] = 'foo'; session_write_close(); } /** * @depends testWrite */ public function testRead() { $this->assertEquals('sessiondata|s:3:"foo";', self::$handler->read('sessionid')); } /** * @depends testWrite */ public function testReopen() { session_write_close(); session_name('sessionname'); session_id('sessionid'); @session_start(); $this->assertEquals('foo', $_SESSION['sessiondata']); session_write_close(); } /** * @depends testWrite */ public function testList() { session_write_close(); session_name('sessionname'); session_id('sessionid2'); @session_start(); $_SESSION['sessiondata2'] = 'foo'; /* List while session is active. */ $ids = self::$handler->getSessionIDs(); sort($ids); $this->assertEquals(array('sessionid', 'sessionid2'), $ids); session_write_close(); /* List while session is inactive. */ $ids = self::$handler->getSessionIDs(); sort($ids); $this->assertEquals(array('sessionid', 'sessionid2'), $ids); } /** * @depends testList */ public function testDestroy() { session_name('sessionname'); session_id('sessionid2'); @session_start(); session_destroy(); $this->assertEquals(array('sessionid'), self::$handler->getSessionIDs()); } /** * @depends testDestroy */ public function testGc() { $this->probability = ini_get('session.gc_probability'); $this->divisor = ini_get('session.gc_divisor'); $this->maxlifetime = ini_get('session.gc_maxlifetime'); ini_set('session.gc_probability', 100); ini_set('session.gc_divisor', 1); ini_set('session.gc_maxlifetime', -1); session_name('sessionname'); @session_start(); $this->assertEquals(array(), self::$handler->getSessionIDs()); } public static function setUpBeforeClass() { parent::setUpBeforeClass(); ini_set('session.save_path', self::$dir); self::$handler = new Horde_SessionHandler_Storage_Builtin(array('path' => self::$dir)); } public function tearDown() { if (isset($this->probability)) { ini_set('session.gc_probability', $this->probability); ini_set('session.gc_divisor', $this->divisor); ini_set('session.gc_maxlifetime', $this->maxlifetime); } } public static function tearDownAfterClass() { parent::tearDownAfterClass(); unset($_SESSION); session_destroy(); session_name(ini_get('session.name')); } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/ExternalTest.php0000664000175000017500000000524512654071112025375 0ustar janjan * @category Horde * @package Horde_SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_ExternalTest extends Horde_SessionHandler_Storage_Base { public function testWrite() { $this->_write(); } /** * @depends testWrite */ public function testRead() { $this->_read(); } /** * @depends testWrite */ public function testReopen() { $this->_reopen(); } /** * The external driver doesn't support listing, so test for existing * sessions manually. * * @depends testWrite */ public function testList() { self::$handler->close(); self::$handler->open(self::$dir, 'sessionname'); self::$handler->read('sessionid2'); self::$handler->write('sessionid2', 'sessiondata2'); /* List while session is active. */ $this->assertNotEmpty(self::$handler->read('sessionid')); $this->assertNotEmpty(self::$handler->read('sessionid2')); self::$handler->close(); /* List while session is inactive. */ self::$handler->open(self::$dir, 'sessionname'); $this->assertNotEmpty(self::$handler->read('sessionid')); $this->assertNotEmpty(self::$handler->read('sessionid2')); self::$handler->close(); } /** * @depends testList */ public function testDestroy() { self::$handler->open(self::$dir, 'sessionname'); self::$handler->read('sessionid2'); self::$handler->destroy('sessionid2'); $this->assertSame('', self::$handler->read('sessionid2')); } /** * @depends testDestroy */ public function testGc() { self::$handler->open(self::$dir, 'sessionname'); self::$handler->gc(-1); $this->assertSame('', self::$handler->read('sessionid')); } public static function setUpBeforeClass() { parent::setUpBeforeClass(); $external = new Horde_SessionHandler_Storage_File(array('path' => self::$dir)); self::$handler = new Horde_SessionHandler_Storage_External( array('open' => array($external, 'open'), 'close' => array($external, 'close'), 'read' => array($external, 'read'), 'write' => array($external, 'write'), 'destroy' => array($external, 'destroy'), 'gc' => array($external, 'gc'))); } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/FileTest.php0000664000175000017500000000234012654071112024463 0ustar janjan * @category Horde * @package Horde_SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_FileTest extends Horde_SessionHandler_Storage_Base { public function testWrite() { $this->_write(); } /** * @depends testWrite */ public function testRead() { $this->_read(); } /** * @depends testWrite */ public function testReopen() { $this->_reopen(); } /** * @depends testWrite */ public function testList() { $this->_list(); } /** * @depends testList */ public function testDestroy() { $this->_destroy(); } /** * @depends testDestroy */ public function testGc() { $this->_gc(); } public static function setUpBeforeClass() { parent::setUpBeforeClass(); self::$handler = new Horde_SessionHandler_Storage_File(array('path' => self::$dir)); } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/MemcacheTest.php0000664000175000017500000000361112654071112025310 0ustar janjan * @category Horde * @package Horde_SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_MemcacheTest extends Horde_SessionHandler_Storage_Base { protected static $reason; public function testWrite() { $this->_write(); } /** * @depends testWrite */ public function testRead() { $this->_read(); } /** * @depends testWrite */ public function testReopen() { $this->_reopen(); } /** * @depends testWrite */ public function testList() { $this->_list(); } /** * @depends testList */ public function testDestroy() { $this->_destroy(); } public static function setUpBeforeClass() { if (!extension_loaded('memcache')) { self::$reason = 'No memcache extension.'; return; } $config = self::getConfig('SESSIONHANDLER_MEMCACHE_TEST_CONFIG', dirname(__FILE__) . '/..'); if (!$config || empty($config['sessionhandler']['memcache'])) { self::$reason = 'No memcache configuration.'; return; } $memcache = new Horde_Memcache($config['sessionhandler']['memcache']); $memcache->delete('sessionid'); $memcache->delete('sessionid2'); self::$handler = new Horde_SessionHandler_Storage_Memcache( array('memcache' => $memcache, 'track' => true)); parent::setUpBeforeClass(); } public function setUp() { if (!self::$handler) { $this->markTestSkipped(self::$reason); } } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/Storage/StackTest.php0000664000175000017500000000331012654071112024647 0ustar janjan * @category Horde * @package Horde_SessionHandler * @subpackage UnitTests * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 */ class Horde_SessionHandler_Storage_StackTest extends Horde_SessionHandler_Storage_Base { public static $reason; public function testWrite() { $this->_write(); } /** * @depends testWrite */ public function testRead() { $this->_read(); } /** * @depends testWrite */ public function testReopen() { $this->_reopen(); } /** * @depends testWrite */ public function testList() { $this->_list(); } /** * @depends testList */ public function testDestroy() { $this->_destroy(); } /** * @depends testDestroy */ public function testGc() { $this->_gc(); } public static function setUpBeforeClass() { parent::setUpBeforeClass(); $storage1 = new Horde_SessionHandler_Storage_File(array( 'path' => self::$dir )); $storage2 = new Horde_SessionHandler_Storage_File(array( 'path' => Horde_Util::createTempDir() )); self::$handler = new Horde_SessionHandler_Storage_Stack(array( 'stack' => array( $storage1, $storage2 ) )); } public function setUp() { if (!self::$handler) { $this->markTestSkipped(self::$reason); } } } Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/AllTests.php0000664000175000017500000000013212654071112023070 0ustar janjanrun(); Horde_SessionHandler-2.2.7/test/Horde/SessionHandler/bootstrap.php0000664000175000017500000000014312654071112023354 0ustar janjan