1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2024-11-14 08:09:02 +01:00

Merge pull request #1 from gcsolaroli/master

First version of the restructured repository
This commit is contained in:
Giulio Cesare Solaroli 2011-10-03 09:04:12 -07:00
commit 541bb378dd
730 changed files with 232934 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
target
*.pyc

BIN
Icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

661
LICENSE.txt Normal file
View File

@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

93
README.md Normal file
View File

@ -0,0 +1,93 @@
# ![Clipperz icon][icon] Clipperz Password Manager - COMMUNITY EDITION
[Clipperz Community Edition][CE] allows you to host on your own server a web service identical to [Clipperz online password manager][clipperz]. It supports multiple backends (PHP/MySQL, Python/AppEngine, …) and you can contribute your own.
Please note that Clipperz Community Edition is not suitable for mass deployments since it lacks several critical capabilities such as bot protection. If you want to offer Clipperz password manager to a wide audience, please wait for the upcoming Provider Edition.
In any case if you want to use Clipperzs software in a commercial, for-profit environment, please contact us to inquire about licensing options for commercial applications.
ALL the code included in this project, if not otherwise stated, is released with the **AGPL v.3 license** (see `LICENSE.txt`), and all rights are reserved to Clipperz Srl.
## Why a Community Edition
But why would you prefer running Clipperz Community Edition from your own server instead of using the free and anonymous online service provided by its developers?
* “Clipperz security architecture is great, but I prefer to store my data on my hardware. I just feel better this way!”
* “Clipperz is cool, but it would be even cooler it it had a Scala backend. I'm going to write it!"
* “I would like to modify the look & feel of Clipperz and embed this powerful password manager within my family intranet.”
* “Clipperz works nicely, but I would love to play with the source code in order to improve feature X and add new features Y and Z.”
* …
Whatever is your motivation, we would love to hear from you about how and where you use Clipperz Community Edition. [Get in contact!][contact]
## Warnings
Please note that Clipperz Community Edition may not be suitable for mass deployments, depending on how robust is the backend you select.
As an example, the current PHP backend lacks several critical capabilities such as bot protection and cuncurrent sessions management.
## Community Edition vs Workgroup Edition
This Community Edition is aimed to **individual users**, but you may be interested to know that we are working on a **Workgroup Edition** targeting organizations that need a
password manager for their workforce (creating and managing employees accounts, defining groups and sharing policies, ...).
The Workgroup Edition development is quite challenging and, while the overall design is already in place, it will still require a fairly large amount of resources for analysis and implementation.
If your organization is interested in such edition, you can subscribe a "pledge" to sustain its development in exchange for a very generous user license with unlimited upgrades and other benefits. Again, [get in contact][contact]!
## Contributions
Your contributions to Clipperz Community Edition are very welcome! In order to avoid jeopardizing the ownership of the code base, we will require every developer to sign the Clipperz [Contributor Agreement][CA]
This enables a single entity to represent the aggregated code base and gives the community flexibility to act as a whole to changing situations.
The CA establishes a joint copyright assignment in which the contributor retains copyright ownership while also granting those rights to Clipperz Srl. With the CA in place, the aggregated code base within any Clipperz open source project is protected by both the distribution license and copyright law.
Please [download][CA] and review the Contributor Agreement for a complete understanding of its terms and conditions. You may send your signed and completed CA to Clipperz by scanning your completed form and emailing the image or by fax. Please retain a copy for your records. **Thanks!**
## Building
In order to build the deployable version, you need to invoke the following command:
./scripts/build clean install debug --frontends beta --backends php
The output will be available in the `target` folder, with a separate folder for each build backend (initially this will be just a `php` folder).
The script, invoked with these parameters, will build both the full version (`install` -> index.html) and the debug version (index_debug.html) of the /beta frontend using the PHP backend.
At the moment this is the only combination that works, but this script will be gradually extended to be able to build also the [/gamma frontend][gamma] (whose code is already in the repository) and possibly also other backends (Python AppEngine being the very first candidate, and a Javascript version per node.js another interesting option)
## Installing
### PHP + MySQL backend
At the moment the only backend that the build script can successfully create is the PHP + MySQL one.
#### PHP
Once the project has been successfully build, the application needs to be moved in a location where the web server can run it. Everything that is needed is located into `target/php`.
#### MySQL
The application needs a simple MySQL database; to configure all the credentials to access the previously allocated DB, edit the file found in `php/configuration.php`. You need to edit the file actually used by the web server; this will usually be the one moved into the right place in the previous step.
Once the application is in place, and the DB credentials have been configured, you should initialize the DB itself; in order to do so, just point your browser at the following url: `http://<host>/<path>/php/setup/index.php`.
Here you will find the standard [POG][pog] setup page: it should be enough to click the "POG me up!" button at the bottom of the page, and then the "Process" button on the next page.
The POG interface will allow also a very basic access to the DB data that may be useful to check that the application is actually writing something on the DB (even if you will not be able to make much sense out of the data you will see, as they are all encrypted!)
More information about building the PHP backend may be found in the `doc/install.php.txt` file.
## Disclaimer
The resulting application has not been fully tested, so there may be still problems due to the new build script or some other changes that were done due to the new repository structure. So, for the moment, **use it at your own risk!**
[icon]: http://0.gravatar.com/avatar/2a9fae49ced80a42830a206f88ea1022?size=100
[CE]: http://clipperz.com/open_source/clipperz_community_edition
[clipperz]: http://www.clipperz.com
[contact]: http://clipperz.com/contact
[CA]: http://www.clipperz.com/open_source/contributor_agreement
[pog]: http://www.phpobjectgenerator.com/

View File

@ -0,0 +1,4 @@
{
"request.path": "../index.php",
"should.pay.toll": "false"
}

View File

@ -0,0 +1,36 @@
<?php
global $configuration;
$configuration['soap'] = "http://www.phpobjectgenerator.com/services/soap.php?wsdl";
$configuration['homepage'] = "http://www.phpobjectgenerator.com";
$configuration['revisionNumber'] = "";
$configuration['versionNumber'] = "3.0d";
$configuration['setup_password'] = '';
// to enable automatic data encoding, run setup, go to the manage plugins tab and install the base64 plugin.
// then set db_encoding = 1 below.
// when enabled, db_encoding transparently encodes and decodes data to and from the database without any
// programmatic effort on your part.
$configuration['db_encoding'] = 0;
// edit the information below to match your database settings
$configuration['db'] = 'clipperz'; // database name
$configuration['host'] = 'localhost'; // database host
$configuration['user'] = 'root'; // database user
$configuration['pass'] = 'pass'; // database password
$configuration['port'] = '3306'; // database port
//proxy settings - if you are behnd a proxy, change the settings below
$configuration['proxy_host'] = false;
$configuration['proxy_port'] = false;
$configuration['proxy_username'] = false;
$configuration['proxy_password'] = false;
//plugin settings
$configuration['plugins_path'] = dirname(__FILE__).'/plugins';
?>

103
backend/php/src/dump.php Normal file
View File

@ -0,0 +1,103 @@
<?php
header('Content-Type: text/html');
header('Content-Disposition: attachment; filename=Clipperz_'.date("Ymd").'.html');
include "./configuration.php";
include "./objects/class.database.php";
include "./objects/class.user.php";
include "./objects/class.record.php";
include "./objects/class.recordversion.php";
include "./objects/class.onetimepassword.php";
include "./objects/class.onetimepasswordstatus.php";
$htmlContent = file_get_contents("../index.html");
session_start();
$user = new user();
$user = $user->Get($_SESSION["userId"]);
$records = $user->GetRecordList();
$recordString = "";
$isFirstRecord = true;
$c = count($records);
for ($i=0; $i<$c; $i++) {
$currentRecord = $records[$i];
$recordVersions = $currentRecord->GetRecordversionList();
if ($isFirstRecord == true) {
$isFirstRecord = false;
} else {
$recordString = $recordString . ",\n";
}
$versionString = "";
$isFirstVersion = true;
$cc = count($recordVersions);
for ($ii=0; $ii<$cc; $ii++) {
$currentVersion = $recordVersions[$ii];
if ($isFirstVersion == true) {
$isFirstVersion = false;
} else {
$versionString = $versionString . ",\n";
}
$versionsString = $versionString . "\t\t\t\t\t\t'" . $currentVersion->reference . "': {\n" .
"\t\t\t\t\t\t\theader: '" . $currentVersion->header . "',\n" .
"\t\t\t\t\t\t\tdata: '" . $currentVersion->data . "',\n" .
"\t\t\t\t\t\t\tversion: '" . $currentVersion->version . "',\n" .
"\t\t\t\t\t\t\tcreationDate: '" . $currentVersion->creation_date . "',\n" .
"\t\t\t\t\t\t\tupdateDate: '" . $currentVersion->update_date . "',\n" .
"\t\t\t\t\t\t\taccessDate: '" . $currentVersion->access_date . "'\n" .
"\t\t\t\t\t\t}";
}
$recordString = $recordString . "\t\t\t\t'" . $currentRecord->reference . "': {\n" .
"\t\t\t\t\tdata: '" . $currentRecord->data . "',\n" .
"\t\t\t\t\tversion: '" . $currentRecord->version . "',\n" .
"\t\t\t\t\tcreationDate: '" . $currentRecord->creation_date . "',\n" .
"\t\t\t\t\tupdateDate: '" . $currentRecord->update_date . "',\n" .
"\t\t\t\t\taccessDate: '" . $currentRecord->access_date . "',\n" .
"\t\t\t\t\tcurrentVersion: '" . $currentVersion->reference . "',\n" .
"\t\t\t\t\tversions: {\n" .
$versionsString . "\n" .
"\t\t\t\t\t}\n" .
"\t\t\t\t}";
}
$data = "_clipperz_dump_data_ = {\n" .
"\tusers:{\n" .
"\t\t'catchAllUser': {\n" .
"\t\t\t__masterkey_test_value__: 'masterkey',\n" .
"\t\t\ts: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00',\n" .
"\t\t\tv: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00'\n" .
"\t\t},\n" .
"\t\t'" . $user->username . "': {\n" .
"\t\t\ts: '" . $user->srp_s . "',\n" .
"\t\t\tv: '" . $user->srp_v . "',\n" .
"\t\t\tversion: '" . $user->auth_version . "',\n" .
"\t\t\tmaxNumberOfRecords: '" . "100" . "',\n" .
"\t\t\tuserDetails: '" . $user->header . "',\n" .
"\t\t\tstatistics: '" . $user->statistics . "',\n" .
"\t\t\tuserDetailsVersion: '" . $user->version . "',\n" .
"\t\t\trecords: {\n" .
$recordString . "\n" .
"\t\t\t}\n" .
"\t\t}\n" .
"\t}\n" .
"}\n" .
"\n" .
"Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.Offline();\n" .
"Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();" .
"\n";
session_write_close();
echo str_replace("/*offline_data_placeholder*/", $data, $htmlContent);
?>

744
backend/php/src/index.php Normal file
View File

@ -0,0 +1,744 @@
<?php
include "./configuration.php";
include "./objects/class.database.php";
include "./objects/class.user.php";
include "./objects/class.record.php";
include "./objects/class.recordversion.php";
include "./objects/class.onetimepassword.php";
include "./objects/class.onetimepasswordstatus.php";
//-----------------------------------------------------------------------------
if ( !function_exists('json_decode') ) {
function json_decode($content, $assoc=false) {
require_once 'json/JSON.php';
if ( $assoc ) {
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
} else {
$json = new Services_JSON;
}
return $json->decode($content);
}
}
if ( !function_exists('json_encode') ) {
function json_encode($content) {
require_once 'json/JSON.php';
$json = new Services_JSON;
return $json->encode($content);
}
}
//-----------------------------------------------------------------------------
// 'dec2base', 'base2dec' and 'digits' are functions found on the following
// PHP manual page: http://ch2.php.net/manual/en/ref.bc.php
//
function dec2base($dec, $base, $digits=FALSE) {
if ($base<2 or $base>256) {
die("Invalid Base: ".$base);
}
bcscale(0);
$value="";
if (!$digits) {
$digits = digits($base);
}
while ($dec > $base-1) {
$rest = bcmod($dec, $base);
$dec = bcdiv($dec, $base);
$value = $digits[$rest].$value;
}
$value=$digits[intval($dec)].$value;
return (string)$value;
}
//.............................................................................
// convert another base value to its decimal value
function base2dec($value, $base, $digits=FALSE) {
if ($base<2 or $base>256) {
die("Invalid Base: ".$base);
}
bcscale(0);
if ($base<37) {
$value=strtolower($value);
}
if (!$digits) {
$digits=digits($base);
}
$size = strlen($value);
$dec="0";
for ($loop=0; $loop<$size; $loop++) {
$element = strpos($digits, $value[$loop]);
$power = bcpow($base, $size-$loop-1);
$dec = bcadd($dec, bcmul($element,$power));
}
return (string)$dec;
}
//.............................................................................
function digits($base) {
if ($base>64) {
$digits="";
for ($loop=0; $loop<256; $loop++) {
$digits.=chr($loop);
}
} else {
$digits ="0123456789abcdefghijklmnopqrstuvwxyz";
$digits.="ABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
}
$digits=substr($digits,0,$base);
return (string)$digits;
}
//-----------------------------------------------------------------------------
function clipperz_hash($value) {
return hash("sha256", hash("sha256", $value, true));
}
//-----------------------------------------------------------------------------
function clipperz_randomSeed() {
$result;
srand((double) microtime()*1000000);
$result = "";
while(strlen($result) < 64) {
$result = $result.dec2base(rand(), 16);
}
$result = substr($result, 0, 64);
return $result;
}
//-----------------------------------------------------------------------------
function updateUserCredentials($parameters, &$user) {
$user->username = $parameters["C"];
$user->srp_s = $parameters["s"];
$user->srp_v = $parameters["v"];
$user->auth_version = $parameters["version"];
}
function updateUserData($parameters, &$user) {
$user->header = $parameters["header"];
$user->statistics = $parameters["statistics"];
$user->version = $parameters["version"];
$user->lock = $parameters["lock"];
}
function updateRecordData($parameters, &$record, &$recordVersion) {
$recordData = $parameters["record"];
$record->reference = $recordData["reference"];
$record->data = $recordData["data"];
$record->version = $recordData["version"];
$recordVersionData = $parameters["currentRecordVersion"];
$recordVersion->reference = $recordVersionData ["reference"];
$recordVersion->data = $recordVersionData ["data"];
$recordVersion->version = $recordVersionData ["version"];
$recordVersion->previous_version_id = $recordVersionData ["previousVersion"];
$recordVersion->previous_version_key = $recordVersionData ["previousVersionKey"];
}
//-----------------------------------------------------------------------------
function updateOTPStatus(&$otp, $status) {
$otpStatus = new onetimepasswordstatus();
$selectedStatuses = $otpStatus->GetList(array(array("code", "=", $status)));
$otpStatus = $selectedStatuses[0];
$otp->SetOnetimepasswordstatus($otpStatus);
}
function updateOTP($parameters, &$otp, $status) {
$otp->reference = $parameters["reference"];
$otp->key = $parameters["key"];
$otp->key_checksum = $parameters["keyChecksum"];
$otp->data = $parameters["data"];
$otp->version = $parameters["version"];
updateOTPStatus($otp, $status);
}
function resetOTP(&$otp, $status) {
$otp->data = "";
updateOTPStatus($otp, $status);
$otp->Save();
}
//-----------------------------------------------------------------------------
function fixOTPStatusTable() {
$otpStatus = new onetimepasswordstatus();
$otpStatusList = $otpStatus->GetList();
if (count($otpStatusList) != 4) {
$otpStatus->DeleteList();
$otpStatus->code = "ACTIVE"; $otpStatus->name = "Active"; $otpStatus->description = "Active"; $otpStatus->SaveNew();
$otpStatus->code = "REQUESTED"; $otpStatus->name = "Requested"; $otpStatus->description = "Requested"; $otpStatus->SaveNew();
$otpStatus->code = "USED"; $otpStatus->name = "Used"; $otpStatus->description = "Used"; $otpStatus->SaveNew();
$otpStatus->code = "DISABLED"; $otpStatus->name = "Disabled"; $otpStatus->description = "Disabled"; $otpStatus->SaveNew();
}
}
//-----------------------------------------------------------------------------
function arrayContainsValue($array, $value) {
$object = NULL;
for ($i=0; $i<count($array); $i++) {
if ($array[$i] == $value) {
$object = $value;
}
}
return !is_null($object);
}
//-----------------------------------------------------------------------------
$result = Array();
session_start();
$method = $_POST['method'];
if (get_magic_quotes_gpc()) {
$parameters = json_decode(stripslashes($_POST['parameters']), true);
} else {
$parameters = json_decode($_POST['parameters'], true);
}
$parameters = $parameters["parameters"];
switch($method) {
case "registration":
error_log("registration");
$message = $parameters["message"];
if ($message == "completeRegistration") {
$user = new user();
updateUserCredentials($parameters["credentials"], $user);
updateUserData($parameters["user"], $user);
$user->Save();
$result["lock"] = $user->lock;
$result["result"] = "done";
}
break;
case "handshake":
error_log("handshake");
$srp_g = "2";
$srp_n = base2dec("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3", 16);
$message = $parameters["message"];
//=============================================================
if ($message == "connect") {
$user= new user();
$_SESSION["C"] = $parameters["parameters"]["C"];
$_SESSION["A"] = $parameters["parameters"]["A"];
$userList = $user->GetList(array(array("username", "=", $_SESSION["C"])));
if (count($userList) == 1) {
$currentUser = $userList[ 0 ];
if (array_key_exists("otpId", $_SESSION)) {
$otp = new onetimepassword();
$otp = $otp->Get($_SESSION["otpId"]);
if ($otp->GetUser()->userId != $currentUser->userId) {
throw new Exception("User missmatch between the current session and 'One Time Password' user");
} else if ($otp->GetOnetimepasswordstatus()->code != "REQUESTED") {
throw new Exception("Tring to use an 'One Time Password' in the wrong state");
}
resetOTP($otp, "USED");
$result["oneTimePassword"] = $otp->reference;
}
$_SESSION["s"] = $currentUser->srp_s;
$_SESSION["v"] = $currentUser->srp_v;
$_SESSION["userId"] = $currentUser->userId;
} else {
$_SESSION["s"] = "112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00";
$_SESSION["v"] = "112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00";
}
$_SESSION["b"] = clipperz_randomSeed();
// $_SESSION["b"] = "5761e6c84d22ea3c5649de01702d60f674ccfe79238540eb34c61cd020230c53";
$_SESSION["B"] = dec2base(bcadd(base2dec($_SESSION["v"], 16), bcpowmod($srp_g, base2dec($_SESSION["b"], 16), $srp_n)), 16);
$result["s"] = $_SESSION["s"];
$result["B"] = $_SESSION["B"];
//=============================================================
} else if ($message == "credentialCheck") {
error_log("credentialCheck");
$u = clipperz_hash(base2dec($_SESSION["B"],16));
$A = base2dec($_SESSION["A"], 16);
$S = bcpowmod(bcmul($A, bcpowmod(base2dec($_SESSION["v"], 16), base2dec($u, 16), $srp_n)), base2dec($_SESSION["b"], 16), $srp_n);
$K = clipperz_hash($S);
$M1 = clipperz_hash($A.base2dec($_SESSION["B"],16).$K);
//$result["B"] = $_SESSION["B"];
//$result["u"] = $u;
//$result["A"] = $A;
//$result["S"] = $S;
//$result["K"] = $K;
//$result["M1"] = $M1;
//$result["_M1"] = $parameters["parameters"]["M1"];
if ($M1 == $parameters["parameters"]["M1"]) {
$_SESSION["K"] = $K;
$M2 = clipperz_hash($A.$M1.$K);
$result["M2"] = $M2;
$result["connectionId"] = "";
$result["loginInfo"] = array();
$result["loginInfo"]["latest"] = array();
$result["loginInfo"]["current"] = array();
$result["offlineCopyNeeded"] = "false";
$result["lock"] = "----";
} else {
$result["error"] = "?";
}
//=============================================================
} else if ($message == "oneTimePassword") {
error_log("oneTimePassword");
//{
// "message":"oneTimePassword",
// "version":"0.2",
// "parameters":{
// "oneTimePasswordKey":"06dfa7f428081f8b2af98b0895e14e18af90b0ef2ff32828e55cc2ac6b24d29b",
// "oneTimePasswordKeyChecksum":"60bcba3f72e56f6bb3f0ff88509b9a0e5ec730dfa71daa4c1e892dbd1b0c360d"
// }
//}
$otp = new onetimepassword();
$otpList = $otp->GetList(array(array("key", "=", $parameters["parameters"]["oneTimePasswordKey"])));
if (count($otpList) == 1) {
$currentOtp = $otpList[0];
if ($currentOtp->GetOnetimepasswordstatus()->code == "ACTIVE") {
if ($currentOtp->key_checksum == $parameters["parameters"]["oneTimePasswordKeyChecksum"]) {
$_SESSION["userId"] = $currentOtp->GetUser()->userId;
$_SESSION["otpId"] = $currentOtp->onetimepasswordId;
$result["data"] = $currentOtp->data;
$result["version"] = $currentOtp->version;
resetOTP($currentOtp, "REQUESTED");
} else {
resetOTP($currentOtp, "DISABLED");
throw new Exception("The requested One Time Password has been disabled, due to a wrong keyChecksum");
}
} else {
throw new Exception("The requested One Time Password was not active");
}
} else {
throw new Exception("The requested One Time Password has not been found");
}
//=============================================================
}
break;
case "message":
error_log("message");
if ($parameters["srpSharedSecret"] == $_SESSION["K"]) {
$message = $parameters["message"];
//=============================================================
if ($message == "getUserDetails") {
//{"message":"getUserDetails", "srpSharedSecret":"f18e5cf7c3a83b67d4db9444af813ee48c13daf4f8f6635397d593e52ba89a08", "parameters":{}}
$user = new user();
$user = $user->Get($_SESSION["userId"]);
$result["header"] = $user->header;
$result["statistics"] = $user->statistics;
$result["version"] = $user->version;
//=============================================================
} else if ($message == "addNewRecords") {
/*
//{
// "message":"addNewRecords",
// "srpSharedSecret":"b58fdf62acebbcb67f63d28c0437f166069f45690c648cd4376a792ae7a325f7",
// "parameters":{
// "records":[
// {
// "record":{
// "reference":"fda703707fee1fff42443124cd0e705f5bea0ac601758d81b2e832705339a610",
// "data":"OBSGtcb6blXq/xaYG.....4EqlQqgAvITN",
// "version":"0.3"
// },
// "currentRecordVersion":{
// "reference":"83ad301525c18f2afd72b6ac82c0a713382e1ef70ac69935ca7e2869dd4ff980",
// "recordReference":"fda703707fee1fff42443124cd0e705f5bea0ac601758d81b2e832705339a610",
// "data":"NXJ5jiZhkd0CMiwwntAq....1TjjF+SGfE=",
// "version":"0.3",
// "previousVersion":"3e174a86afc322271d8af28bc062b0f1bfd7344fad01212cd08b2757c4b199c4",
// "previousVersionKey":"kozaaGCzXWr71LbOKu6Z3nz520V..5U85tSBvb+u44twttv54Kw=="
// }
// }
// ],
// "user":{
// "header":"{\"reco...ersion\":\"0.1\"}",
// "statistics":"rKI6nR6iqggygQJ3SQ58bFUX",
// "version":"0.3",
// "lock":"----"
// }
// }
//}
*/
$user = new user();
$record = new record();
$recordVersion = new recordversion();
$user = $user->Get($_SESSION["userId"]);
updateUserData($parameters["parameters"]["user"], $user);
$recordParameterList = $parameters["parameters"]["records"];
$c = count($recordParameterList);
for ($i=0; $i<$c; $i++) {
updateRecordData($recordParameterList[$i], $record, $recordVersion);
$record->SaveNew();
$recordVersion->SaveNew();
$record->AddRecordversion($recordVersion);
$user->AddRecord($record);
$record->Save();
$recordVersion->Save();
}
$user->Save();
$result["lock"] = $user->lock;
$result["result"] = "done";
//=============================================================
} else if ($message == "getRecordDetail") {
//{
// "message":"getRecordDetail",
// "srpSharedSecret":"4c00dcb66a9f2aea41a87e4707c526874e2eb29cc72d2c7086837e53d6bf2dfe",
// "parameters":{
// "reference":"740009737139a189cfa2b1019a6271aaa39467b59e259706564b642ff3838d50"
// }
//}
//
// result = {
// currentVersion:{
// reference:"88943d709c3ea2442d4f58eaaec6409276037e5a37e0a6d167b9dad9e947e854",
// accessDate:"Wed, 13 February 2008 14:25:12 UTC",
// creationDate:"Tue, 17 April 2007 17:17:52 UTC",
// version:"0.2",
// data:"xI3WXddQLFtL......EGyKnnAVik",
// updateDate:"Tue, 17 April 2007 17:17:52 UTC",
// header:"####"
// }
// reference:"13a5e52976337ab210903cd04872588e1b21fb72bc183e91aa25c494b8138551",
// oldestUsedEncryptedVersion:"0.2",
// accessDate:"Wed, 13 February 2008 14:25:12 UTC",
// creationDate:"Wed, 14 March 2007 13:53:11 UTC",
// version:"0.2",
// updatedDate:"Tue, 17 April 2007 17:17:52 UTC",
// data:"0/BjzyY6jeh71h...pAw2++NEyylGhMC5C5f5m8pBApYziN84s4O3JQ3khW/1UttQl4="
// }
$record = new record();
$recordList = $record->GetList(array(array("reference", "=", $parameters["parameters"]["reference"])));
$currentRecord = $recordList[0];
$currentRecordVersions = $currentRecord->GetRecordversionList();
$currentVersion = $currentRecordVersions[0];
$result["currentVersion"] = array();
$result["currentVersion"]["reference"] = $currentVersion->reference;
$result["currentVersion"]["data"] = $currentVersion->data;
$result["currentVersion"]["header"] = $currentVersion->header;
$result["currentVersion"]["version"] = $currentVersion->version;
$result["currentVersion"]["creationDate"] = $currentVersion->creation_date;
$result["currentVersion"]["updateDate"] = $currentVersion->update_date;
$result["currentVersion"]["accessDate"] = $currentVersion->access_date;
$result["reference"] = $currentRecord->reference;
$result["data"] = $currentRecord->data;
$result["version"] = $currentRecord->version;
$result["creationDate"] = $currentRecord->creation_date;
$result["updateDate"] = $currentRecord->update_date;
$result["accessDate"] = $currentRecord->access_date;
$result["oldestUsedEncryptedVersion"] = "---";
//=============================================================
} else if ($message == "updateData") {
//{
// "message":"updateData",
// "srpSharedSecret":"4e4aadb1d64513ec4dd42f5e8d5b2d4363de75e4424b6bcf178c9d6a246356c5",
// "parameters":{
// "records":[
// {
// "record":{
// "reference":"740009737139a189cfa2b1019a6271aaa39467b59e259706564b642ff3838d50",
// "data":"8hgR0Z+JDrUa812polDJ....JnZUKXNEqKI",
// "version":"0.3"
// },
// "currentRecordVersion":{
// "reference":"b1d82aeb9a0c4f6584bea68ba80839f43dd6ede79791549e29a1860554b144ee",
// "recordReference":"740009737139a189cfa2b1019a6271aaa39467b59e259706564b642ff3838d50",
// "data":"2d/UgKxxV+kBPV9GRUE.....VGonDoW0tqefxOJo=",
// "version":"0.3",
// "previousVersion":"55904195249037394316d3be3f5e78f08073170103bf0e7ab49a911c159cb0be",
// "previousVersionKey":"YWiaZeMIVHaIl96OWW+2e8....6d6nHbn6cr2NA/dbQRuC2w=="
// }
// }
// ],
// "user":{
// "header":"{\"rec.....sion\":\"0.1\"}",
// "statistics":"tt3uU9hWBy8rNnMckgCnxMJh",
// "version":"0.3",
// "lock":"----"
// }
// }
//}
$user = new user();
$user = $user->Get($_SESSION["userId"]);
updateUserData($parameters["parameters"]["user"], $user);
$user->Save();
$recordParameterList = $parameters["parameters"]["records"];
$c = count($recordParameterList);
for ($i=0; $i<$c; $i++) {
$recordList = $user->GetRecordList(array(array("reference", "=", $recordParameterList[$i]["record"]["reference"])));
$currentRecord = $recordList[0];
$currentRecordVersions = $currentRecord->GetRecordversionList();
$currentVersion = $currentRecordVersions[0];
updateRecordData($recordParameterList[$i], $currentRecord, $currentVersion);
$currentRecord->Save();
$currentVersion->Save();
}
$result["lock"] = $user->lock;
$result["result"] = "done";
//=============================================================
} else if ($message == "deleteRecords") {
//{
// "message":"deleteRecords",
// "srpSharedSecret":"4a64982f7ee366954ec50b9efea62a902a097ef111410c2aa7c4d5343bd1cdd1",
// "parameters":{
// "recordReferences":["46494c81d10b80ab190d41e6806ef63869cfcc7a0ab8fe98cc3f93de4729bb9a"],
// "user":{
// "header":"{\"rec...rsion\":\"0.1\"}",
// "statistics":"44kOOda0xYZjbcugJBdagBQx",
// "version":"0.3",
// "lock":"----"
// }
// }
//}
$user = new user();
$user = $user->Get($_SESSION["userId"]);
$recordReferenceList = $parameters["parameters"]["recordReferences"];
$recordList = array();
$c = count($recordReferenceList);
for ($i=0; $i<$c; $i++) {
array_push($recordList, array("reference", "=", $recordReferenceList[$i]));
}
$record = new record();
$record->DeleteList($recordList, true);
updateUserData($parameters["parameters"]["user"], $user);
$user->Save();
$result["recordList"] = $recordList;
$result["lock"] = $user->lock;
$result["result"] = "done";
//=============================================================
} else if ($message == "deleteUser") {
//{"message":"deleteUser", "srpSharedSecret":"e8e4ca6544dca49c95b3647d8358ad54c317048b74d2ac187ac25f719c9bac58", "parameters":{}}
$user = new user();
$user->Get($_SESSION["userId"]);
$user->Delete(true);
$result["result"] = "ok";
//=============================================================
} else if ($message == "addNewOneTimePassword") {
//{
// "message":"addNewOneTimePassword",
// "srpSharedSecret":"96fee4af06c09ce954fe7a9f87970e943449186bebf70bac0af1d6ebb818dabb",
// "parameters":{
// "user":{
// "header":"{\"records\":{\"index\":{\"419ea6....rsion\":\"0.1\"}",
// "statistics":"rrlwNbDt83rpWT4S72upiVsC",
// "version":"0.3",
// "lock":"----"
// },
// "oneTimePassword":{
// "reference":"29e26f3a2aae61fe5cf58c45296c6df4f3dceafe067ea550b455be345f44123c",
// "key":"afb848208758361a96a298b9db08995cf036011747809357a90645bc93fdfa03",
// "keyChecksum":"d1599ae443b5a566bfd93c0aeec4c81b42c0506ee09874dae050449580bb3486",
// "data":"hsyY8DHksgR52x6c4j7XAtIUeY.....dxsr3XWt7CbGg==",
// "version":"0.3"
// }
// }
//}
fixOTPStatusTable();
$user = new user();
$user = $user->Get($_SESSION["userId"]);
$otp = new onetimepassword();
updateOTP($parameters["parameters"]["oneTimePassword"], $otp, "ACTIVE");
$user->AddOnetimepassword($otp);
updateUserData($parameters["parameters"]["user"], $user);
$user->Save();
$result["lock"] = $user->lock;
$result["result"] = "done";
//=============================================================
} else if ($message == "updateOneTimePasswords") {
//{
// "message":"updateOneTimePasswords",
// "srpSharedSecret":"c78f8ed099ea421f4dd0a4e02dbaf1f7da925f0088188d99399874ff064a3d27",
// "parameters":{
// "user":{
// "header":"{\"reco...sion\":\"0.1\"}",
// "statistics":"UeRq75RZHzDC7elzrh/+OB5d",
// "version":"0.3",
// "lock":"----"
// },
// "oneTimePasswords":["f5f44c232f239efe48ab81a6236deea1a840d52946f7d4d782dad52b4c5359ce"]
// }
//}
$user = new user();
$user = $user->Get($_SESSION["userId"]);
$validOtpReferences = $parameters["parameters"]["oneTimePasswords"];
$otpList = $user->GetOnetimepasswordList();
$c = count($otpList);
for ($i=0; $i<$c; $i++) {
$currentOtp = $otpList[$i];
if (arrayContainsValue($validOtpReferences, $currentOtp->reference) == false) {
$currentOtp->Delete();
}
}
updateUserData($parameters["parameters"]["user"], $user);
$user->Save();
$result["result"] = $user->lock;
//=============================================================
} else if ($message == "getOneTimePasswordsDetails") {
//=============================================================
} else if ($message == "getLoginHistory") {
$result["result"] = array();
//=============================================================
} else if ($message == "upgradeUserCredentials") {
//{
// "message":"upgradeUserCredentials",
// "srpSharedSecret":"f1c25322e1478c8fb26063e9eef2f6fc25e0460065a31cb718f80bcff8f8a735",
// "parameters":{
// "user":{
// "header":"{\"reco...sion\":\"0.1\"}",
// "statistics":"s72Xva+w7CLgH+ihwqwXUbyu",
// "version":"0.3",
// "lock":"----"
// },
// "credentials":{
// "C":"57d15a8afbc1ae08103bd991d387ddfd8d26824276476fe709d754f098b6c26d",
// "s":"d6735fc0486f391c4f3c947928f9e61a2418e7bed2bc9b25bb43f93acc52f636",
// "v":"540c2ebbf941a481b6b2c9026c07fb46e8202e4408ed96864a696deb622baece",
// "version":"0.2"
// },
// "oneTimePasswords":{
// "923cdc61c4b877b263236124c44d69b459d240453a461cce8ddf7518b423ca94": "1HD6Ta0xsifEDhDwE....9WDK6tvrS6w==",
// "fb1573cb9497652a81688a099a524fb116e604c6fbc191cf33406eb8438efa5f": "CocN0cSxLmMRdgNF9....o3xhGUEY68Q=="
// }
// }
//}
$user = new user();
$user->Get($_SESSION["userId"]);
$otp = new onetimepassword();
updateUserCredentials($parameters["parameters"]["credentials"], $user);
updateUserData($parameters["parameters"]["user"], $user);
$otpList = $parameters["parameters"]["oneTimePasswords"];
foreach($otpList as $otpReference=>$otpData) {
$otpList = $otp->GetList(array(array("reference", "=", $otpReference)));
$currentOtp = $otpList[0];
$currentOtp->data = $otpData;
$currentOtp->Save();
}
$user->Save();
$result["lock"] = $user->lock;
$result["result"] = "done";
//=============================================================
} else if ($message == "echo") {
$result["result"] = $parameters;
}
//=============================================================
} else {
$result["error"] = "Wrong shared secret!";
}
break;
case "logout":
error_log("logout");
session_destroy();
break;
default:
error_log("default");
$result["result"] = $parameters;
break;
}
session_write_close();
echo(json_encode($result));
error_log("result: ".json_encode($result));
?>

View File

@ -0,0 +1,806 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category
* @package Services_JSON
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
/**
* 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:
*
* <code>
* // 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);
* </code>
*/
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)
{
}
}
}
?>

View File

@ -0,0 +1,79 @@
<?php
/**
* <b>Database Connection</b> class.
* @author Php Object Generator
* @version 3.0d / PHP5.1
* @see http://www.phpobjectgenerator.com/
* @copyright Free for personal & commercial use. (Offered under the BSD license)
*/
Class Database
{
public $connection;
private function Database()
{
$databaseName = $GLOBALS['configuration']['db'];
$serverName = $GLOBALS['configuration']['host'];
$databaseUser = $GLOBALS['configuration']['user'];
$databasePassword = $GLOBALS['configuration']['pass'];
$databasePort = $GLOBALS['configuration']['port'];
$this->connection = mysql_connect ($serverName.":".$databasePort, $databaseUser, $databasePassword);
if ($this->connection)
{
if (!mysql_select_db ($databaseName))
{
throw new Exception('I cannot find the specified database "'.$databaseName.'". Please edit configuration.php.');
}
}
else
{
throw new Exception('I cannot connect to the database. Please edit configuration.php with your database configuration.');
}
}
public static function Connect()
{
static $database = null;
if (!isset($database))
{
$database = new Database();
}
return $database->connection;
}
public static function Reader($query, $connection)
{
$cursor = mysql_query($query, $connection);
return $cursor;
}
public static function Read($cursor)
{
return mysql_fetch_assoc($cursor);
}
public static function NonQuery($query, $connection)
{
mysql_query($query, $connection);
$result = mysql_affected_rows($connection);
if ($result == -1)
{
return false;
}
return $result;
}
public static function Query($query, $connection)
{
$result = mysql_query($query, $connection);
return mysql_num_rows($result);
}
public static function InsertOrUpdate($query, $connection)
{
$result = mysql_query($query, $connection);
return intval(mysql_insert_id($connection));
}
}
?>

View File

@ -0,0 +1,400 @@
<?php
/*
This SQL query will create the table to store your object.
CREATE TABLE `onetimepassword` (
`onetimepasswordid` int(11) NOT NULL auto_increment,
`userid` int(11) NOT NULL,
`onetimepasswordstatusid` int(11) NOT NULL,
`reference` VARCHAR(255) NOT NULL,
`key` VARCHAR(255) NOT NULL,
`key_checksum` VARCHAR(255) NOT NULL,
`data` TEXT NOT NULL,
`version` VARCHAR(255) NOT NULL,
`creation_date` TIMESTAMP NOT NULL,
`request_date` TIMESTAMP NOT NULL,
`usage_date` TIMESTAMP NOT NULL, INDEX(`userid`,`onetimepasswordstatusid`), PRIMARY KEY (`onetimepasswordid`)) ENGINE=MyISAM;
*/
/**
* <b>onetimepassword</b> class with integrated CRUD methods.
* @author Php Object Generator
* @version POG 3.0d / PHP5.1
* @copyright Free for personal & commercial use. (Offered under the BSD license)
* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pog&objectName=onetimepassword&attributeList=array+%28%0A++0+%3D%3E+%27user%27%2C%0A++1+%3D%3E+%27onetimepasswordstatus%27%2C%0A++2+%3D%3E+%27reference%27%2C%0A++3+%3D%3E+%27key%27%2C%0A++4+%3D%3E+%27key_checksum%27%2C%0A++5+%3D%3E+%27data%27%2C%0A++6+%3D%3E+%27version%27%2C%0A++7+%3D%3E+%27creation_date%27%2C%0A++8+%3D%3E+%27request_date%27%2C%0A++9+%3D%3E+%27usage_date%27%2C%0A%29&typeList=array+%28%0A++0+%3D%3E+%27BELONGSTO%27%2C%0A++1+%3D%3E+%27BELONGSTO%27%2C%0A++2+%3D%3E+%27VARCHAR%28255%29%27%2C%0A++3+%3D%3E+%27VARCHAR%28255%29%27%2C%0A++4+%3D%3E+%27VARCHAR%28255%29%27%2C%0A++5+%3D%3E+%27TEXT%27%2C%0A++6+%3D%3E+%27VARCHAR%28255%29%27%2C%0A++7+%3D%3E+%27TIMESTAMP%27%2C%0A++8+%3D%3E+%27TIMESTAMP%27%2C%0A++9+%3D%3E+%27TIMESTAMP%27%2C%0A%29
*/
include_once('class.pog_base.php');
class onetimepassword extends POG_Base
{
public $onetimepasswordId = '';
/**
* @var INT(11)
*/
public $userId;
/**
* @var INT(11)
*/
public $onetimepasswordstatusId;
/**
* @var VARCHAR(255)
*/
public $reference;
/**
* @var VARCHAR(255)
*/
public $key;
/**
* @var VARCHAR(255)
*/
public $key_checksum;
/**
* @var TEXT
*/
public $data;
/**
* @var VARCHAR(255)
*/
public $version;
/**
* @var TIMESTAMP
*/
public $creation_date;
/**
* @var TIMESTAMP
*/
public $request_date;
/**
* @var TIMESTAMP
*/
public $usage_date;
public $pog_attribute_type = array(
"onetimepasswordId" => array('db_attributes' => array("NUMERIC", "INT")),
"user" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
"onetimepasswordstatus" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
"reference" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"key" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"key_checksum" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"data" => array('db_attributes' => array("TEXT", "TEXT")),
"version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"creation_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
"request_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
"usage_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
);
public $pog_query;
/**
* Getter for some private attributes
* @return mixed $attribute
*/
public function __get($attribute)
{
if (isset($this->{"_".$attribute}))
{
return $this->{"_".$attribute};
}
else
{
return false;
}
}
function onetimepassword($reference='', $key='', $key_checksum='', $data='', $version='', $creation_date='', $request_date='', $usage_date='')
{
$this->reference = $reference;
$this->key = $key;
$this->key_checksum = $key_checksum;
$this->data = $data;
$this->version = $version;
$this->creation_date = $creation_date;
$this->request_date = $request_date;
$this->usage_date = $usage_date;
}
/**
* Gets object from database
* @param integer $onetimepasswordId
* @return object $onetimepassword
*/
function Get($onetimepasswordId)
{
$connection = Database::Connect();
$this->pog_query = "select * from `onetimepassword` where `onetimepasswordid`='".intval($onetimepasswordId)."' LIMIT 1";
$cursor = Database::Reader($this->pog_query, $connection);
while ($row = Database::Read($cursor))
{
$this->onetimepasswordId = $row['onetimepasswordid'];
$this->userId = $row['userid'];
$this->onetimepasswordstatusId = $row['onetimepasswordstatusid'];
$this->reference = $this->Unescape($row['reference']);
$this->key = $this->Unescape($row['key']);
$this->key_checksum = $this->Unescape($row['key_checksum']);
$this->data = $this->Unescape($row['data']);
$this->version = $this->Unescape($row['version']);
$this->creation_date = $row['creation_date'];
$this->request_date = $row['request_date'];
$this->usage_date = $row['usage_date'];
}
return $this;
}
/**
* Returns a sorted array of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param string $sortBy
* @param boolean $ascending
* @param int limit
* @return array $onetimepasswordList
*/
function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
{
$connection = Database::Connect();
$sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
$this->pog_query = "select * from `onetimepassword` ";
$onetimepasswordList = Array();
if (sizeof($fcv_array) > 0)
{
$this->pog_query .= " where ";
for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
{
if (sizeof($fcv_array[$i]) == 1)
{
$this->pog_query .= " ".$fcv_array[$i][0]." ";
continue;
}
else
{
if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
{
$this->pog_query .= " AND ";
}
if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
{
if ($GLOBALS['configuration']['db_encoding'] == 1)
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
$this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
}
else
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
}
}
else
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
}
}
}
}
if ($sortBy != '')
{
if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
{
if ($GLOBALS['configuration']['db_encoding'] == 1)
{
$sortBy = "BASE64_DECODE($sortBy) ";
}
else
{
$sortBy = "$sortBy ";
}
}
else
{
$sortBy = "$sortBy ";
}
}
else
{
$sortBy = "onetimepasswordid";
}
$this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
$thisObjectName = get_class($this);
$cursor = Database::Reader($this->pog_query, $connection);
while ($row = Database::Read($cursor))
{
$onetimepassword = new $thisObjectName();
$onetimepassword->onetimepasswordId = $row['onetimepasswordid'];
$onetimepassword->userId = $row['userid'];
$onetimepassword->onetimepasswordstatusId = $row['onetimepasswordstatusid'];
$onetimepassword->reference = $this->Unescape($row['reference']);
$onetimepassword->key = $this->Unescape($row['key']);
$onetimepassword->key_checksum = $this->Unescape($row['key_checksum']);
$onetimepassword->data = $this->Unescape($row['data']);
$onetimepassword->version = $this->Unescape($row['version']);
$onetimepassword->creation_date = $row['creation_date'];
$onetimepassword->request_date = $row['request_date'];
$onetimepassword->usage_date = $row['usage_date'];
$onetimepasswordList[] = $onetimepassword;
}
return $onetimepasswordList;
}
/**
* Saves the object to the database
* @return integer $onetimepasswordId
*/
function Save()
{
$connection = Database::Connect();
$this->pog_query = "select `onetimepasswordid` from `onetimepassword` where `onetimepasswordid`='".$this->onetimepasswordId."' LIMIT 1";
$rows = Database::Query($this->pog_query, $connection);
if ($rows > 0)
{
$this->pog_query = "update `onetimepassword` set
`userid`='".$this->userId."',
`onetimepasswordstatusid`='".$this->onetimepasswordstatusId."',
`reference`='".$this->Escape($this->reference)."',
`key`='".$this->Escape($this->key)."',
`key_checksum`='".$this->Escape($this->key_checksum)."',
`data`='".$this->Escape($this->data)."',
`version`='".$this->Escape($this->version)."',
`creation_date`='".$this->creation_date."',
`request_date`='".$this->request_date."',
`usage_date`='".$this->usage_date."' where `onetimepasswordid`='".$this->onetimepasswordId."'";
}
else
{
$this->pog_query = "insert into `onetimepassword` (`userid`, `onetimepasswordstatusid`, `reference`, `key`, `key_checksum`, `data`, `version`, `creation_date`, `request_date`, `usage_date` ) values (
'".$this->userId."',
'".$this->onetimepasswordstatusId."',
'".$this->Escape($this->reference)."',
'".$this->Escape($this->key)."',
'".$this->Escape($this->key_checksum)."',
'".$this->Escape($this->data)."',
'".$this->Escape($this->version)."',
'".$this->creation_date."',
'".$this->request_date."',
'".$this->usage_date."' )";
}
$insertId = Database::InsertOrUpdate($this->pog_query, $connection);
if ($this->onetimepasswordId == "")
{
$this->onetimepasswordId = $insertId;
}
return $this->onetimepasswordId;
}
/**
* Clones the object and saves it to the database
* @return integer $onetimepasswordId
*/
function SaveNew()
{
$this->onetimepasswordId = '';
return $this->Save();
}
/**
* Deletes the object from the database
* @return boolean
*/
function Delete()
{
$connection = Database::Connect();
$this->pog_query = "delete from `onetimepassword` where `onetimepasswordid`='".$this->onetimepasswordId."'";
return Database::NonQuery($this->pog_query, $connection);
}
/**
* Deletes a list of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param bool $deep
* @return
*/
function DeleteList($fcv_array)
{
if (sizeof($fcv_array) > 0)
{
$connection = Database::Connect();
$pog_query = "delete from `onetimepassword` where ";
for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
{
if (sizeof($fcv_array[$i]) == 1)
{
$pog_query .= " ".$fcv_array[$i][0]." ";
continue;
}
else
{
if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
{
$pog_query .= " AND ";
}
if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
{
$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
}
else
{
$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
}
}
}
return Database::NonQuery($pog_query, $connection);
}
}
/**
* Associates the user object to this one
* @return boolean
*/
function GetUser()
{
$user = new user();
return $user->Get($this->userId);
}
/**
* Associates the user object to this one
* @return
*/
function SetUser(&$user)
{
$this->userId = $user->userId;
}
/**
* Associates the onetimepasswordstatus object to this one
* @return boolean
*/
function GetOnetimepasswordstatus()
{
$onetimepasswordstatus = new onetimepasswordstatus();
return $onetimepasswordstatus->Get($this->onetimepasswordstatusId);
}
/**
* Associates the onetimepasswordstatus object to this one
* @return
*/
function SetOnetimepasswordstatus(&$onetimepasswordstatus)
{
$this->onetimepasswordstatusId = $onetimepasswordstatus->onetimepasswordstatusId;
}
}
?>

View File

@ -0,0 +1,368 @@
<?php
/*
This SQL query will create the table to store your object.
CREATE TABLE `onetimepasswordstatus` (
`onetimepasswordstatusid` int(11) NOT NULL auto_increment,
`code` VARCHAR(255) NOT NULL,
`name` VARCHAR(255) NOT NULL,
`description` TEXT NOT NULL, PRIMARY KEY (`onetimepasswordstatusid`)) ENGINE=MyISAM;
*/
/**
* <b>onetimepasswordstatus</b> class with integrated CRUD methods.
* @author Php Object Generator
* @version POG 3.0d / PHP5.1 MYSQL
* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
* @copyright Free for personal & commercial use. (Offered under the BSD license)
* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=onetimepasswordstatus&attributeList=array+%28%0A++0+%3D%3E+%27onetimepassword%27%2C%0A++1+%3D%3E+%27code%27%2C%0A++2+%3D%3E+%27name%27%2C%0A++3+%3D%3E+%27description%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527TEXT%2527%252C%250A%2529
*/
include_once('class.pog_base.php');
class onetimepasswordstatus extends POG_Base
{
public $onetimepasswordstatusId = '';
/**
* @var private array of onetimepassword objects
*/
private $_onetimepasswordList = array();
/**
* @var VARCHAR(255)
*/
public $code;
/**
* @var VARCHAR(255)
*/
public $name;
/**
* @var TEXT
*/
public $description;
public $pog_attribute_type = array(
"onetimepasswordstatusId" => array('db_attributes' => array("NUMERIC", "INT")),
"onetimepassword" => array('db_attributes' => array("OBJECT", "HASMANY")),
"code" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"name" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"description" => array('db_attributes' => array("TEXT", "TEXT")),
);
public $pog_query;
/**
* Getter for some private attributes
* @return mixed $attribute
*/
public function __get($attribute)
{
if (isset($this->{"_".$attribute}))
{
return $this->{"_".$attribute};
}
else
{
return false;
}
}
function onetimepasswordstatus($code='', $name='', $description='')
{
$this->_onetimepasswordList = array();
$this->code = $code;
$this->name = $name;
$this->description = $description;
}
/**
* Gets object from database
* @param integer $onetimepasswordstatusId
* @return object $onetimepasswordstatus
*/
function Get($onetimepasswordstatusId)
{
$connection = Database::Connect();
$this->pog_query = "select * from `onetimepasswordstatus` where `onetimepasswordstatusid`='".intval($onetimepasswordstatusId)."' LIMIT 1";
$cursor = Database::Reader($this->pog_query, $connection);
while ($row = Database::Read($cursor))
{
$this->onetimepasswordstatusId = $row['onetimepasswordstatusid'];
$this->code = $this->Unescape($row['code']);
$this->name = $this->Unescape($row['name']);
$this->description = $this->Unescape($row['description']);
}
return $this;
}
/**
* Returns a sorted array of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param string $sortBy
* @param boolean $ascending
* @param int limit
* @return array $onetimepasswordstatusList
*/
function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
{
$connection = Database::Connect();
$sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
$this->pog_query = "select * from `onetimepasswordstatus` ";
$onetimepasswordstatusList = Array();
if (sizeof($fcv_array) > 0)
{
$this->pog_query .= " where ";
for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
{
if (sizeof($fcv_array[$i]) == 1)
{
$this->pog_query .= " ".$fcv_array[$i][0]." ";
continue;
}
else
{
if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
{
$this->pog_query .= " AND ";
}
if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
{
if ($GLOBALS['configuration']['db_encoding'] == 1)
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
$this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
}
else
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
}
}
else
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
}
}
}
}
if ($sortBy != '')
{
if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
{
if ($GLOBALS['configuration']['db_encoding'] == 1)
{
$sortBy = "BASE64_DECODE($sortBy) ";
}
else
{
$sortBy = "$sortBy ";
}
}
else
{
$sortBy = "$sortBy ";
}
}
else
{
$sortBy = "onetimepasswordstatusid";
}
$this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
$thisObjectName = get_class($this);
$cursor = Database::Reader($this->pog_query, $connection);
while ($row = Database::Read($cursor))
{
$onetimepasswordstatus = new $thisObjectName();
$onetimepasswordstatus->onetimepasswordstatusId = $row['onetimepasswordstatusid'];
$onetimepasswordstatus->code = $this->Unescape($row['code']);
$onetimepasswordstatus->name = $this->Unescape($row['name']);
$onetimepasswordstatus->description = $this->Unescape($row['description']);
$onetimepasswordstatusList[] = $onetimepasswordstatus;
}
return $onetimepasswordstatusList;
}
/**
* Saves the object to the database
* @return integer $onetimepasswordstatusId
*/
function Save($deep = true)
{
$connection = Database::Connect();
$this->pog_query = "select `onetimepasswordstatusid` from `onetimepasswordstatus` where `onetimepasswordstatusid`='".$this->onetimepasswordstatusId."' LIMIT 1";
$rows = Database::Query($this->pog_query, $connection);
if ($rows > 0)
{
$this->pog_query = "update `onetimepasswordstatus` set
`code`='".$this->Escape($this->code)."',
`name`='".$this->Escape($this->name)."',
`description`='".$this->Escape($this->description)."' where `onetimepasswordstatusid`='".$this->onetimepasswordstatusId."'";
}
else
{
$this->pog_query = "insert into `onetimepasswordstatus` (`code`, `name`, `description` ) values (
'".$this->Escape($this->code)."',
'".$this->Escape($this->name)."',
'".$this->Escape($this->description)."' )";
}
$insertId = Database::InsertOrUpdate($this->pog_query, $connection);
if ($this->onetimepasswordstatusId == "")
{
$this->onetimepasswordstatusId = $insertId;
}
if ($deep)
{
foreach ($this->_onetimepasswordList as $onetimepassword)
{
$onetimepassword->onetimepasswordstatusId = $this->onetimepasswordstatusId;
$onetimepassword->Save($deep);
}
}
return $this->onetimepasswordstatusId;
}
/**
* Clones the object and saves it to the database
* @return integer $onetimepasswordstatusId
*/
function SaveNew($deep = false)
{
$this->onetimepasswordstatusId = '';
return $this->Save($deep);
}
/**
* Deletes the object from the database
* @return boolean
*/
function Delete($deep = false, $across = false)
{
if ($deep)
{
$onetimepasswordList = $this->GetOnetimepasswordList();
foreach ($onetimepasswordList as $onetimepassword)
{
$onetimepassword->Delete($deep, $across);
}
}
$connection = Database::Connect();
$this->pog_query = "delete from `onetimepasswordstatus` where `onetimepasswordstatusid`='".$this->onetimepasswordstatusId."'";
return Database::NonQuery($this->pog_query, $connection);
}
/**
* Deletes a list of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param bool $deep
* @return
*/
function DeleteList($fcv_array, $deep = false, $across = false)
{
if (sizeof($fcv_array) > 0)
{
if ($deep || $across)
{
$objectList = $this->GetList($fcv_array);
foreach ($objectList as $object)
{
$object->Delete($deep, $across);
}
}
else
{
$connection = Database::Connect();
$pog_query = "delete from `onetimepasswordstatus` where ";
for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
{
if (sizeof($fcv_array[$i]) == 1)
{
$pog_query .= " ".$fcv_array[$i][0]." ";
continue;
}
else
{
if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
{
$pog_query .= " AND ";
}
if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
{
$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
}
else
{
$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
}
}
}
return Database::NonQuery($pog_query, $connection);
}
}
}
/**
* Gets a list of onetimepassword objects associated to this one
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param string $sortBy
* @param boolean $ascending
* @param int limit
* @return array of onetimepassword objects
*/
function GetOnetimepasswordList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
{
$onetimepassword = new onetimepassword();
$fcv_array[] = array("onetimepasswordstatusId", "=", $this->onetimepasswordstatusId);
$dbObjects = $onetimepassword->GetList($fcv_array, $sortBy, $ascending, $limit);
return $dbObjects;
}
/**
* Makes this the parent of all onetimepassword objects in the onetimepassword List array. Any existing onetimepassword will become orphan(s)
* @return null
*/
function SetOnetimepasswordList(&$list)
{
$this->_onetimepasswordList = array();
$existingOnetimepasswordList = $this->GetOnetimepasswordList();
foreach ($existingOnetimepasswordList as $onetimepassword)
{
$onetimepassword->onetimepasswordstatusId = '';
$onetimepassword->Save(false);
}
$this->_onetimepasswordList = $list;
}
/**
* Associates the onetimepassword object to this one
* @return
*/
function AddOnetimepassword(&$onetimepassword)
{
$onetimepassword->onetimepasswordstatusId = $this->onetimepasswordstatusId;
$found = false;
foreach($this->_onetimepasswordList as $onetimepassword2)
{
if ($onetimepassword->onetimepasswordId > 0 && $onetimepassword->onetimepasswordId == $onetimepassword2->onetimepasswordId)
{
$found = true;
break;
}
}
if (!$found)
{
$this->_onetimepasswordList[] = $onetimepassword;
}
}
}
?>

View File

@ -0,0 +1,143 @@
<?php
class POG_Base
{
/**
* Overloading
*/
function __call($method, $argv)
{
include_once($GLOBALS['configuration']['plugins_path']."/IPlugin.php");
include_once($GLOBALS['configuration']['plugins_path']."/plugin.".strtolower($method).".php");
eval('$plugin = new $method($this,$argv);');
return $plugin->Execute();
}
/**
* constructor
*
* @return POG_Base
*/
private function POG_Base()
{
}
function SetFieldAttribute($fieldName, $attributeName, $attributeValue)
{
if (isset($this->pog_attribute_type[$fieldName]) && isset($this->pog_attribute_type[$fieldName][$attributeName]))
{
$this->pog_attribute_type[$fieldName][$attributeName] = $attributeValue;
}
}
function GetFieldAttribute($fieldName, $attributeName)
{
if (isset($this->pog_attribute_type[$fieldName]) && isset($this->pog_attribute_type[$fieldName][$attributeName]))
{
return $this->pog_attribute_type[$fieldName][$attributeName];
}
return null;
}
///////////////////////////
// Data manipulation
///////////////////////////
/**
* This function will try to encode $text to base64, except when $text is a number. This allows us to Escape all data before they're inserted in the database, regardless of attribute type.
* @param string $text
* @return string encoded to base64
*/
public function Escape($text)
{
if ($GLOBALS['configuration']['db_encoding'] && !is_numeric($text))
{
return base64_encode($text);
}
return addslashes($text);
}
/**
* Enter description here...
*
* @param unknown_type $text
* @return unknown
*/
public function Unescape($text)
{
if ($GLOBALS['configuration']['db_encoding'] && !is_numeric($text))
{
return base64_decode($text);
}
return stripcslashes($text);
}
////////////////////////////////
// Table -> Object Mapping
////////////////////////////////
/**
* Executes $query against database and returns the result set as an array of POG objects
*
* @param string $query. SQL query to execute against database
* @param string $objectClass. POG Object type to return
* @param bool $lazy. If true, will also load all children/sibling
*/
public function FetchObjects($query, $objectClass, $lazy = true)
{
$databaseConnection = Database::Connect();
$result = Database::Query($query, $databaseConnection);
$objectList = $this->CreateObjects($result, $objectClass, $lazy);
return $objectList;
}
private function CreateObjects($mysql_result, $objectClass, $lazyLoad = true)
{
$objectList = array();
while ($row = mysql_fetch_assoc($mysql_result))
{
$pog_object = new $objectClass();
$this->PopulateObjectAttributes($row, $pog_object);
$objectList[] = $pog_object;
}
return $objectList;
}
private function PopulateObjectAttributes($fetched_row, $pog_object)
{
foreach ($this->GetAttributes($pog_object) as $column)
{
$pog_object->{$column} = $this->Unescape($fetched_row[strtolower($column)]);
}
return $pog_object;
}
private function GetAttributes($object)
{
$columns = array();
foreach ($object->pog_attribute_type as $att => $properties)
{
if ($properties['db_attributes'][0] != 'OBJECT')
{
$columns[] = $att;
}
}
return $columns;
}
//misc
public static function IsColumn($value)
{
if (strlen($value) > 2)
{
if (substr($value, 0, 1) == '`' && substr($value, strlen($value) - 1, 1) == '`')
{
return true;
}
return false;
}
return false;
}
}
?>

View File

@ -0,0 +1,436 @@
<?php
/*
This SQL query will create the table to store your object.
CREATE TABLE `record` (
`recordid` int(11) NOT NULL auto_increment,
`userid` int(11) NOT NULL,
`reference` VARCHAR(255) NOT NULL,
`data` LONGTEXT NOT NULL,
`version` VARCHAR(255) NOT NULL,
`creation_date` TIMESTAMP NOT NULL,
`update_date` TIMESTAMP NOT NULL,
`access_date` TIMESTAMP NOT NULL, INDEX(`userid`), PRIMARY KEY (`recordid`)) ENGINE=MyISAM;
*/
/**
* <b>record</b> class with integrated CRUD methods.
* @author Php Object Generator
* @version POG 3.0e / PHP5.1 MYSQL
* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
* @copyright Free for personal & commercial use. (Offered under the BSD license)
* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=record&attributeList=array+%28%0A++0+%3D%3E+%27user%27%2C%0A++1+%3D%3E+%27recordversion%27%2C%0A++2+%3D%3E+%27reference%27%2C%0A++3+%3D%3E+%27data%27%2C%0A++4+%3D%3E+%27version%27%2C%0A++5+%3D%3E+%27creation_date%27%2C%0A++6+%3D%3E+%27update_date%27%2C%0A++7+%3D%3E+%27access_date%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527BELONGSTO%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B4%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B5%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B6%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B7%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2529
*/
include_once('class.pog_base.php');
class record extends POG_Base
{
public $recordId = '';
/**
* @var INT(11)
*/
public $userId;
/**
* @var private array of recordversion objects
*/
private $_recordversionList = array();
/**
* @var VARCHAR(255)
*/
public $reference;
/**
* @var LONGTEXT
*/
public $data;
/**
* @var VARCHAR(255)
*/
public $version;
/**
* @var TIMESTAMP
*/
public $creation_date;
/**
* @var TIMESTAMP
*/
public $update_date;
/**
* @var TIMESTAMP
*/
public $access_date;
public $pog_attribute_type = array(
"recordId" => array('db_attributes' => array("NUMERIC", "INT")),
"user" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
"recordversion" => array('db_attributes' => array("OBJECT", "HASMANY")),
"reference" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"data" => array('db_attributes' => array("TEXT", "LONGTEXT")),
"version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"creation_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
"update_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
"access_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
);
public $pog_query;
/**
* Getter for some private attributes
* @return mixed $attribute
*/
public function __get($attribute)
{
if (isset($this->{"_".$attribute}))
{
return $this->{"_".$attribute};
}
else
{
return false;
}
}
function record($reference='', $data='', $version='', $creation_date='', $update_date='', $access_date='')
{
$this->_recordversionList = array();
$this->reference = $reference;
$this->data = $data;
$this->version = $version;
$this->creation_date = $creation_date;
$this->update_date = $update_date;
$this->access_date = $access_date;
}
/**
* Gets object from database
* @param integer $recordId
* @return object $record
*/
function Get($recordId)
{
$connection = Database::Connect();
$this->pog_query = "select * from `record` where `recordid`='".intval($recordId)."' LIMIT 1";
$cursor = Database::Reader($this->pog_query, $connection);
while ($row = Database::Read($cursor))
{
$this->recordId = $row['recordid'];
$this->userId = $row['userid'];
$this->reference = $this->Unescape($row['reference']);
$this->data = $this->Unescape($row['data']);
$this->version = $this->Unescape($row['version']);
$this->creation_date = $row['creation_date'];
$this->update_date = $row['update_date'];
$this->access_date = $row['access_date'];
}
return $this;
}
/**
* Returns a sorted array of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param string $sortBy
* @param boolean $ascending
* @param int limit
* @return array $recordList
*/
function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
{
$connection = Database::Connect();
$sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
$this->pog_query = "select * from `record` ";
$recordList = Array();
if (sizeof($fcv_array) > 0)
{
$this->pog_query .= " where ";
for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
{
if (sizeof($fcv_array[$i]) == 1)
{
$this->pog_query .= " ".$fcv_array[$i][0]." ";
continue;
}
else
{
if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
{
$this->pog_query .= " AND ";
}
if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
{
if ($GLOBALS['configuration']['db_encoding'] == 1)
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
$this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
}
else
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
}
}
else
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
}
}
}
}
if ($sortBy != '')
{
if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
{
if ($GLOBALS['configuration']['db_encoding'] == 1)
{
$sortBy = "BASE64_DECODE($sortBy) ";
}
else
{
$sortBy = "$sortBy ";
}
}
else
{
$sortBy = "$sortBy ";
}
}
else
{
$sortBy = "recordid";
}
$this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
$thisObjectName = get_class($this);
$cursor = Database::Reader($this->pog_query, $connection);
while ($row = Database::Read($cursor))
{
$record = new $thisObjectName();
$record->recordId = $row['recordid'];
$record->userId = $row['userid'];
$record->reference = $this->Unescape($row['reference']);
$record->data = $this->Unescape($row['data']);
$record->version = $this->Unescape($row['version']);
$record->creation_date = $row['creation_date'];
$record->update_date = $row['update_date'];
$record->access_date = $row['access_date'];
$recordList[] = $record;
}
return $recordList;
}
/**
* Saves the object to the database
* @return integer $recordId
*/
function Save($deep = true)
{
$connection = Database::Connect();
$this->pog_query = "select `recordid` from `record` where `recordid`='".$this->recordId."' LIMIT 1";
$rows = Database::Query($this->pog_query, $connection);
if ($rows > 0)
{
$this->pog_query = "update `record` set
`userid`='".$this->userId."',
`reference`='".$this->Escape($this->reference)."',
`data`='".$this->Escape($this->data)."',
`version`='".$this->Escape($this->version)."',
`creation_date`='".$this->creation_date."',
`update_date`='".$this->update_date."',
`access_date`='".$this->access_date."' where `recordid`='".$this->recordId."'";
}
else
{
$this->pog_query = "insert into `record` (`userid`, `reference`, `data`, `version`, `creation_date`, `update_date`, `access_date` ) values (
'".$this->userId."',
'".$this->Escape($this->reference)."',
'".$this->Escape($this->data)."',
'".$this->Escape($this->version)."',
'".$this->creation_date."',
'".$this->update_date."',
'".$this->access_date."' )";
}
$insertId = Database::InsertOrUpdate($this->pog_query, $connection);
if ($this->recordId == "")
{
$this->recordId = $insertId;
}
if ($deep)
{
foreach ($this->_recordversionList as $recordversion)
{
$recordversion->recordId = $this->recordId;
$recordversion->Save($deep);
}
}
return $this->recordId;
}
/**
* Clones the object and saves it to the database
* @return integer $recordId
*/
function SaveNew($deep = false)
{
$this->recordId = '';
return $this->Save($deep);
}
/**
* Deletes the object from the database
* @return boolean
*/
function Delete($deep = false, $across = false)
{
if ($deep)
{
$recordversionList = $this->GetRecordversionList();
foreach ($recordversionList as $recordversion)
{
$recordversion->Delete($deep, $across);
}
}
$connection = Database::Connect();
$this->pog_query = "delete from `record` where `recordid`='".$this->recordId."'";
return Database::NonQuery($this->pog_query, $connection);
}
/**
* Deletes a list of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param bool $deep
* @return
*/
function DeleteList($fcv_array, $deep = false, $across = false)
{
if (sizeof($fcv_array) > 0)
{
if ($deep || $across)
{
$objectList = $this->GetList($fcv_array);
foreach ($objectList as $object)
{
$object->Delete($deep, $across);
}
}
else
{
$connection = Database::Connect();
$pog_query = "delete from `record` where ";
for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
{
if (sizeof($fcv_array[$i]) == 1)
{
$pog_query .= " ".$fcv_array[$i][0]." ";
continue;
}
else
{
if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
{
$pog_query .= " AND ";
}
if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
{
$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
}
else
{
$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
}
}
}
return Database::NonQuery($pog_query, $connection);
}
}
}
/**
* Associates the user object to this one
* @return boolean
*/
function GetUser()
{
$user = new user();
return $user->Get($this->userId);
}
/**
* Associates the user object to this one
* @return
*/
function SetUser(&$user)
{
$this->userId = $user->userId;
}
/**
* Gets a list of recordversion objects associated to this one
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param string $sortBy
* @param boolean $ascending
* @param int limit
* @return array of recordversion objects
*/
function GetRecordversionList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
{
$recordversion = new recordversion();
$fcv_array[] = array("recordId", "=", $this->recordId);
$dbObjects = $recordversion->GetList($fcv_array, $sortBy, $ascending, $limit);
return $dbObjects;
}
/**
* Makes this the parent of all recordversion objects in the recordversion List array. Any existing recordversion will become orphan(s)
* @return null
*/
function SetRecordversionList(&$list)
{
$this->_recordversionList = array();
$existingRecordversionList = $this->GetRecordversionList();
foreach ($existingRecordversionList as $recordversion)
{
$recordversion->recordId = '';
$recordversion->Save(false);
}
$this->_recordversionList = $list;
}
/**
* Associates the recordversion object to this one
* @return
*/
function AddRecordversion(&$recordversion)
{
$recordversion->recordId = $this->recordId;
$found = false;
foreach($this->_recordversionList as $recordversion2)
{
if ($recordversion->recordversionId > 0 && $recordversion->recordversionId == $recordversion2->recordversionId)
{
$found = true;
break;
}
}
if (!$found)
{
$this->_recordversionList[] = $recordversion;
}
}
}
?>

View File

@ -0,0 +1,381 @@
<?php
/*
This SQL query will create the table to store your object.
CREATE TABLE `recordversion` (
`recordversionid` int(11) NOT NULL auto_increment,
`recordid` int(11) NOT NULL,
`reference` VARCHAR(255) NOT NULL,
`header` LONGTEXT NOT NULL,
`data` LONGTEXT NOT NULL,
`version` VARCHAR(255) NOT NULL,
`previous_version_key` VARCHAR(255) NOT NULL,
`previous_version_id` INT NOT NULL,
`creation_date` TIMESTAMP NOT NULL,
`update_date` TIMESTAMP NOT NULL,
`access_date` TIMESTAMP NOT NULL, INDEX(`recordid`), PRIMARY KEY (`recordversionid`)) ENGINE=MyISAM;
*/
/**
* <b>recordversion</b> class with integrated CRUD methods.
* @author Php Object Generator
* @version POG 3.0e / PHP5.1 MYSQL
* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
* @copyright Free for personal & commercial use. (Offered under the BSD license)
* @link http://www.phpobjectgenerator.com/?language=php5.1=pdo&pdoDriver=mysql&objectName=recordversion&attributeList=array+%28%0A++0+%3D%3E+%27record%27%2C%0A++1+%3D%3E+%27reference%27%2C%0A++2+%3D%3E+%27header%27%2C%0A++3+%3D%3E+%27data%27%2C%0A++4+%3D%3E+%27version%27%2C%0A++5+%3D%3E+%27previous_version_key%27%2C%0A++6+%3D%3E+%27previous_version_id%27%2C%0A++7+%3D%3E+%27creation_date%27%2C%0A++8+%3D%3E+%27update_date%27%2C%0A++9+%3D%3E+%27access_date%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527BELONGSTO%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B4%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B5%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B6%2B%253D%253E%2B%2527INT%2527%252C%250A%2B%2B7%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B8%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B9%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2529
*/
include_once('class.pog_base.php');
class recordversion extends POG_Base
{
public $recordversionId = '';
/**
* @var INT(11)
*/
public $recordId;
/**
* @var VARCHAR(255)
*/
public $reference;
/**
* @var LONGTEXT
*/
public $header;
/**
* @var LONGTEXT
*/
public $data;
/**
* @var VARCHAR(255)
*/
public $version;
/**
* @var VARCHAR(255)
*/
public $previous_version_key;
/**
* @var INT
*/
public $previous_version_id;
/**
* @var TIMESTAMP
*/
public $creation_date;
/**
* @var TIMESTAMP
*/
public $update_date;
/**
* @var TIMESTAMP
*/
public $access_date;
public $pog_attribute_type = array(
"recordversionId" => array('db_attributes' => array("NUMERIC", "INT")),
"record" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
"reference" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"header" => array('db_attributes' => array("TEXT", "LONGTEXT")),
"data" => array('db_attributes' => array("TEXT", "LONGTEXT")),
"version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"previous_version_key" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"previous_version_id" => array('db_attributes' => array("NUMERIC", "INT")),
"creation_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
"update_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
"access_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
);
public $pog_query;
/**
* Getter for some private attributes
* @return mixed $attribute
*/
public function __get($attribute)
{
if (isset($this->{"_".$attribute}))
{
return $this->{"_".$attribute};
}
else
{
return false;
}
}
function recordversion($reference='', $header='', $data='', $version='', $previous_version_key='', $previous_version_id='', $creation_date='', $update_date='', $access_date='')
{
$this->reference = $reference;
$this->header = $header;
$this->data = $data;
$this->version = $version;
$this->previous_version_key = $previous_version_key;
$this->previous_version_id = $previous_version_id;
$this->creation_date = $creation_date;
$this->update_date = $update_date;
$this->access_date = $access_date;
}
/**
* Gets object from database
* @param integer $recordversionId
* @return object $recordversion
*/
function Get($recordversionId)
{
$connection = Database::Connect();
$this->pog_query = "select * from `recordversion` where `recordversionid`='".intval($recordversionId)."' LIMIT 1";
$cursor = Database::Reader($this->pog_query, $connection);
while ($row = Database::Read($cursor))
{
$this->recordversionId = $row['recordversionid'];
$this->recordId = $row['recordid'];
$this->reference = $this->Unescape($row['reference']);
$this->header = $this->Unescape($row['header']);
$this->data = $this->Unescape($row['data']);
$this->version = $this->Unescape($row['version']);
$this->previous_version_key = $this->Unescape($row['previous_version_key']);
$this->previous_version_id = $this->Unescape($row['previous_version_id']);
$this->creation_date = $row['creation_date'];
$this->update_date = $row['update_date'];
$this->access_date = $row['access_date'];
}
return $this;
}
/**
* Returns a sorted array of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param string $sortBy
* @param boolean $ascending
* @param int limit
* @return array $recordversionList
*/
function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
{
$connection = Database::Connect();
$sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
$this->pog_query = "select * from `recordversion` ";
$recordversionList = Array();
if (sizeof($fcv_array) > 0)
{
$this->pog_query .= " where ";
for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
{
if (sizeof($fcv_array[$i]) == 1)
{
$this->pog_query .= " ".$fcv_array[$i][0]." ";
continue;
}
else
{
if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
{
$this->pog_query .= " AND ";
}
if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
{
if ($GLOBALS['configuration']['db_encoding'] == 1)
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
$this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
}
else
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
}
}
else
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
}
}
}
}
if ($sortBy != '')
{
if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
{
if ($GLOBALS['configuration']['db_encoding'] == 1)
{
$sortBy = "BASE64_DECODE($sortBy) ";
}
else
{
$sortBy = "$sortBy ";
}
}
else
{
$sortBy = "$sortBy ";
}
}
else
{
$sortBy = "recordversionid";
}
$this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
$thisObjectName = get_class($this);
$cursor = Database::Reader($this->pog_query, $connection);
while ($row = Database::Read($cursor))
{
$recordversion = new $thisObjectName();
$recordversion->recordversionId = $row['recordversionid'];
$recordversion->recordId = $row['recordid'];
$recordversion->reference = $this->Unescape($row['reference']);
$recordversion->header = $this->Unescape($row['header']);
$recordversion->data = $this->Unescape($row['data']);
$recordversion->version = $this->Unescape($row['version']);
$recordversion->previous_version_key = $this->Unescape($row['previous_version_key']);
$recordversion->previous_version_id = $this->Unescape($row['previous_version_id']);
$recordversion->creation_date = $row['creation_date'];
$recordversion->update_date = $row['update_date'];
$recordversion->access_date = $row['access_date'];
$recordversionList[] = $recordversion;
}
return $recordversionList;
}
/**
* Saves the object to the database
* @return integer $recordversionId
*/
function Save()
{
$connection = Database::Connect();
$this->pog_query = "select `recordversionid` from `recordversion` where `recordversionid`='".$this->recordversionId."' LIMIT 1";
$rows = Database::Query($this->pog_query, $connection);
if ($rows > 0)
{
$this->pog_query = "update `recordversion` set
`recordid`='".$this->recordId."',
`reference`='".$this->Escape($this->reference)."',
`header`='".$this->Escape($this->header)."',
`data`='".$this->Escape($this->data)."',
`version`='".$this->Escape($this->version)."',
`previous_version_key`='".$this->Escape($this->previous_version_key)."',
`previous_version_id`='".$this->Escape($this->previous_version_id)."',
`creation_date`='".$this->creation_date."',
`update_date`='".$this->update_date."',
`access_date`='".$this->access_date."' where `recordversionid`='".$this->recordversionId."'";
}
else
{
$this->pog_query = "insert into `recordversion` (`recordid`, `reference`, `header`, `data`, `version`, `previous_version_key`, `previous_version_id`, `creation_date`, `update_date`, `access_date` ) values (
'".$this->recordId."',
'".$this->Escape($this->reference)."',
'".$this->Escape($this->header)."',
'".$this->Escape($this->data)."',
'".$this->Escape($this->version)."',
'".$this->Escape($this->previous_version_key)."',
'".$this->Escape($this->previous_version_id)."',
'".$this->creation_date."',
'".$this->update_date."',
'".$this->access_date."' )";
}
$insertId = Database::InsertOrUpdate($this->pog_query, $connection);
if ($this->recordversionId == "")
{
$this->recordversionId = $insertId;
}
return $this->recordversionId;
}
/**
* Clones the object and saves it to the database
* @return integer $recordversionId
*/
function SaveNew()
{
$this->recordversionId = '';
return $this->Save();
}
/**
* Deletes the object from the database
* @return boolean
*/
function Delete()
{
$connection = Database::Connect();
$this->pog_query = "delete from `recordversion` where `recordversionid`='".$this->recordversionId."'";
return Database::NonQuery($this->pog_query, $connection);
}
/**
* Deletes a list of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param bool $deep
* @return
*/
function DeleteList($fcv_array)
{
if (sizeof($fcv_array) > 0)
{
$connection = Database::Connect();
$pog_query = "delete from `recordversion` where ";
for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
{
if (sizeof($fcv_array[$i]) == 1)
{
$pog_query .= " ".$fcv_array[$i][0]." ";
continue;
}
else
{
if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
{
$pog_query .= " AND ";
}
if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
{
$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
}
else
{
$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
}
}
}
return Database::NonQuery($pog_query, $connection);
}
}
/**
* Associates the record object to this one
* @return boolean
*/
function GetRecord()
{
$record = new record();
return $record->Get($this->recordId);
}
/**
* Associates the record object to this one
* @return
*/
function SetRecord(&$record)
{
$this->recordId = $record->recordId;
}
}
?>

View File

@ -0,0 +1,502 @@
<?php
/*
This SQL query will create the table to store your object.
CREATE TABLE `user` (
`userid` int(11) NOT NULL auto_increment,
`username` VARCHAR(255) NOT NULL,
`srp_s` VARCHAR(255) NOT NULL,
`srp_v` VARCHAR(255) NOT NULL,
`header` LONGTEXT NOT NULL,
`statistics` LONGTEXT NOT NULL,
`auth_version` VARCHAR(255) NOT NULL,
`version` VARCHAR(255) NOT NULL,
`lock` VARCHAR(255) NOT NULL, PRIMARY KEY (`userid`)) ENGINE=MyISAM;
*/
/**
* <b>user</b> class with integrated CRUD methods.
* @author Php Object Generator
* @version POG 3.0e / PHP5.1 MYSQL
* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
* @copyright Free for personal & commercial use. (Offered under the BSD license)
* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=user&attributeList=array+%28%0A++0+%3D%3E+%27username%27%2C%0A++1+%3D%3E+%27srp_s%27%2C%0A++2+%3D%3E+%27srp_v%27%2C%0A++3+%3D%3E+%27header%27%2C%0A++4+%3D%3E+%27statistics%27%2C%0A++5+%3D%3E+%27auth_version%27%2C%0A++6+%3D%3E+%27version%27%2C%0A++7+%3D%3E+%27lock%27%2C%0A++8+%3D%3E+%27record%27%2C%0A++9+%3D%3E+%27onetimepassword%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B4%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B5%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B6%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B7%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B8%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2B%2B9%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2529
*/
include_once('class.pog_base.php');
class user extends POG_Base
{
public $userId = '';
/**
* @var VARCHAR(255)
*/
public $username;
/**
* @var VARCHAR(255)
*/
public $srp_s;
/**
* @var VARCHAR(255)
*/
public $srp_v;
/**
* @var LONGTEXT
*/
public $header;
/**
* @var LONGTEXT
*/
public $statistics;
/**
* @var VARCHAR(255)
*/
public $auth_version;
/**
* @var VARCHAR(255)
*/
public $version;
/**
* @var VARCHAR(255)
*/
public $lock;
/**
* @var private array of record objects
*/
private $_recordList = array();
/**
* @var private array of onetimepassword objects
*/
private $_onetimepasswordList = array();
public $pog_attribute_type = array(
"userId" => array('db_attributes' => array("NUMERIC", "INT")),
"username" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"srp_s" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"srp_v" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"header" => array('db_attributes' => array("TEXT", "LONGTEXT")),
"statistics" => array('db_attributes' => array("TEXT", "LONGTEXT")),
"auth_version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"lock" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
"record" => array('db_attributes' => array("OBJECT", "HASMANY")),
"onetimepassword" => array('db_attributes' => array("OBJECT", "HASMANY")),
);
public $pog_query;
/**
* Getter for some private attributes
* @return mixed $attribute
*/
public function __get($attribute)
{
if (isset($this->{"_".$attribute}))
{
return $this->{"_".$attribute};
}
else
{
return false;
}
}
function user($username='', $srp_s='', $srp_v='', $header='', $statistics='', $auth_version='', $version='', $lock='')
{
$this->username = $username;
$this->srp_s = $srp_s;
$this->srp_v = $srp_v;
$this->header = $header;
$this->statistics = $statistics;
$this->auth_version = $auth_version;
$this->version = $version;
$this->lock = $lock;
$this->_recordList = array();
$this->_onetimepasswordList = array();
}
/**
* Gets object from database
* @param integer $userId
* @return object $user
*/
function Get($userId)
{
$connection = Database::Connect();
$this->pog_query = "select * from `user` where `userid`='".intval($userId)."' LIMIT 1";
$cursor = Database::Reader($this->pog_query, $connection);
while ($row = Database::Read($cursor))
{
$this->userId = $row['userid'];
$this->username = $this->Unescape($row['username']);
$this->srp_s = $this->Unescape($row['srp_s']);
$this->srp_v = $this->Unescape($row['srp_v']);
$this->header = $this->Unescape($row['header']);
$this->statistics = $this->Unescape($row['statistics']);
$this->auth_version = $this->Unescape($row['auth_version']);
$this->version = $this->Unescape($row['version']);
$this->lock = $this->Unescape($row['lock']);
}
return $this;
}
/**
* Returns a sorted array of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param string $sortBy
* @param boolean $ascending
* @param int limit
* @return array $userList
*/
function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
{
$connection = Database::Connect();
$sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
$this->pog_query = "select * from `user` ";
$userList = Array();
if (sizeof($fcv_array) > 0)
{
$this->pog_query .= " where ";
for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
{
if (sizeof($fcv_array[$i]) == 1)
{
$this->pog_query .= " ".$fcv_array[$i][0]." ";
continue;
}
else
{
if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
{
$this->pog_query .= " AND ";
}
if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
{
if ($GLOBALS['configuration']['db_encoding'] == 1)
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
$this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
}
else
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
}
}
else
{
$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
}
}
}
}
if ($sortBy != '')
{
if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
{
if ($GLOBALS['configuration']['db_encoding'] == 1)
{
$sortBy = "BASE64_DECODE($sortBy) ";
}
else
{
$sortBy = "$sortBy ";
}
}
else
{
$sortBy = "$sortBy ";
}
}
else
{
$sortBy = "userid";
}
$this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
$thisObjectName = get_class($this);
$cursor = Database::Reader($this->pog_query, $connection);
while ($row = Database::Read($cursor))
{
$user = new $thisObjectName();
$user->userId = $row['userid'];
$user->username = $this->Unescape($row['username']);
$user->srp_s = $this->Unescape($row['srp_s']);
$user->srp_v = $this->Unescape($row['srp_v']);
$user->header = $this->Unescape($row['header']);
$user->statistics = $this->Unescape($row['statistics']);
$user->auth_version = $this->Unescape($row['auth_version']);
$user->version = $this->Unescape($row['version']);
$user->lock = $this->Unescape($row['lock']);
$userList[] = $user;
}
return $userList;
}
/**
* Saves the object to the database
* @return integer $userId
*/
function Save($deep = true)
{
$connection = Database::Connect();
$this->pog_query = "select `userid` from `user` where `userid`='".$this->userId."' LIMIT 1";
$rows = Database::Query($this->pog_query, $connection);
if ($rows > 0)
{
$this->pog_query = "update `user` set
`username`='".$this->Escape($this->username)."',
`srp_s`='".$this->Escape($this->srp_s)."',
`srp_v`='".$this->Escape($this->srp_v)."',
`header`='".$this->Escape($this->header)."',
`statistics`='".$this->Escape($this->statistics)."',
`auth_version`='".$this->Escape($this->auth_version)."',
`version`='".$this->Escape($this->version)."',
`lock`='".$this->Escape($this->lock)."'where `userid`='".$this->userId."'";
}
else
{
$this->pog_query = "insert into `user` (`username`, `srp_s`, `srp_v`, `header`, `statistics`, `auth_version`, `version`, `lock`) values (
'".$this->Escape($this->username)."',
'".$this->Escape($this->srp_s)."',
'".$this->Escape($this->srp_v)."',
'".$this->Escape($this->header)."',
'".$this->Escape($this->statistics)."',
'".$this->Escape($this->auth_version)."',
'".$this->Escape($this->version)."',
'".$this->Escape($this->lock)."')";
}
$insertId = Database::InsertOrUpdate($this->pog_query, $connection);
if ($this->userId == "")
{
$this->userId = $insertId;
}
if ($deep)
{
foreach ($this->_recordList as $record)
{
$record->userId = $this->userId;
$record->Save($deep);
}
foreach ($this->_onetimepasswordList as $onetimepassword)
{
$onetimepassword->userId = $this->userId;
$onetimepassword->Save($deep);
}
}
return $this->userId;
}
/**
* Clones the object and saves it to the database
* @return integer $userId
*/
function SaveNew($deep = false)
{
$this->userId = '';
return $this->Save($deep);
}
/**
* Deletes the object from the database
* @return boolean
*/
function Delete($deep = false, $across = false)
{
if ($deep)
{
$recordList = $this->GetRecordList();
foreach ($recordList as $record)
{
$record->Delete($deep, $across);
}
$onetimepasswordList = $this->GetOnetimepasswordList();
foreach ($onetimepasswordList as $onetimepassword)
{
$onetimepassword->Delete($deep, $across);
}
}
$connection = Database::Connect();
$this->pog_query = "delete from `user` where `userid`='".$this->userId."'";
return Database::NonQuery($this->pog_query, $connection);
}
/**
* Deletes a list of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param bool $deep
* @return
*/
function DeleteList($fcv_array, $deep = false, $across = false)
{
if (sizeof($fcv_array) > 0)
{
if ($deep || $across)
{
$objectList = $this->GetList($fcv_array);
foreach ($objectList as $object)
{
$object->Delete($deep, $across);
}
}
else
{
$connection = Database::Connect();
$pog_query = "delete from `user` where ";
for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
{
if (sizeof($fcv_array[$i]) == 1)
{
$pog_query .= " ".$fcv_array[$i][0]." ";
continue;
}
else
{
if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
{
$pog_query .= " AND ";
}
if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
{
$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
}
else
{
$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
}
}
}
return Database::NonQuery($pog_query, $connection);
}
}
}
/**
* Gets a list of record objects associated to this one
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param string $sortBy
* @param boolean $ascending
* @param int limit
* @return array of record objects
*/
function GetRecordList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
{
$record = new record();
$fcv_array[] = array("userId", "=", $this->userId);
$dbObjects = $record->GetList($fcv_array, $sortBy, $ascending, $limit);
return $dbObjects;
}
/**
* Makes this the parent of all record objects in the record List array. Any existing record will become orphan(s)
* @return null
*/
function SetRecordList(&$list)
{
$this->_recordList = array();
$existingRecordList = $this->GetRecordList();
foreach ($existingRecordList as $record)
{
$record->userId = '';
$record->Save(false);
}
$this->_recordList = $list;
}
/**
* Associates the record object to this one
* @return
*/
function AddRecord(&$record)
{
$record->userId = $this->userId;
$found = false;
foreach($this->_recordList as $record2)
{
if ($record->recordId > 0 && $record->recordId == $record2->recordId)
{
$found = true;
break;
}
}
if (!$found)
{
$this->_recordList[] = $record;
}
}
/**
* Gets a list of onetimepassword objects associated to this one
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param string $sortBy
* @param boolean $ascending
* @param int limit
* @return array of onetimepassword objects
*/
function GetOnetimepasswordList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
{
$onetimepassword = new onetimepassword();
$fcv_array[] = array("userId", "=", $this->userId);
$dbObjects = $onetimepassword->GetList($fcv_array, $sortBy, $ascending, $limit);
return $dbObjects;
}
/**
* Makes this the parent of all onetimepassword objects in the onetimepassword List array. Any existing onetimepassword will become orphan(s)
* @return null
*/
function SetOnetimepasswordList(&$list)
{
$this->_onetimepasswordList = array();
$existingOnetimepasswordList = $this->GetOnetimepasswordList();
foreach ($existingOnetimepasswordList as $onetimepassword)
{
$onetimepassword->userId = '';
$onetimepassword->Save(false);
}
$this->_onetimepasswordList = $list;
}
/**
* Associates the onetimepassword object to this one
* @return
*/
function AddOnetimepassword(&$onetimepassword)
{
$onetimepassword->userId = $this->userId;
$found = false;
foreach($this->_onetimepasswordList as $onetimepassword2)
{
if ($onetimepassword->onetimepasswordId > 0 && $onetimepassword->onetimepasswordId == $onetimepassword2->onetimepasswordId)
{
$found = true;
break;
}
}
if (!$found)
{
$this->_onetimepasswordList[] = $onetimepassword;
}
}
}
?>

View File

@ -0,0 +1,48 @@
<?php
/**
* All functions must be implemented to create a correct POG plugin
* The 'optional' functions SetupRender() and AuthorPage() must be implemented and return null
* if your plugin does not need them.
*
*/
interface POG_Plugin
{
/**
*
* REQUIRED
* This function must return the version of the plugin.
* It will be used to automatically notify developer when your plugin is updated.
*
*/
function Version();
/**
*
* REQUIRED
* This function performs the actions that your plugin provides.
*
*/
function Execute();
/**
* 'OPTIONAL'
* If your plugin needs an administrative interface, implement this function.
* Else return null
*
*/
function SetupRender();
/**
*
* 'OPTIONAL'
* Implement this function to provide a link to your homepage.
* e.g. return 'http://myhomepage.com';
*
* return null if you do not want to link to your homepage
* e.g. return null
*
*/
function AuthorPage();
}
?>

View File

@ -0,0 +1,172 @@
-- base64.sql - MySQL base64 encoding/decoding functions
-- Copyright (C) 2006 Ian Gulliver
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of version 2 of the GNU General Public License as
-- published by the Free Software Foundation.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
DROP TABLE IF EXISTS base64_data |
CREATE TABLE base64_data (c CHAR(1) BINARY, val TINYINT) |
INSERT INTO base64_data VALUES
('A',0), ('B',1), ('C',2), ('D',3), ('E',4), ('F',5), ('G',6), ('H',7), ('I',8), ('J',9),
('K',10), ('L',11), ('M',12), ('N',13), ('O',14), ('P',15), ('Q',16), ('R',17), ('S',18), ('T',19),
('U',20), ('V',21), ('W',22), ('X',23), ('Y',24), ('Z',25), ('a',26), ('b',27), ('c',28), ('d',29),
('e',30), ('f',31), ('g',32), ('h',33), ('i',34), ('j',35), ('k',36), ('l',37), ('m',38), ('n',39),
('o',40), ('p',41), ('q',42), ('r',43), ('s',44), ('t',45), ('u',46), ('v',47), ('w',48), ('x',49),
('y',50), ('z',51), ('0',52), ('1',53), ('2',54), ('3',55), ('4',56), ('5',57), ('6',58), ('7',59),
('8',60), ('9',61), ('+',62), ('/',63), ('=',0) |
DROP FUNCTION IF EXISTS BASE64_DECODE |
CREATE FUNCTION BASE64_DECODE (input BLOB)
RETURNS BLOB
CONTAINS SQL
DETERMINISTIC
SQL SECURITY INVOKER
BEGIN
DECLARE ret BLOB DEFAULT '';
DECLARE done TINYINT DEFAULT 0;
IF input IS NULL THEN
RETURN NULL;
END IF;
each_block:
WHILE NOT done DO BEGIN
DECLARE accum_value BIGINT UNSIGNED DEFAULT 0;
DECLARE in_count TINYINT DEFAULT 0;
DECLARE out_count TINYINT DEFAULT 3;
each_input_char:
WHILE in_count < 4 DO BEGIN
DECLARE first_char CHAR(1);
IF LENGTH(input) = 0 THEN
RETURN ret;
END IF;
SET first_char = SUBSTRING(input,1,1);
SET input = SUBSTRING(input,2);
BEGIN
DECLARE tempval TINYINT UNSIGNED;
DECLARE error TINYINT DEFAULT 0;
DECLARE base64_getval CURSOR FOR SELECT val FROM base64_data WHERE c = first_char;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET error = 1;
OPEN base64_getval;
FETCH base64_getval INTO tempval;
CLOSE base64_getval;
IF error THEN
ITERATE each_input_char;
END IF;
SET accum_value = (accum_value << 6) + tempval;
END;
SET in_count = in_count + 1;
IF first_char = '=' THEN
SET done = 1;
SET out_count = out_count - 1;
END IF;
END; END WHILE;
-- We've now accumulated 24 bits; deaccumulate into bytes
-- We have to work from the left, so use the third byte position and shift left
WHILE out_count > 0 DO BEGIN
SET ret = CONCAT(ret,CHAR((accum_value & 0xff0000) >> 16));
SET out_count = out_count - 1;
SET accum_value = (accum_value << 8) & 0xffffff;
END; END WHILE;
END; END WHILE;
RETURN ret;
END |
DROP FUNCTION IF EXISTS BASE64_ENCODE |
CREATE FUNCTION BASE64_ENCODE (input BLOB)
RETURNS BLOB
CONTAINS SQL
DETERMINISTIC
SQL SECURITY INVOKER
BEGIN
DECLARE ret BLOB DEFAULT '';
DECLARE done TINYINT DEFAULT 0;
IF input IS NULL THEN
RETURN NULL;
END IF;
each_block:
WHILE NOT done DO BEGIN
DECLARE accum_value BIGINT UNSIGNED DEFAULT 0;
DECLARE in_count TINYINT DEFAULT 0;
DECLARE out_count TINYINT;
each_input_char:
WHILE in_count < 3 DO BEGIN
DECLARE first_char CHAR(1);
IF LENGTH(input) = 0 THEN
SET done = 1;
SET accum_value = accum_value << (8 * (3 - in_count));
LEAVE each_input_char;
END IF;
SET first_char = SUBSTRING(input,1,1);
SET input = SUBSTRING(input,2);
SET accum_value = (accum_value << 8) + ASCII(first_char);
SET in_count = in_count + 1;
END; END WHILE;
-- We've now accumulated 24 bits; deaccumulate into base64 characters
-- We have to work from the left, so use the third byte position and shift left
CASE
WHEN in_count = 3 THEN SET out_count = 4;
WHEN in_count = 2 THEN SET out_count = 3;
WHEN in_count = 1 THEN SET out_count = 2;
ELSE RETURN ret;
END CASE;
WHILE out_count > 0 DO BEGIN
BEGIN
DECLARE out_char CHAR(1);
DECLARE base64_getval CURSOR FOR SELECT c FROM base64_data WHERE val = (accum_value >> 18);
OPEN base64_getval;
FETCH base64_getval INTO out_char;
CLOSE base64_getval;
SET ret = CONCAT(ret,out_char);
SET out_count = out_count - 1;
SET accum_value = accum_value << 6 & 0xffffff;
END;
END; END WHILE;
CASE
WHEN in_count = 2 THEN SET ret = CONCAT(ret,'=');
WHEN in_count = 1 THEN SET ret = CONCAT(ret,'==');
ELSE BEGIN END;
END CASE;
END; END WHILE;
RETURN ret;
END |

View File

@ -0,0 +1,20 @@
-- base64.sql - MySQL base64 encoding/decoding functions
-- Copyright (C) 2006 Ian Gulliver
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of version 2 of the GNU General Public License as
-- published by the Free Software Foundation.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
DROP TABLE IF EXISTS base64_data |
DROP FUNCTION IF EXISTS BASE64_DECODE |
DROP FUNCTION IF EXISTS BASE64_ENCODE |

View File

@ -0,0 +1,128 @@
<?php
class Base64
{
var $sourceObject;
var $argv;
var $version = '1.0';
function Version()
{
return $this->version;
}
function Base64($sourceObject, $argv)
{
$this->sourceObject = $sourceObject;
$this->argv = $argv;
}
function Execute()
{
return null;
}
function SetupRender()
{
if (isset($_POST['install_base64']) || isset($_POST['uninstall_base64']))
{
$this->SetupExecute();
}
else
{
$out = "This plugin allows you to install and uninstall a base64 custom function to and from your database.
You can then set \$configuration['db_encoding'] = 1 so that all data is transparently encoded and decoded
with the minimal overhead possible. Enabling data encoding has quite a few advantages: <br/><br/>
";
$out .= "<br/><br/><textarea>BASE64 Status";
if (Base64::IsBase64FunctionInstalled())
{
$out .= "\n\tChecking MySQL function....OK!";
if (!isset($GLOBALS['configuration']['db_encoding']) || $GLOBALS['configuration']['db_encoding'] != 1)
{
$out .= "\n\tChecking db_encoding status....Failed";
$out .= "\n\n---------------------------------------------------";
$out .= "\n\$configuration['db_encoding'] is set to 0. Make sure you set the value to 1 to enable data encoding.";
}
else
{
$out .= "\n\tChecking db_encoding status....OK!";
$out .= "\n\nBASE64 Status...OK!";
$out .= "\n---------------------------------------------------";
}
$out .= "</textarea><div style='padding-left:250px;padding-top:10px;'><input type='submit' value='UNINSTALL' name='uninstall_base64'/></div>";
}
else
{
$out .= "\n\tChecking MySQL function....NOT INSTALLED";
$out .= "\n\tChecking db_encoding status ignored";
$out .= "\n\n---------------------------------------------------";
$out .= "\nClick the INSTALL button below to install the base64 function to your database.";
$out .= "</textarea><div style='padding-left:250px;padding-top:10px;'><input type='submit' value='INSTALL' name='install_base64'/></div>";
}
$out .= "<input type='hidden' name='plugins' value='true'/>";
echo $out;
}
}
function AuthorPage()
{
return null;
}
function SetupExecute()
{
$out = '';
$connection = Database::Connect();
if (isset($_POST['install_base64']) && isset($_POST['install_base64']) == true)
{
$initialData = file_get_contents('../plugins/base64_install.sql');
$statements = explode('|', $initialData);
if (sizeof($statements) > 0)
{
foreach ($statements as $statement)
{
if (trim($statement) != '')
{
Database::NonQuery($statement, $connection);
}
}
}
$out .= "<textarea>INSTALL SUCCESSFUL\n\n";
$out .= "Make sure you set \$configuration[db_encoding] = 1 in the configuration file.</textarea>";
}
else if (isset($_POST['uninstall_base64']) && $_POST['uninstall_base64'] == true)
{
$initialData = file_get_contents('../plugins/base64_uninstall.sql');
$statements = explode('|', $initialData);
if (sizeof($statements) > 0)
{
foreach ($statements as $statement)
{
if (trim($statement) != '')
{
Database::NonQuery($statement, $connection);
}
}
}
$out .= "<textarea>UNINSTALL SUCCESSFUL\n\n";
$out .= "Make sure you set \$configuration[db_encoding] = 0 in the configuration file.</textarea>";
}
echo $out;
}
function IsBase64FunctionInstalled()
{
$sql1 = "show function status where Db='".$GLOBALS['configuration']['db']."' and (Name='BASE64_DECODE' or Name='BASE64_ENCODE')";
$sql2 = "show tables like 'base64_data'";
$connection = Database::Connect();
$result = Database::Query($sql1, $connection);
$result2 = Database::Query($sql2, $connection);
if ($result == 2 && $result2 == 1)
{
return true;
}
return false;
}
}

View File

@ -0,0 +1,13 @@
Hello there,
To make use of the Data Initialization feature in POG Setup, put your insert statements in the data_initialization.sql file. (One per line).
Then, on step 1 of Setup, choose "Drop, recreate tables and reset data":
This will
1. Drop any tables that have the same name as the object(s) you have in the objects folder.
2. Recreate the tables and indexes(if needed)
3. Execute the insert statements in data_initialization.sql one by one.
Regards,
The POG Team

View File

@ -0,0 +1,205 @@
<?php
/* $Id: read_dump.lib.php,v 2.11 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* Removes comment lines and splits up large sql files into individual queries
*
* Last revision: September 23, 2001 - gandon
*
* @param array the splitted sql commands
* @param string the sql commands
* @param integer the MySQL release number (because certains php3 versions
* can't get the value of a constant from within a function)
*
* @return boolean always true
*
* @access public
*/
function PMA_splitSqlFile(&$ret, $sql, $release)
{
// do not trim, see bug #1030644
//$sql = trim($sql);
$sql = rtrim($sql, "\n\r");
$sql_len = strlen($sql);
$char = '';
$string_start = '';
$in_string = FALSE;
$nothing = TRUE;
$time0 = time();
for ($i = 0; $i < $sql_len; ++$i) {
$char = $sql[$i];
// We are in a string, check for not escaped end of strings except for
// backquotes that can't be escaped
if ($in_string) {
for (;;) {
$i = strpos($sql, $string_start, $i);
// No end of string found -> add the current substring to the
// returned array
if (!$i) {
$ret[] = array('query' => $sql, 'empty' => $nothing);
return TRUE;
}
// Backquotes or no backslashes before quotes: it's indeed the
// end of the string -> exit the loop
elseif ($string_start == '`' || $sql[$i-1] != '\\') {
$string_start = '';
$in_string = FALSE;
break;
}
// one or more Backslashes before the presumed end of string...
else {
// ... first checks for escaped backslashes
$j = 2;
$escaped_backslash = FALSE;
while ($i-$j > 0 && $sql[$i-$j] == '\\') {
$escaped_backslash = !$escaped_backslash;
$j++;
}
// ... if escaped backslashes: it's really the end of the
// string -> exit the loop
if ($escaped_backslash) {
$string_start = '';
$in_string = FALSE;
break;
}
// ... else loop
else {
$i++;
}
} // end if...elseif...else
} // end for
} // end if (in string)
// lets skip comments (/*, -- and #)
elseif (($char == '-' && $sql_len > $i + 2 && $sql[$i + 1] == '-' && $sql[$i + 2] <= ' ') || $char == '#' || ($char == '/' && $sql_len > $i + 1 && $sql[$i + 1] == '*')) {
$i = strpos($sql, $char == '/' ? '*/' : "\n", $i);
// didn't we hit end of string?
if ($i === FALSE) {
break;
}
if ($char == '/') {
$i++;
}
}
// We are not in a string, first check for delimiter...
elseif ($char == ';') {
// if delimiter found, add the parsed part to the returned array
$ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing);
$nothing = TRUE;
$sql = ltrim(substr($sql, min($i + 1, $sql_len)));
$sql_len = strlen($sql);
if ($sql_len) {
$i = -1;
} else {
// The submited statement(s) end(s) here
return TRUE;
}
} // end elseif (is delimiter)
// ... then check for start of a string,...
elseif (($char == '"') || ($char == '\'') || ($char == '`')) {
$in_string = TRUE;
$nothing = FALSE;
$string_start = $char;
} // end elseif (is start of string)
elseif ($nothing) {
$nothing = FALSE;
}
// loic1: send a fake header each 30 sec. to bypass browser timeout
$time1 = time();
if ($time1 >= $time0 + 30) {
$time0 = $time1;
header('X-pmaPing: Pong');
} // end if
} // end for
// add any rest to the returned array
if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) {
$ret[] = array('query' => $sql, 'empty' => $nothing);
}
return TRUE;
} // end of the 'PMA_splitSqlFile()' function
/**
* Reads (and decompresses) a (compressed) file into a string
*
* @param string the path to the file
* @param string the MIME type of the file, if empty MIME type is autodetected
*
* @global array the phpMyAdmin configuration
*
* @return string the content of the file or
* boolean FALSE in case of an error.
*/
function PMA_readFile($path, $mime = '') {
global $cfg;
if (!file_exists($path)) {
return FALSE;
}
switch ($mime) {
case '':
$file = @fopen($path, 'rb');
if (!$file) {
return FALSE;
}
$test = fread($file, 3);
fclose($file);
if ($test[0] == chr(31) && $test[1] == chr(139)) {
return PMA_readFile($path, 'application/x-gzip');
}
if ($test == 'BZh') {
return PMA_readFile($path, 'application/x-bzip');
}
return PMA_readFile($path, 'text/plain');
case 'text/plain':
$file = @fopen($path, 'rb');
if (!$file) {
return FALSE;
}
$content = fread($file, filesize($path));
fclose($file);
break;
case 'application/x-gzip':
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
$file = @gzopen($path, 'rb');
if (!$file) {
return FALSE;
}
$content = '';
while (!gzeof($file)) {
$content .= gzgetc($file);
}
gzclose($file);
} else {
return FALSE;
}
break;
case 'application/x-bzip':
if ($cfg['BZipDump'] && @function_exists('bzdecompress')) {
$file = @fopen($path, 'rb');
if (!$file) {
return FALSE;
}
$content = fread($file, filesize($path));
fclose($file);
$content = bzdecompress($content);
} else {
return FALSE;
}
break;
default:
return FALSE;
}
return $content;
}
?>

View File

@ -0,0 +1,717 @@
<?php
/**
* @author Joel Wan & Mark Slemko. Designs by Jonathan Easton
* @link http://www.phpobjectgenerator.com
* @copyright Offered under the BSD license
*
* This setup file does the following:
* 1. Checks if configuration file is present
* 2. Checks if the data in the configuration file is correct
* 3. Checks if the database and table exist
* 4. Create table if not present
* 5. Tests 5 CRUD functions and determine if everything is OK for all objects within the current directory
* 6. When all tests pass, provides an interface to the database and a way to manage objects.
*/
if (!isset($_SESSION))
{
session_start();
}
if(file_exists("../configuration.php"))
{
include_once("../configuration.php");
}
include_once("setup_library/authentication.php");
include_once("setup_library/setup_misc.php");
include_once("data_initialization/read_dump_lib.php");
if(!isset($_SESSION['diagnosticsSuccessful']) || (isset($_GET['step']) && $_GET['step']=="diagnostics"))
{
$_SESSION['diagnosticsSuccessful'] = false;
}
?>
<?php include "setup_library/inc.header.php";?>
<?php
ini_set("max_execution_time", 0);
if(count($_POST) > 0 && $_SESSION['diagnosticsSuccessful']==false)
{
?>
<form action="./index.php" method="POST">
<div class="container">
<div class="left">
<div class="logo2"></div>
<div class="text"><div class="gold">POG setup diagnostics</div>
<br/>Setup performs unit tests on all your objects in the object directory and makes sure they're OK. <br/>This makes sure that your objects can talk to your database correctly. This can also be useful if you modify / customize the objects manually and want to make sure they still work once you're done.
<br/><br/>The diagnostics screen on the right shows the results of those tests. If all tests pass successfully, you can be assured that all objects are working correctly.
</div>
</div>
<div class="middle">
<div id="tabs">
<a href="./index.php?step=diagnostics"><img src="./setup_images/tab_setup.gif"/></a>
<img src="./setup_images/tab_separator.gif"/>
<img src="./setup_images/tab_diagnosticresults_on.gif"/>
<img src="./setup_images/tab_separator.gif"/>
<img src="./setup_images/tab_manageobjects.gif"/>
<img src="./setup_images/tab_separator.gif"/>
<img src="./setup_images/tab_manageplugins_off.gif"/>
</div><div class="subtabs">&nbsp;</div><a href="./index.php?step=diagnostics"><img src="./setup_images/setup_recheck.jpg" border="0"/></a><div class="middle2">
<?php
$errors = 0;
AddTrace('Initializing POG Setup....OK!');
if (isset($GLOBALS['configuration']['pdoDriver']))
{
$errors++;
AddError('POG setup for PHP4/5 objects cannot be run with a PDO configuration file. Regenerate configuration.php');
}
else
{
/**
* verify file structure status
*/
if(!file_exists("../objects/class.database.php"))
{
$errors++;
AddError('Database wrapper (class.database.php) is missing.');
}
else
{
include "../objects/class.database.php";
}
if(!file_exists("../objects/class.pog_base.php"))
{
$errors++;
AddError('POG Base class (class.pog_base.php) is missing.');
}
else
{
include "../objects/class.pog_base.php";
}
if (!file_exists("../configuration.php"))
{
$errors++;
AddError('Configuration file (configuration.php) is missing');
}
if ($GLOBALS['configuration']['plugins_path'] == '')
{
$errors++;
AddError('Path to plugin folder has not been specified in configuration.php');
}
else
{
if (!file_exists($GLOBALS['configuration']['plugins_path']."/plugin.base64.php"))
{
$errors++;
AddError('Base64 plugin file (plugins/plugin.base64.php) is missing');
}
else
{
include_once($GLOBALS['configuration']['plugins_path']."/plugin.base64.php");
}
}
//load object names to be ignored
$ignoreObjects = file("../objects/ignore_objects.txt");
foreach ($ignoreObjects as $key=>$ignoreObject){
$ignoreObjects[$key] = trim($ignoreObject);
}
$dir = opendir('../objects/');
$objects = array();
while(($file = readdir($dir)) !== false)
{
if(strlen($file) > 4 && substr(strtolower($file), strlen($file) - 4) === '.php' && !is_dir($file) && $file != "class.database.php" && $file != "class.pog_base.php")
{
$objects[] = $file;
include_once("../objects/{$file}");
}
}
closedir($dir);
if (sizeof($objects) == 0)
{
$errors++;
AddError("[objects] folder does not contain any POG object.");
}
if ($errors == 0)
{
$dir = opendir($GLOBALS['configuration']['plugins_path']);
$plugins = array();
while(($file = readdir($dir)) !== false)
{
if(file_exists($GLOBALS['configuration']['plugins_path']."/IPlugin.php"))
{
include_once($GLOBALS['configuration']['plugins_path']."/IPlugin.php");
}
if(strlen($file) > 4 && substr(strtolower($file), strlen($file) - 4) === '.php' && !is_dir($file) && strtolower(substr($file, 0, 6)) == 'plugin')
{
include_once($GLOBALS['configuration']['plugins_path']."/{$file}");
$pluginName = GetPluginName($file);
if ($pluginName != '')
{
$plugins[] = $file;
}
}
}
closedir($dir);
}
/**
* verify configuration info
*/
if ($errors == 0)
{
AddTrace('File Structure....OK!');
if (!@mysql_connect ($GLOBALS['configuration']['host'].":".$GLOBALS['configuration']['port'], $GLOBALS['configuration']['user'], $GLOBALS['configuration']['pass']))
{
$errors++;
AddError('Cannot connect to the specified database server. Edit configuration.php');
}
if (isset($GLOBALS['configuration']['db_encoding']) && $GLOBALS['configuration']['db_encoding'] == 1 && !Base64::IsBase64FunctionInstalled())
{
$errors++;
AddError('$configuration[db_encoding] needs to be set to 0 until you install the base64 plugin. Set db_encoding to 0 by editing configuration.php, run setup again and go to the "Manage Plugins" tab. Install the base64 plugin. Then you can set db_encoding = 1');
}
if ($errors == 0)
{
if (!@mysql_select_db ($GLOBALS['configuration']['db']))
{
$errors++;
AddError('Cannot find the specified database "'.$GLOBALS['configuration']['db'].'". Edit configuration.php');
}
}
}
/**
* verify storage status
*/
if ($errors == 0)
{
AddTrace("Configuration Info....OK!\n");
AddTrace("Storage Status");
foreach($objects as $object)
{
$objectName = GetObjectName("../objects/".$object);
eval ('$instance = new '.$objectName.'();');
if (TestStorageExists($objectName, "mysql"))
{
if (isset($_POST['pog_table']) && ($_POST['pog_table'] == "recreate" || $_POST['pog_table'] == "recreate_import"))
{
if (!TestDeleteStorage($instance))
{
$errors++;
AddError("Dropping table '".strtolower($objectName)."' failed. Drop and recreate the table manually.");
}
else
{
if (!TestCreateStorage("../objects/".$object))
{
$errors++;
AddError("Creating table [".strtolower($objectName)."] failed. Create the table manually using the generated SQL query in the object header.");
}
else
{
AddTrace("\tDropping & Recreating table [".strtolower($objectName)."]....OK!");
}
}
}
else
{
if (!TestAlterStorage($instance))
{
$errors++;
AddError("Aligning [$objectName] with table '".strtolower($objectName)."' failed. Alter the table manually so that object attributes and table columns match.");
}
else
{
AddTrace("\tAligning [$objectName] with table '".strtolower($objectName)."'....OK!");
}
}
}
else
{
if (!TestCreateStorage("../objects/".$object))
{
$errors++;
AddError("Creating table [".strtolower($objectName)."] failed. Create the table manually using the generated SQL query in the object header.");
}
else
{
AddTrace("\tCreating table [".strtolower($objectName)."]....OK!");
}
}
}
}
$objectNameList = array();
/**
* Initialize test data?
*/
if (isset($_POST['pog_table']) && $_POST['pog_table'] == 'recreate_import')
{
$initialData = file_get_contents('data_initialization/data_initialization.sql');
PMA_splitSqlFile($statements, $initialData, 4);
if (sizeof($statements) > 0)
{
foreach ($statements as $statement)
{
if (!TestExecuteQuery($statement['query']))
{
$errors++;
AddError('Statement "'.$statement['query'].'" failed');
}
}
}
$structure_changes = file_get_contents('data_initialization/additional_table_structures.sql');
unset($statements);
PMA_splitSqlFile($statements, $structure_changes, 4);
if (sizeof($statements) > 0)
{
foreach ($statements as $statement)
{
if (!TestExecuteQuery($statement['query']))
{
$errors++;
AddError('Statement "'.$statement['query'].'" failed');
}
}
}
}
/**
* verify object status
*/
$objectNameList = array();
foreach($objects as $object)
{
$objectName = GetObjectName("../objects/".$object);
if (isset($objectName) && array_search($objectName, $ignoreObjects) ===false)
{
$objectNameList[] = $objectName;
}
}
if ($errors == 0)
{
$pluginNameList = array();
foreach($plugins as $plugin)
{
$pluginName = GetPluginName($plugin);
if ($pluginName != '')
{
$pluginNameList[] = $pluginName;
}
}
}
if ($errors == 0 && isset($_POST['pog_test']) && $_POST['pog_test'] == 'yes')
{
AddTrace("\nPOG Essentials");
$_SESSION['links'] = array();
$objectCount = 1;
foreach($objects as $object)
{
$objectName = GetObjectName("../objects/".$object);
if (isset($objectName) && array_search($objectName, $ignoreObjects) ===false)
{
eval('$instance = new '.$objectName.'();');
AddTrace("\t[".$objectName."]");
$link = GetAtLink("../objects/".$object);
$_SESSION['links'][$objectName] = $link;
if (!TestEssentials($instance))
{
$errors++;
AddError("Object $objectName failed essential tests");
}
if ($objectCount != sizeof($objects))
{
AddTrace("\t***");
}
}
$objectCount++;
}
}
if ($errors == 0 && isset($_POST['pog_test']) && $_POST['pog_test'] == 'yes')
{
AddTrace("\nPOG Relations PreRequisites");
$objectCount = 1;
foreach ($objects as $object)
{
$objectName = GetObjectName("../objects/".$object);
if (isset($objectName) && array_search($objectName, $ignoreObjects) ===false)
{
eval('$instance = new '.$objectName.'();');
AddTrace("\t[".$objectName."]");
if (!TestRelationsPreRequisites($instance, $objectNameList, $objectName, $ignoreObjects))
{
$errors++;
}
if ($objectCount != sizeof($objects))
{
AddTrace("\t***");
}
}
$objectCount++;
}
}
if ($errors == 0 && isset($_POST['pog_test']) && $_POST['pog_test'] == 'yes')
{
AddTrace("\nPOG Relations");
$objectCount = 1;
foreach ($objects as $object)
{
$objectName = GetObjectName("../objects/".$object);
if (isset($objectName) && array_search($objectName, $ignoreObjects) ===false)
{
eval('$instance = new '.$objectName.'();');
AddTrace("\t[".$objectName."]");
if (!TestRelations($instance, $objectNameList, $ignoreObjects))
{
$errors++;
AddError("Object $objectName failed relations tests");
}
if ($objectCount != sizeof($objects))
{
AddTrace("\t***");
}
}
$objectCount++;
}
}
if ($errors == 0)
{
$_SESSION['diagnosticsSuccessful'] = true;
}
if(isset($_POST['pog_test']) && $_POST['pog_test'] == 'no')
{
AddTrace("\nUNIT TESTS NOT PERFORMED. FOUND $errors ERROR(S)");
}
else
{
AddTrace("\nCHECKED ".count($objectNameList)." OBJECT(S). FOUND $errors ERROR(S)".($errors == 0 ? ". HURRAY!" : ":"));
}
AddTrace("---------------------------------------------------");
if (isset($_SESSION['errorMessages']))
{
$errorMessages = unserialize($_SESSION['errorMessages']);
}
$traceMessages = unserialize($_SESSION['traceMessages']);
$diagnostics = '';
foreach ($traceMessages as $traceMessage)
{
$diagnostics .= "\n$traceMessage";
}
if (isset($errorMessages))
{
foreach ($errorMessages as $errorMessage)
{
$diagnostics .= "\n$errorMessage\n";
}
}
$_SESSION['fileNames'] = serialize($objects);
$_SESSION['objectNameList'] = serialize($objectNameList);
if (isset($pluginNameList))
{
$_SESSION['pluginNameList'] = serialize($pluginNameList);
}
}
echo "<textarea>".$diagnostics."</textarea><br/><br/><br/></div>";
if ($_SESSION['diagnosticsSuccessful'])
{
echo '<input type="image" src="./setup_images/setup_proceed.gif" name="submit"/>';
}
unset($_POST, $instanceId, $_SESSION['traceMessages'], $_SESSION['errorMessages']);
?>
</div></div>
</form>
<?php
}
else if($_SESSION['diagnosticsSuccessful'] == true && (!isset($_GET['plugins']) || $_GET['plugins'] != true) )
{
$pluginNameList = unserialize($_SESSION['pluginNameList']);
?>
<form action="./index.php" method="POST">
<div class="container">
<div class="left">
<div class="logo3"></div>
<div class="text"><div class="gold">POG documentation summary</div>
<br/><br/>The following 3 documents summarize what POG is all about:<br/><br/>
1. <a href="http://www.phpobjectgenerator.com/plog/file_download/15">POG Essentials</a><br/><br/>
2. <a href="http://www.phpobjectgenerator.com/plog/file_download/21">POG Object Relations</a><br/><br/>
3. <a href="http://www.phpobjectgenerator.com/plog/file_download/18">POG SOAP API</a>
</div><!--text-->
</div><!--left-->
<div class="middle33">
<div id="tabs3">
<a href="./index.php?step=diagnostics"><img src="./setup_images/tab_setup.gif"/></a>
<img src="./setup_images/tab_separator.gif"/>
<img src="./setup_images/tab_diagnosticresults.gif"/>
<img src="./setup_images/tab_separator.gif"/>
<a href="./index.php"><img src="./setup_images/tab_manageobjects_on.gif"/></a>
<img src="./setup_images/tab_separator.gif"/>
<?php
if (sizeof($pluginNameList) > 0)
{
?>
<a href="./index.php?plugins=true"><img src="./setup_images/tab_manageplugins_off.gif" border="0"/></a>
<?php
}
?>
</div><!--tabs3--><div class="subtabs">
<?php
//provide interface to the database
include "./setup_library/xPandMenu.php";
$root = new XMenu();
if(file_exists("configuration.php"))
{
include "../configuration.php";
}
if(file_exists("../objects/class.database.php"))
{
include "../objects/class.database.php";
}
$fileNames = unserialize($_SESSION['fileNames']);
foreach($fileNames as $filename)
{
include_once("../objects/{$filename}");
}
$objectNameList = unserialize($_SESSION['objectNameList']);
if (isset($_GET['objectName']))
{
$_SESSION['objectName'] = $_GET['objectName'];
}
$objectName = (isset($_SESSION['objectName'])?$_SESSION['objectName']:$objectNameList[0]);
?>
<div id="header">
<ul>
<li id='inactive'>My Objects:</li>
<?php
if (!isset($_SESSION['objectName']))
{
$_SESSION['objectName'] = $objectNameList[0];
}
for($i=0; $i<count($objectNameList); $i++)
{
$name = $objectNameList[$i];
eval('$instance = new '.$name.'();');
if (!TestIsMapping($instance))
{
echo "<li ".($_SESSION['objectName']==$objectNameList[$i]?"id='current'":'')."><a href='./index.php?objectName=".$objectNameList[$i]."'>".$objectNameList[$i]."</a></li>";
//echo "<a href='./index.php?objectName=".$objectNameList[$i]."'".(isset($_SESSION['objectName']) && $_SESSION['objectName']==$objectNameList[$i]?"class='activetab'":(!isset($_SESSION['objectName'])&&$i==0?"class='activetab'":"inactivetab")).">".$objectNameList[$i]."</a> ";
}
}
?>
</ul>
</div><!--header-->
</div><!--subtabs-->
<div class="toolbar"><a href="<?php echo $_SESSION['links'][$_SESSION['objectName']]?>" target="_blank" title="modify and regenerate object"><img src="./setup_images/setup_regenerate.jpg" border="0"/></a><a href="#" title="Delete all objects" onclick="if (confirm('Are you sure you want to delete all objects in this table? TPress OK to Delete.')){window.location='./?thrashall=true';}else{alert('Phew, nothing was deleted ;)');}"><img src='./setup_images/setup_deleteall.jpg' alt='delete all' border="0"/></a><a href="#" onclick="javascript:expandAll();return false;" title="expand all nodes"><img src='./setup_images/setup_expandall.jpg' alt='expand all' border="0"/></a><a href="#" onclick="javascript:collapseAll();return false;" title="collapse all nodes"><img src='./setup_images/setup_collapseall.jpg' alt='collapse all' border="0"/></a><a href="#" title="update all objects to newest POG version" onclick="if (confirm('Setup will now attempt to upgrade your objects by contacting the POG SOAP server. Would you like to continue?')){window.location='./setup_library/upgrade.php';}else{alert('Upgrade aborted');}"><img src='./setup_images/setup_updateall.jpg' alt='update all objects' border='0'/></a></div><div class="middle3">
<?php
//is there an action to perform?
if (isset($_GET['thrashall']))
{
eval('$instance = new '.$objectName.'();');
$instanceId = strtolower(get_class($instance))."Id";
$instanceList = $instance->GetList(array(array($instanceId, ">", "0")));
foreach ($instanceList as $instance)
{
$instance->Delete();
}
unset($_GET);
}
echo '<div id="container"></div>';
$_SESSION['fileNames'] = serialize($fileNames);
$_SESSION['objectNameList'] = serialize($objectNameList);
?>
<b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b>
</div><!--middle3-->
</div><!--middle33-->
</div><!--container-->
</form>
<?php
echo "<script>sndReq('GetList', '', '$objectName', '', '', '', '$objectName');</script>";
}
else if ($_SESSION['diagnosticsSuccessful'] && $_GET['plugins'])
{
?>
<form action="./index.php?plugins=true" method="POST">
<div class="container">
<div class="left">
<div class="logo3"></div>
<div class="text"><div class="gold">POG documentation summary</div>
<br/><br/>The following 3 documents summarize what POG is all about:<br/><br/>
1. <a href="http://www.phpobjectgenerator.com/plog/file_download/15">POG Essentials</a><br/><br/>
2. <a href="http://www.phpobjectgenerator.com/plog/file_download/21" target="_blank">POG Object Relations</a><br/><br/>
3. <a href="http://www.phpobjectgenerator.com/plog/file_download/18">POG SOAP API</a>
</div><!--text-->
</div><!--left-->
<div class="middle33">
<div id="tabs3">
<a href="./index.php?step=diagnostics"><img src="./setup_images/tab_setup.gif"/></a>
<img src="./setup_images/tab_separator.gif"/>
<img src="./setup_images/tab_diagnosticresults.gif"/>
<img src="./setup_images/tab_separator.gif"/>
<a href="./index.php"><img src="./setup_images/tab_manageobjects.gif"/></a>
<img src="./setup_images/tab_separator.gif"/>
<img src="./setup_images/tab_manageplugins_on.gif"/>
</div><!--tabs3--><div class="subtabs">
<?php
//provide interface to the database
include "./setup_library/xPandMenu.php";
$root = new XMenu();
if(file_exists("configuration.php"))
{
include "../configuration.php";
}
if(file_exists("../objects/class.database.php"))
{
include "../objects/class.database.php";
}
include_once('../objects/class.pog_base.php');
if(file_exists($GLOBALS['configuration']['plugins_path']."/IPlugin.php"))
{
include_once($GLOBALS['configuration']['plugins_path'].'/IPlugin.php');
}
$pluginNameList = unserialize($_SESSION['pluginNameList']);
foreach($pluginNameList as $pluginName)
{
include_once($GLOBALS['configuration']['plugins_path']."/plugin.".$pluginName.".php");
}
?>
<div id="header">
<ul>
<li id='inactive'>My Plugins:</li>
<?php
if (isset($_GET['pluginName']))
{
$_SESSION['pluginName'] = $_GET['pluginName'];
}
$pluginName = (isset($_SESSION['pluginName'])?$_SESSION['pluginName']:$pluginNameList[0]);
$_SESSION['pluginName'] = $pluginName;
for($i=0; $i<count($pluginNameList); $i++)
{
$name = $pluginNameList[$i];
echo "<li ".($_SESSION['pluginName']==$pluginNameList[$i]?"id='current'":'')."><a href='./index.php?plugins=true&pluginName=".$pluginNameList[$i]."'>".$pluginNameList[$i]."</a></li>";
}
$pluginInstance = new $_SESSION['pluginName']('', '');
?>
</ul>
</div><!--header-->
</div><!--subtabs-->
<div class="toolbar"><img src="setup_images/button_toolbar_left.gif"/>
<a href='http://plugins.phpobjectgenerator.com/?id=<?=get_class($pluginInstance)?>' target="_blank"><img src="setup_images/button_toolbar_homepage.gif" border='0'/></a>
<img src="setup_images/toolbar_separator.gif"/>
<?php
if ($pluginInstance->AuthorPage() != null)
{
?>
<a href='<?php echo $pluginInstance->AuthorPage();?>' target="_blank"><img src="setup_images/button_toolbar_author.gif" border='0'/></a>
<img src="setup_images/toolbar_separator.gif"/>
<?php
}
?>
<a href='http://plugins.phpobjectgenerator.com/?id=<?=get_class($pluginInstance)?>&help' target="_blank"><img src="setup_images/button_toolbar_help.gif" border='0'/></a>
</div><div class="middle3">
<?php
echo '<div id="container"><div style="padding:30px;">';
$pluginInstance->SetupRender();
echo '</div></div>';
$_SESSION['pluginNameList'] = serialize($pluginNameList);
?>
<b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b>
</div><!--middle3-->
</div><!--middle33-->
</div><!--container-->
</form>
<?php
}
else
{
unset($_SESSION['objectNameList'], $_SESSION['fileNames'], $_SESSION['links'], $_SESSION['pluginNameList']);
//welcome screen
?>
<form action="./index.php" method="POST">
<div class="container">
<div class="left">
<div class="logo"></div>
<div class="text"><div class="gold">What is POG Setup?</div>POG Setup is an extension of the online Php Object Generator. It is meant to help the veteran POG user and the novice alike.
<br/><br/>POG Setup is a 3 step process which:<br/><br/>
1. Creates tables for your generated objects.<br/><br/>
2. Performs diagnostics tests on all objects within your 'objects' directory.<br/><br/>
3. Provides a light interface to your object tables.</div>
</div>
<div class="middle">
<div id="tabs">
<img src="./setup_images/tab_setup_on.gif"/>
<img src="./setup_images/tab_separator.gif" height="20px" width="17px"/>
<img src="./setup_images/tab_diagnosticresults.gif" height="20px" width="137px"/>
<img src="./setup_images/tab_separator.gif" height="20px" width="17px"/>
<img src="./setup_images/tab_manageobjects.gif" height="20px" width="129px"/>
<img src="./setup_images/tab_separator.gif"/>
<img src="./setup_images/tab_manageplugins_off.gif"/>
</div>
<div id="nifty">
<div style="height:500px">
<img src="./setup_images/setup_welcome.jpg" height="47px" width="617px"/>
<div class="col1"><img src="./setup_images/pog_setup_closed.jpg"/><div class="gold">What is POG?</div>POG generates PHP objects with integrated CRUD methods to dramatically accelerate web application development in PHP. <br/>
<br/>POG allows developers to easily map object attributes onto columns of a database table without having to write SQL queries.</div>
<div class="col2"><img src="./setup_images/pog_setup_open.jpg"/><div class="gold">What is POG Setup?</div>You've generated one or more objects using Php Object Generator ... Now what?<br/>
<br/>POG SETUP is an answer to this question and takes the POG experience one step further. The Setup process automates <b>table creation</b>, <b>unit testing</b> and provides a light <b>scaffolding</b> environment.</div>
<div class="col3">
<div class="gold">If you are ready to get POG'd up, click on thebutton below to proceed. Doing this will:</div><br/>
<table>
<tr>
<td>TABLES:</td>
<td>
<select class="ss" name="pog_table">
<option value="align">Align tables with objects (default)</option>
<option value="recreate">Recreate tables</option>
<option value="recreate_import">Recreate tables and initialize data</option>
</select>
</td>
</tr>
<tr>
<td>TESTS:</td>
<td>
<select class="ss" name="pog_test">
<option value="yes">Perform unit tests (default)</option>
<option value="no">Bypass unit tests</option>
</select>
</td>
</tr>
</table><br/>
<br/><input type="image" onclick="PleaseWait('');" src="./setup_images/setup_pogmeup.gif" name="submit"/>
<div align="center" id="pleasewait" style="display:none;"><img src="./setup_images/loading.gif"/></div>
</div>
</div>
<b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b>
</div>
</div>
</div>
</form>
<?php
}
?>
<div class="footer">
<?php include "setup_library/inc.footer.php";?>
</div>
</body>
</html>

View File

@ -0,0 +1,227 @@
<?php
include "./setup_library/xPandMenu.php";
include "./setup_library/setup_misc.php";
if(file_exists("../configuration.php"))
{
include_once("../configuration.php");
}
if(file_exists("../objects/class.database.php"))
{
include_once("../objects/class.database.php");
}
include_once('../objects/class.pog_base.php');
$objectName = isset($_REQUEST['objectname']) ? $_REQUEST['objectname'] : '';
$anchor = isset($_REQUEST['anchor']) ? $_REQUEST['anchor'] : '';
$offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : '';
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : '';
//include all classes (possible relations)
$dir = opendir('../objects/');
$objects = array();
while(($file = readdir($dir)) !== false)
{
if(strlen($file) > 4 && substr(strtolower($file), strlen($file) - 4) === '.php' && !is_dir($file) && $file != "class.database.php" && $file != "configuration.php" && $file != "setup.php" && $file != "class.pog_base.php")
{
$objects[] = $file;
}
}
closedir($dir);
foreach ($objects as $object)
{
include_once("../objects/{$object}");
}
eval ('$instance = new '.$objectName.'();');
$attributeList = array_keys(get_object_vars($instance));
$noOfExternalAttributes = sizeof($attributeList) - 3;
// get object id to perform action. required for Delete() and Update()
$objectId = isset($_REQUEST['objectid']) ? $_REQUEST['objectid'] : '';
// get the ids of all open nodes before action is performed
$openNodes = isset($_REQUEST['opennodes']) ? explode('-', $_REQUEST['opennodes']) : '';
// get action to perform
$action = $_GET['action'];
$currentNode = -1;
if (isset($_GET['currentnode']))
{
// get the node id on which the action is performed. required for Delete() and Update()
$currentNode = $_GET['currentnode'];
$currentNodeParts = explode('Xnode', $currentNode);
if (isset($currentNodeParts[1]))
{
$currentNode = $currentNodeParts[1];
}
}
$root = new XMenu();
if ($openNodes != '')
{
foreach ($openNodes as $openNode)
{
$openNodeParts = explode('Xtree', $openNode);
$noParts = sizeof($openNodeParts);
// all open nodes when action is initiated
if ($noParts > 0 && is_numeric($openNodeParts[$noParts - 1]))
{
// initialize all open nodes
$root->visibleNodes[] = $openNodeParts[$noParts - 1];
}
}
}
// perform requested action
switch($action)
{
case 'Add':
eval ('$instance = new '.$objectName.'();');
$attributeList = array_keys(get_object_vars($instance));
foreach($attributeList as $attribute)
{
if ($attribute != "pog_attribute_type" && $attribute!= "pog_query")
{
if (isset($instance->pog_attribute_type[$attribute]))
{
if (isset($_GET[$attribute]))
{
$instance->{$attribute} = $_GET[$attribute];
}
}
}
}
if ($instance->Save())
{
for ($i = 0; $i < sizeof($root->visibleNodes); $i++)
{
if ($root->visibleNodes[$i] > ($noOfExternalAttributes + 2))
{
$root->visibleNodes[$i] += ($noOfExternalAttributes + 1);
}
}
}
RefreshTree($anchor, $root);
break;
case 'Refresh':
RefreshTree($objectName, $root, $offset, $limit);
break;
case 'GetList':
RefreshTree($anchor, $root, $offset, $limit);
break;
case 'DeleteDeep':
case 'Delete':
eval ('$instance = new '.$objectName.'();');
$instance->Get($objectId);
$instance->Delete(($action == 'DeleteDeep'));
for ($i = 0; $i < sizeof($root->visibleNodes); $i++)
{
if ($root->visibleNodes[$i] > ($noOfExternalAttributes + 2))
{
if (intval($root->visibleNodes[$i]) == intval($openNodeParts[$noParts - 1]))
{
$root->visibleNodes[$i] = null;
}
else if ($root->visibleNodes[$i] > $currentNode)
{
$root->visibleNodes[$i] -= ($noOfExternalAttributes + 1);
}
}
}
RefreshTree($anchor, $root);
break;
case 'Update':
eval ('$instance = new '.$objectName.'();');
$instance->Get($objectId);
$attributeList = array_keys(get_object_vars($instance));
foreach($attributeList as $attribute)
{
if ($attribute != "pog_attribute_type" && $attribute!= "pog_query")
{
if (isset($instance->pog_attribute_type[$attribute]))
{
if (isset($_GET[$attribute]))
{
$instance->{$attribute} = $_GET[$attribute];
}
}
}
}
$instance->Save();
RefreshTree($anchor, $root);
break;
}
/**
* Refreshes the tree after an operation while preserving node statuses
*
* @param unknown_type $objectName
* @param unknown_type $root
*/
function RefreshTree($objectName, $root, $offset = '', $limit = '')
{
if ($limit == '')
{
$offset = 0;
$limit = 50;
}
$sqlLimit = "$offset, $limit";
$js = "new Array(";
eval ('$instance = new '.$objectName.'();');
$recCount = GetNumberOfRecords(strtolower($objectName));
$attributeList = array_keys(get_object_vars($instance));
$instanceList = $instance->GetList(array(array(strtolower($objectName)."Id",">",0)), strtolower($objectName)."Id", false, $sqlLimit);
$x = 0;
$masterNode = &$root->addItem(new XNode("<span style='color:#998D05'>".$objectName."</span>&nbsp;<span style='font-weight:normal'>{Dimensions:[".sizeof($instanceList)."]}</span>", false, "setup_images/folderclose.gif","setup_images/folderopen.gif"));
$node = &$masterNode->addItem(new XNode("<span style='color:#998D05'>ADD RECORD</span>", false,"setup_images/folderclose.gif","setup_images/folderopen.gif"));
foreach($attributeList as $attribute)
{
if ($attribute != "pog_attribute_type" && $attribute!= "pog_query")
{
if ($x != 0 && isset($instance->pog_attribute_type[$attribute]))
{
$js .= '"'.$attribute.'",';
$thisValue = ConvertAttributeToHtml($attribute, $instance->pog_attribute_type[$attribute]['db_attributes'], $instance->{$attribute}, $instance->{$attributeList[0]});
$subnode = &$node->addItem(new XNode("<br/><span style='color:#998D05'>".$attribute."</span>&nbsp;<span style='font-weight:normal;color:#ADA8B2;'>{".$instance->pog_attribute_type[$attribute]['db_attributes'][1]."}</span><br/>".$thisValue."<br/>", false,'',"setup_images/folderopen.gif"));
}
}
$x++;
}
$js = trim($js, ",");
$js .= ")";
$subnode = &$node->addItem(new XNode("<br/><a href='#' onclick='javascript:sndReq(\"Add\", getOpenNodes(), \"$objectName\", \"".$instance->{strtolower($objectName).'Id'}."\", this.parentNode.parentNode.parentNode.parentNode.id, $js, \"$objectName\");return false;'><img src='./setup_images/button_add.gif' border='0'/></a>", false,'',"folderopen.gif"));
if ($instanceList != null)
{
foreach($instanceList as $instance)
{
ConvertObjectToNode($instance, $masterNode, $js, $objectName);
}
}
$menu_html_code = $root->generateTree();
$menu_html_code .= "<div class='nav'>";
$pre = "<div class='nav'>";
if ($offset != '' && $offset != 0)
{
$pre .= "&#8249;&#8249;<a href='#' onclick='javascript:refTree(".($offset-$limit).", $limit, \"$objectName\");return false;'>Newer</a> | ";
$menu_html_code.= "&#8249;&#8249;<a href='#' onclick='javascript:refTree(".($offset-$limit).", $limit, \"$objectName\");return false;'>Newer</a> | ";
}
$pre .= "<b>".($recCount-$offset-$limit < 0 ? 0 : $recCount-$offset-$limit)." - ".($recCount-$offset)." of $recCount </b>";
$menu_html_code .= "<b>".($recCount-$offset-$limit < 0 ? 0 : $recCount-$offset-$limit)." - ".($recCount-$offset)." of $recCount </b>";
if ($offset <= $recCount - $limit)
{
$pre .= "| <a href='#' onclick='javascript:refTree(".($offset+$limit).", $limit, \"$objectName\");return false;'>Older</a>&#8250;&#8250;";
$menu_html_code.= "| <a href='#' onclick='javascript:refTree(".($offset+$limit).", $limit, \"$objectName\");return false;'>Older</a>&#8250;&#8250;";
}
$menu_html_code .= "</div>";
$pre .= "</div>";
$table = "<div id='container'><br/><br/>".$pre.$menu_html_code."</div>";
echo $table;
}
?>

View File

@ -0,0 +1,77 @@
.container {background:url('./setup_images/gradient_container.gif') top left repeat-x}
.logo {width:234px;height:191px;position:relative;float:left;background:url('./setup_images/setup_logo1.jpg') top left no-repeat}
.logo2 {width:234px;height:191px;position:relative;float:left;background:url('./setup_images/setup_logo2.jpg') top left no-repeat}
.logo3 {width:234px;height:191px;position:relative;float:left;background:url('./setup_images/setup_logo3.jpg') top left no-repeat}
.bottom3 {float:left;display:inline;position:relative;width:100%;background:url('./setup_images/setup_bottom3tile.jpg') top left repeat-x}
.toolbar {float:left;display:inline;width:100%;height:42px;background-color:#444;background:url('./setup_images/setup_toolbargradient.jpg') top left repeat-x}
body {margin:0 auto;padding:0;color:#828282;background:#fff;font:normal 10px Verdana}
.activetab {font-weight:bold;color:#7B7F0E;background:#ccc}
.error {background:#f00}
.warning {background:#0cf}
.succeed {background:#0f0}
.header {width:90%;height:90px;padding:15px 0 0 15px}
.footer {width:90%;padding-left:15px;vertical-align:middle;height:35px}
.footer img {vertical-align:middle;height:35px}
.toolbar img {display:inline}
.bottom3 img {display:inline}
.left {width:234px;height:550px;z-Index:9;position:absolute;}
.text {width:194px;height:319px;line-height:15px;position:relative;float:left;padding:22px}
.gold {color:#998D05;font-weight:bold;display:block;}
.middle {width:617px;padding-left:234px;height:596px;color:#404855}
.middle2 {float:left;position:relative;padding:20px 0 0 22px;width:594px;background:#E7E9EE}
.middle33 {height:596px;position:relative;padding-left:234px;color:#404855}
.middle3 {float:left;position:relative;width:100%;background:#E7E9EE}
.subtabs {padding-top:35px;float:left;position:relative}
#tabs {width:617px;height:20px;float:left}
#tabs3 {width:100%;height:20px;float:left}
#tabs img,#tabs3 img {float:left;border:none}
.middle img,.middle input,.middle2 img,.middle2 input {display:inline;margin:0;padding:0}
a {text-decoration:none;color:#7F7714}
input.i {position:relative;padding:2px 3px;width:200px;color:#5A4F64;font-size:9px;vertical-align:middle;border-top:1px solid #404040;border-left:1px solid #404040;border-right:1px solid #D1D0CC;border-bottom:1px solid #D1D0CC; background-color:#F7F7F7;}
textarea {width:575px;height:325px;font-size:12px;border-top:1px solid #404040;border-left:1px solid #404040;border-right:1px solid #D1D0CC;border-bottom:1px solid #D1D0CC}
textarea.t {width:450px;height:50px;font-size:12px;border-top:1px solid #404040; color:#5A4F64; border-left:1px solid #404040;border-right:1px solid #D1D0CC;border-bottom:1px solid #D1D0CC; background-color:#F7F7F7;}
select.s, input.c {border-top:1px solid #404040; color:#5A4F64; border-left:1px solid #404040;border-right:1px solid #D1D0CC;border-bottom:1px solid #D1D0CC; background-color:#F7F7F7;}
.ss{font-size:95%;}
table {position:relative;display:inline;background:#E8E9EE}
td {height:25px}
.id {font-weight:bold;padding-left:5px}
div#nifty {background:#E7E9EE;margin-top:40px;position:relative;float:left;width:617px}
div.nifty{margin-top:0;background:#E7E9EE}
b.rtop,b.rbottom {display:block;background:#FFF}
b.rtop b {display:block;height:1px;overflow:hidden;background:#FFF}
b.rbottom b {display:block;height:1px;overflow:hidden;background:#E7E9EE}
b.r1 {margin:0 5px}
b.r2 {margin:0 3px}
b.r3 {margin:0 2px}
b.rtop b.r4,b.rbottom b.r4 {margin:0 1px;height:2px}
.col1,.col2 {padding-left:15px;padding-right:15px;margin-left:10px;line-height:14px;color:#848484;position:relative;width:250px;height:270px;display:inline;float:left}
.col3 {width:300px;padding-left:150px;padding-right:150px;height:190px;display:block;float:left color:#848484}
#header {float:left;width:100%;line-height:normal;}
#header ul {margin:0;padding:8px 10px 0;list-style:none;color:#818183}
#header li {float:left;background:url("norm_right.gif") no-repeat right top;margin-right:5px;padding:0}
#header a {display:block;background:url("norm_left.gif") no-repeat left top;padding:3px 8px 2px;color:#B1B97D}
#header #current {background-image:url("./setup_images/tab_activeobjectright.gif")}
#header #current a {background-image:url("./setup_images/tab_activeobjectleft.gif");padding:3px 8px 2px;font-weight:bold;color:#867C1D}
#header #inactive {padding:3px 3px 2px 5px;font-weight:bold}
a.deleteDeep:hover
{
text-decoration:none;
background-color:#9a1818;
color:#fff;
}
a.deleteShallow:hover
{
text-decoration:none;
background-color:#f3e508;
color:#000;
}
a.deleteCancel:hover
{
text-decoration:none;
background-color:#bee8b6;
color:#000;
}
.nav
{
padding-left:80px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

View File

@ -0,0 +1,30 @@
<?php
if (sizeof($_POST) > 0 && $GLOBALS['configuration']['setup_password'] != "" && (!isset($_SESSION['authenticated']) || !$_SESSION['authenticated']))
{
if ($_POST['setup_password'] == $GLOBALS['configuration']['setup_password'])
{
$_SESSION['authenticated'] = true;
}
$_POST = null;
}
if ((!isset($_SESSION['authenticated']) || !$_SESSION['authenticated']) && $GLOBALS['configuration']['setup_password'] != "")
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Php Object Generator Setup <?=$GLOBALS['configuration']['versionNumber'].$GLOBALS['configuration']['revisionNumber']?></title>
<link rel="stylesheet" href="./setup.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="./setup_library/xPandMenu.css"/>
<div align="center">
<form action="./index.php" method="POST"><br/>
<img src="setup_images/mini_pog.jpg"/><br/><br/>
<input name="setup_password" type="password" class="i"/>
<br/><br/><input type="image" src="setup_images/generate.jpg" name="submit"/>
</form>
</div>
</html>
<?php
exit;
}
?>

View File

@ -0,0 +1,212 @@
<?php
/**
* Class to dynamically create a zip file (archive)
*
* @author Rochak Chauhan. Extended by Joel Wan & Mark Slemko
*/
class createZip {
var $compressedData = array();
var $centralDirectory = array(); // central directory
var $endOfCentralDirectory = "\x50\x4b\x05\x06\x00\x00\x00\x00"; //end of Central directory record
var $oldOffset = 0;
/**
* Function to create the directory where the file(s) will be unzipped
*
* @param $directoryName string
*
*/
function addDirectory($directoryName) {
$directoryName = str_replace("\\", "/", $directoryName);
$feedArrayRow = "\x50\x4b\x03\x04";
$feedArrayRow .= "\x0a\x00";
$feedArrayRow .= "\x00\x00";
$feedArrayRow .= "\x00\x00";
$feedArrayRow .= "\x00\x00\x00\x00";
$feedArrayRow .= pack("V",0);
$feedArrayRow .= pack("V",0);
$feedArrayRow .= pack("V",0);
$feedArrayRow .= pack("v", strlen($directoryName) );
$feedArrayRow .= pack("v", 0 );
$feedArrayRow .= $directoryName;
$feedArrayRow .= pack("V",0);
$feedArrayRow .= pack("V",0);
$feedArrayRow .= pack("V",0);
$this -> compressedData[] = $feedArrayRow;
$newOffset = strlen(implode("", $this->compressedData));
$addCentralRecord = "\x50\x4b\x01\x02";
$addCentralRecord .="\x00\x00";
$addCentralRecord .="\x0a\x00";
$addCentralRecord .="\x00\x00";
$addCentralRecord .="\x00\x00";
$addCentralRecord .="\x00\x00\x00\x00";
$addCentralRecord .= pack("V",0);
$addCentralRecord .= pack("V",0);
$addCentralRecord .= pack("V",0);
$addCentralRecord .= pack("v", strlen($directoryName) );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("v", 0 );
$ext = "\x00\x00\x10\x00";
$ext = "\xff\xff\xff\xff";
$addCentralRecord .= pack("V", 16 );
$addCentralRecord .= pack("V", $this -> oldOffset );
$this -> oldOffset = $newOffset;
$addCentralRecord .= $directoryName;
$this -> centralDirectory[] = $addCentralRecord;
}
/**
* Function to add file(s) to the specified directory in the archive
*
* @param $directoryName string
*
*/
function addFile($data, $directoryName) {
$directoryName = str_replace("\\", "/", $directoryName);
$feedArrayRow = "\x50\x4b\x03\x04";
$feedArrayRow .= "\x14\x00";
$feedArrayRow .= "\x00\x00";
$feedArrayRow .= "\x08\x00";
$feedArrayRow .= "\x00\x00\x00\x00";
$uncompressedLength = strlen($data);
$compression = crc32($data);
$gzCompressedData = gzcompress($data);
$gzCompressedData = substr( substr($gzCompressedData, 0, strlen($gzCompressedData) - 4), 2);
$compressedLength = strlen($gzCompressedData);
$feedArrayRow .= pack("V",$compression);
$feedArrayRow .= pack("V",$compressedLength);
$feedArrayRow .= pack("V",$uncompressedLength);
$feedArrayRow .= pack("v", strlen($directoryName) );
$feedArrayRow .= pack("v", 0 );
$feedArrayRow .= $directoryName;
$feedArrayRow .= $gzCompressedData;
$feedArrayRow .= pack("V",$compression);
$feedArrayRow .= pack("V",$compressedLength);
$feedArrayRow .= pack("V",$uncompressedLength);
$this -> compressedData[] = $feedArrayRow;
$newOffset = strlen(implode("", $this->compressedData));
$addCentralRecord = "\x50\x4b\x01\x02";
$addCentralRecord .="\x00\x00";
$addCentralRecord .="\x14\x00";
$addCentralRecord .="\x00\x00";
$addCentralRecord .="\x08\x00";
$addCentralRecord .="\x00\x00\x00\x00";
$addCentralRecord .= pack("V",$compression);
$addCentralRecord .= pack("V",$compressedLength);
$addCentralRecord .= pack("V",$uncompressedLength);
$addCentralRecord .= pack("v", strlen($directoryName) );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("v", 0 );
$addCentralRecord .= pack("V", 32 );
$addCentralRecord .= pack("V", $this -> oldOffset );
$this -> oldOffset = $newOffset;
$addCentralRecord .= $directoryName;
$this -> centralDirectory[] = $addCentralRecord;
}
/**
* Fucntion to return the zip file
*
* @return zipfile (archive)
*/
function getZippedfile() {
$data = implode("", $this -> compressedData);
$controlDirectory = implode("", $this -> centralDirectory);
return
$data.
$controlDirectory.
$this -> endOfCentralDirectory.
pack("v", sizeof($this -> centralDirectory)).
pack("v", sizeof($this -> centralDirectory)).
pack("V", strlen($controlDirectory)).
pack("V", strlen($data)).
"\x00\x00";
}
/**
*
* Function to force the download of the archive as soon as it is created
*
* @param archiveName string - name of the created archive file
*/
function forceDownload($archiveName) {
$headerInfo = '';
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=".basename($archiveName).";" );
header("Content-Transfer-Encoding: binary");
echo $this->getZippedfile();
}
/**
* Generates zip file from POG package.
*
* @param multi-d array $package
* @param array $paths
*/
function addPOGPackage($package, $paths=array())
{
$i = 0;
foreach ($package as $key=>$value)
{
$path = '';
foreach ($paths as $p)
{
$path .= (($path == '') ? $p : "/$p");
}
if (strpos($key, ".") == false)
{
$paths[] = $key;
$this->addDirectory((($path == '') ? "$key/" : "$path/$key/"));
$this->addPOGPackage($package[$key], &$paths);
}
else
{
$this->addFile(base64_decode($value), (($path == '') ? $key : "$path/$key"));
}
if ($i == (sizeof($package)-1))
{
array_pop($paths);
}
$i++;
}
}
}
?>

View File

@ -0,0 +1,6 @@
<img src="./setup_images/setup_footer.jpg"/>
<a href="http://www.phpobjectgenerator.com" title="Php Object Generator Homepage">PHP Object Generator</a> |
<a href="http://www.phpobjectgenerator.com/plog" title="Php Weblog">POG Weblog</a> |
<a href="http://groups.google.com/group/Php-Object-Generator" title="POG Google Group">Google group</a> |
<a href="http://www.phpobjectgenerator.com/plog/tutorials" title="POG Tutorials">Tutorials</a> |
<a href="mailto:pogguys@phpobjectgenerator.com" title="Contact the POG authors">Contact us</a>

View File

@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Php Object Generator Setup <?=$GLOBALS['configuration']['versionNumber'].$GLOBALS['configuration']['revisionNumber']?></title>
<link rel="stylesheet" type="text/css" href="./setup_library/xPandMenu.css"/>
<link rel="stylesheet" href="./setup.css" type="text/css" />
<script src="./setup_library/xPandMenu.js"></script>
</head>
<body>
<div class="header">
<script type="text/javascript"><!--
google_ad_client = "pub-7832108692498114";
google_alternate_color = "FFFFFF";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="1767526614";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "716500";
google_color_url = "B8B8B8";
google_color_text = "CCC078";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<script type="text/javascript"><!--
function PleaseWait(id)
{
var div = document.getElementById("pleasewait"+id);
div.style.display = "block";
return false;
}
//--></script>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,140 @@
<?php
/**
* @author Joel Wan & Mark Slemko. Designs by Jonathan Easton
* @link http://www.phpobjectgenerator.com
* @copyright Offered under the BSD license
*
* This upgrade file does the following:
* 1. Checks if there is a new version of POG
* 2. If there is, it reads generates newer versions of all objects in the object directory,
* zip then and present them to the user to 'download'
*/
ini_set("max_execution_time", 0);
include_once "../../configuration.php";
include_once "class.zipfile.php";
include_once "setup_misc.php";
/**
* Connects to POG SOAP server defined in configuration.php and
* generates new versions of all objects detected in /objects/ dir.
* All upgraded objects are then zipped and presented to user.
*
* @param string $path
*/
function UpdateAllObjects($path)
{
$dir = opendir($path);
$objects = array();
while(($file = readdir($dir)) !== false)
{
if(strlen($file) > 4 && substr(strtolower($file), strlen($file) - 4) === '.php' && !is_dir($file) && $file != "class.database.php" && $file != "configuration.php" && $file != "setup.php" && $file != "class.pog_base.php")
{
$objects[] = $file;
}
}
closedir($dir);
$i = 0;
foreach($objects as $object)
{
$content = file_get_contents($path."/".$object);
$contentParts = split("<b>",$content);
if (isset($contentParts[1]))
{
$contentParts2 = split("</b>",$contentParts[1]);
}
if (isset($contentParts2[0]))
{
$className = trim($contentParts2[0]);
}
if (isset($className))
{
eval ('include_once("../../objects/class.'.strtolower($className).'.php");');
$instance = new $className();
if (!TestIsMapping($instance))
{
$objectNameList[] = $className;
$linkParts1 = split("\*\/", $contentParts[1]);
$linkParts2 = split("\@link", $linkParts1[0]);
$link = $linkParts2[1];
$options = false;
if ($GLOBALS['configuration']['proxy_host'] != false &&
$GLOBALS['configuration']['proxy_port'] != false &&
$GLOBALS['configuration']['proxy_username'] != false &&
$GLOBALS['configuration']['proxy_password'] != false)
{
$options = array(
'proxy_host' => $GLOBALS['configuration']['proxy_host'],
'proxy_port' => $GLOBALS['configuration']['proxy_port'],
'proxy_login' => $GLOBALS['configuration']['proxy_username'],
'proxy_password' => $GLOBALS['configuration']['proxy_password']
);
}
$client = new SoapClient(
$GLOBALS['configuration']['soap'],
$options) ;
if ($i == 0)
{
$package = unserialize($client->GeneratePackageFromLink($link));
}
else
{
$objectString = $client->GenerateObjectFromLink($link);
$package["objects"]["class.".strtolower($className).".php"] = $objectString;
}
}
}
$i++;
}
//upgrade mapping classes if any
foreach ($objectNameList as $objectName)
{
$instance = new $objectName();
foreach ($instance->pog_attribute_type as $key => $attribute_type)
{
if ($attribute_type['db_attributes'][1] == "JOIN")
{
$mappingString = $client->GenerateMapping($objectName, $key, (isset($GLOBALS['configuration']['pdoDriver']) ? 'php5.1' :'php5'), (isset($GLOBALS['configuration']['pdoDriver']) ? 'pdo' :'pog'), (isset($GLOBALS['configuration']['pdoDriver']) ? 'mysql' :''));
$package["objects"]['class.'.strtolower(MappingName($objectName, $key)).'.php'] = $mappingString;
}
}
}
$zipfile = new createZip();
$zipfile -> addPOGPackage($package);
$zipfile -> forceDownload("pog.".time().".zip");
}
/**
* Checks if POG generator has been updated
*
* @return unknown
*/
function UpdateAvailable()
{
$client = new SoapClient($GLOBALS['configuration']['soap']);
$generatorVersion = base64_decode($client -> GetGeneratorVersion());
if ($generatorVersion != $GLOBALS['configuration']['versionNumber'].$GLOBALS['configuration']['revisionNumber'])
{
return true;
}
else
{
return false;
}
}
if (UpdateAvailable())
{
UpdateAllObjects("../../objects/");
}
else
{
echo "<script>
alert('All POG objects are already up to date');
window.close();
</script>";
}
?>

View File

@ -0,0 +1,55 @@
#container {
width:500px;
background-color:#E7E9EE;
}
.Xtree, .XtreeRoot {
list-style-type:none;
margin:15px 20px;
}
.Xtree {
/* Indentation of a sub-item compared to its parent */
padding-left:25px;
margin-left:3px;
border-left:1px dotted #998D05;
width:100%;
}
.Xnode {
/* Top and bottom space for a node item */
margin-top:-3px;margin-bottom:3px;
/* Height of the node item */
height:20px;
/* Node background color */
background:#E7E9EE;
/* Font specifications for a node */
font-weight:bold;
font-size:10px;
cursor:pointer;
vertical-align:middle;
width:100%;
}
.Xnode img{ vertical-align:middle; }
.Xleaf {
/* Top and bottom space for a leaf item */
margin-top:-10px;margin-bottom:1px;
/* Height of the leag item */
/* Leaf background color */
/* Font specifications for a leaf */
font-weight:normal;
font-size:10px;
padding:2px;
}
.Xnode a {
text-decoration:none;
}
.Xnode a:hover {
color:red;
text-decoration:underline;
}
.Xleaf a {
text-decoration:none;
}
.Xleaf a:hover {
color:red;
text-decoration:none;
background:#eee;
}

View File

@ -0,0 +1,273 @@
/********************************
* xPandMenu MULTI-LEVEL class
*********************************
* Javascript file
*********************************
* Patrick Brosset
* patrickbrosset@gmail.com
*********************************
* 02/2005
*********************************/
// Show / hide a sub-menu
function xMenuShowHide(obj)
{
if(obj.style.display == 'none'){
obj.style.display = 'block';
}else{
obj.style.display = 'none';
}
}
// Toggle expanded / collapsed versions of items' images
function xSwapImg(imgDiv,srcImg,srcAltImg){
/* Update by Christian Vallee <cv@valtechnologie.com>
==> No need to specify absolute URL for images anymore, this feature will find it on its own */
// looking for the images' root URL based on the current image
var str = imgDiv.src;
var pos = str.search(srcImg);
// if the URL root wasn't found using the first image, try with the alternative one
if ( pos == -1 ) { pos = str.search(srcAltImg); }
// extracting the URL root
var root = str.substring(0,pos);
// adding the root the image path supplied
srcImg = root.concat(srcImg);
srcAltImg = root.concat(srcAltImg);
/* End Update */
if(imgDiv.src == srcImg){
imgDiv.src = srcAltImg;
}else{
imgDiv.src = srcImg;
}
}
// Restore the menu state when the page loads
function xRestoreState()
{
//restore list state
var name = "xMenuState";
var start = document.cookie.indexOf(name+"=");
if(start != -1)
{
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
var value = unescape(document.cookie.substring(len,end));
var values = value.split("|");
for(i=0;i<values.length-1;i++)
{
var couple = values[i].split(":");
document.getElementById(couple[0]).style.display = couple[1];
}
}
//restore img state
name = "xMenuStateImg";
start = document.cookie.indexOf(name+"=");
if(start != -1)
{
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
var value = unescape(document.cookie.substring(len,end));
var values = value.split("[]");
for(i=0;i<values.length-1;i++)
{
var couple = values[i].split(">>");
var imgs = couple[1].split(",");
for(var il in imgs)
{
document.getElementById(imgs[il]).src = couple[0];
}
}
}
}
//Get the ids of all open nodes
function getOpenNodes()
{
value = new Array();
var myLists = document.getElementsByTagName("UL");
for(i=0;i<myLists.length;i++)
{
if(myLists[i].className == "Xtree" && myLists[i].style.display == "block") value += myLists[i].id + "-";
}
return value;
}
// Save the menu state when the page unloads
function xSaveState()
{
//Save list state
var value = "";
var myLists = document.getElementsByTagName("UL");
for(i=0;i<myLists.length;i++)
{
if(myLists[i].className == "Xtree") value += myLists[i].id + ":" + myLists[i].style.display + "|";
}
document.cookie = "xMenuState=" + escape(value) + ";";
//save img state
value = new Array();
myLists = document.getElementsByTagName("IMG");
for(i=0;i<myLists.length;i++)
{
if(myLists[i].id.substring(0,4) == "Ximg")
{
if(value[myLists[i].src]){value[myLists[i].src] += "," + myLists[i].id;}
else{value[myLists[i].src] = myLists[i].id;}
}
}
var str = "";
for(var imgPath in value)
{
str += imgPath + ">>" + value[imgPath] + "[]";
}
var cook = str.substring(0,str.length-2);
document.cookie = "xMenuStateImg=" + escape(cook) + ";";
}
function createRequestObject()
{
var ro;
if (window.XMLHttpRequest)
{
ro = new XMLHttpRequest();
}
else
{
ro = new ActiveXObject('MSXML2.XMLHTTP.3.0');
}
return ro;
}
var http = createRequestObject();
function refTree(offset, limit, objectName)
{
http = createRequestObject();
var req = './rpc.php?action=Refresh&offset='+offset+'&limit='+limit+'&objectname='+objectName;
http.open('get', req);
http.onreadystatechange = handleResponse;
http.send(null);
}
function sndReq(action, openNodes, objectName, objectId, currentNode, attributes, anchor)
{
http = createRequestObject();
var req = './rpc.php?action='+action+'&opennodes='+openNodes+'&objectname='+objectName+'&objectid='+objectId+'&currentnode='+currentNode+'&anchor='+anchor;
if (action == "Add")
{
for (i=0; i<attributes.length; i++)
{
thisId = attributes[i];
var thisInput = document.getElementById(thisId);
if (thisInput != null)
{
if (thisInput.type == "checkbox")
{
if (thisInput.checked)
{
req += "&" + thisId + "=" + thisInput.value;
}
}
else
{
req += "&" + thisId + "=" + thisInput.value;
}
}
}
}
else if (action == "Update")
{
for (i=0; i<attributes.length; i++)
{
thisId = attributes[i];
var thisInput = document.getElementById(thisId+"_"+objectId);
if (thisInput.type == "checkbox")
{
if (thisInput.checked)
{
req += "&" + thisId + "=" + thisInput.value;
}
}
else
{
req += "&" + thisId + "=" + thisInput.value;
}
}
}
http.open('get', req);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse()
{
if(http.readyState == 4)
{
var response = http.responseText;
document.getElementById('container').innerHTML = response;
}
}
function expandAll()
{
var myLists = document.getElementsByTagName("UL");
for(i=0;i<myLists.length;i++)
{
if(myLists[i].className == "Xtree" && myLists[i].style.display == "none") myLists[i].style.display = "block";
}
myLists = document.getElementsByTagName("IMG");
for(i=0;i<myLists.length;i++)
{
if(myLists[i].id.substring(0,4) == "Ximg")
{
myLists[i].src = "setup_images/folderopen.gif";
}
}
}
function collapseAll()
{
var myLists = document.getElementsByTagName("UL");
for(i=0;i<myLists.length;i++)
{
if(myLists[i].className == "Xtree" && myLists[i].style.display == "block") myLists[i].style.display = "none";
}
myLists = document.getElementsByTagName("IMG");
for(i=0;i<myLists.length;i++)
{
if(myLists[i].id.substring(0,4) == "Ximg")
{
myLists[i].src = "setup_images/folderclose.gif";
}
}
}
function ToggleElementVisibility(elementId)
{
var element = document.getElementById(elementId);
if (element.style.display != 'none')
{
element.style.display = 'none';
}
else
{
element.style.display = 'inline';
}
}

View File

@ -0,0 +1,233 @@
<?php
/********************************
* xPandMenu MULTI-LEVEL class
*********************************
* Creates a tree-view menu.
* The menu can be as deep as needed
* The menu items are organised in HTML unordered lists
* Container nodes can be expanded/collapsed thanks to Javascript actions
*********************************
* Patrick Brosset
* patrickbrosset@gmail.com
*********************************
* 02/2005
*********************************/
// Path to default image files (directories and documents icons) -- (use absolute URL)
define('NODE_DEFAULT_IMG','http://project.zoe.co.nz/patrick/xpand/multi/images/folder_win.gif');
define('LEAF_DEFAULT_IMG','http://project.zoe.co.nz/patrick/xpand/multi/images/document_win.gif');
define('NODE_DEFAULT_ALT_IMG','http://project.zoe.co.nz/patrick/xpand/multi/images/folder_win_o.gif');
define('LEAF_DEFAULT_ALT_IMG','http://project.zoe.co.nz/patrick/xpand/multi/images/document_win_o.gif');
// Reference to the File class for saving and loading the generated menu
//include_once 'File.php';
// Xmenu class
class XMenu
{
// Sub-nodes contained in this menu (references to Xnode objects)
var $items = array();
// Keeps track of the HTML code indent to use (formatting of UL and LI)
var $indent;
// Is it the first node ?
var $first;
// Used for assigning unique IDs to HTML elements (for the javascript function)
var $treeCount;
// Same for images
var $imgCount;
// Contains the generated HTML code
var $output;
// Contains the nodes to expand when generating tree
var $visibleNodes = array("1");
// Constructor
function XMenu()
{
$this->indent = 0;
$this->first = true;
$this->treeCount = 0;
$this->imgCount = 0;
$this->output = "";
}
// addItem, adds a child to this menu
// Takes a XNode object reference as argument
function &addItem(&$node)
{
$this->items[] = &$node;
return $this->items[count($this->items) - 1];
}
// generateTree, generates the HTML code (UL list) for the dynamic tree-view
function generateTree($root = false)
{
if(!$root) $root = $this;
if($this->first){
$this->output .= $this->codeIndent()."<ul id=\"XRoot\" class=\"XtreeRoot\">\n";
$this->first = false;
}else{
if (array_search($this->treeCount, $this->visibleNodes) !== false)
{
$this->output .= $this->codeIndent()."<ul id=\"Xtree".$this->treeCount."\" class=\"Xtree\" style=\"display:block;\">\n";
}
else
{
$this->output .= $this->codeIndent()."<ul id=\"Xtree".$this->treeCount."\" class=\"Xtree\" style=\"display:none;\">\n";
}
}
$this->treeCount ++;
foreach($root->items as $myChild){
$this->imgCount ++;
if($myChild->img){
if($myChild->alt_img){
$img_js = "xSwapImg(document.getElementById('Ximg".$this->imgCount."'),'".$myChild->img."','".$myChild->alt_img."');";
}else{
$img_js = "";
}
if (array_search($this->treeCount, $this->visibleNodes) !== false)
{
$img = "<img onClick=\"".$img_js."xMenuShowHide(document.getElementById('Xtree".$this->treeCount."'));\" id=\"Ximg".$this->imgCount."\" src=\"".$myChild->alt_img."\" border=\"0\">&nbsp;&nbsp;";
}
else
{
$img = "<img onClick=\"".$img_js."xMenuShowHide(document.getElementById('Xtree".$this->treeCount."'));\" id=\"Ximg".$this->imgCount."\" src=\"".$myChild->img."\" border=\"0\">&nbsp;&nbsp;";
}
}else{
$img = "";$img_js = "";
}
if($myChild->link){
$href_open = "<a href=\"".$myChild->link."\">";
$href_close = "</a>";
}else{
$href_open = "";
$href_close = "";
}
if(count($myChild->items) != 0){
$this->output .= $this->codeIndent()."<li class=\"Xnode\" id=\"Xnode".$this->treeCount."\"><div>".$href_open.$img.$myChild->name.$href_close."</div></li>\n";
$this->indent ++;
$this->generateTree($myChild);
}else{
$this->output .= $this->codeIndent()."<li class=\"Xleaf\"><div onClick=\"".$img_js."\">".$href_open.$img.$myChild->name.$href_close."</div></li>\n";
}
}
$this->output .= $this->codeIndent()."</ul>\n";
$this->indent --;
return $this->output;
}
// saveTree and restoreTree - thanks to Niels Fanoe (niels.f@noee.dk) for giving me the idea
// saveTree, save the generated HTML code to a file for future use without generating again
function saveTree($filename = "xMenuCache.html")
{
$file = new File();
$file->write($this->output,$filename);
$file->printError();
return $filename;
}
// restoreTree, returns the previously generated HTML code stored in a file
// Call this method STATICALLY for easier use: XMenu::restoreTree("xPandMenuCode.html");
function restoreTree($filename = "xMenuCache.html")
{
$file = new File();
$menu = $file->read($filename);
$error = $file->getError();
if(!empty($error)) return false;
else return $menu;
}
// codeIndent, only used to create a nice and readable HTML code (indents the UL and LI tags)
function codeIndent()
{
$str = "";
for($i=0;$i<$this->indent;$i++){
$str .= " ";
}
return $str;
}
}
// XNode class: A node item in the menu
class XNode
{
// Name assigned to this node (Text shown on the item)
var $name;
// Link for the item (if any)
var $link;
// Sub-items of this node
var $items = array();
// Absolute URL of this node's icon
var $img;
// Absolute URL of this node's icon (alternate, used for expanded and collapsed states)
var $alt_img;
// constructor
// $name: text shown for this item
// $link: where does this item links to when clicked (optional)
// $img and $alt_img: images displayed next to this item (absolute paths to images must be used)
function XNode($name,$link = false,$img = LEAF_DEFAULT_IMG,$alt_img = LEAF_DEFAULT_ALT_IMG)
{
$this->name = $name;
$this->link = $link;
$this->img = $img;
$this->alt_img = $alt_img;
}
// addItem, adds a subnode under this node
// Takes a XNode object reference as argument
function &addItem(&$node)
{
if($this->img == LEAF_DEFAULT_IMG){$this->img = NODE_DEFAULT_IMG;}
if($this->alt_img == LEAF_DEFAULT_ALT_IMG){$this->alt_img = NODE_DEFAULT_ALT_IMG;}
$this->items[] = &$node;
return $this->items[count($this->items) - 1];
}
}
?>

15
backend/php/src/test.php Normal file
View File

@ -0,0 +1,15 @@
<?php
// $Id: index.php,v 1.0 2004/05/11 11:11:11 phppp(D.J.) Exp $
// Copyright (c) 2004 INFOphp.com //
// ---------------------------------------------------------------- //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// ---------------------------------------------------------------- //
// include "infophp.inc";
// echo infophp::phpinfo();
echo phpinfo();
?>

View File

@ -0,0 +1,20 @@
application: clipperz
version: 1
runtime: python
api_version: 1
handlers:
- url: /json
script: clipperz.py
- url: /css
static_dir: css
- url: /js
static_dir: js
- url: /images
static_dir: images
- url: /.*
script: clipperz.py

View File

@ -0,0 +1,708 @@
#
# Copyright 2008-2011 Clipperz Srl
#
# This file is part of Clipperz's Javascript Crypto Library.
# Javascript Crypto Library provides web developers with an extensive
# and efficient set of cryptographic functions. The library aims to
# obtain maximum execution speed while preserving modularity and
# reusability.
# For further information about its features and functionalities please
# refer to http://www.clipperz.com
#
# * Javascript Crypto Library is free software: you can redistribute
# it and/or modify it under the terms of the GNU Affero General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# * Javascript Crypto Library is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# * You should have received a copy of the GNU Affero General Public
# License along with Javascript Crypto Library. If not, see
# <http://www.gnu.org/licenses/>.
#
import os
import cgi
import wsgiref.handlers
import datetime
import uuid
import random
import hashlib
import logging
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from django.utils import simplejson
#==============================================================================
sessionTimeout = datetime.timedelta(minutes=-2)
def randomSeed():
return hex(random.getrandbits(32*8))[2:-1]
def clipperzHash(aString):
#logging.info(">>> string: " + aString)
firstRound = hashlib.sha256()
firstRound.update(aString)
#logging.info("firstRound: " + firstRound.hexdigest() + " - " + firstRound.digest())
result = hashlib.sha256()
result.update(firstRound.digest())
#logging.info("<<< finalResul: " + result.hexdigest())
return result.hexdigest()
#==============================================================================
class User(db.Model):
username = db.StringProperty()
srp_s = db.StringProperty()
srp_v = db.StringProperty()
header = db.TextProperty()
statistics = db.TextProperty()
auth_version= db.StringProperty()
version = db.StringProperty()
lock = db.StringProperty()
def updateCredentials(self, someCredentials):
self.username = someCredentials['C']
self.srp_s = someCredentials['s']
self.srp_v = someCredentials['v']
self.auth_version = someCredentials['version']
def update(self, someData):
self.header = someData['header']
self.statistics = someData['statistics']
self.version = someData['version']
self.lock = someData['lock']
#------------------------------------------------------------------------------
class Record(db.Model):
user = db.ReferenceProperty(User)
reference = db.StringProperty()
data = db.TextProperty()
version = db.StringProperty()
creation_date = db.DateTimeProperty(auto_now_add=True)
update_date = db.DateTimeProperty(auto_now_add=True)
access_date = db.DateTimeProperty(auto_now_add=True)
#------------------------------------------------------------------------------
class RecordVersion(db.Model):
record = db.ReferenceProperty(Record)
reference = db.StringProperty()
header = db.TextProperty()
data = db.TextProperty()
version = db.StringProperty()
previousVersionKey = db.StringProperty()
previousVersion = db.SelfReferenceProperty()
creation_date = db.DateTimeProperty(auto_now_add=True)
update_date = db.DateTimeProperty(auto_now_add=True)
access_date = db.DateTimeProperty(auto_now_add=True)
def update(self, someData):
recordData = someData['record'];
self.parent().reference = recordData['reference']
self.parent().data = recordData['data']
self.parent().version = recordData['version']
self.parent().update_date = datetime.datetime.now()
recordVersionData = someData['currentRecordVersion'];
self.reference = recordVersionData ['reference']
self.data = recordVersionData ['data']
self.version = recordVersionData ['version']
#self.previous_version = #recordVersionData ['previousVersion']
self.previous_version_key = recordVersionData ['previousVersionKey']
self.update_date = datetime.datetime.now()
#------------------------------------------------------------------------------
class OneTimePassword(db.Model):
user = db.ReferenceProperty(User)
status = db.StringProperty()
reference = db.StringProperty()
keyValue = db.StringProperty()
keyChecksum = db.StringProperty()
data = db.TextProperty()
version = db.StringProperty()
creation_date = db.DateTimeProperty(auto_now_add=True)
request_date = db.DateTimeProperty()
usage_date = db.DateTimeProperty()
def update(self, someParameters, aStatus):
self.reference = someParameters['reference']
self.keyValue = someParameters['key']
self.keyChecksum = someParameters['keyChecksum']
self.data = someParameters['data']
self.version = someParameters['version']
self.status = aStatus
def reset(self, aStatus):
self.data = ""
self.status = aStatus
return self
#------------------------------------------------------------------------------
class Session(db.Expando):
sessionId = db.StringProperty()
access_date = db.DateTimeProperty()
#==============================================================================
class MainPage(webapp.RequestHandler):
def get(self):
path = os.path.join(os.path.dirname(__file__), 'static%s' % self.request.path)
self.response.out.write(template.render(path, {}))
#==============================================================================
class XHR(webapp.RequestHandler):
#==========================================================================
def get(self):
logging.info("self.request.path: " + self.request.path)
if self.request.path == "/dump":
session = self.getSession()
userData = {}
offline_data_placeholder = ""
user = db.Query(User).filter('username =', session.C).get()
userData['users'] = {
'catchAllUser': {
'__masterkey_test_value__': 'masterkey',
's': '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00',
'v': '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00'
}
}
records = {}
for currentRecord in db.Query(Record).ancestor(user):
versions = {}
for currentVersion in db.Query(RecordVersion).ancestor(currentRecord):
versions[currentVersion.reference] ={
'header': currentVersion.header,
'data': currentVersion.data,
'version': currentVersion.version,
'creationDate': str(currentVersion.creation_date),
'updateDate': str(currentVersion.update_date),
'accessDate': str(currentVersion.access_date)
}
records[currentRecord.reference] = {
'data': currentRecord.data,
'version': currentRecord.version,
'creationDate': str(currentRecord.creation_date),
'updateDate': str(currentRecord.update_date),
'accessDate': str(currentRecord.access_date),
'currentVersion': currentVersion.reference,
'versions': versions
}
userData['users'][user.username] = {
's': user.srp_s,
'v': user.srp_v,
'version': user.auth_version,
'maxNumberOfRecords': '100',
'userDetails': user.header,
'statistics': user.statistics,
'userDetailsVersion': user.version,
'records': records
}
offline_data_placeholder = offline_data_placeholder + "_clipperz_dump_data_ = " + simplejson.dumps(userData, indent=4) + "\n"
offline_data_placeholder = offline_data_placeholder + "Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.Offline();" + "\n"
offline_data_placeholder = offline_data_placeholder + "Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();" + "\n"
path = os.path.join(os.path.dirname(__file__), 'static/dump.html')
self.response.headers.add_header('Content-Type', 'text/html')
self.response.headers.add_header('Content-Disposition', 'attachment', filename='Clipperz.html')
self.response.out.write(template.render(path, {'offline_data_placeholder': offline_data_placeholder}))
#==========================================================================
def post(self):
method = self.request.get('method')
parameters = simplejson.loads(self.request.get('parameters'))
session = self.getSession()
result = {};
#----------------------------------------------------------------------
if method == 'registration':
message = parameters['message'];
if message == 'completeRegistration':
user = User()
user.updateCredentials(parameters['credentials'])
user.update(parameters['user'])
user.put()
result['lock'] = user.lock
result['result'] = "done"
#----------------------------------------------------------------------
elif method == 'handshake':
srp_g = 2L
srp_n = long("0x%s" % "115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3", 16)
message = parameters['message'];
#------------------------------------------------------------------
if message == 'connect':
session.C = parameters['parameters']['C']
session.A = parameters['parameters']['A']
user = db.Query(User).filter('username =', session.C).get()
if user != None:
try:
optId = session.otpId
oneTimePassword = db.Query(OneTimePassword).filter('keyValue =', optId).get()
if oneTimePassword.parent().username != user.username:
oneTimePassword.reset('DISABLED').put()
raise Exception, "User missmatch between the current session and 'One Time Password' user"
elif oneTimePassword.status != 'REQUESTED':
oneTimePassword.reset('DISABLED').put()
raise Exception, "Tring to use an 'One Time Password' in the wrong state"
oneTimePassword.reset("USED").put()
result['oneTimePassword'] = oneTimePassword.reference
except Exception, detail:
logging.error("connect.optId: " + str(detail))
session.s = user.srp_s
session.v = user.srp_v
else:
session.s = "112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00"
session.v = "112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00"
session.b = randomSeed()
session.B = hex(long("0x%s" % session.v, 16) + pow(srp_g, long("0x%s" %session.b, 16), srp_n))[2:-1]
result['s'] = session.s
result['B'] = session.B
#------------------------------------------------------------------
elif message == 'credentialCheck':
B = long("0x%s" % session.B, 16)
b = long("0x%s" % session.b, 16)
A = long("0x%s" % session.A, 16)
v = long("0x%s" % session.v, 16)
u = long("0x%s" % clipperzHash(str(B)), 16)
n = srp_n
S = pow((A * pow(v, u, n)), b, n)
K = clipperzHash(str(S))
M1 = clipperzHash(str(A) + str(B) + K)
if M1 == parameters['parameters']['M1']:
session.K = K
M2 = clipperzHash(str(A) + M1 + K)
result['M2'] = M2
result["connectionId"] = ""
result["loginInfo"] = {}
result["loginInfo"]["latest"] = {}
result["loginInfo"]["current"] = {}
result["offlineCopyNeeded"] = "false";
result["lock"] = "----";
else:
result['error'] = "?"
#------------------------------------------------------------------
elif message == 'oneTimePassword':
oneTimePassword = db.Query(OneTimePassword).filter("keyValue =", parameters["parameters"]["oneTimePasswordKey"]).get()
if oneTimePassword != None:
if oneTimePassword.status == 'ACTIVE':
if oneTimePassword.keyChecksum == parameters['parameters']['oneTimePasswordKeyChecksum']:
#session.userId = str(oneTimePassword.parent().username)
session.otpId = str(oneTimePassword.keyValue)
result['data'] = oneTimePassword.data
result['version'] = oneTimePassword.version
oneTimePassword.reset('REQUESTED').put()
else:
oneTimePassword.reset('DISABLED').put()
raise Exception, "The requested One Time Password has been disabled, due to a wrong keyChecksum"
else:
raise Exception, "The requested One Time Password was not active"
else:
raise Exception, "The requested One Time Password has not been found"
#----------------------------------------------------------------------
elif method == 'message':
if parameters['srpSharedSecret'] == session.K:
message = parameters['message']
if message == 'getUserDetails':
# {"message":"getUserDetails", "srpSharedSecret":"f18e5cf7c3a83b67d4db9444af813ee48c13daf4f8f6635397d593e52ba89a08", "parameters":{}}
user = db.Query(User).filter('username =', session.C).get()
result['header'] = user.header;
result['statistics'] = user.statistics;
result['version'] = user.version;
elif message == "addNewRecords":
user = db.Query(User).filter('username =', session.C).get()
result = db.run_in_transaction(self.addNewRecords, session, user, parameters)
"""
user = db.Query(User).filter('username =', session.C).get()
user.update(parameters['parameters']['user'])
for recordParameter in parameters['parameters']['records']:
record = Record(parent=user)
record.put()
recordVersion = RecordVersion(parent=record)
recordVersion.put()
recordVersion.update(recordParameter)
record.put()
recordVersion.put()
user.put();
result['lock'] = user.lock
result['result'] = 'done'
"""
elif message == 'getRecordDetail':
record = db.Query(Record).ancestor(db.Query(User).filter('username =', session.C).get()).filter('reference =', parameters["parameters"]["reference"]).get()
recordVersion = db.Query(RecordVersion).ancestor(record).get()
result['currentVersion'] = {}
result['currentVersion']['reference'] = recordVersion.reference
result['currentVersion']['data'] = recordVersion.data
result['currentVersion']['header'] = recordVersion.header
result['currentVersion']['version'] = recordVersion.version
result['currentVersion']['creationDate'] = str(recordVersion.creation_date)
result['currentVersion']['updateDate'] = str(recordVersion.update_date)
result['currentVersion']['accessDate'] = str(recordVersion.access_date)
result['reference'] = record.reference
result['data'] = record.data
result['version'] = record.version
result['creationDate'] = str(record.creation_date)
result['updateDate'] = str(record.update_date)
result['accessDate'] = str(record.access_date)
result['oldestUsedEncryptedVersion'] = "---"
elif message == 'updateData':
user = db.Query(User).filter('username =', session.C).get()
user.update(parameters['parameters']['user'])
for recordParameter in parameters['parameters']['records']:
logging.info('reference =' + recordParameter['record']['reference'])
record = db.Query(Record).ancestor(user).filter('reference =', recordParameter['record']['reference']).get()
recordVersion = db.Query(RecordVersion).ancestor(record).get()
recordVersion.update(recordParameter)
recordVersion.put()
recordVersion.parent().put()
user.put();
result['lock'] = user.lock
result['result'] = 'done'
elif message == 'deleteRecords':
user = db.Query(User).filter('username =', session.C).get()
user.update(parameters['parameters']['user'])
for recordReference in parameters['parameters']['recordReferences']:
record = db.Query(Record).ancestor(user).filter('reference =', recordReference).get()
#recordVersion = db.Query(RecordVersion).ancestor(record).get()
db.delete(db.Query(RecordVersion).ancestor(record))
record.delete()
user.put()
result['lock'] = user.lock
result['result'] = 'done'
elif message == 'deleteUser':
user = db.Query(User).filter('username =', session.C).get()
db.delete(db.Query(RecordVersion).ancestor(user))
db.delete(db.Query(Record).ancestor(user))
user.delete()
elif message == 'addNewOneTimePassword':
user = db.Query(User).filter('username =', session.C).get()
user.update(parameters['parameters']['user'])
oneTimePassword = OneTimePassword(parent=user)
oneTimePassword.update(parameters['parameters']['oneTimePassword'], "ACTIVE")
oneTimePassword.put()
user.put()
result['lock'] = user.lock
result['result'] = 'done'
elif message == 'updateOneTimePasswords':
user = db.Query(User).filter('username =', session.C).get()
user.update(parameters['parameters']['user'])
validOtpReferences = parameters['parameters']['oneTimePasswords']
for currentOtp in db.Query(OneTimePassword).ancestor(user):
if currentOtp.reference in validOtpReferences:
pass
else:
currentOtp.delete()
user.put()
result['result'] = user.lock
elif message == 'getOneTimePasswordsDetails':
pass
elif message == 'getLoginHistory':
result["result"] = []
elif message == 'upgradeUserCredentials':
user = db.Query(User).filter('username =', session.C).get()
user.updateCredentials(parameters['parameters']['credentials'])
user.update(parameters['parameters']['user'])
for oneTimePasswordReference in parameters['parameters']['oneTimePasswords']:
oneTimePassword = db.Query(OneTimePassword).ancestor(user).filter("reference =", oneTimePasswordReference).get()
if oneTimePassword != None:
oneTimePassword.data = parameters['parameters']['oneTimePasswords'][oneTimePasswordReference]
oneTimePassword.put()
user.put()
result['lock'] = user.lock
result['result'] = 'done'
"""
$user = new user();
$user->Get($_SESSION["userId"]);
$otp = new onetimepassword();
updateUserCredentials($parameters["parameters"]["credentials"], $user);
updateUserData($parameters["parameters"]["user"], $user);
$otpList = $parameters["parameters"]["oneTimePasswords"];
foreach($otpList as $otpReference=>$otpData) {
$otpList = $otp->GetList(array(array("reference", "=", $otpReference)));
$currentOtp = $otpList[0];
$currentOtp->data = $otpData;
$currentOtp->Save();
}
$user->Save();
$result["lock"] = $user->lock;
$result["result"] = "done";
"""
#=============================================================
"""
java.util.Map result;
try {
java.util.Map credentials;
if (someParameters.get("credentials") != null) {
credentials = (java.util.Map)someParameters.get("credentials");
} else {
credentials = someParameters;
}
aUser.setUsername((java.lang.String)credentials.get("C"));
aUser.setSrpS((java.lang.String)credentials.get("s"));
aUser.setSrpV((java.lang.String)credentials.get("v"));
aUser.setVersion((java.lang.String)credentials.get("version"));
if (someParameters.get("user") != null) {
com.clipperz.dataModel.EncoderHelper.updateWithMap(aUser, (java.util.Map)someParameters.get("user"));
}
if (someParameters.get("oneTimePasswords") != null) {
java.util.Map updatedOneTimePasswords;
java.util.List usersOneTimePasswords;
int i,c;
updatedOneTimePasswords = (java.util.Map)someParameters.get("oneTimePasswords");
usersOneTimePasswords = com.clipperz.dataModel.OneTimePassword.oneTimePasswordsForUser(this.user());
c = usersOneTimePasswords.size();
for (i=0; i<c; i++) {
com.clipperz.dataModel.OneTimePassword currentOneTimePassword;
currentOneTimePassword = (com.clipperz.dataModel.OneTimePassword)usersOneTimePasswords.get(i);
if (updatedOneTimePasswords.get(currentOneTimePassword.getReference()) != null) {
currentOneTimePassword.setData((java.lang.String)updatedOneTimePasswords.get(currentOneTimePassword.getReference()));
}
}
}
result = new java.util.Hashtable();
this.dataContext().commitChanges();
result.put("lock", this.user().getNewLock());
result.put("result", "done");
} catch(java.lang.Exception exception) {
this.dataContext().rollbackChanges();
logger.error(exception);
throw exception;
}
return result;
"""
elif message == 'echo':
result['result'] = parameters;
else:
result['error'] = "Wrong shared secret!"
#----------------------------------------------------------------------
elif method == 'logout':
result['method'] = 'logout'
#----------------------------------------------------------------------
else:
result['method'] = 'PRRRRRR'
#----------------------------------------------------------------------
self.saveSession(session)
self.response.out.write(simplejson.dumps(result))
#==========================================================================
def addNewRecords (self, aSession, aUser, someParameters):
result = {}
#user = db.Query(User).filter('username =', aSession.C).get()
aUser.update(someParameters['parameters']['user'])
for recordParameter in someParameters['parameters']['records']:
record = Record(parent=aUser)
record.put()
recordVersion = RecordVersion(parent=record)
recordVersion.put()
recordVersion.update(recordParameter)
record.put()
recordVersion.put()
aUser.put();
result['lock'] = aUser.lock
result['result'] = 'done'
return result
#==========================================================================
def getSession(self):
#logging.info(">>> getSession (%d) => %s" % (db.Query(Session).count(), str(map(lambda v: v.sessionId, db.Query(Session).fetch(100)))) )
result = None
try:
sessionId = self.request.cookies['sessionId']
except:
sessionId = None
#logging.info("wannabe sessionId: " + str(sessionId))
if sessionId != None:
#query = db.Query(Session)
#query.filter('sessionId =', sessionId)
#result = query.get()
#result = db.Query(Session).filter('sessionId =', str(sessionId)).filter('access_date >', (datetime.datetime.utcnow() - sessionTimeout)).get()
result = db.Query(Session).filter('sessionId =', str(sessionId)).get()
#logging.info("searching session on datastore. Found: " + str(result))
if result == None:
sessionId = str(uuid.uuid4())
#logging.info("creating a new session with sessionId=" + str(sessionId))
result = Session(sessionId=sessionId)
result.access_date = datetime.datetime.utcnow()
result.put()
#logging.info("<<< getSession (%d)" % db.Query(Session).count())
return result
#==========================================================================
def saveSession(self, aSession):
#logging.info(">>> saveSession (%d)" % db.Query(Session).count())
#self.response.set_cookie('sessionId', aSession.sessionId, max_age=360, path='/', domain='example.org', secure=True)
aSession.put()
self.response.headers.add_header('Set-Cookie', 'sessionId=' + str(aSession.sessionId), path='/')
self.cleanOldSessions()
#logging.info("<<< saveSession (%d)" % db.Query(Session).count())
#==========================================================================
def cleanOldSessions(self):
query = db.Query(Session).filter('accessDate <', (datetime.datetime.utcnow() - sessionTimeout))
expiredSessions = query.count();
if expiredSessions != 0:
#logging.info("deleting %d sessions" % expiredSessions)
pass
"""
try:
db.delete(query)
except Exception, exception:
logging.error("some issues raised while deleting the expired sessions")
logging.error("exception type: " + str(type(exception)))
logging.error("exception: " + str(exception))
"""
pass
#==============================================================================
def main():
application = webapp.WSGIApplication([('/xhr', XHR), ('/dump', XHR), ('/.*', MainPage)], debug=True)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == "__main__":
main()

31
doc/install.php.txt Normal file
View File

@ -0,0 +1,31 @@
Instructions on how to install and configure your personal instance of the Clipperz application
Configure the settings on the /php/configuration.php file.
The most important configuration options are the one to connect to the MySQL database:
- $configuration['db'] = 'clipperz'; // database name
- $configuration['host'] = 'localhost'; // database host
- $configuration['user'] = 'root'; // database user
- $configuration['pass'] = 'pass'; // database password
- $configuration['port'] = '3306'; // database port
The MySQL database configured above, should already exists, but the setup procedure will take care of creating all the tables used by the application.
Once the configuration are setup, you should load the /php/setup/index.php page.
Following the instructions, the script will generate all the database objects, and run some tests to double-check that everything works fine.
In the first page you have to press the "POG me up!" button at the bottom of the page; in the next page, if all the checks are successful, a "Proceed" button will be enabled below the main text area. Clicking the "Proceed" button you will access the tab of the POG application that enable you to inspect and edit the content of the database used by the Clipperz application.
Once the application is successfully installed, it is probably a good idea to remove, disable or protect the whole "/php/setup/" folder, in order to avoid anyone from deleting random records from the database. Your data will not be leaked, but it would be possible to delete them anyway.
At this point the database should be ready to run.
The PHP code is quite simple, but there are a few dependency on external library that you may have to include, depending of the version of PHP you are using.
- PDO: http://ca.php.net/pdo
- JSON: http://aurore.net/projects/php-json/
- BCMath: http://it.php.net/bc
The code has been compiled using PHP 5.1.6
The POG class definitions have been configure for use with PHP 5.1+
For added convenience, we have added a page at /php/test.php that reports the detailed PHP configuration available on your computer.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,162 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz's Javascript Crypto Library.
Javascript Crypto Library provides web developers with an extensive
and efficient set of cryptographic functions. The library aims to
obtain maximum execution speed while preserving modularity and
reusability.
For further information about its features and functionalities please
refer to http://www.clipperz.com
* Javascript Crypto Library is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Javascript Crypto Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Javascript Crypto Library. If not, see
<http://www.gnu.org/licenses/>.
*/
/* @override https://www.example.com/css/compact.css */
body.compact div#mainDiv {
/*
width: 250px;
height: 95%;
border: 1px solid #333366;
*/
padding: 0px;
}
body.compact div#compactHeader {
background-color: #333366;
}
body.compact div#compactHeader img {
padding: 2px 20px 2px 4px;
width: 60;
}
body.compact div#compactHeader a {
color: white;
text-decoration: none;
font-size: 10pt;
/* position: absolute; */
right: 10px;
top: 6px;
}
body.compact div#compactHeader a:hover {
color: #ff9400;
}
body.compact h4 {
color: #999999;
text-align: center;
padding: 20px;
font-weight: normal;
font-size: 12pt;
font-style: italic;
}
body.compact div.loginPanel form {
padding: 10px;
}
body.compact div.loginPanel dt {
color: #aaaaaa;
font-size: 10pt;
}
body.compact div.loginPanel input {
width: 180px;
}
body.compact ul#directLogins {
background-image: none;
padding: 4px 0px;
}
body.compact ul#directLogins li {
width:auto;
}
body.compact ul#directLogins li.hover {
width:auto;
padding-right: 0px;
}
body.compact div.lockPanel {
color: #999999;
font-size: 10pt;
padding: 10px;
}
div#compactMiscLinks ul {
/* text-align: center; */
display: block;
padding-left: 22px;
background-color: #ff9400;
}
div#compactMiscLinks ul li {
display: inline;
padding: 2px 5px;
}
div#compactHeader div#compactMiscLinks ul li a {
font-size: 9pt;
}
div#compactHeader div#compactMiscLinks ul li a:hover {
color: #333366;
}
div#lockBlock {
position: absolute;
right: 10px;
top: 6px;
}
div#lockBlock input {
width: auto;
padding-bottom: 2px;
}
div#lockBlock span {
font-size: 9pt;
padding: 0px 5px 0px 4px;
color: #aaaaaa;
}
div#lockBlock a#lock {
font-size: 9pt;
}
/* @group Donate */
a#donateHeaderLink {
font-weight: bold;
}
div#compactMiscLinks a#donateHeaderIconLink img#donateHeaderLinkIcon {
display: inline;
position: absolute;
top: 22px;
left: 1px;
width: 12px;
height: 12px;
}
/* @end */

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,250 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz's Javascript Crypto Library.
Javascript Crypto Library provides web developers with an extensive
and efficient set of cryptographic functions. The library aims to
obtain maximum execution speed while preserving modularity and
reusability.
For further information about its features and functionalities please
refer to http://www.clipperz.com
* Javascript Crypto Library is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Javascript Crypto Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Javascript Crypto Library. If not, see
<http://www.gnu.org/licenses/>.
*/
.ydlg-proxy {
background-image: url(../images/default/gradient-bg.gif);
background-color:#c3daf9;
border:1px solid #6593cf;
z-index:10001;
overflow:hidden;
position:absolute;
left:0;top:0;
}
.ydlg-shadow{
background:#aaaaaa;
position:absolute;
left:0;top:0;
}
.ydlg-focus{
-moz-outline:0 none;
outline:0 none;
width:0;
height:0;
overflow:hidden;
position:absolute;
top:0;
left:0;
}
.ydlg-mask{
z-index:10000;
display:none;
position:absolute;
top:0;
left:0;
-moz-opacity: 0.5;
opacity:.50;
filter: alpha(opacity=50);
background-color:#CCC;
}
body.masked{
}
body.masked select {
visibility:hidden;
}
body.masked .ydlg select {
visibility:visible;
}
.ydlg{
z-index:10001;
overflow:hidden;
position:absolute;
left:300;top:0;
}
.yresizable-proxy{
z-index:10002;
}
.ydlg .ydlg-hd {
background: url(../images/default/basic-dialog/hd-sprite.gif) repeat-x 0 -82px;
background-color:navy;
color:#ffffff;
font:bold 12px "sans serif", tahoma, verdana, helvetica;
overflow:hidden;
padding:5px;
}
.ydlg .ydlg-hd-left {
background: url(../images/default/basic-dialog/hd-sprite.gif) no-repeat 0 -41px;
padding-left:3px;
margin:0px;
}
.ydlg .ydlg-hd-right {
background: url(../images/default/basic-dialog/hd-sprite.gif) no-repeat right 0;
padding-right:3px;
}
.ydlg .ydlg-dlg-body{
background:url(../images/default/layout/gradient-bg.gif);
border:1px solid #6593cf;
border-top:0 none;
padding:10px;
overflow:hidden;
}
.ydlg .ydlg-bd{
overflow:hidden;
}
.ydlg .ydlg-ft{
overflow:hidden;
padding:5px;
padding-bottom:0;
}
.ydlg .yui-ext-tabbody{
background:white;
overflow:auto;
}
.ydlg .ytabs-top .yui-ext-tabbody{
border:1px solid #6593cf;
border-top:0 none;
}
.ydlg .ytabs-bottom .yui-ext-tabbody{
border:1px solid #6593cf;
border-bottom:0 none;
}
.ydlg .ylayout-container .yui-ext-tabbody{
border:0 none;
}
.ydlg .inner-tab{
margin:5px;
}
.ydlg .ydlg-ft .ybtn{
margin-right:5px;
float:right;
clear:none;
}
.ydlg .ydlg-ft .ydlg-btns td {
border:0;
padding:0;
}
.ydlg .ydlg-ft .ydlg-btns-right table{
float:right;
clear:none;
}
.ydlg .ydlg-ft .ydlg-btns-left table{
float:left;
clear:none;
}
.ydlg .ydlg-ft .ydlg-btns-center{
text-align:center; /*ie*/
}
.ydlg .ydlg-ft .ydlg-btns-center table{
margin:0 auto; /*everyone else*/
}
.ydlg-draggable .ydlg-hd{
cursor:move;
}
.ydlg-closable .ydlg-hd{
padding-right:22px;
}
.ydlg .ydlg-close {
position:absolute;
top:4px;
right:4px;
z-index:6;
height:15px;
width:15px;
margin:0;
padding:0;
line-height:1px;
font-size:1px;
background-repeat:no-repeat;
cursor:pointer;
visibility:inherit;
background-image:url(../images/default/basic-dialog/close.gif);
}
.ydlg div.yresizable-handle-east{
background-image:url(../images/default/sizer/e-handle-dark.gif);
border:0;
background-position:left;
margin-right:0;
}
.ydlg div.yresizable-handle-south{
background-image:url(../images/default/sizer/s-handle-dark.gif);
border:0;
height:6px;
}
.ydlg div.yresizable-handle-west{
background-image:url(../images/default/sizer/e-handle-dark.gif);
border:0;
background-position:1px;
}
.ydlg div.yresizable-handle-north{
background-image:url(../images/default/s.gif);
border:0;
}
.ydlg div.yresizable-handle-northeast, .ytheme-gray .ydlg div.yresizable-handle-northeast{
background-image:url(../images/default/s.gif);
border:0;
}
.ydlg div.yresizable-handle-northwest, .ytheme-gray .ydlg div.yresizable-handle-northwest{
background-image:url(../images/default/s.gif);
border:0;
}
.ydlg div.yresizable-handle-southeast{
background-image:url(../images/default/sizer/corners-sprite.gif);
background-position: top left;
width:8px;
height:8px;
border:0;
}
.ydlg div.yresizable-handle-southwest{
background-image:url(../images/default/sizer/corners-sprite.gif);
background-position: top right;
margin-left:1px;
margin-bottom:1px;
border:0;
}
#mb-dlg .ydlg-ft .ybtn{
float:none;
clear:none;
margin:0 3px;
}
#mb-dlg .ydlg-bd {
padding:5px;
overflow:hidden !important;
}
#mb-dlg .ext-mb-input {
margin-top:4px;
width:95%;
}
#mb-dlg .ext-mb-textarea {
margin-top:4px;
font:normal 13px verdana,tahoma,sans-serif;
}
#mb-dlg .ext-mb-progress-wrap {
margin-top:4px;
border:1px solid #6593cf;
}
#mb-dlg .ext-mb-progress {
height:18px;
background:transparent url(../images/default/basic-dialog/progress2.gif) repeat-x 1px 1px;
}
#mb-dlg .ext-mb-progress-bar {
height:18px;
overflow:hidden;
width:0;
background:#8bb8f3;
}

View File

@ -0,0 +1,86 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz's Javascript Crypto Library.
Javascript Crypto Library provides web developers with an extensive
and efficient set of cryptographic functions. The library aims to
obtain maximum execution speed while preserving modularity and
reusability.
For further information about its features and functionalities please
refer to http://www.clipperz.com
* Javascript Crypto Library is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Javascript Crypto Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Javascript Crypto Library. If not, see
<http://www.gnu.org/licenses/>.
*/
.ybtn{
font:normal 11px arial, tahoma, verdana, helvetica;
cursor:pointer;
white-space: nowrap;
}
.ybtn-left, .ybtn-right{
font-size:1px;
line-height:1px;
}
.ybtn-left{
width:3px;
height:21px;
background:url(../images/default/basic-dialog/btn-sprite.gif) no-repeat 0 0;
}
.ybtn-right{
width:3px;
height:21px;
background:url(../images/default/basic-dialog/btn-sprite.gif) no-repeat 0 -21px;
}
.ybtn-focus{
text-decoration:none !important;
color:black !important;
display: -moz-inline-block;
display:inline-block;
width:auto;
position:relative;
white-space: nowrap;
}
.ybtn-center{
background:url(../images/default/basic-dialog/btn-sprite.gif) repeat-x 0 -42px;
font:normal 11px "san serif",tahoma,verdana,helvetica;
vertical-align: middle;
text-align:center;
padding:0 5px;
cursor:pointer;
white-space:nowrap;
-moz-user-select: none;
-khtml-user-select: none;
}
.ybtn-over .ybtn-left{
background-position:0 -63px;
}
.ybtn-over .ybtn-right{
background-position:0 -84px;
}
.ybtn-over .ybtn-center{
background-position:0 -105px;
}
.ybtn-click .ybtn-center{
background-position:0 -126px;
}
.ybtn-disabled{
cursor:default;
}
.ybtn-disabled .ybtn-center{
color:gray;
cursor:default;
}

View File

@ -0,0 +1,53 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz's Javascript Crypto Library.
Javascript Crypto Library provides web developers with an extensive
and efficient set of cryptographic functions. The library aims to
obtain maximum execution speed while preserving modularity and
reusability.
For further information about its features and functionalities please
refer to http://www.clipperz.com
* Javascript Crypto Library is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Javascript Crypto Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Javascript Crypto Library. If not, see
<http://www.gnu.org/licenses/>.
*/
.ext-el-mask {
z-index:20000;
position:absolute;
top:0;
left:0;
-moz-opacity: 0.5;
opacity:.50;
filter: alpha(opacity=50);
background-color:#CCC;
width:100%;
height:100%;
zoom:1;
}
.ext-masked {
overflow:hidden !important;
}
.ext-masked select,.ext-masked object,.ext-masked embed{
visibility:hidden;
}
.ylayer-shadow{
background:#cccccc;
opacity:.3;
-moz-opacity:.3;
filter: alpha(opacity=30);
}

View File

@ -0,0 +1,81 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz's Javascript Crypto Library.
Javascript Crypto Library provides web developers with an extensive
and efficient set of cryptographic functions. The library aims to
obtain maximum execution speed while preserving modularity and
reusability.
For further information about its features and functionalities please
refer to http://www.clipperz.com
* Javascript Crypto Library is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Javascript Crypto Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Javascript Crypto Library. If not, see
<http://www.gnu.org/licenses/>.
*/
.ydd-drag-proxy{
position:absolute;
left:0;top:0;
visibility:hidden;
z-index:15000;
}
.ydd-drag-ghost{
color: black;
font: normal 11px arial, helvetica, sans-serif;
-moz-opacity: 0.85;
opacity:.85;
filter: alpha(opacity=85);
border-top:1px solid #dddddd;
border-left:1px solid #dddddd;
border-right:1px solid #bbbbbb;
border-bottom:1px solid #bbbbbb;
padding:3px;
padding-left:20px;
background-color:white;
white-space:nowrap;
}
.ydd-drag-repair .ydd-drag-ghost{
-moz-opacity: 0.4;
opacity:.4;
filter: alpha(opacity=40);
border:0 none;
padding:0;
background-color:transparent;
}
.ydd-drag-repair .ydd-drop-icon{
visibility:hidden;
}
.ydd-drop-icon{
position:absolute;
top:3px;
left:3px;
display:block;
width:16px;
height:16px;
background-color:transparent;
background-position: center;
background-repeat: no-repeat;
z-index:1;
}
.ydd-drop-nodrop .ydd-drop-icon{
background-image: url(../images/default/dd/drop-no.gif);
}
.ydd-drop-ok .ydd-drop-icon{
background-image: url(../images/default/dd/drop-yes.gif);
}
.ydd-drop-ok-add .ydd-drop-icon{
background-image: url(../images/default/dd/drop-add.gif);
}

View File

@ -0,0 +1,584 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz's Javascript Crypto Library.
Javascript Crypto Library provides web developers with an extensive
and efficient set of cryptographic functions. The library aims to
obtain maximum execution speed while preserving modularity and
reusability.
For further information about its features and functionalities please
refer to http://www.clipperz.com
* Javascript Crypto Library is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Javascript Crypto Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Javascript Crypto Library. If not, see
<http://www.gnu.org/licenses/>.
*/
.ygrid-cell-text {
display: block;
overflow: hidden;
padding: 3px 5px;
white-space: nowrap;
}
.ygrid-col{
cursor: default;
height:21px !important;
box-sizing: border-box;
-moz-box-sizing: border-box;
position:absolute;
display:block;
-moz-outline: none;
-moz-user-focus: normal;
overflow: hidden;
border-left: 1px solid #f1efe2;
}
.yeditgrid .ygrid-col{
-moz-outline: normal;
}
.ygrid-col, .ygrid-hd {
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
}
.ygrid-col-0{
border-left: 0;
}
.ygrid-col-last{
border-right: 1px solid #f1efe2;
}
.ygrid-editor{
box-sizing: border-box;
-moz-box-sizing: border-box;
position:absolute;
visibility:hidden;
font: normal 8pt arial;
border: 1px solid #afbdc9;
z-index:10;
}
.ygrid-editor input{
font: normal 8pt arial;
border: 0;
padding-top:2px;
padding-left:3px;
}
.ygrid-editor-container{
overflow:hidden;
display:block;
background-color:white;
}
.ygrid-editor .pick-button{
width:15px;
height:20px;
position:absolute;
display:block;
right:0;
top:0;
z-index:2;
background-image: url(../images/default/grid/pick-button.gif);
background-repeat: no-repeat;
}
.ygrid-editor-invalid{
background-image: url(../images/default/grid/invalid_line.gif);
background-repeat: repeat-x;
background-position: bottom;
border: 1px solid #afbdc9;
}
.ygrid-checkbox-editor{
text-align: center;
overflow:hidden;
display:block;
background-color:white;
}
.ygrid-checkbox-editor input{
margin-top:3px;
height:13px;
width:13px;
}
select.ygrid-editor{
padding: 0;
-moz-outline: none;
border: 1px solid #afbdc9;
}
.ygrid-num-editor{
text-align:right;
padding-top:2px;
padding-left:3px;
}
.ygrid-text-editor{
padding-top:2px;
padding-left:3px;
}
.ygrid-hd{
font: normal 8pt arial;
background-color: #ebeadb;
box-sizing: border-box;
-moz-box-sizing: border-box;
display: block;
position: absolute;
overflow:hidden;
}
.ygrid-column-sizer {
width:1px;
border-right:1px dashed #6593cf;
background:none;
cursor: col-resize;
}
.ygrid-drag-proxy{
width:150px;
height:24px;
background-color:#3366cc;
border: 1px solid #002266;
position:absolute;
visibility:hidden;
z-index:10000;
}
.ygrid-drag-text{
font: normal 8pt arial;
color:white;
position:absolute;
top:0;
left:26px;
padding:3px;
display:block;
}
.ygrid-drop-icon{
position:absolute;
top:0;
left:0;
display:block;
width:24px;
height:100%;
background-position: center;
background-repeat: no-repeat;
}
.ygrid-drop-nodrop{
background-image: url(../images/default/grid/drop-no.gif);
}
.ygrid-drop-ok{
background-image: url(../images/default/grid/drop-yes.gif);
}
.ygrid-hd .sort-asc {
background-image: url(../images/default/grid/sort_asc.gif);
background-position: right;
background-repeat: no-repeat;
display: none;
height: 14px;
width: 16px;
}
.ygrid-hd .sort-desc {
background-image: url(../images/default/grid/sort_desc.gif);
background-position: right;
background-repeat: no-repeat;
display: none;
height: 14px;
width: 16px;
}
.ygrid-hd-body {
cursor: default;
display: block;
font: normal 8pt arial;
left: 0;
overflow: hidden;
padding: 3px 5px;
position: relative;
top: 0;
white-space: nowrap;
}
.ygrid-hd-body span {
font: normal 8pt arial;
white-space: nowrap;
}
.ygrid-hd-over{
border-bottom: 2px solid #fcc247;
}
.ygrid-hd-over .ygrid-hd-body{
background-color: #faf9f4;
border-bottom: 1px solid #f9a900;
}
.ygrid-hd-split {
background-image: url(../images/default/grid/grid-split.gif);
background-position: center;
background-repeat: no-repeat;
cursor: e-resize;
display: block;
font-size: 1px;
height: 16px;
overflow: hidden;
position: absolute;
top: 2px;
width: 6px;
z-index: 3;
}
.ygrid-hrow{
background: #ebeadb url(../images/default/grid/grid-hrow.gif) repeat-x;
display: block;
height: 22px;
left: 0;
position: relative;
top: 0;
width: 10000px;
overflow:hidden;
z-index:2;
}
.ygrid-hrow-frame{
height: 22px;
left: 0;
display:block;
position: absolute;
top: 0;
width: 10000px;
z-index:1;
}
.ygrid-footer .ytoolbar{
border:0;
}
.ygrid-page-number{
width:24px;
height:14px;
}
.ygrid-page-first{
background-image: url(../images/default/grid/page-first.gif);
}
.ygrid-loading{
background-image: url(../images/default/grid/done.gif);
}
.ygrid-page-last{
background-image: url(../images/default/grid/page-last.gif);
}
.ygrid-page-next{
background-image: url(../images/default/grid/page-next.gif);
}
.ygrid-page-prev{
background-image: url(../images/default/grid/page-prev.gif);
}
.ytb-button-disabled .ygrid-loading{
background-image: url(../images/default/grid/loading.gif);
}
.ytb-button-disabled .ygrid-page-first{
background-image: url(../images/default/grid/page-first-disabled.gif);
}
.ytb-button-disabled .ygrid-page-last{
background-image: url(../images/default/grid/page-last-disabled.gif);
}
.ytb-button-disabled .ygrid-page-next{
background-image: url(../images/default/grid/page-next-disabled.gif);
}
.ytb-button-disabled .ygrid-page-prev{
background-image: url(../images/default/grid/page-prev-disabled.gif);
}
.ygrid-mso{
}
.ygrid-mso .ygrid-hd{
background:none;
border-bottom:0;
}
.ygrid-mso .ygrid-footer {
border-top: 1px solid #6593cf;
}
.ygrid-mso .ygrid-footer .ygrid-fbutton{
border:0;
}
.ygrid-mso .ygrid-hd-body {
border-bottom:0;
}
.ygrid-mso .ygrid-hd-over{
border-bottom:0;
}
.ygrid-mso .ygrid-hd-over .ygrid-hd-body{
background-color: transparent;
}
.ygrid-mso .ygrid-hd-split {
background-image: url(../images/default/grid/grid-blue-split.gif);
}
.ygrid-mso .ytoolbar .ytb-sep {
background-image: url(../images/default/grid/grid-blue-split.gif);
}
.ygrid-mso .ygrid-hrow{
background: url(../images/default/grid/mso-hd.gif);
border-bottom: 1px solid #6593cf;
height: 21px;
}
.ygrid-mso .ygrid-row{
color: black;
border-bottom: 1px solid #ddecfe;
}
.ygrid-mso .ygrid-row-alt{
background-color: #f5f5f5;
}
.ygrid-mso .ygrid-row-selected{
background-color: #b3c8e8 !important;
color: black;
}
.ygrid-mso .ygrid-row-selected span{
color: black !important;
}
.yprops-grid .ygrid-col-1{
background-color: #f1efe2;
}
.yprops-grid .ygrid-col-1 .ygrid-cell-text{
background-color: white;
}
.yprops-grid .ygrid-col-0{
background-color: #f1efe2;
}
.yprops-grid .ygrid-col-0 .ygrid-cell-text{
background-color: white;
margin-left:10px;
}
.yprops-grid .ygrid-prop-edting .ygrid-col-0 .ygrid-cell-text{
background-color: #316ac5;
color: white;
}
.yprops-grid .ygrid-prop-edting .ygrid-col-0{
color: white;
}
.yprops-grid .ygrid-num-editor{
text-align:left;
}
.ygrid-row{
font: normal 8pt arial;
border-bottom: 1px solid #f1efe2;
overflow: visible;
white-space: nowrap;
height:21px;
width:10000px;
box-sizing: border-box;
-moz-box-sizing: border-box;
display:block;
position:absolute;
}
.ygrid-row-alt{
background-color: #fcfaf6;
}
.ygrid-row-over{
background-color: #f1f1f1;
color: black;
}
.ygrid-row-selected{
background-color: #316ac5 !important;
color: white;
}
.ygrid-row-selected span{
color: white !important;
}
.ygrid-vista{
border:1px solid #535353;
}
.ygrid-vista .ygrid-hd{
border-bottom:0px;
background:none;
}
.ygrid-vista .ygrid-hd-body {
border-bottom: 1px solid #b3bcc0;
}
.ygrid-vista .ygrid-hd-over{
border-bottom:0px;
}
.ygrid-vista .ygrid-hd-over .ygrid-hd-body{
background-color: transparent;
border-bottom:0;
}
.ygrid-vista .ygrid-hd-split {
background-image: url(../images/default/grid/grid-split.gif);
}
.ygrid-vista .ygrid-hrow{
background: url(../images/default/grid/grid-vista-hd.gif);
height: 21px;
}
.ygrid-vista .ygrid-row-alt{
background-color: #f5f5f5;
}
.ygrid-vista .ygrid-row-selected{
background-color: #535353 !important;
color: white;
}
.ygrid-vista .ygrid-row-selected span{
color: white !important;
}
.ygrid-vista .ygrid-wrap-body {
}
.ygrid-vista .ytoolbar{
border: 0px none;
background: url(../images/default/grid/grid-vista-hd.gif);
}
.ygrid-vista .ytoolbar .ytb-sep{
background-image: url(../images/default/grid/grid-split.gif);
}
/*
To have the scrollbars overlap the header, change .ygrid-wrap top style to 0 and
and ygrid-wrap-body top to 22px
Then grid.getView().scrollbarMode = YAHOO.ext.grid.GridView.SCROLLBARS_OVERLAP;
*/
.ygrid-wrap {
height: 100%;
left: 0;
overflow: auto;
position: relative;
top: 22px;
width: 100%;
}
.ygrid-footer{
display: block;
padding:0;
border-top: 1px solid #cbc7b8;
}
.ygrid-wrap-footer {
display: block;
overflow: hidden;
width:100%;
height:25px;
box-sizing: border-box;
-moz-box-sizing: border-box;
background-color: #ebeadb;
position:absolute;
bottom:0;
}
.ygrid-wrap-body {
left: 0;
overflow: hidden;
position: absolute;
top: 0;
display: block;
}
.ygrid-wrap-headers {
left: 0;
overflow: hidden;
position: absolute;
top: 0;
z-index: 12;
}
.ypopcal{
background: white;
padding:2px;
border: 1px solid gray;
z-index:12001;
-moz-outline:none;
position:absolute;
display:none;
top:0;
left:0;
}
.ypopcal-shadow {
background: #dddddd;
filter: progid:DXImageTransform.Microsoft.Blur(MakeShadow=true,pixelradius=1) Alpha(opacity=35,style=1,startX=0,finishX=200,FinishOpacity=35);
padding: 0;
position:absolute;
z-index:12000;
display:none;
top:0;
left:0;
}
.ypopcal-head{
width:150px;
background: #93b5e4;
}
.ypopcal-head td{
padding:1px;
}
.ypopcal-month{
color: white;
font: bold 7pt verdana;
text-decoration: none;
text-align:center;
}
.ypopcal-head .ypopcal-arrow{
width:16px;
text-align:center;
cursor:pointer;
-moz-user-select: none;
}
.ypopcal-head .next-month{
width:16px;
background-image: url(../images/default/grid/arrow-right-white.gif);
background-position: center;
background-repeat: no-repeat;
cursor:pointer;
}
.ypopcal-head .prev-month{
width:16px;
background-image: url(../images/default/grid/arrow-left-white.gif);
background-position: center;
background-repeat: no-repeat;
cursor:pointer;
}
.ypopcal-table {
background:white;
border-bottom: 1px solid #cccccc;
}
.ypopcal-table tr{
}
.ypopcal-table td{
box-sizing: border-box;
-moz-box-sizing: border-box;
border: 1px solid white;
text-align:right;
color:#aaaaaa;
cursor:pointer;
font:normal 8pt arial;
background:white;
padding:1px 2px;
width:12px;
height:12px;
}
.ypopcal-table td.today{
border: 1px solid darkred;
}
.ypopcal-table .ypopcal-daynames td{
text-align:center !important;
border:0;
border-bottom: 1px solid #cccccc;
font-size: 8pt;
font-weight: normal;
text-align:right;
color:black;
cursor:default;
}
.ypopcal-table td.active{
cursor:pointer;
color:black;
}
.ypopcal-table td.ypopcal-disabled{
cursor:default;
background:#eeeeee;
border: 1px solid #eeeeee;
color:#bbbbbb;
}
.ypopcal-table td.selected{
background: #ddecfe;
border: 1px solid #c3daf9;
}
.ypopcal-today{
color: black;
cursor: hand;
display: inline-block;
font: normal 8pt arial;
margin-left: 2px;
text-decoration: none;
margin-top:2px;
}
.ygrid-simple-view .ygrid-col{
height:100% !important;
position:static;
display:table-cell;
display:inline-block;
}
.ygrid-simple-view .ygrid-row{
position:static;
display: table-row;
}

View File

@ -0,0 +1,60 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz's Javascript Crypto Library.
Javascript Crypto Library provides web developers with an extensive
and efficient set of cryptographic functions. The library aims to
obtain maximum execution speed while preserving modularity and
reusability.
For further information about its features and functionalities please
refer to http://www.clipperz.com
* Javascript Crypto Library is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Javascript Crypto Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Javascript Crypto Library. If not, see
<http://www.gnu.org/licenses/>.
*/
.yinline-editor {
border: 1px solid #a3bac9;
font: normal 11px arial,helvetica,sans-serif;
left: 0;
overflow: hidden;
padding: 1px 0 0 1px;
position: absolute;
top: 0;
}
.yinline-editor-multiline {
overflow: hidden;
padding: 0;
white-space: nowrap;
}
.yinline-editor-sizer {
font: normal 11px arial,helvetica,sans-serif;
left: -1000px;
padding: 3px;
padding-right: 6px;
position: absolute;
top: -1000px;
visibility: hidden;
white-space: nowrap;
}
.yinline-editor-wrap {
color: white;
overflow: auto;
position: absolute;
top: 0;
visibility: hidden;
z-index: 15002;
}

View File

@ -0,0 +1,228 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz's Javascript Crypto Library.
Javascript Crypto Library provides web developers with an extensive
and efficient set of cryptographic functions. The library aims to
obtain maximum execution speed while preserving modularity and
reusability.
For further information about its features and functionalities please
refer to http://www.clipperz.com
* Javascript Crypto Library is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Javascript Crypto Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Javascript Crypto Library. If not, see
<http://www.gnu.org/licenses/>.
*/
.ylayout-container{
width:100%;
height:100%;
overflow:hidden;
background-color:#c3daf9;
}
.ylayout-collapsed{
position:absolute;
left:-10000px;
top:-10000px;
visibility:hidden;
background-color:#c3daf9;
width:20px;
height:20px;
overflow:hidden;
border:1px solid #98c0f4;
z-index:20;
}
.ylayout-collapsed-over{
cursor:pointer;
background-color:#d9e8fb;
}
.ylayout-collapsed-west .ylayout-tools-button{
float:right;
}
.ylayout-collapsed-east .ylayout-tools-button{
float:left;
}
.ylayout-collapsed-north, .ylayout-collapsed-south{
text-align:right;
}
.ylayout-collapsed .ylayout-tools-button{
margin:2px;
width:12px;
text-align:center;
}
.ylayout-inactive-content{
position:absolute;
left:-10000px;
top:-10000px;
visibility:hidden;
}
.ylayout-active-content{
visibility:visible;
}
.ylayout-panel{
position:absolute;border:1px solid #98c0f4;overflow:hidden;background-color:white;
}
.ylayout-panel-east, .ylayout-panel-west {
z-index:10;
}
.ylayout-panel-north, .ylayout-panel-south {
z-index:11;
}
.ylayout-collapsed-north, .ylayout-collapsed-south, .ylayout-collapsed-east, .ylayout-collapsed-west {
z-index:12;
}
.ylayout-panel-body{
overflow:hidden;
}
.ylayout-grid-wrapper{
}
.ylayout-split{
position:absolute;
height:5px;
width:5px;
line-height:1px;
font-size:1px;
z-index:3;
background-color:#c3daf9;
}
.ylayout-panel-hd{
background-image: url(../images/default/layout/panel-title-light-bg.gif);
color: black;
border-bottom:1px solid #98c0f4;
position:relative;
}
.ylayout-panel-hd-text{
font:normal 11px tahoma, verdana, helvetica;
padding: 4px;
padding-left: 4px;
display:block;
white-space:nowrap;
}
.ylayout-panel-hd-tools{
position:absolute;
right:0;
top:0;
text-align:right;
padding-top:2px;
padding-right:2px;width:40px;
}
.ylayout-tools-button{
z-index:6;
padding:2px;
cursor:pointer;
}
.ylayout-tools-button-over{
padding:1px;
border:1px solid #98c0f4;
background-color:white;
}
.ylayout-tools-button-inner{
height:12px;
width:12px;
line-height:1px;
font-size:1px;
background-repeat:no-repeat;
background-position:center;
}
.ylayout-close{
background-image:url(../images/default/layout/layout-sprite.gif);
background-repeat: no-repeat;
background-position: 50% -48px;
}
.ylayout-collapse-west,.ylayout-expand-east{
background-image:url(../images/default/layout/layout-sprite.gif);
background-repeat: no-repeat;
background-position: 50% 0;
}
.ylayout-expand-west,.ylayout-collapse-east{
background-image:url(../images/default/layout/layout-sprite.gif);
background-repeat: no-repeat;
background-position: 50% -12px;
}
.ylayout-collapse-north,.ylayout-expand-south{
background-image:url(../images/default/layout/layout-sprite.gif);
background-repeat: no-repeat;
background-position: 50% -24px;
}
.ylayout-expand-north,.ylayout-collapse-south{
background-image:url(../images/default/layout/layout-sprite.gif);
background-repeat: no-repeat;
background-position: 50% -36px;
}
.ylayout-split-h{
background-image:url(../images/default/sizer/e-handle.gif);
background-position: left;
}
.ylayout-split-v{
background-image:url(../images/default/sizer/s-handle.gif);
background-position: top;
}
.ylayout-panel .ytab-wrap{
background:url(../images/default/layout/gradient-bg.gif);
}
.ylayout-panel .yui-ext-tabbody {
background-color:white;
overflow:auto;height:100%;
}
.ylayout-component-panel, .ylayout-nested-layout {
position:relative;
padding:0;
overflow:hidden;
width:200px;
height:200px;
}
.ylayout-nested-layout .ylayout-panel {
border:0 none;
}
.ylayout-nested-layout .ylayout-panel-north {
border-bottom:1px solid #98c0f4;
}
.ylayout-nested-layout .ylayout-panel-south {
border-top:1px solid #98c0f4;
}
.ylayout-nested-layout .ylayout-panel-east {
border-left:1px solid #98c0f4;
}
.ylayout-nested-layout .ylayout-panel-west {
border-right:1px solid #98c0f4;
}
.yui-ext-repaint{
zoom:1;
background-color: transparent;
}
.ylayout-panel-dragover {
border: 2px solid #6593cf;
}
.ylayout-panel-proxy {
background-image: url(../images/default/layout/gradient-bg.gif);
background-color:#c3daf9;
border:1px dashed #6593cf;
z-index:10001;
overflow:hidden;
position:absolute;
left:0;top:0;
}
.ylayout-slider {
z-index:15;
overflow:hidden;
position:absolute;
}
.yunselectable{
-moz-user-select: none;
-khtml-user-select: none;
cursor:default;
}

View File

@ -0,0 +1,70 @@
/*
Copyright 2008-2011 Clipperz Srl
This file is part of Clipperz's Javascript Crypto Library.
Javascript Crypto Library provides web developers with an extensive
and efficient set of cryptographic functions. The library aims to
obtain maximum execution speed while preserving modularity and
reusability.
For further information about its features and functionalities please
refer to http://www.clipperz.com
* Javascript Crypto Library is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
* Javascript Crypto Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Javascript Crypto Library. If not, see
<http://www.gnu.org/licenses/>.
*/
.ytip{
position: absolute;
top: 0;
visibility: hidden;
z-index: 11000;
}
.ytip .ytip-bd{
background: #e0e8f3 url(../images/default/qtip/bg.gif) repeat-x;
border: 1px solid #a3bad9;
font: normal 11px arial,helvetica,sans-serif;
padding: 5px;
}
.ytip .ytip-close{
background-image: url(../images/default/basic-dialog/close.gif);
height: 15px;
position: absolute;
right: 3px;
top: 3px;
width: 15px;
}
.ytip .ytip-hd {
background: url(../images/default/basic-dialog/hd-sprite.gif) repeat-x 0px -82px;
background-color: navy;
color: #FFF;
display: block;
font: bold 11px tahoma, arial, verdana, helvetica;
padding: 4px;
}
.ytip .ytip-hd-left {
background: url(../images/default/basic-dialog/hd-sprite.gif) no-repeat 0px -41px;
display: block;
margin: 0px;
padding-left: 3px;
}
.ytip .ytip-hd-right {
background: url(../images/default/basic-dialog/hd-sprite.gif) no-repeat right 0px;
display: block;
padding-right: 3px;
}
y\:qtip, qtip{
display: none;
}

Some files were not shown because too many files have changed in this diff Show More