Updated data access layer
Renamed classes, methods & variables from "User" to "Player" Fixed dependencies requirements in the research lab queue Updated overview Added MVC's controller Added build files Updated directory structure Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
parent
d40313279a
commit
690a7f60f3
1435 changed files with 5772 additions and 5764 deletions
18
src/.htaccess
Normal file
18
src/.htaccess
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
SetEnv DEBUG On
|
||||
SetEnv DEPRECATION On
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
Options +FollowSymLinks
|
||||
RewriteEngine On
|
||||
|
||||
RewriteBase /
|
||||
|
||||
## workaround for HTTP authorization in CGI environment
|
||||
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
RewriteCond %{REQUEST_URI} !^/(skin|js)/
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-l
|
||||
RewriteRule .* index.php [L]
|
||||
</IfModule>
|
||||
675
src/LICENCE
Normal file
675
src/LICENCE
Normal file
|
|
@ -0,0 +1,675 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 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 General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
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 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU 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 the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
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 GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
||||
68
src/add_declare.php
Normal file
68
src/add_declare.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
require_once dirname(__FILE__) .'/application/bootstrap.php';
|
||||
|
||||
|
||||
includeLang('admin');
|
||||
|
||||
$mode = $_POST['mode'];
|
||||
|
||||
$PageTpl = gettemplate("add_declare");
|
||||
$parse = $lang;
|
||||
|
||||
if ($mode == 'addit') {
|
||||
$declarator = $user['id'];
|
||||
$declarator_name = addslashes(htmlspecialchars($user['username']));
|
||||
$decl1 = addslashes(htmlspecialchars($_POST['dec1']));
|
||||
$decl2 = addslashes(htmlspecialchars($_POST['dec2']));
|
||||
$decl3 = addslashes(htmlspecialchars($_POST['dec3']));
|
||||
$reason1 = addslashes(htmlspecialchars($_POST['reason']));
|
||||
|
||||
$QryDeclare = "INSERT INTO {{table}} SET ";
|
||||
$QryDeclare .= "`declarator` = '". $declarator ."', ";
|
||||
$QryDeclare .= "`declarator_name` = '". $declarator_name ."', "; $QryDeclare .= "`declared_1` = '". $decl1 ."', ";
|
||||
$QryDeclare .= "`declared_2` = '". $decl2 ."', ";
|
||||
$QryDeclare .= "`declared_3` = '". $decl3 ."', ";
|
||||
$QryDeclare .= "`reason` = '". $reason1 ."' ";
|
||||
|
||||
doquery( $QryDeclare, "declared");
|
||||
doquery("UPDATE {{table}} SET multi_validated ='1' WHERE username='{$user['username']}'","users");
|
||||
|
||||
AdminMessage ( "Merci, votre demande a ete prise en compte. Les autres joueurs que vous avez implique doivent egalement et imperativement suivre cette procedure aussi.", "Ajout" );
|
||||
}
|
||||
$Page = parsetemplate($PageTpl, $parse);
|
||||
|
||||
display ($Page, "Declaration d\'IP partagee", false, '', true);
|
||||
|
||||
|
||||
?>
|
||||
79
src/admin/ElementQueueFixer.php
Normal file
79
src/admin/ElementQueueFixer.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
includeLang('admin');
|
||||
|
||||
$QrySelectPlanet = "SELECT `id`, `id_owner`, `b_hangar`, `b_hangar_id` ";
|
||||
$QrySelectPlanet .= "FROM {{table}} ";
|
||||
$QrySelectPlanet .= "WHERE ";
|
||||
$QrySelectPlanet .= "`b_hangar_id` != '0';";
|
||||
$AffectedPlanets = doquery ($QrySelectPlanet, 'planets');
|
||||
$DeletedQueues = 0;
|
||||
while ( $ActualPlanet = mysql_fetch_assoc($AffectedPlanets) ) {
|
||||
$HangarQueue = explode (";", $ActualPlanet['b_hangar_id']);
|
||||
$bDelQueue = false;
|
||||
if (count($HangarQueue)) {
|
||||
for ( $Queue = 0; $Queue < count($HangarQueue); $Queue++) {
|
||||
$InQueue = explode (",", $HangarQueue[$Queue]);
|
||||
if ($InQueue[1] > MAX_FLEET_OR_DEFS_PER_ROW) {
|
||||
$bDelQueue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($bDelQueue) {
|
||||
$QryUpdatePlanet = "UPDATE {{table}} ";
|
||||
$QryUpdatePlanet .= "SET ";
|
||||
$QryUpdatePlanet .= "`b_hangar` = '0', ";
|
||||
$QryUpdatePlanet .= "`b_hangar_id` = '0' ";
|
||||
$QryUpdatePlanet .= "WHERE ";
|
||||
$QryUpdatePlanet .= "`id` = '".$ActualPlanet['id']."';";
|
||||
doquery ($QryUpdatePlanet, 'planets');
|
||||
$DeletedQueues += 1;
|
||||
}
|
||||
}
|
||||
if ($DeletedQueues > 0) {
|
||||
$QuitMessage = $lang['adm_cleaned']." ". $DeletedQueues;
|
||||
} else {
|
||||
$QuitMessage = $lang['adm_done'];
|
||||
}
|
||||
|
||||
AdminMessage ($QuitMessage, $lang['adm_cleaner_title']);
|
||||
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
59
src/admin/QueryExecute.php
Normal file
59
src/admin/QueryExecute.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN))) {
|
||||
includeLang('admin/Queries');
|
||||
|
||||
$parse = $lang;
|
||||
|
||||
if ($_POST['really_do_it'] == 'on') {
|
||||
|
||||
mysql_query ($_POST['qry_sql']);
|
||||
AdminMessage ($lang['qry_succesful'], 'Succes', '?');
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
|
||||
$PageTpl = gettemplate("admin/exec_query");
|
||||
$Page = parsetemplate( $PageTpl, $parse);
|
||||
|
||||
display( $Page, $lang['qry_title'], false, '', true );
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
50
src/admin/ShowFlyingFleets.php
Normal file
50
src/admin/ShowFlyingFleets.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
include(ROOT_PATH . 'includes/functions/BuildFlyingFleetTable.'.PHPEXT);
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
includeLang('admin/fleets');
|
||||
$PageTPL = gettemplate('admin/fleet_body');
|
||||
|
||||
$parse = $lang;
|
||||
$parse['flt_table'] = BuildFlyingFleetTable ();
|
||||
|
||||
$page = parsetemplate( $PageTPL, $parse );
|
||||
display ( $page, $lang['flt_title'], false, '', true);
|
||||
|
||||
} else {
|
||||
AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
138
src/admin/XNovaResetUnivers.php
Normal file
138
src/admin/XNovaResetUnivers.php
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
includeLang('admin');
|
||||
|
||||
function WootookResetUnivers ( $CurrentUser ) {
|
||||
global $lang;
|
||||
|
||||
if (in_array($CurrentUser['authlevel'], array(LEVEL_ADMIN))) {
|
||||
|
||||
// Copier la table users et planets vers des tables de replis !
|
||||
doquery( "RENAME TABLE {{table}} TO {{table}}_s", 'planets');
|
||||
doquery( "RENAME TABLE {{table}} TO {{table}}_s", 'users');
|
||||
doquery( "RENAME TABLE {{table}} TO {{table}}_s", 'galaxy');
|
||||
doquery( "RENAME TABLE {{table}} TO {{table}}_s", 'banned');
|
||||
|
||||
// Recreer la structure des tables renommées
|
||||
doquery( "CREATE TABLE IF NOT EXISTS {{table}} ( LIKE {{table}}_s );", 'planets');
|
||||
doquery( "CREATE TABLE IF NOT EXISTS {{table}} ( LIKE {{table}}_s );", 'users');
|
||||
doquery( "CREATE TABLE IF NOT EXISTS {{table}} ( LIKE {{table}}_s );", 'galaxy');
|
||||
doquery( "CREATE TABLE IF NOT EXISTS {{table}} ( LIKE {{table}}_s );", 'banned');
|
||||
|
||||
// Vider toutes les tables !
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'aks');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'alliance');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'annonce');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'banned');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'buddy');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'chat');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'galaxy');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'errors');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'fleets');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'iraks');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'lunas');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'messages');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'notes');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'rw');
|
||||
doquery( "TRUNCATE TABLE {{table}}", 'statpoints');
|
||||
|
||||
$AllUsers = doquery ("SELECT `username`,`password`,`email`, `email_2`,`authlevel`,`galaxy`,`system`,`planet`, `sex`, `dpath`, `onlinetime`, `register_time`, `id_planet` FROM {{table}} WHERE 1;", 'users_s');
|
||||
$LimitTime = time() - (15 * (24 * (60 * 60)));
|
||||
$TransUser = 0;
|
||||
while ( $TheUser = mysql_fetch_assoc($AllUsers) ) {
|
||||
if ( $TheUser['onlinetime'] > $LimitTime ) {
|
||||
$UserPlanet = doquery ("SELECT `name` FROM {{table}} WHERE `id` = '". $TheUser['id_planet']."';", 'planets_s', true);
|
||||
if ($UserPlanet['name'] != "") {
|
||||
// Creation de l'utilisateur
|
||||
$QryInsertUser = "INSERT INTO {{table}} SET ";
|
||||
$QryInsertUser .= "`username` = '". $TheUser['username'] ."', ";
|
||||
$QryInsertUser .= "`email` = '". $TheUser['email'] ."', ";
|
||||
$QryInsertUser .= "`email_2` = '". $TheUser['email_2'] ."', ";
|
||||
$QryInsertUser .= "`sex` = '". $TheUser['sex'] ."', ";
|
||||
$QryInsertUser .= "`id_planet` = '0', ";
|
||||
$QryInsertUser .= "`authlevel` = '". $TheUser['authlevel'] ."', ";
|
||||
$QryInsertUser .= "`dpath` = '". $TheUser['dpath'] ."', ";
|
||||
$QryInsertUser .= "`galaxy` = '". $TheUser['galaxy'] ."', ";
|
||||
$QryInsertUser .= "`system` = '". $TheUser['system'] ."', ";
|
||||
$QryInsertUser .= "`planet` = '". $TheUser['planet'] ."', ";
|
||||
$QryInsertUser .= "`register_time` = '". $TheUser['register_time'] ."', ";
|
||||
$QryInsertUser .= "`password` = '". $TheUser['password'] ."';";
|
||||
doquery( $QryInsertUser, 'users');
|
||||
|
||||
// On cherche le numero d'enregistrement de l'utilisateur fraichement cr<63><72>
|
||||
$NewUser = doquery("SELECT `id` FROM {{table}} WHERE `username` = '". $TheUser['username'] ."' LIMIT 1;", 'users', true);
|
||||
|
||||
CreateOnePlanetRecord ($TheUser['galaxy'], $TheUser['system'], $TheUser['planet'], $NewUser['id'], $UserPlanet['name'], true);
|
||||
// Recherche de la reference de la nouvelle planete (qui est unique normalement !
|
||||
$PlanetID = doquery("SELECT `id` FROM {{table}} WHERE `id_owner` = '". $NewUser['id'] ."' LIMIT 1;", 'planets', true);
|
||||
|
||||
// Mise a jour de l'enregistrement utilisateur avec les infos de sa planete mere
|
||||
$QryUpdateUser = "UPDATE {{table}} SET ";
|
||||
$QryUpdateUser .= "`id_planet` = '". $PlanetID['id'] ."', ";
|
||||
$QryUpdateUser .= "`current_planet` = '". $PlanetID['id'] ."' ";
|
||||
$QryUpdateUser .= "WHERE ";
|
||||
$QryUpdateUser .= "`id` = '". $NewUser['id'] ."';";
|
||||
doquery( $QryUpdateUser, 'users');
|
||||
$TransUser++;
|
||||
}
|
||||
}
|
||||
} // while
|
||||
// Mise a jour du nombre de joueurs inscripts
|
||||
doquery("UPDATE {{table}} SET `config_value` = '". $TransUser ."' WHERE `config_name` = 'users_amount' LIMIT 1;", 'config');
|
||||
|
||||
// Menage on vire les tables transitoires
|
||||
doquery("DROP TABLE {{table}}", 'planets_s');
|
||||
doquery("DROP TABLE {{table}}", 'users_s');
|
||||
|
||||
AdminMessage ( $TransUser . $lang['adm_rz_done'], $lang['adm_rz_ttle'] );
|
||||
} else {
|
||||
AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
return $Page;
|
||||
}
|
||||
|
||||
$mode = $_POST['mode'];
|
||||
$PageTpl = gettemplate("admin/reset_body");
|
||||
$parse = $lang;
|
||||
|
||||
if ($mode == 'reset') {
|
||||
WootookResetUnivers ( $user );
|
||||
} else {
|
||||
$Page = parsetemplate($PageTpl, $parse);
|
||||
display ($Page, $lang['Reset'], false, '', true);
|
||||
}
|
||||
|
||||
?>
|
||||
67
src/admin/activeplanet.php
Normal file
67
src/admin/activeplanet.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
|
||||
|
||||
if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
includeLang('admin');
|
||||
|
||||
$parse = $lang;
|
||||
$parse['dpath'] = $dpath;
|
||||
$parse['mf'] = $mf;
|
||||
|
||||
$PageTPL = gettemplate('admin/activeplanet_body');
|
||||
$AllActivPlanet = doquery("SELECT * FROM {{table}} WHERE `last_update` >= '". (time()-15 * 60) ."' ORDER BY `id` ASC", 'planets');
|
||||
$Count = 0;
|
||||
|
||||
while ($ActivPlanet = $AllActivPlanet->fetch(PDO::FETCH_BOTH)) {
|
||||
$parse['online_list'] .= "<tr>";
|
||||
$parse['online_list'] .= "<td class=b><center><b>". $ActivPlanet['name'] ."</b></center></td>";
|
||||
$parse['online_list'] .= "<td class=b><center><b>[". $ActivPlanet['galaxy'] .":". $ActivPlanet['system'] .":". $ActivPlanet['planet'] ."]</b></center></td>";
|
||||
$parse['online_list'] .= "<td class=m><center><b>". pretty_number($ActivPlanet['points'] / 1000) ."</b></center></td>";
|
||||
$parse['online_list'] .= "<td class=b><center><b>". pretty_time(time() - $ActivPlanet['last_update']) . "</b></center></td>";
|
||||
$parse['online_list'] .= "</tr>";
|
||||
$Count++;
|
||||
}
|
||||
$parse['online_list'] .= "<tr>";
|
||||
$parse['online_list'] .= "<th class=\"b\" colspan=\"4\">". $lang['adm_pl_they'] ." ". $Count ." ". $lang['adm_pl_apla'] ."</th>";
|
||||
$parse['online_list'] .= "</tr>";
|
||||
|
||||
$page = parsetemplate( $PageTPL , $parse );
|
||||
display( $page, $lang['adm_pl_title'], false, '', true );
|
||||
103
src/admin/add_fleet.php
Normal file
103
src/admin/add_fleet.php
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
|
||||
|
||||
if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
includeLang('admin/add_fleet');
|
||||
$mode = $_GET['mode'];
|
||||
|
||||
if($mode != 'add') {
|
||||
$parse['ID'] = $lang['Id'];
|
||||
$parse['Cle'] = $lang['cle'];
|
||||
$parse['Clourd'] = $lang['clourd'];
|
||||
$parse['Pt'] = $lang['pt'];
|
||||
$parse['Gt'] = $lang['gt'];
|
||||
$parse['Cruise'] = $lang['cruise'];
|
||||
$parse['Vb'] = $lang['vb'];
|
||||
$parse['Colo'] = $lang['colo'];
|
||||
$parse['Rc'] = $lang['rc'];
|
||||
$parse['Spy'] = $lang['spy'];
|
||||
$parse['Bomb'] = $lang['bomb'];
|
||||
$parse['Solar'] = $lang['solar'];
|
||||
$parse['Des'] = $lang['des'];
|
||||
$parse['Rip'] = $lang['rip'];
|
||||
$parse['Traq'] = $lang['traq'];
|
||||
|
||||
} else if($mode == 'add') {
|
||||
$id = $_POST['id'];
|
||||
$cle = $_POST['cle'];
|
||||
$clourd = $_POST['clourd'];
|
||||
$pt = $_POST['pt'];
|
||||
$gt = $_POST['gt'];
|
||||
$cruise = $_POST['cruise'];
|
||||
$vb = $_POST['vb'];
|
||||
$colo = $_POST['colo'];
|
||||
$rc = $_POST['rc'];
|
||||
$spy = $_POST['spy'];
|
||||
$bomb = $_POST['bomb'];
|
||||
$solar = $_POST['solar'];
|
||||
$des = $_POST['des'];
|
||||
$rip = $_POST['rip'];
|
||||
$traq = $_POST['traq'];
|
||||
|
||||
$SqlAdd = "UPDATE {{table}} SET";
|
||||
$SqlAdd .= "`light_hunter` = '".$cle."+light_hunter', ";
|
||||
$SqlAdd .= "`heavy_hunter` = '".$clourd."+heavy_hunter', ";
|
||||
$SqlAdd .= "`small_ship_cargo` = '".$pt."+small_ship_cargo', ";
|
||||
$SqlAdd .= "`big_ship_cargo` = '".$gt."+big_ship_cargo', ";
|
||||
$SqlAdd .= "`crusher` = '".$cruise."+crusher', ";
|
||||
$SqlAdd .= "`battle_ship` = '".$vb."+battle_ship', ";
|
||||
$SqlAdd .= "`colonizer` = '".$colo."+colonizer', ";
|
||||
$SqlAdd .= "`recycler` = '".$rc."+recycler', ";
|
||||
$SqlAdd .= "`spy_sonde`= '".$spy."+spy_sonde', ";
|
||||
$SqlAdd .= "`bomber_ship` = '".$bomb."+bomber_ship', ";
|
||||
$SqlAdd .= "`solar_satelit` = '".$solar."+solar_satelit', ";
|
||||
$SqlAdd .= "`destructor` = '".$des."+destructor', ";
|
||||
$SqlAdd .= "`dearth_star` = '".$rip."+dearth_star', ";
|
||||
$SqlAdd .= "`battleship` = '".$traq."+battleship', ";
|
||||
$SqlAdd .= " WHERE `id` = '".$id."' LIMIT 1";
|
||||
doquery($SqlAdd, "planets");
|
||||
message('Ajout OK');
|
||||
}
|
||||
|
||||
$page = parsetemplate(gettemplate('admin/add_fleet'), $parse);
|
||||
display( $page);
|
||||
|
||||
68
src/admin/add_money.php
Normal file
68
src/admin/add_money.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
|
||||
|
||||
if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
includeLang('admin');
|
||||
|
||||
$mode = $_POST['mode'];
|
||||
|
||||
$PageTpl = gettemplate("admin/add_money");
|
||||
$parse = $lang;
|
||||
|
||||
if ($mode == 'addit') {
|
||||
$id = $_POST['id'];
|
||||
$metal = $_POST['metal'];
|
||||
$cristal = $_POST['cristal'];
|
||||
$deut = $_POST['deut'];
|
||||
|
||||
$QryUpdatePlanet = "UPDATE {{table}} SET ";
|
||||
$QryUpdatePlanet .= "`metal` = `metal` + '". $metal ."', ";
|
||||
$QryUpdatePlanet .= "`crystal` = `crystal` + '". $cristal ."', ";
|
||||
$QryUpdatePlanet .= "`deuterium` = `deuterium` + '". $deut ."' ";
|
||||
$QryUpdatePlanet .= "WHERE ";
|
||||
$QryUpdatePlanet .= "`id` = '". $id ."' ";
|
||||
doquery( $QryUpdatePlanet, "planets");
|
||||
|
||||
AdminMessage ( $lang['adm_am_done'], $lang['adm_am_ttle'] );
|
||||
}
|
||||
$Page = parsetemplate($PageTpl, $parse);
|
||||
|
||||
display ($Page, $lang['adm_am_ttle'], false, '', true);
|
||||
69
src/admin/add_moon.php
Normal file
69
src/admin/add_moon.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
includeLang('admin/addmoon');
|
||||
|
||||
$mode = $_POST['mode'];
|
||||
|
||||
$PageTpl = gettemplate("admin/add_moon");
|
||||
$parse = $lang;
|
||||
|
||||
if ($mode == 'addit') {
|
||||
$PlanetID = $_POST['user'];
|
||||
$MoonName = $_POST['name'];
|
||||
|
||||
$QrySelectPlanet = "SELECT * FROM {{table}} ";
|
||||
$QrySelectPlanet .= "WHERE ";
|
||||
$QrySelectPlanet .= "`id` = '". $PlanetID ."';";
|
||||
$PlanetSelected = doquery ( $QrySelectPlanet, 'planets', true);
|
||||
|
||||
$Galaxy = $PlanetSelected['galaxy'];
|
||||
$System = $PlanetSelected['system'];
|
||||
$Planet = $PlanetSelected['planet'];
|
||||
$Owner = $PlanetSelected['id_owner'];
|
||||
$MoonID = time();
|
||||
|
||||
CreateOneMoonRecord ( $Galaxy, $System, $Planet, $Owner, $MoonID, $MoonName, 20 );
|
||||
|
||||
AdminMessage ( $lang['addm_done'], $lang['addm_title'] );
|
||||
}
|
||||
$Page = parsetemplate($PageTpl, $parse);
|
||||
|
||||
display ($Page, $lang['addm_title'], false, '', true);
|
||||
} else {
|
||||
AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
?>
|
||||
47
src/admin/autounban.php
Normal file
47
src/admin/autounban.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN))) {
|
||||
doquery("UPDATE {{table}} SET `banaday` =` banaday` - '1' WHERE `banaday` != '0';",'users');
|
||||
doquery("UPDATE {{table}} SET `bana` = '0' WHERE `banaday` < '1';",'users');
|
||||
|
||||
$response = Wootook::getResponse()
|
||||
->setRedirect(Wootook::getStaticUrl('admin/overview.php'))
|
||||
->sendHeaders();
|
||||
exit(0);
|
||||
} else {
|
||||
message ( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
89
src/admin/banned.php
Normal file
89
src/admin/banned.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
includeLang('admin');
|
||||
|
||||
$mode = $_POST['mode'];
|
||||
|
||||
$PageTpl = gettemplate("admin/banned");
|
||||
|
||||
$parse = $lang;
|
||||
if ($mode == 'banit') {
|
||||
$name = $_POST['name'];
|
||||
$reas = $_POST['why'];
|
||||
$days = $_POST['days'];
|
||||
$hour = $_POST['hour'];
|
||||
$mins = $_POST['mins'];
|
||||
$secs = $_POST['secs'];
|
||||
|
||||
$admin = $user['username'];
|
||||
$mail = $user['email'];
|
||||
|
||||
$Now = time();
|
||||
$BanTime = $days * 86400;
|
||||
$BanTime += $hour * 3600;
|
||||
$BanTime += $mins * 60;
|
||||
$BanTime += $secs;
|
||||
$BannedUntil = $Now + $BanTime;
|
||||
|
||||
$QryInsertBan = "INSERT INTO {{table}} SET ";
|
||||
$QryInsertBan .= "`who` = \"". $name ."\", ";
|
||||
$QryInsertBan .= "`theme` = '". $reas ."', ";
|
||||
$QryInsertBan .= "`who2` = '". $name ."', ";
|
||||
$QryInsertBan .= "`time` = '". $Now ."', ";
|
||||
$QryInsertBan .= "`longer` = '". $BannedUntil ."', ";
|
||||
$QryInsertBan .= "`author` = '". $admin ."', ";
|
||||
$QryInsertBan .= "`email` = '". $mail ."';";
|
||||
doquery( $QryInsertBan, 'banned');
|
||||
|
||||
$QryUpdateUser = "UPDATE {{table}} SET ";
|
||||
$QryUpdateUser .= "`bana` = '1', ";
|
||||
$QryUpdateUser .= "`banaday` = '". $BannedUntil ."' ";
|
||||
$QryUpdateUser .= "WHERE ";
|
||||
$QryUpdateUser .= "`username` = \"". $name ."\";";
|
||||
doquery( $QryUpdateUser, 'users');
|
||||
|
||||
$DoneMessage = $lang['adm_bn_thpl'] ." ". $name ." ". $lang['adm_bn_isbn'];
|
||||
AdminMessage ($DoneMessage, $lang['adm_bn_ttle']);
|
||||
}
|
||||
|
||||
$Page = parsetemplate($PageTpl, $parse);
|
||||
display( $Page, $lang['adm_bn_ttle'], false, '', true);
|
||||
} else {
|
||||
AdminMessage ($lang['sys_noalloaw'], $lang['sys_noaccess']);
|
||||
}
|
||||
|
||||
?>
|
||||
56
src/admin/changelog.php
Normal file
56
src/admin/changelog.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
includeLang('changelog');
|
||||
$template = gettemplate('changelog_table');
|
||||
|
||||
$parse = $lang;
|
||||
|
||||
foreach($lang['changelog'] as $a => $b)
|
||||
{
|
||||
|
||||
$parse['version_number'] = $a;
|
||||
$parse['description'] = nl2br($b);
|
||||
|
||||
$body .= parsetemplate($template, $parse);
|
||||
|
||||
}
|
||||
|
||||
$parse['body'] = $body;
|
||||
|
||||
$page .= parsetemplate(gettemplate('changelog_body'), $parse);
|
||||
|
||||
display( $page, "Changelog", false, '', true);
|
||||
|
||||
?>
|
||||
66
src/admin/chat.php
Normal file
66
src/admin/chat.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
includeLang('admin');
|
||||
$parse = $lang;
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN))) {
|
||||
|
||||
// Système de suppression
|
||||
extract($_GET);
|
||||
if (isset($delete)) {
|
||||
doquery("DELETE FROM {{table}} WHERE `messageid`=$delete", 'chat');
|
||||
} elseif ($deleteall == 'yes') {
|
||||
doquery("DELETE FROM {{table}}", 'chat');
|
||||
}
|
||||
|
||||
// Affichage des messages
|
||||
$query = doquery("SELECT * FROM {{table}} ORDER BY messageid DESC LIMIT 25", 'chat');
|
||||
$i = 0;
|
||||
while ($e = $query->fetch(PDO::FETCH_BOTH)) {
|
||||
$i++;
|
||||
$parse['msg_list'] .= stripslashes("<tr><th class=b>" . date('h:i:s', $e['timestamp']) . "</th>".
|
||||
"<th class=b>". $e['user'] . "</th>".
|
||||
"<td class=b>" . nl2br($e['message']) . "</td>".
|
||||
"<th class=b><a href=?delete=".$e['messageid']."><img src=\"../images/r1.png\" border=\"0\"></a></th></tr>");
|
||||
}
|
||||
$parse['msg_list'] .= "<tr><th class=b colspan=4>{$i} ".$lang['adm_ch_nbs']."</th></tr>";
|
||||
|
||||
display(parsetemplate(gettemplate('admin/chat_body'), $parse), "Chat", false, '', true);
|
||||
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
73
src/admin/credit.php
Normal file
73
src/admin/credit.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
includeLang('credit');
|
||||
$parse = $lang;
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN))) {
|
||||
if ($_POST['opt_save'] == "1") {
|
||||
// Extended copyright is activated?
|
||||
if (isset($_POST['ExtCopyFrame']) && $_POST['ExtCopyFrame'] == 'on') {
|
||||
$gameConfig['ExtCopyFrame'] = "1";
|
||||
$gameConfig['ExtCopyOwner'] = $_POST['ExtCopyOwner'];
|
||||
$gameConfig['ExtCopyFunct'] = $_POST['ExtCopyFunct'];
|
||||
} else {
|
||||
$gameConfig['ExtCopyFrame'] = "0";
|
||||
$gameConfig['ExtCopyOwner'] = "";
|
||||
$gameConfig['ExtCopyFunct'] = "";
|
||||
}
|
||||
|
||||
// Update values
|
||||
doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['ExtCopyFrame'] ."' WHERE `config_name` = 'ExtCopyFrame';", 'config');
|
||||
doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['ExtCopyOwner'] ."' WHERE `config_name` = 'ExtCopyOwner';", 'config');
|
||||
doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['ExtCopyFunct'] ."' WHERE `config_name` = 'ExtCopyFunct';", 'config');
|
||||
|
||||
AdminMessage ($lang['cred_done'], $lang['cred_ext']);
|
||||
|
||||
} else {
|
||||
//View values
|
||||
$parse['ExtCopyFrame'] = ($gameConfig['ExtCopyFrame'] == 1) ? " checked = 'checked' ":"";
|
||||
$parse['ExtCopyOwnerVal'] = $gameConfig['ExtCopyOwner'];
|
||||
$parse['ExtCopyFunctVal'] = $gameConfig['ExtCopyFunct'];
|
||||
|
||||
$BodyTPL = gettemplate('admin/credit_body');
|
||||
$page = parsetemplate($BodyTPL, $parse);
|
||||
display($page, $lang['cred_credit'], false);
|
||||
}
|
||||
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
83
src/admin/declare_list.php
Normal file
83
src/admin/declare_list.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
includeLang('admin');
|
||||
if ($_GET['cmd'] == 'dele') {
|
||||
DeleteSelectedUser ( $_GET['user'] );
|
||||
}
|
||||
if ($_GET['cmd'] == 'sort') {
|
||||
$TypeSort = $_GET['type'];
|
||||
} else {
|
||||
$TypeSort = "id";
|
||||
}
|
||||
|
||||
$PageTPL = gettemplate('admin/declarelist_body');
|
||||
$RowsTPL = gettemplate('admin/declarelist_rows');
|
||||
|
||||
$query = doquery("SELECT * FROM {{table}} ORDER BY `declarator` DESC", 'declared');
|
||||
|
||||
$parse = $lang;
|
||||
$parse['adm_ul_table'] = "";
|
||||
$i = 0;
|
||||
$Color = "lime";
|
||||
while ($u = $query->fetch(PDO::FETCH_ASSOC) ) {
|
||||
if ($PrevIP != "") {
|
||||
if ($PrevIP == $u['declarator']) {
|
||||
$Color = "red";
|
||||
} else {
|
||||
$Color = "lime";
|
||||
}
|
||||
}
|
||||
$Bloc['adm_ul_data_id'] = stripslashes($u['declarator_name']);
|
||||
$Bloc['adm_ul_data_name'] = stripslashes($u['declarator']);
|
||||
$Bloc['adm_ul_data_mail'] = stripslashes($u['declared_1']);
|
||||
$Bloc['adm_ul_data_adip'] = stripslashes($u['declared_2']);
|
||||
$Bloc['adm_ul_data_detai'] = stripslashes($u['declared_3']);
|
||||
$Bloc['adm_ul_data_regd'] = stripslashes($u['reason']);
|
||||
|
||||
|
||||
$parse['adm_ul_table'] .= parsetemplate( $RowsTPL, $Bloc );
|
||||
$i++;
|
||||
}
|
||||
$parse['adm_ul_count'] = $i;
|
||||
|
||||
$page = parsetemplate( $PageTPL, $parse );
|
||||
display( $page, "Liste des joueurs ayant declare une IP collective", false, '', true);
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
50
src/admin/deletuser.php
Normal file
50
src/admin/deletuser.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($CurrentUser['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
$PageTpl = gettemplate( "admin/deletuser" );
|
||||
|
||||
if ( $mode != "delet" ) {
|
||||
$parse['adm_bt_delet'] = $lang['adm_bt_delet'];
|
||||
}
|
||||
|
||||
$Page = parsetemplate( $PageTpl, $parse );
|
||||
display ( $Page, $lang['adminpanel'], false, '', true );
|
||||
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
70
src/admin/errors.php
Normal file
70
src/admin/errors.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
includeLang('admin');
|
||||
$parse = $lang;
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN))) {
|
||||
|
||||
// Supprimer les erreurs
|
||||
extract($_GET);
|
||||
if (isset($delete)) {
|
||||
doquery("DELETE FROM {{table}} WHERE `error_id`=$delete", 'errors');
|
||||
} elseif ($deleteall == 'yes') {
|
||||
doquery("TRUNCATE TABLE {{table}}", 'errors');
|
||||
}
|
||||
|
||||
// Afficher les erreurs
|
||||
$query = doquery("SELECT * FROM {{table}}", 'errors');
|
||||
$i = 0;
|
||||
while ($u = $query->fetch(PDO::FETCH_BOTH)) {
|
||||
$i++;
|
||||
$parse['errors_list'] .= "
|
||||
<tr><td width=\"25\" class=n>". $u['error_id'] ."</td>
|
||||
<td width=\"170\" class=n>". $u['error_type'] ."</td>
|
||||
<td width=\"230\" class=n>". date('d/m/Y h:i:s', $u['error_time']) ."</td>
|
||||
<td width=\"95\" class=n><a href=\"?delete=". $u['error_id'] ."\"><img src=\"../images/r1.png\"></a></td></tr>
|
||||
<tr><td colspan=\"4\" class=b>". nl2br($u['error_text'])."</td></tr>";
|
||||
}
|
||||
$parse['errors_list'] .= "<tr>
|
||||
<th class=b colspan=5>". $i ." ". $lang['adm_er_nbs'] ."</th>
|
||||
</tr>";
|
||||
|
||||
display(parsetemplate(gettemplate('admin/errors_body'), $parse), "Bledy", false, '', true);
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
50
src/admin/leftmenu.php
Normal file
50
src/admin/leftmenu.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
includeLang('leftmenu');
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
$parse = $lang;
|
||||
$parse['mf'] = "Hauptframe";
|
||||
$parse['dpath'] = $dpath;
|
||||
$parse['WootookRelease'] = VERSION;
|
||||
$parse['servername'] = 'Wootook';
|
||||
$Page = parsetemplate(gettemplate('admin/left_menu'), $parse);
|
||||
display($Page, "", false, '', true);
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
60
src/admin/md5changepass.php
Normal file
60
src/admin/md5changepass.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
includeLang('admin/changepass');
|
||||
|
||||
$parse = $lang;
|
||||
|
||||
if ($_POST['md5q'] != "") {
|
||||
|
||||
doquery ("UPDATE {{table}} SET `password` = '" . md5 ($_POST['md5q']) . "' WHERE `username` = '".$_POST['user']."';", 'users');
|
||||
//$QueryUpdatePass = "UPDATE {{table}} SET ";
|
||||
//$QueryUpdatePass .= "`password` = '" . md5 ($_POST['md5q']) . "', ";
|
||||
//$QueryUpdatePass = "WHERE ";
|
||||
//$QueryUpdatePass .= "`username`=" . $_POST['user'] . "";
|
||||
// doquery($QueryUpdatePass, 'users');
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$PageTpl = gettemplate("admin/changepass");
|
||||
$Page = parsetemplate( $PageTpl, $parse);
|
||||
|
||||
display( $Page, $lang['md5_title'], false, '', true );
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
57
src/admin/md5enc.php
Normal file
57
src/admin/md5enc.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
includeLang('admin/md5enc');
|
||||
|
||||
$parse = $lang;
|
||||
|
||||
if ($_POST['md5q'] != "") {
|
||||
$parse['md5_md5'] = $_POST['md5q'];
|
||||
$parse['md5_enc'] = md5 ($_POST['md5q']);
|
||||
} else {
|
||||
$parse['md5_md5'] = "";
|
||||
$parse['md5_enc'] = md5 ("");
|
||||
}
|
||||
|
||||
$PageTpl = gettemplate("admin/md5enc");
|
||||
$Page = parsetemplate( $PageTpl, $parse);
|
||||
|
||||
display( $Page, $lang['md5_title'], false, '', true );
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
148
src/admin/messagelist.php
Normal file
148
src/admin/messagelist.php
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
includeLang('admin/messagelist');
|
||||
|
||||
$BodyTpl = gettemplate('admin/messagelist_body');
|
||||
$RowsTpl = gettemplate('admin/messagelist_table_rows');
|
||||
|
||||
$Prev = ( !empty($_POST['prev']) ) ? true : false;
|
||||
$Next = ( !empty($_POST['next']) ) ? true : false;
|
||||
$DelSel = ( !empty($_POST['delsel']) ) ? true : false;
|
||||
$DelDat = ( !empty($_POST['deldat']) ) ? true : false;
|
||||
$CurrPage = ( !empty($_POST['curr']) ) ? $_POST['curr'] : 1;
|
||||
$Selected = ( !empty($_POST['sele']) ) ? $_POST['sele'] : 0;
|
||||
$SelType = $_POST['type'];
|
||||
$SelPage = $_POST['page'];
|
||||
|
||||
$ViewPage = 1;
|
||||
if ( $Selected != $SelType ) {
|
||||
$Selected = $SelType;
|
||||
$ViewPage = 1;
|
||||
} elseif ( $CurrPage != $SelPage ) {
|
||||
$ViewPage = ( !empty($SelPage) ) ? $SelPage : 1;
|
||||
}
|
||||
|
||||
if ($Prev == true) {
|
||||
$CurrPage -= 1;
|
||||
if ($CurrPage >= 1) {
|
||||
$ViewPage = $CurrPage;
|
||||
} else {
|
||||
$ViewPage = 1;
|
||||
}
|
||||
} elseif ($Next == true) {
|
||||
$Mess = doquery("SELECT COUNT(*) AS `max` FROM {{table}} WHERE `message_type` = '". $Selected ."';", 'messages', true);
|
||||
$MaxPage = ceil ( ($Mess['max'] / 25) );
|
||||
$CurrPage += 1;
|
||||
if ($CurrPage <= $MaxPage) {
|
||||
$ViewPage = $CurrPage;
|
||||
} else {
|
||||
$ViewPage = $MaxPage;
|
||||
}
|
||||
} elseif ($DelSel == true) {
|
||||
foreach($_POST['sele'] as $MessId => $Value) {
|
||||
if ($Value = "on") {
|
||||
doquery ( "DELETE FROM {{table}} WHERE `message_id` = '". $MessId ."';", 'messages');
|
||||
}
|
||||
}
|
||||
} elseif ($DelDat == true) {
|
||||
$SelDay = $_POST['selday'];
|
||||
$SelMonth = $_POST['selmonth'];
|
||||
$SelYear = $_POST['selyear'];
|
||||
$LimitDate = mktime (0,0,0, $SelMonth, $SelDay, $SelYear );
|
||||
if ($LimitDate != false) {
|
||||
doquery ( "DELETE FROM {{table}} WHERE `message_time` <= '". $LimitDate ."';", 'messages');
|
||||
doquery ( "DELETE FROM {{table}} WHERE `time` <= '". $LimitDate ."';", 'rw');
|
||||
}
|
||||
}
|
||||
|
||||
$Mess = doquery("SELECT COUNT(*) AS `max` FROM {{table}} WHERE `message_type` = '". $Selected ."';", 'messages', true);
|
||||
$MaxPage = ceil ( ($Mess['max'] / 25) );
|
||||
|
||||
$parse = $lang;
|
||||
$parse['mlst_data_page'] = $ViewPage;
|
||||
$parse['mlst_data_pagemax'] = $MaxPage;
|
||||
$parse['mlst_data_sele'] = $Selected;
|
||||
|
||||
$parse['mlst_data_types'] = "<option value=\"0\"". (($Selected == "0") ? " SELECTED" : "") .">". $lang['mlst_mess_typ__0'] ."</option>";
|
||||
$parse['mlst_data_types'] .= "<option value=\"1\"". (($Selected == "1") ? " SELECTED" : "") .">". $lang['mlst_mess_typ__1'] ."</option>";
|
||||
$parse['mlst_data_types'] .= "<option value=\"2\"". (($Selected == "2") ? " SELECTED" : "") .">". $lang['mlst_mess_typ__2'] ."</option>";
|
||||
$parse['mlst_data_types'] .= "<option value=\"3\"". (($Selected == "3") ? " SELECTED" : "") .">". $lang['mlst_mess_typ__3'] ."</option>";
|
||||
$parse['mlst_data_types'] .= "<option value=\"4\"". (($Selected == "4") ? " SELECTED" : "") .">". $lang['mlst_mess_typ__4'] ."</option>";
|
||||
$parse['mlst_data_types'] .= "<option value=\"5\"". (($Selected == "5") ? " SELECTED" : "") .">". $lang['mlst_mess_typ__5'] ."</option>";
|
||||
$parse['mlst_data_types'] .= "<option value=\"15\"". (($Selected == "15") ? " SELECTED" : "") .">". $lang['mlst_mess_typ_15'] ."</option>";
|
||||
$parse['mlst_data_types'] .= "<option value=\"99\"". (($Selected == "99") ? " SELECTED" : "") .">". $lang['mlst_mess_typ_99'] ."</option>";
|
||||
|
||||
$parse['mlst_data_pages'] = "";
|
||||
for ( $cPage = 1; $cPage <= $MaxPage; $cPage++ ) {
|
||||
$parse['mlst_data_pages'] .= "<option value=\"".$cPage."\"". (($ViewPage == $cPage) ? " SELECTED" : "") .">". $cPage ."/". $MaxPage ."</option>";
|
||||
}
|
||||
|
||||
$parse['mlst_scpt'] = "<script language=\"JavaScript\">\n";
|
||||
$parse['mlst_scpt'] .= "function f(target_url, win_name) {\n";
|
||||
$parse['mlst_scpt'] .= "var new_win = window.open(target_url,win_name,'resizable=yes,scrollbars=yes,menubar=no,toolbar=no,width=550,height=280,top=0,left=0');\n";
|
||||
$parse['mlst_scpt'] .= "new_win.focus();\n";
|
||||
$parse['mlst_scpt'] .= "}\n";
|
||||
$parse['mlst_scpt'] .= "</script>\n";
|
||||
|
||||
$parse['tbl_rows'] = "";
|
||||
$parse['mlst_title'] = $lang['mlst_title'];
|
||||
|
||||
$StartRec = 1 + (($ViewPage - 1) * 25);
|
||||
$Messages = doquery("SELECT * FROM {{table}} WHERE `message_type` = '". $Selected ."' ORDER BY `message_time` DESC LIMIT ". $StartRec .",25;", 'messages');
|
||||
while ($row = $Messages->fetch(PDO::FETCH_ASSOC)) {
|
||||
$OwnerData = doquery ("SELECT `username` FROM {{table}} WHERE `id` = '". $row['message_owner'] ."';", 'users',true);
|
||||
$bloc['mlst_id'] = $row['message_id'];
|
||||
$bloc['mlst_from'] = $row['message_from'];
|
||||
$bloc['mlst_to'] = $OwnerData['username'] ." ID:". $row['message_owner'];
|
||||
$bloc['mlst_text'] = $row['message_text'];
|
||||
$bloc['mlst_time'] = gmdate ( "d. M Y H:i:s", $row['message_time'] );
|
||||
|
||||
$parse['mlst_data_rows'] .= parsetemplate($RowsTpl , $bloc);
|
||||
}
|
||||
|
||||
$display = parsetemplate($BodyTpl , $parse);
|
||||
|
||||
if (isset($_POST['delit'])) {
|
||||
doquery ("DELETE FROM {{table}} WHERE `message_id` = '". $_POST['delit'] ."';", 'messages');
|
||||
AdminMessage ( $lang['mlst_mess_del'] ." ( ". $_POST['delit'] ." )", $lang['mlst_title'], "./messagelist.".PHPEXT, 3);
|
||||
}
|
||||
display ($display, $lang['mlst_title'], false, '', true);
|
||||
} else {
|
||||
message($lang['sys_noalloaw'], $lang['sys_noaccess']);
|
||||
}
|
||||
|
||||
?>
|
||||
75
src/admin/messall.php
Normal file
75
src/admin/messall.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
if (!empty($_POST)) {
|
||||
if (isset($_POST["tresc"]) && $_POST["tresc"] != '') {
|
||||
$tresc = $_POST['tresc'];
|
||||
}
|
||||
if (isset($_POST["temat"]) && $_POST["temat"] != '') {
|
||||
$temat = $_POST['temat'];
|
||||
}
|
||||
if ($user['authlevel'] == LEVEL_ADMIN) {
|
||||
$kolor = 'red';
|
||||
$ranga = 'Administrator';
|
||||
} elseif ($user['authlevel'] == LEVEL_OPERATOR) {
|
||||
$kolor = 'skyblue';
|
||||
$ranga = 'Operator';
|
||||
} elseif ($user['authlevel'] == LEVEL_MODERATOR) {
|
||||
$kolor = 'yellow';
|
||||
$ranga = 'Moderator';
|
||||
}
|
||||
if (isset($tresc) && isset($temat)) {
|
||||
$sq = doquery("SELECT `id` FROM {{table}}", "users");
|
||||
$Time = time();
|
||||
$From = "<font color=\"". $kolor ."\">". $ranga ." ".$user['username']."</font>";
|
||||
$Subject = "<font color=\"". $kolor ."\">". $temat ."</font>";
|
||||
$Message = "<font color=\"". $kolor ."\"><b>". $tresc ."</b></font>";
|
||||
while ($u = $sq->fetch(PDO::FETCH_BOTH)) {
|
||||
SendSimpleMessage($u['id'], $user['id'], $Time, 97, $From, $Subject, $Message);
|
||||
}
|
||||
message("<font color=\"lime\">Wys<79>a<EFBFBD>e<EFBFBD> wiadomo<6D><6F> do wszystkich graczy</font>", "Complete", "../overview." . PHPEXT, 3);
|
||||
}
|
||||
} else {
|
||||
$parse = array();
|
||||
$parse['dpath'] = $dpath;
|
||||
$parse['debug'] = (defined('DEBUG')) ? " checked='checked'/":'';
|
||||
$page .= parsetemplate(gettemplate('admin/messall_body'), $parse);
|
||||
display($page, '', false,'', true);
|
||||
}
|
||||
} else {
|
||||
message($lang['sys_noalloaw'], $lang['sys_noaccess']);
|
||||
}
|
||||
62
src/admin/moonlist.php
Normal file
62
src/admin/moonlist.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
includeLang('overview');
|
||||
|
||||
$parse = $lang;
|
||||
$query = doquery("SELECT * FROM {{table}} WHERE planet_type='3'", "planets");
|
||||
$i = 0;
|
||||
while ($u = $query->fetch(PDO::FETCH_BOTH)) {
|
||||
$parse['moon'] .= "<tr>"
|
||||
. "<td class=b><center><b>" . $u[0] . "</center></b></td>"
|
||||
. "<td class=b><center><b>" . $u[1] . "</center></b></td>"
|
||||
. "<td class=b><center><b>" . $u[2] . "</center></b></td>"
|
||||
. "<td class=b><center><b>" . $u[4] . "</center></b></td>"
|
||||
. "<td class=b><center><b>" . $u[5] . "</center></b></td>"
|
||||
. "<td class=b><center><b>" . $u[6] . "</center></b></td>"
|
||||
. "</tr>";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($i == "1")
|
||||
$parse['moon'] .= "<tr><th class=b colspan=6>Il y a qu'une seule lune</th></tr>";
|
||||
else
|
||||
$parse['moon'] .= "<tr><th class=b colspan=6>Il y a {$i} lunes</th></tr>";
|
||||
|
||||
display(parsetemplate(gettemplate('admin/moonlist_body'), $parse), 'Lunalist' , false, '', true);
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
?>
|
||||
65
src/admin/multi.php
Normal file
65
src/admin/multi.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
includeLang('admin/multi');
|
||||
|
||||
$query = doquery("SELECT * FROM {{table}}", 'multi');
|
||||
|
||||
$parse = $lang;
|
||||
$parse['adm_mt_table'] = "";
|
||||
$i = 0;
|
||||
|
||||
$RowsTPL = gettemplate('admin/multi_rows');
|
||||
$PageTPL = gettemplate('admin/multi_body');
|
||||
|
||||
while ($infos = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$Bloc['player'] = $infos['player'];
|
||||
$Bloc['text'] = $infos['text'];
|
||||
|
||||
$parse['adm_mt_table'] .= parsetemplate( $RowsTPL, $Bloc );
|
||||
$i++;
|
||||
}
|
||||
|
||||
$parse['adm_mt_count'] = $i;
|
||||
|
||||
$page = parsetemplate( $PageTPL, $parse );
|
||||
display( $page, $lang['adm_mt_title'], false, '', true);
|
||||
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
115
src/admin/overview.php
Normal file
115
src/admin/overview.php
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
includeLang('admin');
|
||||
|
||||
if ($_GET['cmd'] == 'sort') {
|
||||
$TypeSort = $_GET['type'];
|
||||
} else {
|
||||
$TypeSort = "id";
|
||||
}
|
||||
|
||||
$PageTPL = gettemplate('admin/overview_body');
|
||||
$RowsTPL = gettemplate('admin/overview_rows');
|
||||
|
||||
$parse = $lang;
|
||||
$parse['dpath'] = $dpath;
|
||||
$parse['mf'] = $mf;
|
||||
$parse['adm_ov_data_yourv'] = colorRed(VERSION);
|
||||
|
||||
$Last15Mins = doquery("SELECT * FROM {{table}} WHERE `onlinetime` >= '". (time() - 15 * 60) ."' ORDER BY `". $TypeSort ."` ASC;", 'users');
|
||||
$Count = 0;
|
||||
$Color = "lime";
|
||||
while ($TheUser = $Last15Mins->fetch(PDO::FETCH_ASSOC) ) {
|
||||
if ($PrevIP != "") {
|
||||
if ($PrevIP == $TheUser['user_lastip']) {
|
||||
$Color = "red";
|
||||
} else {
|
||||
$Color = "lime";
|
||||
}
|
||||
}
|
||||
|
||||
$UserPoints = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $TheUser['id'] . "';", 'statpoints', true);
|
||||
$Bloc['dpath'] = $dpath;
|
||||
$Bloc['adm_ov_altpm'] = $lang['adm_ov_altpm'];
|
||||
$Bloc['adm_ov_wrtpm'] = $lang['adm_ov_wrtpm'];
|
||||
$Bloc['adm_ov_data_id'] = $TheUser['id'];
|
||||
$Bloc['adm_ov_data_name'] = $TheUser['username'];
|
||||
$Bloc['adm_ov_data_agen'] = $TheUser['user_agent'];
|
||||
$Bloc['current_page'] = $TheUser['current_page'];
|
||||
$Bloc['usr_s_id'] = $TheUser['id'];
|
||||
|
||||
$Bloc['adm_ov_data_clip'] = $Color;
|
||||
$Bloc['adm_ov_data_adip'] = $TheUser['user_lastip'];
|
||||
$Bloc['adm_ov_data_ally'] = $TheUser['ally_name'];
|
||||
$Bloc['adm_ov_data_point'] = pretty_number ( $UserPoints['total_points'] );
|
||||
$Bloc['adm_ov_data_activ'] = pretty_time ( time() - $TheUser['onlinetime'] );
|
||||
$Bloc['adm_ov_data_pict'] = "m.gif";
|
||||
$PrevIP = $TheUser['user_lastip'];
|
||||
|
||||
//Tweaks vue g<>n<EFBFBD>rale
|
||||
$Bloc['usr_email'] = $TheUser['email'];
|
||||
$Bloc['usr_xp_raid'] = $TheUser['xpraid'];
|
||||
$Bloc['usr_xp_min'] = $TheUser['xpminier'];
|
||||
|
||||
if ($TheUser['urlaubs_modus'] == 1) {
|
||||
$Bloc['state_vacancy'] = "<img src=\"../images/true.png\" >";
|
||||
} else {
|
||||
$Bloc['state_vacancy'] = "<img src=\"../images/false.png\">";
|
||||
}
|
||||
|
||||
if ($TheUser['bana'] == 1) {
|
||||
$Bloc['is_banned'] = "<img src=\"../images/banned.png\" >";
|
||||
} else {
|
||||
$Bloc['is_banned'] = $lang['is_banned_lang'];
|
||||
}
|
||||
$Bloc['usr_planet_gal'] = $TheUser['galaxy'];
|
||||
$Bloc['usr_planet_sys'] = $TheUser['system'];
|
||||
$Bloc['usr_planet_pos'] = $TheUser['planet'];
|
||||
|
||||
|
||||
$parse['adm_ov_data_table'] .= parsetemplate( $RowsTPL, $Bloc );
|
||||
$Count++;
|
||||
}
|
||||
|
||||
$parse['adm_ov_data_count'] = $Count;
|
||||
$Page = parsetemplate($PageTPL, $parse);
|
||||
|
||||
display( $Page, $lang['sys_overview'], false, '', true);
|
||||
} else {
|
||||
AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
236
src/admin/paneladmina.php
Normal file
236
src/admin/paneladmina.php
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
|
||||
includeLang('admin/adminpanel');
|
||||
|
||||
$PanelMainTPL = gettemplate('admin/admin_panel_main');
|
||||
|
||||
$parse = $lang;
|
||||
$parse['adm_sub_form1'] = "";
|
||||
$parse['adm_sub_form2'] = "";
|
||||
$parse['adm_sub_form3'] = "";
|
||||
|
||||
// Afficher les templates
|
||||
if (isset($_GET['result'])) {
|
||||
|
||||
switch ($_GET['result']){
|
||||
case 'usr_search':
|
||||
$db = Legacies_Database::getSingleton();
|
||||
$sql =<<<SQL_EOF
|
||||
SELECT
|
||||
planet.id AS planet_id,
|
||||
planet.name AS planet_name,
|
||||
planet.galaxy AS planet_galaxy,
|
||||
planet.system AS planet_system,
|
||||
planet.planet AS planet_position,
|
||||
user.id AS user_id,
|
||||
user.username AS username,
|
||||
user.user_lastip AS user_lastip,
|
||||
user.email AS email,
|
||||
user.authlevel AS authlevel,
|
||||
user.sex AS sex
|
||||
|
||||
FROM {{table}}planets AS planet
|
||||
INNER JOIN {{table}}users AS user ON user.id_planet=planet.id
|
||||
WHERE user.id = {$db->quote('%' . str_replace('*', '%', str_replace('%', '%%', $_GET['player'])) . '%')}"
|
||||
SQL_EOF;
|
||||
$statement = $db->prepare($sql);
|
||||
$statement->execute();
|
||||
$data = $statement->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$bloc = $lang;
|
||||
$bloc['answer1'] = $data['user_id'];
|
||||
$bloc['answer2'] = $data['username'];
|
||||
$bloc['answer3'] = $data['user_lastip'];
|
||||
$bloc['answer4'] = $data['email'];
|
||||
$bloc['answer5'] = $lang['adm_usr_level'][$data['authlevel']];
|
||||
$bloc['answer6'] = $lang['adm_usr_genre'][$data['sex']];
|
||||
$bloc['answer7'] = "[".$data['planet_id']."] {$data['planet_name']}";
|
||||
$bloc['answer8'] = "[".$SelUser['planet_galaxy'].":".$SelUser['planet_system'].":".$SelUser['planet_position']."] ";
|
||||
$SubPanelTPL = gettemplate('admin/admin_panel_asw1');
|
||||
$parse['adm_sub_form2'] = parsetemplate($SubPanelTPL, $bloc);
|
||||
break;
|
||||
|
||||
case 'usr_data':
|
||||
$db = Legacies_Database::getSingleton();
|
||||
$sql =<<<SQL_EOF
|
||||
SELECT
|
||||
planet.id AS planet_id,
|
||||
planet.name AS planet_name,
|
||||
planet.galaxy AS planet_galaxy,
|
||||
planet.system AS planet_system,
|
||||
planet.planet AS planet_position,
|
||||
user.id AS user_id,
|
||||
user.username AS username,
|
||||
user.user_lastip AS user_lastip,
|
||||
user.email AS email,
|
||||
user.authlevel AS authlevel,
|
||||
user.sex AS sex
|
||||
|
||||
FROM {{table}}planets AS planet
|
||||
INNER JOIN {{table}}users AS user ON user.id_planet=planet.id
|
||||
WHERE user.id = {$db->quote('%' . str_replace('*', '%', str_replace('%', '%%', $_GET['player'])) . '%')}"
|
||||
SQL_EOF;
|
||||
$statement = $db->prepare($sql);
|
||||
$statement->execute();
|
||||
$data = $statement->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$pattern = mysql_real_escape_string($_GET['player']);
|
||||
$SelUser = doquery("SELECT * FROM {{table}} WHERE `username` LIKE '%". $pattern ."%' LIMIT 1;", 'users', true);
|
||||
$UsrMain = doquery("SELECT `name` FROM {{table}} WHERE `id` = '". $SelUser['id_planet'] ."';", 'planets', true);
|
||||
|
||||
$bloc = $lang;
|
||||
$bloc['answer1'] = $data['user_id'];
|
||||
$bloc['answer2'] = $data['username'];
|
||||
$bloc['answer3'] = $data['user_lastip'];
|
||||
$bloc['answer4'] = $data['email'];
|
||||
$bloc['answer5'] = $lang['adm_usr_level'][$data['authlevel']];
|
||||
$bloc['answer6'] = $lang['adm_usr_genre'][$data['sex']];
|
||||
$bloc['answer7'] = "[".$data['planet_id']."] {$data['planet_name']}";
|
||||
$bloc['answer8'] = "[".$SelUser['planet_galaxy'].":".$SelUser['planet_system'].":".$SelUser['planet_position']."] ";
|
||||
$SubPanelTPL = gettemplate('admin/admin_panel_asw1');
|
||||
$parse['adm_sub_form1'] = parsetemplate( $SubPanelTPL, $bloc );
|
||||
|
||||
$parse['adm_sub_form2'] = "<table><tbody>";
|
||||
$parse['adm_sub_form2'] .= "<tr><td colspan=\"4\" class=\"c\">".$lang['adm_colony']."</td></tr>";
|
||||
$UsrColo = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '". $SelUser['id'] ." ORDER BY `galaxy` ASC, `planet` ASC, `system` ASC, `planet_type` ASC';", 'planets');
|
||||
while ( $Colo = mysql_fetch_assoc($UsrColo) ) {
|
||||
if ($Colo['id'] != $SelUser['id_planet']) {
|
||||
$parse['adm_sub_form2'] .= "<tr><th>".$Colo['id']."</th>";
|
||||
$parse['adm_sub_form2'] .= "<th>". (($Colo['planet_type'] == 1) ? $lang['adm_planet'] : $lang['adm_moon'] ) ."</th>";
|
||||
$parse['adm_sub_form2'] .= "<th>[".$Colo['galaxy'].":".$Colo['system'].":".$Colo['planet']."]</th>";
|
||||
$parse['adm_sub_form2'] .= "<th>".$Colo['name']."</th></tr>";
|
||||
}
|
||||
}
|
||||
$parse['adm_sub_form2'] .= "</tbody></table>";
|
||||
|
||||
$parse['adm_sub_form3'] = "<table><tbody>";
|
||||
$parse['adm_sub_form3'] .= "<tr><td colspan=\"4\" class=\"c\">".$lang['adm_technos']."</td></tr>";
|
||||
for ($Item = 100; $Item <= 199; $Item++) {
|
||||
if ($resource[$Item] != "") {
|
||||
$parse['adm_sub_form3'] .= "<tr><th>".$lang['tech'][$Item]."</th>";
|
||||
$parse['adm_sub_form3'] .= "<th>".$SelUser[$resource[$Item]]."</th></tr>";
|
||||
}
|
||||
}
|
||||
$parse['adm_sub_form3'] .= "</tbody></table>";
|
||||
break;
|
||||
|
||||
case 'usr_level':
|
||||
if (!isset($_GET['s']) || !isset($_SESSION['CSRF']) || $_GET['s'] !== $_SESSION['CSRF']) {
|
||||
AdminMessage(
|
||||
'One have tried to overcome administration privilleges.',
|
||||
'Hacking attempt');
|
||||
break;
|
||||
}
|
||||
|
||||
$player = isset($_GET['player']) ? mysql_real_escape_string($_GET['player']) : '';
|
||||
$level = isset($_GET['authlvl']) ? mysql_real_escape_string($_GET['authlvl']) : '';
|
||||
|
||||
if ($level >= $user['authlevel'] && $user['authlevel'] != LEVEL_ADMIN) {
|
||||
AdminMessage('Not enough privilleges to promote user.', $lang['adm_mod_level']);
|
||||
break;
|
||||
}
|
||||
|
||||
$userData = doquery("SELECT id FROM {{table}} WHERE `username` = '".$player."';", 'users', true);
|
||||
if (empty($user)) {
|
||||
AdminMessage('No such user.', $lang['adm_mod_level']);
|
||||
break;
|
||||
}
|
||||
|
||||
doquery("UPDATE {{table}} SET `authlevel` = '{$level}' WHERE id={$userData['id']}", 'users');
|
||||
$message = $lang['adm_mess_lvl1']. " ". $player ." ".$lang['adm_mess_lvl2'];
|
||||
$message .= "<font color=\"red\">".$lang['adm_usr_level'][$level]."</font>!";
|
||||
|
||||
AdminMessage($message, $lang['adm_mod_level']);
|
||||
break;
|
||||
|
||||
case 'ip_search':
|
||||
$pattern = isset($_GET['ip']) ? mysql_real_escape_string($_GET['ip']) : '';
|
||||
$SelUser = doquery("SELECT * FROM {{table}} WHERE `user_lastip` = '". $pattern ."' LIMIT 10;", 'users');
|
||||
$bloc = $lang;
|
||||
$bloc['adm_this_ip'] = $pattern;
|
||||
while ( $Usr = mysql_fetch_assoc($SelUser) ) {
|
||||
$UsrMain = doquery("SELECT `name` FROM {{table}} WHERE `id` = '". $Usr['id_planet'] ."';", 'planets', true);
|
||||
$bloc['adm_plyer_lst'] .= "<tr><th>".$Usr['username']."</th><th>[".$Usr['galaxy'].":".$Usr['system'].":".$Usr['planet']."] ".$UsrMain['name']."</th></tr>";
|
||||
}
|
||||
$SubPanelTPL = gettemplate('admin/admin_panel_asw2');
|
||||
$parse['adm_sub_form2'] = parsetemplate( $SubPanelTPL, $bloc );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Traiter les reponses aux formulaires
|
||||
if (isset($_GET['action'])) {
|
||||
$bloc = $lang;
|
||||
|
||||
$_SESSION['CSRF'] = sha1(uniqid(null, true));
|
||||
$bloc['csrf_hack'] = $_SESSION['CSRF'];
|
||||
|
||||
switch ($_GET['action']){
|
||||
case 'usr_search':
|
||||
$SubPanelTPL = gettemplate('admin/admin_panel_frm1');
|
||||
break;
|
||||
|
||||
case 'usr_data':
|
||||
$SubPanelTPL = gettemplate('admin/admin_panel_frm4');
|
||||
break;
|
||||
|
||||
case 'usr_level':
|
||||
for ($Lvl = 0; $Lvl < 4; $Lvl++) {
|
||||
$bloc['adm_level_lst'] .= "<option value=\"". $Lvl ."\">". $lang['adm_usr_level'][ $Lvl ] ."</option>";
|
||||
}
|
||||
$SubPanelTPL = gettemplate('admin/admin_panel_frm3');
|
||||
break;
|
||||
|
||||
case 'ip_search':
|
||||
$SubPanelTPL = gettemplate('admin/admin_panel_frm2');
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$parse['adm_sub_form2'] = parsetemplate( $SubPanelTPL, $bloc );
|
||||
}
|
||||
|
||||
$page = parsetemplate( $PanelMainTPL, $parse );
|
||||
display( $page, $lang['panel_mainttl'], false, '', true );
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
63
src/admin/planetlist.php
Normal file
63
src/admin/planetlist.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
|
||||
$parse = $lang;
|
||||
$query = doquery("SELECT * FROM {{table}} WHERE planet_type='1'", "planets");
|
||||
$i = 0;
|
||||
while ($u = $query->fetch(PDO::FETCH_BOTH)) {
|
||||
$parse['planetes'] .= "<tr>"
|
||||
. "<td class=b><center><b>" . $u[0] . "</center></b></td>"
|
||||
. "<td class=b><center><b>" . $u[1] . "</center></b></td>"
|
||||
. "<td class=b><center><b>" . $u[4] . "</center></b></td>"
|
||||
. "<td class=b><center><b>" . $u[5] . "</center></b></td>"
|
||||
. "<td class=b><center><b>" . $u[6] . "</center></b></td>"
|
||||
. "</tr>";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($i == "1")
|
||||
$parse['planetes'] .= "<tr><th class=b colspan=5>Il y a qu'une seule planète</th></tr>";
|
||||
else
|
||||
$parse['planetes'] .= "<tr><th class=b colspan=5>Il y a {$i} planètes</th></tr>";
|
||||
|
||||
display(parsetemplate(gettemplate('admin/planetlist_body'), $parse), 'Planetlist', false, '', true);
|
||||
} else {
|
||||
message($lang['sys_noalloaw'], $lang['sys_noaccess']);
|
||||
}
|
||||
|
||||
// Created by e-Zobar. All rights reversed (C) Wootook Team 2008
|
||||
?>
|
||||
242
src/admin/settings.php
Normal file
242
src/admin/settings.php
Normal file
|
|
@ -0,0 +1,242 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
|
||||
function DisplayGameSettingsPage($CurrentUser) {
|
||||
global $lang;
|
||||
|
||||
includeLang('admin/settings');
|
||||
|
||||
if (in_array((int) $CurrentUser['authlevel'], array(LEVEL_ADMIN))) {
|
||||
if (isset($_POST['opt_save']) && $_POST['opt_save'] == "1") {
|
||||
// Jeu Ouvert ou Ferm<72> !
|
||||
if (isset($_POST['closed']) && $_POST['closed'] == 'on') {
|
||||
Wootook::setConfig('game/general/active', true, 1, 1);
|
||||
} else {
|
||||
Wootook::setConfig('game/general/active', false, 1, 1);
|
||||
}
|
||||
|
||||
if (isset($_POST['close_reason'])) {
|
||||
Wootook::setConfig('game/general/closing-message', $_POST['close_reason'], 1, 1);
|
||||
}
|
||||
|
||||
// Y a un News Frame ? !
|
||||
if (isset($_POST['newsframe']) && $_POST['newsframe'] == 'on') {
|
||||
Wootook::setConfig('game/news/active', true, 1, 1);
|
||||
} else {
|
||||
Wootook::setConfig('game/news/active', false, 1, 1);
|
||||
}
|
||||
|
||||
if (isset($_POST['NewsText'])) {
|
||||
Wootook::setConfig('game/news/content', $_POST['NewsText'], 1, 1);
|
||||
}
|
||||
|
||||
// Y a un TCHAT externe ??
|
||||
if (isset($_POST['chatframe']) && $_POST['chatframe'] == 'on') {
|
||||
Wootook::setConfig('engine/options/chat', true, 1, 1);
|
||||
} else {
|
||||
Wootook::setConfig('engine/options/chat', false, 1, 1);
|
||||
}
|
||||
|
||||
if (isset($_POST['ga']) && $_POST['ga'] == 'on') {
|
||||
Wootook::setConfig('engine/options/ga', true, 1, 1);
|
||||
} else {
|
||||
Wootook::setConfig('engine/options/ga', false, 1, 1);
|
||||
}
|
||||
if (isset($_POST['ga_id']) && !empty($_POST['ga_id'])) {
|
||||
Wootook::setConfig('engine/options/ga-id', $_POST['ga_id'], 1, 1);
|
||||
}
|
||||
|
||||
// Y a un BANNER Frame ?
|
||||
if (isset($_POST['bannerframe']) && $_POST['bannerframe'] == 'on') {
|
||||
Wootook::setConfig('engine/options/banner', true, 1, 1);
|
||||
} else {
|
||||
Wootook::setConfig('engine/options/banner', false, 1, 1);
|
||||
}
|
||||
|
||||
// Nom du Jeu
|
||||
if (isset($_POST['game_name']) && !empty($_POST['game_name'])) {
|
||||
Wootook::setConfig('game/general/name', $_POST['game_name'], 1, 1);
|
||||
}
|
||||
|
||||
// Adresse du Forum
|
||||
if (isset($_POST['forum_url']) && !empty($_POST['forum_url'])) {
|
||||
Wootook::setConfig('game/general/boards-url', $_POST['forum_url'], 1, 1);
|
||||
}
|
||||
|
||||
// Vitesse du Jeu
|
||||
if (isset($_POST['game_speed']) && is_numeric($_POST['game_speed'])) {
|
||||
Wootook::setConfig('game/speed/general', $_POST['game_speed'], 1, 1);
|
||||
}
|
||||
|
||||
// Vitesse des Flottes
|
||||
if (isset($_POST['fleet_speed']) && is_numeric($_POST['fleet_speed'])) {
|
||||
Wootook::setConfig('game/speed/fleet', $_POST['fleet_speed'], 1, 1);
|
||||
}
|
||||
|
||||
// Multiplicateur de Production
|
||||
if (isset($_POST['resource_multiplier']) && is_numeric($_POST['resource_multiplier'])) {
|
||||
Wootook::setConfig('game/resource/multiplier', $_POST['resource_multiplier'], 1, 1);
|
||||
}
|
||||
|
||||
// Taille de la planete mère
|
||||
if (isset($_POST['initial_fields']) && is_numeric($_POST['initial_fields'])) {
|
||||
Wootook::setConfig('resource/initial/fields', $_POST['initial_fields'], 1, 1);
|
||||
}
|
||||
|
||||
// Revenu de base Metal
|
||||
if (isset($_POST['metal_basic_income']) && is_numeric($_POST['metal_basic_income'])) {
|
||||
Wootook::setConfig('resource/initial/metal', $_POST['metal_basic_income'], 1, 1);
|
||||
}
|
||||
|
||||
// Revenu de base Cristal
|
||||
if (isset($_POST['crystal_basic_income']) && is_numeric($_POST['crystal_basic_income'])) {
|
||||
Wootook::setConfig('resource/initial/cristal', $_POST['crystal_basic_income'], 1, 1);
|
||||
}
|
||||
|
||||
// Revenu de base Deuterium
|
||||
if (isset($_POST['deuterium_basic_income']) && is_numeric($_POST['deuterium_basic_income'])) {
|
||||
Wootook::setConfig('resource/initial/deuterium', $_POST['deuterium_basic_income'], 1, 1);
|
||||
}
|
||||
|
||||
// Revenu de base Energie
|
||||
if (isset($_POST['energy_basic_income']) && is_numeric($_POST['energy_basic_income'])) {
|
||||
Wootook::setConfig('resource/initial/energy', $_POST['energy_basic_income'], 1, 1);
|
||||
}
|
||||
|
||||
// Lien supplémentaire dans le menu
|
||||
if (isset($_POST['url_link_']) && is_numeric($_POST['url_link_'])) {
|
||||
Wootook::setConfig('game/general/boards-url', $_POST['url_link_'], 1, 1);
|
||||
}
|
||||
|
||||
// Image de la bannière
|
||||
if (isset($_POST['banner_source_post'])) {
|
||||
Wootook::setConfig('engine/options/banner', $_POST['banner_source_post'], 1, 1);
|
||||
}
|
||||
// 1 point = ??? Ressources ?
|
||||
if (isset($_POST['stat_settings']) && is_numeric($_POST['stat_settings'])) {
|
||||
Wootook::setConfig('game/resource/multiplier', $_POST['stat_settings'], 1, 1);
|
||||
}
|
||||
// Activation -ou non- des annonces
|
||||
if (isset($_POST['enable_announces_']) && is_numeric($_POST['enable_announces_'])) {
|
||||
Wootook::setConfig('engine/options/announces', $_POST['enable_announces_'], 1, 1);
|
||||
}
|
||||
// Activation -ou non- du marchand
|
||||
if (isset($_POST['enable_marchand_']) && is_numeric($_POST['enable_marchand_'])) {
|
||||
Wootook::setConfig('engine/options/retailer', $_POST['enable_marchand_'], 1, 1);
|
||||
}
|
||||
// Activation -ou non- des notes
|
||||
if (isset($_POST['enable_notes_']) && is_numeric($_POST['enable_notes_'])) {
|
||||
Wootook::setConfig('engine/options/notes', $_POST['enable_notes_'], 1, 1);
|
||||
}
|
||||
// Nom du bot antimulti
|
||||
if (isset($_POST['name_bot'])) {
|
||||
Wootook::setConfig('engine/bot/name', $_POST['name_bot'], 1, 1);
|
||||
}
|
||||
// email du bot antimulti
|
||||
if (isset($_POST['adress_bot'])) {
|
||||
Wootook::setConfig('engine/bot/email', $_POST['adress_bot'], 1, 1);
|
||||
}
|
||||
|
||||
// Activation -ou non- des notes
|
||||
if (isset($_POST['duration_ban']) && is_numeric($_POST['duration_ban'])) {
|
||||
Wootook::setConfig('engine/ban/duration', $_POST['duration_ban'], 1, 1);
|
||||
}
|
||||
|
||||
// Activation -ou non- du bot
|
||||
if (isset($_POST['bot_enable']) && is_numeric($_POST['bot_enable'])) {
|
||||
Wootook::setConfig('engine/bot/active', $_POST['bot_enable'], 1, 1);
|
||||
}
|
||||
|
||||
// BBCode ou pas ?
|
||||
if (isset($_POST['bbcode_field']) && is_numeric($_POST['bbcode_field'])) {
|
||||
Wootook::setConfig('engine/options/bbcode', $_POST['bbcode_field'], 1, 1);
|
||||
}
|
||||
|
||||
AdminMessage('Options changees avec succes !', 'Succes', '?');
|
||||
} else {
|
||||
$parse = $lang;
|
||||
$parse['game_name'] = Wootook::getGameConfig('game/general/name');
|
||||
$parse['game_speed'] = Wootook::getGameConfig('game/speed/general');
|
||||
$parse['fleet_speed'] = Wootook::getGameConfig('game/speed/fleet');
|
||||
$parse['resource_multiplier'] = Wootook::getGameConfig('game/resource/multiplier');
|
||||
$parse['forum_url'] = Wootook::getGameConfig('game/general/boards-url');
|
||||
$parse['initial_fields'] = Wootook::getGameConfig('resource/initial/fields');
|
||||
$parse['metal_basic_income'] = Wootook::getGameConfig('resource/initial/metal');
|
||||
$parse['crystal_basic_income'] = Wootook::getGameConfig('resource/initial/cristal');
|
||||
$parse['deuterium_basic_income'] = Wootook::getGameConfig('resource/initial/deuterium');
|
||||
$parse['energy_basic_income'] = Wootook::getGameConfig('resource/initial/energy');
|
||||
$parse['enable_link'] = $gameConfig['link_enable'];
|
||||
$parse['name_link'] = Wootook::getGameConfig('game/general/extra-url-title');
|
||||
$parse['url_link'] = Wootook::getGameConfig('game/general/extra-url');
|
||||
$parse['enable_announces'] = Wootook::getGameConfig('engine/options/announces');
|
||||
$parse['enable_marchand'] = Wootook::getGameConfig('engine/options/retailer');
|
||||
$parse['enable_notes'] = Wootook::getGameConfig('engine/options/notes');
|
||||
$parse['bot_name'] = Wootook::getGameConfig('engine/bot/name');
|
||||
$parse['bot_adress'] = Wootook::getGameConfig('engine/bot/email');
|
||||
$parse['ban_duration'] = Wootook::getGameConfig('engine/ban/duration');
|
||||
$parse['enable_bot'] = Wootook::getGameConfig('engine/bot/active');
|
||||
$parse['enable_bbcode'] = Wootook::getGameConfig('engine/options/bbcode');
|
||||
|
||||
$parse['banner_source_post'] = Wootook::getGameConfig('engine/options/banner');
|
||||
$parse['stat_settings'] = Wootook::getGameConfig('game/resource/multiplier');
|
||||
|
||||
$parse['closed'] = (!Wootook::getGameConfig('game/general/active')) ? " checked = 'checked' ":"";
|
||||
$parse['close_reason'] = Wootook::getGameConfig('game/general/closing-message');
|
||||
|
||||
$parse['newsframe'] = (Wootook::getGameConfig('game/news/active')) ? " checked = 'checked' ":"";
|
||||
$parse['NewsTextVal'] = Wootook::getGameConfig('game/news/content');
|
||||
|
||||
$parse['chatframe'] = ($gameConfig['OverviewExternChat'] == 1) ? " checked = 'checked' ":"";
|
||||
$parse['ExtTchatVal'] = stripslashes( $gameConfig['OverviewExternChatCmd'] );
|
||||
|
||||
$parse['ga'] = (Wootook::getGameConfig('engine/options/ga')) ? " checked = 'checked' ":"";
|
||||
$parse['ga_id'] = Wootook::getGameConfig('engine/options/ga-id');
|
||||
|
||||
$parse['bannerframe'] = ($gameConfig['ForumBannerFrame'] == 1) ? " checked = 'checked' ":"";
|
||||
|
||||
$PageTPL = gettemplate('admin/options_body');
|
||||
$Page = parsetemplate($PageTPL, $parse);
|
||||
|
||||
display($Page, $lang['adm_opt_title'], false, '', true);
|
||||
}
|
||||
} else {
|
||||
AdminMessage($lang['sys_noalloaw'], $lang['sys_noaccess']);
|
||||
}
|
||||
return $Page;
|
||||
}
|
||||
|
||||
$Page = DisplayGameSettingsPage($user);
|
||||
|
||||
272
src/admin/statbuilder.php
Normal file
272
src/admin/statbuilder.php
Normal file
|
|
@ -0,0 +1,272 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
include(ROOT_PATH . 'admin/statfunctions.' . PHPEXT);
|
||||
|
||||
|
||||
if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
includeLang('admin');
|
||||
|
||||
$StatDate = time();
|
||||
// Rotation des statistiques
|
||||
doquery ( "DELETE FROM {{table}} WHERE `stat_code` >= '10';" , 'statpoints');
|
||||
doquery ( "UPDATE {{table}} SET `stat_code` = `stat_code` + '1';" , 'statpoints');
|
||||
|
||||
$GameUsers = doquery("SELECT * FROM {{table}} WHERE authlevel<3", 'users');
|
||||
|
||||
$resourceMultiplier = Wootook::getGameConfig('game/resource/multiplier');
|
||||
|
||||
while ($CurUser = $GameUsers->fetch(PDO::FETCH_ASSOC)) {
|
||||
// Recuperation des anciennes statistiques
|
||||
$OldStatRecord = doquery ("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `id_owner` = '".$CurUser['id']."';", 'statpoints', true);
|
||||
if ($OldStatRecord) {
|
||||
$OldTotalRank = $OldStatRecord['total_rank'];
|
||||
$OldTechRank = $OldStatRecord['tech_rank'];
|
||||
$OldBuildRank = $OldStatRecord['build_rank'];
|
||||
$OldDefsRank = $OldStatRecord['defs_rank'];
|
||||
$OldFleetRank = $OldStatRecord['fleet_rank'];
|
||||
// Suppression de l'ancien enregistrement
|
||||
doquery ("DELETE FROM {{table}} WHERE `stat_type` = '1' AND `id_owner` = '".$CurUser['id']."';",'statpoints');
|
||||
} else {
|
||||
$OldTotalRank = 0;
|
||||
$OldTechRank = 0;
|
||||
$OldBuildRank = 0;
|
||||
$OldDefsRank = 0;
|
||||
$OldFleetRank = 0;
|
||||
}
|
||||
|
||||
// Total des unitées consommée pour la recherche
|
||||
$Points = GetTechnoPoints ( $CurUser );
|
||||
$TTechCount = $Points['TechCount'];
|
||||
$TTechPoints = ($Points['TechPoint'] / $resourceMultiplier);
|
||||
|
||||
// Totalisation des points accumulés par planete
|
||||
$TBuildCount = 0;
|
||||
$TBuildPoints = 0;
|
||||
$TDefsCount = 0;
|
||||
$TDefsPoints = 0;
|
||||
$TFleetCount = 0;
|
||||
$TFleetPoints = 0;
|
||||
$GCount = $TTechCount;
|
||||
$GPoints = $TTechPoints;
|
||||
$UsrPlanets = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '". $CurUser['id'] ."';", 'planets');
|
||||
while ($CurPlanet = $UsrPlanets->fetch(PDO::FETCH_ASSOC)) {
|
||||
$Points = GetBuildPoints ( $CurPlanet );
|
||||
$TBuildCount += $Points['BuildCount'];
|
||||
$GCount += $Points['BuildCount'];
|
||||
$PlanetPoints = ($Points['BuildPoint'] / $resourceMultiplier);
|
||||
$TBuildPoints += ($Points['BuildPoint'] / $resourceMultiplier);
|
||||
|
||||
$Points = GetDefensePoints ( $CurPlanet );
|
||||
$TDefsCount += $Points['DefenseCount'];;
|
||||
$GCount += $Points['DefenseCount'];
|
||||
$PlanetPoints += ($Points['DefensePoint'] / $resourceMultiplier);
|
||||
$TDefsPoints += ($Points['DefensePoint'] / $resourceMultiplier);
|
||||
|
||||
$Points = GetFleetPoints ( $CurPlanet );
|
||||
$TFleetCount += $Points['FleetCount'];
|
||||
$GCount += $Points['FleetCount'];
|
||||
$PlanetPoints += ($Points['FleetPoint'] / $resourceMultiplier);
|
||||
$TFleetPoints += ($Points['FleetPoint'] / $resourceMultiplier);
|
||||
|
||||
$GPoints += $PlanetPoints;
|
||||
$QryUpdatePlanet = "UPDATE {{table}} SET ";
|
||||
$QryUpdatePlanet .= "`points` = '". $PlanetPoints ."' ";
|
||||
$QryUpdatePlanet .= "WHERE ";
|
||||
$QryUpdatePlanet .= "`id` = '". $CurPlanet['id'] ."';";
|
||||
doquery ( $QryUpdatePlanet , 'planets');
|
||||
}
|
||||
|
||||
$QryInsertStats = "INSERT INTO {{table}} SET ";
|
||||
$QryInsertStats .= "`id_owner` = '". $CurUser['id'] ."', ";
|
||||
$QryInsertStats .= "`id_ally` = '". $CurUser['ally_id'] ."', ";
|
||||
$QryInsertStats .= "`stat_type` = '1', "; // 1 pour joueur , 2 pour alliance
|
||||
$QryInsertStats .= "`stat_code` = '1', "; // de 1 a 2 mis a jour de maniere automatique
|
||||
$QryInsertStats .= "`tech_points` = '". $TTechPoints ."', ";
|
||||
$QryInsertStats .= "`tech_count` = '". $TTechCount ."', ";
|
||||
$QryInsertStats .= "`tech_old_rank` = '". $OldTechRank ."', ";
|
||||
$QryInsertStats .= "`build_points` = '". $TBuildPoints ."', ";
|
||||
$QryInsertStats .= "`build_count` = '". $TBuildCount ."', ";
|
||||
$QryInsertStats .= "`build_old_rank` = '". $OldBuildRank ."', ";
|
||||
$QryInsertStats .= "`defs_points` = '". $TDefsPoints ."', ";
|
||||
$QryInsertStats .= "`defs_count` = '". $TDefsCount ."', ";
|
||||
$QryInsertStats .= "`defs_old_rank` = '". $OldDefsRank ."', ";
|
||||
$QryInsertStats .= "`fleet_points` = '". $TFleetPoints ."', ";
|
||||
$QryInsertStats .= "`fleet_count` = '". $TFleetCount ."', ";
|
||||
$QryInsertStats .= "`fleet_old_rank` = '". $OldFleetRank ."', ";
|
||||
$QryInsertStats .= "`total_points` = '". $GPoints ."', ";
|
||||
$QryInsertStats .= "`total_count` = '". $GCount ."', ";
|
||||
$QryInsertStats .= "`total_old_rank` = '". $OldTotalRank ."', ";
|
||||
$QryInsertStats .= "`stat_date` = '". $StatDate ."';";
|
||||
doquery ( $QryInsertStats , 'statpoints');
|
||||
}
|
||||
|
||||
$Rank = 1;
|
||||
$RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `tech_points` DESC;", 'statpoints');
|
||||
while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) {
|
||||
$QryUpdateStats = "UPDATE {{table}} SET ";
|
||||
$QryUpdateStats .= "`tech_rank` = '". $Rank ."' ";
|
||||
$QryUpdateStats .= "WHERE ";
|
||||
$QryUpdateStats .= " `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $TheRank['id_owner'] ."';";
|
||||
doquery ( $QryUpdateStats , 'statpoints');
|
||||
$Rank++;
|
||||
}
|
||||
|
||||
$Rank = 1;
|
||||
$RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `build_points` DESC;", 'statpoints');
|
||||
while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC) ) {
|
||||
$QryUpdateStats = "UPDATE {{table}} SET ";
|
||||
$QryUpdateStats .= "`build_rank` = '". $Rank ."' ";
|
||||
$QryUpdateStats .= "WHERE ";
|
||||
$QryUpdateStats .= " `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $TheRank['id_owner'] ."';";
|
||||
doquery ( $QryUpdateStats , 'statpoints');
|
||||
$Rank++;
|
||||
}
|
||||
|
||||
$Rank = 1;
|
||||
$RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `defs_points` DESC;", 'statpoints');
|
||||
while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) {
|
||||
$QryUpdateStats = "UPDATE {{table}} SET ";
|
||||
$QryUpdateStats .= "`defs_rank` = '". $Rank ."' ";
|
||||
$QryUpdateStats .= "WHERE ";
|
||||
$QryUpdateStats .= " `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $TheRank['id_owner'] ."';";
|
||||
doquery ( $QryUpdateStats , 'statpoints');
|
||||
$Rank++;
|
||||
}
|
||||
|
||||
$Rank = 1;
|
||||
$RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `fleet_points` DESC;", 'statpoints');
|
||||
while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) {
|
||||
$QryUpdateStats = "UPDATE {{table}} SET ";
|
||||
$QryUpdateStats .= "`fleet_rank` = '". $Rank ."' ";
|
||||
$QryUpdateStats .= "WHERE ";
|
||||
$QryUpdateStats .= " `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $TheRank['id_owner'] ."';";
|
||||
doquery ( $QryUpdateStats , 'statpoints');
|
||||
$Rank++;
|
||||
}
|
||||
|
||||
$Rank = 1;
|
||||
$RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `total_points` DESC;", 'statpoints');
|
||||
while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) {
|
||||
$QryUpdateStats = "UPDATE {{table}} SET ";
|
||||
$QryUpdateStats .= "`total_rank` = '". $Rank ."' ";
|
||||
$QryUpdateStats .= "WHERE ";
|
||||
$QryUpdateStats .= " `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $TheRank['id_owner'] ."';";
|
||||
doquery ( $QryUpdateStats , 'statpoints');
|
||||
$Rank++;
|
||||
}
|
||||
|
||||
// Statistiques des alliances ...
|
||||
$GameAllys = doquery("SELECT * FROM {{table}}", 'alliance');
|
||||
|
||||
while ($CurAlly = $GameAllys->fetch(PDO::FETCH_ASSOC)) {
|
||||
// Recuperation des anciennes statistiques
|
||||
$OldStatRecord = doquery ("SELECT * FROM {{table}} WHERE `stat_type` = '2' AND `id_owner` = '".$CurAlly['id']."';",'statpoints', true);
|
||||
if ($OldStatRecord) {
|
||||
$OldTotalRank = $OldStatRecord['total_rank'];
|
||||
$OldTechRank = $OldStatRecord['tech_rank'];
|
||||
$OldBuildRank = $OldStatRecord['build_rank'];
|
||||
$OldDefsRank = $OldStatRecord['defs_rank'];
|
||||
$OldFleetRank = $OldStatRecord['fleet_rank'];
|
||||
// Suppression de l'ancien enregistrement
|
||||
doquery ("DELETE FROM {{table}} WHERE `stat_type` = '2' AND `id_owner` = '".$CurAlly['id']."';",'statpoints');
|
||||
} else {
|
||||
$OldTotalRank = 0;
|
||||
$OldTechRank = 0;
|
||||
$OldBuildRank = 0;
|
||||
$OldDefsRank = 0;
|
||||
$OldFleetRank = 0;
|
||||
}
|
||||
|
||||
// Total des unitées consommée pour la recherche
|
||||
$QrySumSelect = "SELECT ";
|
||||
$QrySumSelect .= "SUM(`tech_points`) as `TechPoint`, ";
|
||||
$QrySumSelect .= "SUM(`tech_count`) as `TechCount`, ";
|
||||
$QrySumSelect .= "SUM(`build_points`) as `BuildPoint`, ";
|
||||
$QrySumSelect .= "SUM(`build_count`) as `BuildCount`, ";
|
||||
$QrySumSelect .= "SUM(`defs_points`) as `DefsPoint`, ";
|
||||
$QrySumSelect .= "SUM(`defs_count`) as `DefsCount`, ";
|
||||
$QrySumSelect .= "SUM(`fleet_points`) as `FleetPoint`, ";
|
||||
$QrySumSelect .= "SUM(`fleet_count`) as `FleetCount`, ";
|
||||
$QrySumSelect .= "SUM(`total_points`) as `TotalPoint`, ";
|
||||
$QrySumSelect .= "SUM(`total_count`) as `TotalCount` ";
|
||||
$QrySumSelect .= "FROM {{table}} ";
|
||||
$QrySumSelect .= "WHERE ";
|
||||
$QrySumSelect .= "`stat_type` = '1' AND ";
|
||||
$QrySumSelect .= "`id_ally` = '". $CurAlly['id'] ."';";
|
||||
$Points = doquery( $QrySumSelect, 'statpoints', true);
|
||||
|
||||
$TTechCount = $Points['TechCount'];
|
||||
$TTechPoints = $Points['TechPoint'];
|
||||
$TBuildCount = $Points['BuildCount'];
|
||||
$TBuildPoints = $Points['BuildPoint'];
|
||||
$TDefsCount = $Points['DefsCount'];
|
||||
$TDefsPoints = $Points['DefsPoint'];
|
||||
$TFleetCount = $Points['FleetCount'];
|
||||
$TFleetPoints = $Points['FleetPoint'];
|
||||
$GCount = $Points['TotalCount'];
|
||||
$GPoints = $Points['TotalPoint'];
|
||||
|
||||
$QryInsertStats = "INSERT INTO {{table}} SET ";
|
||||
$QryInsertStats .= "`id_owner` = '". $CurAlly['id'] ."', ";
|
||||
$QryInsertStats .= "`id_ally` = '0', ";
|
||||
$QryInsertStats .= "`stat_type` = '2', "; // 1 pour joueur , 2 pour alliance
|
||||
$QryInsertStats .= "`stat_code` = '1', "; // de 1 a 5 mis a jour de maniere automatique
|
||||
$QryInsertStats .= "`tech_points` = '". $TTechPoints ."', ";
|
||||
$QryInsertStats .= "`tech_count` = '". $TTechCount ."', ";
|
||||
$QryInsertStats .= "`tech_old_rank` = '". $OldTechRank ."', ";
|
||||
$QryInsertStats .= "`build_points` = '". $TBuildPoints ."', ";
|
||||
$QryInsertStats .= "`build_count` = '". $TBuildCount ."', ";
|
||||
$QryInsertStats .= "`build_old_rank` = '". $OldBuildRank ."', ";
|
||||
$QryInsertStats .= "`defs_points` = '". $TDefsPoints ."', ";
|
||||
$QryInsertStats .= "`defs_count` = '". $TDefsCount ."', ";
|
||||
$QryInsertStats .= "`defs_old_rank` = '". $OldDefsRank ."', ";
|
||||
$QryInsertStats .= "`fleet_points` = '". $TFleetPoints ."', ";
|
||||
$QryInsertStats .= "`fleet_count` = '". $TFleetCount ."', ";
|
||||
$QryInsertStats .= "`fleet_old_rank` = '". $OldFleetRank ."', ";
|
||||
$QryInsertStats .= "`total_points` = '". $GPoints ."', ";
|
||||
$QryInsertStats .= "`total_count` = '". $GCount ."', ";
|
||||
$QryInsertStats .= "`total_old_rank` = '". $OldTotalRank ."', ";
|
||||
$QryInsertStats .= "`stat_date` = '". $StatDate ."';";
|
||||
doquery ( $QryInsertStats , 'statpoints');
|
||||
}
|
||||
|
||||
AdminMessage ( $lang['adm_done'], $lang['adm_stat_title'] );
|
||||
|
||||
} else {
|
||||
AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
107
src/admin/statfunctions.php
Normal file
107
src/admin/statfunctions.php
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
function GetTechnoPoints ( $CurrentUser ) {
|
||||
global $resource, $pricelist, $reslist;
|
||||
|
||||
$TechCounts = 0;
|
||||
$TechPoints = 0;
|
||||
foreach ( $reslist['tech'] as $n => $Techno ) {
|
||||
if ( $CurrentUser[ $resource[ $Techno ] ] > 0 ) {
|
||||
for ( $Level = 1; $Level < $CurrentUser[ $resource[ $Techno ] ]; $Level++ ) {
|
||||
$Units = $pricelist[ $Techno ]['metal'] + $pricelist[ $Techno ]['cristal'] + $pricelist[ $Techno ]['deuterium'];
|
||||
$LevelMul = pow( $pricelist[ $Techno ]['factor'], $Level );
|
||||
$TechPoints += ($Units * $LevelMul);
|
||||
$TechCounts += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$RetValue['TechCount'] = $TechCounts;
|
||||
$RetValue['TechPoint'] = $TechPoints;
|
||||
|
||||
return $RetValue;
|
||||
}
|
||||
|
||||
function GetBuildPoints ( $CurrentPlanet ) {
|
||||
global $resource, $pricelist, $reslist;
|
||||
|
||||
$BuildCounts = 0;
|
||||
$BuildPoints = 0;
|
||||
foreach($reslist['build'] as $n => $Building) {
|
||||
if ( $CurrentPlanet[ $resource[ $Building ] ] > 0 ) {
|
||||
for ( $Level = 1; $Level < $CurrentPlanet[ $resource[ $Building ] ]; $Level++ ) {
|
||||
$Units = $pricelist[ $Building ]['metal'] + $pricelist[ $Building ]['cristal'] + $pricelist[ $Building ]['deuterium'];
|
||||
$LevelMul = pow( $pricelist[ $Building ]['factor'], $Level );
|
||||
$BuildPoints += ($Units * $LevelMul);
|
||||
$BuildCounts += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$RetValue['BuildCount'] = $BuildCounts;
|
||||
$RetValue['BuildPoint'] = $BuildPoints;
|
||||
|
||||
return $RetValue;
|
||||
}
|
||||
|
||||
function GetDefensePoints ( $CurrentPlanet ) {
|
||||
global $resource, $pricelist, $reslist;
|
||||
|
||||
$DefenseCounts = 0;
|
||||
$DefensePoints = 0;
|
||||
foreach($reslist['defense'] as $n => $Defense) {
|
||||
if ($CurrentPlanet[ $resource[ $Defense ] ] > 0) {
|
||||
$Units = $pricelist[ $Defense ]['metal'] + $pricelist[ $Defense ]['cristal'] + $pricelist[ $Defense ]['deuterium'];
|
||||
$DefensePoints += ($Units * $CurrentPlanet[ $resource[ $Defense ] ]);
|
||||
$DefenseCounts += $CurrentPlanet[ $resource[ $Defense ] ];
|
||||
}
|
||||
}
|
||||
$RetValue['DefenseCount'] = $DefenseCounts;
|
||||
$RetValue['DefensePoint'] = $DefensePoints;
|
||||
|
||||
return $RetValue;
|
||||
}
|
||||
|
||||
function GetFleetPoints ( $CurrentPlanet ) {
|
||||
global $resource, $pricelist, $reslist;
|
||||
|
||||
$FleetCounts = 0;
|
||||
$FleetPoints = 0;
|
||||
foreach($reslist['fleet'] as $n => $Fleet) {
|
||||
if ($CurrentPlanet[ $resource[ $Fleet ] ] > 0) {
|
||||
$Units = $pricelist[ $Fleet ]['metal'] + $pricelist[ $Fleet ]['cristal'] + $pricelist[ $Fleet ]['deuterium'];
|
||||
$FleetPoints += ($Units * $CurrentPlanet[ $resource[ $Fleet ] ]);
|
||||
$FleetCounts += $CurrentPlanet[ $resource[ $Fleet ] ];
|
||||
}
|
||||
}
|
||||
$RetValue['FleetCount'] = $FleetCounts;
|
||||
$RetValue['FleetPoint'] = $FleetPoints;
|
||||
|
||||
return $RetValue;
|
||||
}
|
||||
57
src/admin/unbanned.php
Normal file
57
src/admin/unbanned.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
|
||||
$parse['dpath'] = $dpath;
|
||||
$parse = $lang;
|
||||
|
||||
$mode = $_GET['mode'];
|
||||
|
||||
if ($mode != 'change') {
|
||||
$parse['Name'] = "Nom du joueur";
|
||||
} elseif ($mode == 'change') {
|
||||
$nam = $_POST['nam'];
|
||||
doquery("DELETE FROM {{table}} WHERE who2='{$nam}'", 'banned');
|
||||
doquery("UPDATE {{table}} SET bana=0, banaday=0 WHERE username='{$nam}'", "users");
|
||||
message("Le joueur {$nam} a bien été débanni!", 'Information');
|
||||
}
|
||||
|
||||
display(parsetemplate(gettemplate('admin/unbanned'), $parse), "Overview", false, '', true);
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
89
src/admin/userlist.php
Normal file
89
src/admin/userlist.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
|
||||
includeLang('admin');
|
||||
if ($_GET['cmd'] == 'dele') {
|
||||
DeleteSelectedUser ( $_GET['user'] );
|
||||
}
|
||||
if ($_GET['cmd'] == 'sort') {
|
||||
$TypeSort = $_GET['type'];
|
||||
} else {
|
||||
$TypeSort = "id";
|
||||
}
|
||||
|
||||
$PageTPL = gettemplate('admin/userlist_body');
|
||||
$RowsTPL = gettemplate('admin/userlist_rows');
|
||||
|
||||
$query = doquery("SELECT * FROM {{table}} ORDER BY `". $TypeSort ."` ASC", 'users');
|
||||
|
||||
$parse = $lang;
|
||||
$parse['adm_ul_table'] = "";
|
||||
$i = 0;
|
||||
$Color = "lime";
|
||||
while ($u = mysql_fetch_assoc ($query) ) {
|
||||
if ($PrevIP != "") {
|
||||
if ($PrevIP == $u['user_lastip']) {
|
||||
$Color = "red";
|
||||
} else {
|
||||
$Color = "lime";
|
||||
}
|
||||
}
|
||||
|
||||
$Bloc['adm_ul_data_id'] = $u['id'];
|
||||
$Bloc['adm_ul_data_name'] = $u['username'];
|
||||
$Bloc['adm_ul_data_mail'] = $u['email'];
|
||||
$Bloc['ip_adress_at_register'] = $u['ip_at_reg'];
|
||||
$Bloc['adm_ul_data_adip'] = "<font color=\"".$Color."\">". $u['user_lastip'] ."</font>";
|
||||
$Bloc['adm_ul_data_regd'] = gmdate ( "d/m/Y G:i:s", $u['register_time'] );
|
||||
$Bloc['adm_ul_data_lconn'] = gmdate ( "d/m/Y G:i:s", $u['onlinetime'] );
|
||||
$Bloc['adm_ul_data_banna'] = ( $u['bana'] == 1 ) ? "<a href # title=\"". gmdate ( "d/m/Y G:i:s", $u['banaday']) ."\">". $lang['adm_ul_yes'] ."</a>" : $lang['adm_ul_no'];
|
||||
$Bloc['adm_ul_data_detai'] = ""; // Lien vers une page de details genre Empire
|
||||
$Bloc['adm_ul_data_actio'] = "<a href=\"userlist.php?cmd=dele&user=".$u['id']."\"><img src=\"../images/r1.png\"></a>"; // Lien vers actions 'effacer'
|
||||
|
||||
|
||||
$PrevIP = $u['user_lastip'];
|
||||
$parse['adm_ul_table'] .= parsetemplate( $RowsTPL, $Bloc );
|
||||
$i++;
|
||||
}
|
||||
$parse['adm_ul_count'] = $i;
|
||||
|
||||
$page = parsetemplate( $PageTPL, $parse );
|
||||
display( $page, $lang['adm_ul_title'], false, '', true);
|
||||
} else {
|
||||
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
47
src/admin/variables.php
Normal file
47
src/admin/variables.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
define('IN_ADMIN', true);
|
||||
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
|
||||
|
||||
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
|
||||
|
||||
$parse['phpinfo'] = phpinfo();
|
||||
|
||||
$Page = parsetemplate($PageTPL, $parse);
|
||||
|
||||
display ( $Page, "PhpInfo", false, '', true);
|
||||
} else {
|
||||
AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
|
||||
}
|
||||
|
||||
?>
|
||||
1231
src/alliance.php
Normal file
1231
src/alliance.php
Normal file
File diff suppressed because it is too large
Load diff
122
src/annonce.php
Normal file
122
src/annonce.php
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
require_once dirname(__FILE__) .'/application/bootstrap.php';
|
||||
$users = doquery("SELECT * FROM {{table}} WHERE id='".$user['id']."';", 'users');
|
||||
$annonce = doquery("SELECT * FROM {{table}} ", 'annonce');
|
||||
$action = $_GET['action'];
|
||||
|
||||
if ($action == 5) {
|
||||
$metalvendre = $_POST['metalvendre'];
|
||||
$cristalvendre = $_POST['cristalvendre'];
|
||||
$deutvendre = $_POST['deutvendre'];
|
||||
|
||||
$metalsouhait = $_POST['metalsouhait'];
|
||||
$cristalsouhait = $_POST['cristalsouhait'];
|
||||
$deutsouhait = $_POST['deutsouhait'];
|
||||
|
||||
while ($v_annonce = $users->fetch(PDO::FETCH_BOTH)) {
|
||||
$user = $v_annonce['username'];
|
||||
$galaxie = $v_annonce['galaxy'];
|
||||
$systeme = $v_annonce['system'];
|
||||
}
|
||||
|
||||
doquery("INSERT INTO {{table}} SET
|
||||
user='{$user}',
|
||||
galaxie='{$galaxie}',
|
||||
systeme='{$systeme}',
|
||||
metala='{$metalvendre}',
|
||||
cristala='{$cristalvendre}',
|
||||
deuta='{$deutvendre}',
|
||||
metals='{$metalsouhait}',
|
||||
cristals='{$cristalsouhait}',
|
||||
deuts='{$deutsouhait}'" , "annonce");
|
||||
|
||||
$page2 .= <<<HTML
|
||||
<center>
|
||||
<br>
|
||||
<p>Votre Annonce a bien été enregistrée !</p>
|
||||
<br><p><a href="annonce.php">Retour aux annonces</a></p>
|
||||
|
||||
HTML;
|
||||
|
||||
display($page2);
|
||||
}
|
||||
|
||||
if ($action != 5) {
|
||||
$annonce = doquery("SELECT * FROM {{table}} ORDER BY `id` DESC ", "annonce");
|
||||
|
||||
$page2 = "<HTML>
|
||||
<center>
|
||||
<br>
|
||||
<table width=\"600\">
|
||||
<td class=\"c\" colspan=\"10\"><font color=\"#FFFFFF\">Petites Annonces</font></td></tr>
|
||||
<tr><th colspan=\"3\">Infos de livraison</th><th colspan=\"3\">Ressources à vendre</th><th colspan=\"3\">Ressources souhaitées</th><th>Action</th></tr>
|
||||
<tr><th>Vendeur</th><th>Galaxie</th><th>Système</th><th>Métal</th><th>Cristal</th><th>Deuterium</th><th>Métal</th><th>Cristal</th><th>Deuterium</th><th>Delet</th></tr>
|
||||
|
||||
|
||||
|
||||
|
||||
";
|
||||
while ($b = $annonce->fetch(PDO::FETCH_BOTH)) {
|
||||
$page2 .= '<tr><th> ';
|
||||
$page2 .= $b["user"] ;
|
||||
$page2 .= '</th><th>';
|
||||
$page2 .= $b["galaxie"];
|
||||
$page2 .= '</th><th>';
|
||||
$page2 .= $b["systeme"];
|
||||
$page2 .= '</th><th>';
|
||||
$page2 .= $b["metala"];
|
||||
$page2 .= '</th><th>';
|
||||
$page2 .= $b["gcristala"];
|
||||
$page2 .= '</th><th>';
|
||||
$page2 .= $b["deuta"];
|
||||
$page2 .= '</th><th>';
|
||||
$page2 .= $b["metals"];
|
||||
$page2 .= '</th><th>';
|
||||
$page2 .= $b["cristals"];
|
||||
$page2 .= '</th><th>';
|
||||
$page2 .= $b["deuts"];
|
||||
$page2 .= '</th><th>';
|
||||
$page2 .= "</th></tr>";
|
||||
}
|
||||
|
||||
$page2 .= "
|
||||
<tr><th colspan=\"10\" align=\"center\"><a href=\"annonce2.php?action=2\">Ajouter une Annonce</a></th></tr>
|
||||
</td>
|
||||
</table>
|
||||
</HTML>";
|
||||
|
||||
display($page2);
|
||||
}
|
||||
|
||||
?>
|
||||
62
src/annonce2.php
Normal file
62
src/annonce2.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('INSIDE' , true);
|
||||
define('INSTALL' , false);
|
||||
require_once dirname(__FILE__) .'/application/bootstrap.php';
|
||||
|
||||
$actions = $_GET['action'];
|
||||
|
||||
if($actions == 2)
|
||||
{
|
||||
$page .=<<<HTML
|
||||
<center>
|
||||
<br>
|
||||
<table width="600">
|
||||
<td class="c" colspan="10" align="center"><b><font color="white">Ajouter une Annonce</font></b></td></tr>
|
||||
<td class="c" colspan="10" align="center"><b>Ressources à Vendre</font></b></td></tr>
|
||||
|
||||
<form action="annonce.php?action=5" method="post">
|
||||
<tr><th colspan="5">Métal</th><th colspan="5"><input type="texte" value="0" name="metalvendre" /></th></tr>
|
||||
<tr><th colspan="5">Cristal</th><th colspan="5"><input type="texte" value="0" name="cristalvendre" /></th></tr>
|
||||
<tr><th colspan="5">Deuterium</th><th colspan="5"><input type="texte" value="0" name="deutvendre" /></th></tr>
|
||||
<td class="c" colspan="10" align="center"><b>Ressources Souhaitées</font></b></td></tr>
|
||||
<tr><th colspan="5">Métal</th><th colspan="5"><input type="texte" value="0" name="metalsouhait" /></th></tr>
|
||||
<tr><th colspan="5">Cristal</th><th colspan="5"><input type="texte" value="0" name="cristalsouhait" /></th></tr>
|
||||
<tr><th colspan="5">Deuterium</th><th colspan="5"><input type="texte" value="0" name="deutsouhait" /></th></tr>
|
||||
<tr><th colspan="10"><input type="submit" value="Envoyer" /></th></tr>
|
||||
|
||||
<form>
|
||||
</table>
|
||||
HTML;
|
||||
|
||||
display($page);
|
||||
}
|
||||
?>
|
||||
166
src/application/bootstrap.php
Normal file
166
src/application/bootstrap.php
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
define('DEBUG', true);
|
||||
define('DEPRECATION', true);
|
||||
|
||||
if (!defined('PHP_VERSION_ID')) {
|
||||
$version = explode('.',PHP_VERSION);
|
||||
define('PHP_VERSION_ID', (((int)$version[0]) * 10000 + ((int)$version[1]) * 100 + ((int)$version[2])));
|
||||
unset($version);
|
||||
}
|
||||
|
||||
if (!defined('DEBUG') && ($env = getenv('DEBUG')) !== false && in_array(strtolower($env), array('1', 'on', 'true'))) {
|
||||
define('DEBUG', true);
|
||||
} else if (!defined('DEBUG') && isset($_SERVER['DEBUG']) && in_array(strtolower($_SERVER['DEBUG']), array('1', 'on', 'true'))) {
|
||||
define('DEBUG', true);
|
||||
}
|
||||
|
||||
if (!defined('DEPRECATION') && ($env = getenv('DEPRECATION')) !== false && in_array(strtolower($env), array('1', 'on', 'true'))) {
|
||||
define('DEPRECATION', true);
|
||||
} else if (!defined('DEPRECATION') && isset($_SERVER['DEPRECATION']) && in_array(strtolower($_SERVER['DEPRECATION']), array('1', 'on', 'true'))) {
|
||||
define('DEPRECATION', true);
|
||||
}
|
||||
|
||||
if (!defined('BCNUMBERS') && ($env = getenv('BCNUMBERS')) !== false && in_array(strtolower($env), array('1', 'on', 'true'))) {
|
||||
define('BCNUMBERS', true);
|
||||
} else if (!defined('BCNUMBERS') && isset($_SERVER['BCNUMBERS']) && in_array(strtolower($_SERVER['BCNUMBERS']), array('1', 'on', 'true'))) {
|
||||
define('BCNUMBERS', true);
|
||||
}
|
||||
|
||||
if (!defined('DEBUG')) {
|
||||
@ini_set('display_errors', false);
|
||||
} else {
|
||||
@ini_set('display_errors', true);
|
||||
@error_reporting(E_ALL | E_STRICT);
|
||||
}
|
||||
|
||||
defined('ROOT_PATH') || define('ROOT_PATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
|
||||
defined('APPLICATION_PATH') || define('APPLICATION_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
||||
|
||||
defined('PHPEXT') || define('PHPEXT', 'php');
|
||||
|
||||
defined('VERSION') || define('VERSION', '1.5.0-beta2');
|
||||
|
||||
set_include_path(implode(PATH_SEPARATOR, array(
|
||||
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'libraries',
|
||||
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'local',
|
||||
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'community',
|
||||
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'core',
|
||||
get_include_path()
|
||||
)));
|
||||
|
||||
function __autoload($class) {
|
||||
include_once str_replace('_', '/', $class) . '.php';
|
||||
}
|
||||
|
||||
if (defined('IN_ADMIN')) {
|
||||
$website = new Wootook_Core_Model_Website();
|
||||
$website->setId(0)->setData('code', 'admin');
|
||||
Wootook::addWebsite($website);
|
||||
Wootook::setDefaultWebsite($website);
|
||||
|
||||
$game = new Wootook_Core_Model_Game();
|
||||
$game->setId(0)->setData('code', 'admin')->setData('website_id', $website->getId());
|
||||
Wootook::addGame($game);
|
||||
Wootook::setDefaultGame($game);
|
||||
}
|
||||
|
||||
include ROOT_PATH . 'includes/constants.php';
|
||||
|
||||
Wootook_Core_ErrorProfiler::register();
|
||||
Wootook_Core_Model_Config_Events::registerEvents();
|
||||
|
||||
if (!defined('IN_INSTALL') && 0 === filesize(APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'local.php')) {
|
||||
Wootook::getResponse()
|
||||
->setRedirect(Wootook::getStaticUrl('install/'), Wootook_Core_Controller_Response_Http::REDIRECT_TEMPORARY)
|
||||
->sendHeaders();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$lang = array();
|
||||
|
||||
define('DEFAULT_LANG', 'fr');
|
||||
|
||||
include(ROOT_PATH . 'includes/debug.class.'.PHPEXT);
|
||||
$debug = new Debug();
|
||||
|
||||
include(ROOT_PATH . 'includes/functions.' . PHPEXT);
|
||||
include(ROOT_PATH . 'includes/unlocalised.' . PHPEXT);
|
||||
include(ROOT_PATH . 'includes/todofleetcontrol.' . PHPEXT);
|
||||
include(ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg');
|
||||
include(ROOT_PATH . 'includes/vars.' . PHPEXT);
|
||||
include(ROOT_PATH . 'includes/strings.' . PHPEXT);
|
||||
|
||||
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
|
||||
|
||||
if (!defined('DISABLE_IDENTITY_CHECK')) {
|
||||
if ($user === null || !$user->getId()) {
|
||||
Wootook::getResponse()
|
||||
->setRedirect(Wootook::getUrl('player/account/login'))
|
||||
->sendHeaders();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!Wootook::getGameConfig('game/general/active') && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))) {
|
||||
$layout = new Wootook_Core_Layout(Wootook_Core_Layout::DOMAIN_FRONTEND);
|
||||
$layout->load('message');
|
||||
|
||||
$block = $layout->getBlock('message');
|
||||
$block['title'] = Wootook::__('Game is disabled.');
|
||||
$block['message'] = Wootook::getGameConfig('game/general/closing-message');
|
||||
|
||||
echo $layout->render();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
includeLang('system');
|
||||
includeLang('tech');
|
||||
|
||||
if (($user !== null && $user->getId())) {
|
||||
if (isset($_GET['cp']) && !empty($_GET['cp'])) {
|
||||
$user->updateCurrentPlanet((int) $_GET['cp']);
|
||||
}
|
||||
|
||||
$planet = $user->getCurrentPlanet();
|
||||
|
||||
foreach ($user->getPlanetCollection() as $userPlanet) {
|
||||
FlyingFleetHandler($userPlanet); // TODO: implement logic into a refactored model
|
||||
}
|
||||
|
||||
/*
|
||||
* Update planet resources and constructions
|
||||
*/
|
||||
Wootook::dispatchEvent('planet.update', array(
|
||||
'planet' => $planet
|
||||
));
|
||||
$planet->save();
|
||||
}
|
||||
0
src/application/cache/.placeholder
vendored
Normal file
0
src/application/cache/.placeholder
vendored
Normal file
0
src/application/code/community/.placeholder
Normal file
0
src/application/code/community/.placeholder
Normal file
158
src/application/code/core/Legacies/Empire.php
Normal file
158
src/application/code/core/Legacies/Empire.php
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
|
||||
class Legacies_Empire
|
||||
{
|
||||
const TYPE_BUILDING = 'build';
|
||||
const TYPE_BUILDING_MOON = 'build_moon';
|
||||
const TYPE_BUILDING_PLANET = 'build_planet';
|
||||
const TYPE_RESEARCH = 'tech';
|
||||
const TYPE_SHIP = 'fleet';
|
||||
const TYPE_DEFENSE = 'defense';
|
||||
const TYPE_SPECIAL = 'special';
|
||||
const TYPE_OFFICER = 'officier';
|
||||
const TYPE_PRODUCTION = 'prod';
|
||||
const TYPE_FLEET_MISSION = 'mission';
|
||||
|
||||
const RESOURCE_METAL = 'metal';
|
||||
const RESOURCE_CRISTAL = 'cristal';
|
||||
const RESOURCE_DEUTERIUM = 'deuterium';
|
||||
const RESOURCE_ENERGY = 'energy';
|
||||
|
||||
const RESOURCE_MULTIPLIER = 'factor';
|
||||
const RESOURCE_FORMULA = 'formule';
|
||||
const RESOURCE_CLASS = 'class';
|
||||
const BASE_BUILDING_TIME = 'base_time';
|
||||
|
||||
const SHIPS_CONSUMPTION_PRIMARY = 'consumption';
|
||||
const SHIPS_CELERITY_PRIMARY = 'speed';
|
||||
const SHIPS_CONSUMPTION_SECONDARY = 'consumption2';
|
||||
const SHIPS_CELERITY_SECONDARY = 'speed2';
|
||||
const SHIPS_CAPACITY = 'capacity';
|
||||
|
||||
const ID_BUILDING_METAL_MINE = 1;
|
||||
const ID_BUILDING_CRISTAL_MINE = 2;
|
||||
const ID_BUILDING_DEUTERIUM_SYNTHETISER = 3;
|
||||
const ID_BUILDING_SOLAR_PLANT = 4;
|
||||
const ID_BUILDING_FUSION_REACTOR = 12;
|
||||
const ID_BUILDING_ROBOTIC_FACTORY = 14;
|
||||
const ID_BUILDING_NANITE_FACTORY = 15;
|
||||
const ID_BUILDING_SHIPYARD = 21;
|
||||
const ID_BUILDING_METAL_STORAGE = 22;
|
||||
const ID_BUILDING_CRISTAL_STORAGE = 23;
|
||||
const ID_BUILDING_DEUTERIUM_TANK = 24;
|
||||
const ID_BUILDING_RESEARCH_LAB = 31;
|
||||
const ID_BUILDING_TERRAFORMER = 33;
|
||||
const ID_BUILDING_ALLIANCE_DEPOT = 34;
|
||||
const ID_BUILDING_LUNAR_BASE = 41;
|
||||
const ID_BUILDING_SENSOR_PHALANX = 42;
|
||||
const ID_BUILDING_JUMP_GATE = 43;
|
||||
const ID_BUILDING_MISSILE_SILO = 44;
|
||||
|
||||
const ID_RESEARCH_ESPIONAGE_TECHNOLOGY = 106;
|
||||
const ID_RESEARCH_COMPUTER_TECHNOLOGY = 108;
|
||||
const ID_RESEARCH_WEAPON_TECHNOLOGY = 109;
|
||||
const ID_RESEARCH_SHIELDING_TECHNOLOGY = 110;
|
||||
const ID_RESEARCH_ARMOUR_TECHNOLOGY = 111;
|
||||
const ID_RESEARCH_ENERGY_TECHNOLOGY = 113;
|
||||
const ID_RESEARCH_HYPERSPACE_TECHNOLOGY = 114;
|
||||
const ID_RESEARCH_COMBUSTION_DRIVE = 115;
|
||||
const ID_RESEARCH_IMPULSE_DRIVE = 117;
|
||||
const ID_RESEARCH_HYPERSPACE_DRIVE = 118;
|
||||
const ID_RESEARCH_LASER_TECHNOLOGY = 120;
|
||||
const ID_RESEARCH_ION_TECHNOLOGY = 121;
|
||||
const ID_RESEARCH_PLASMA_TECHNOLOGY = 122;
|
||||
const ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK = 123;
|
||||
const ID_RESEARCH_EXPEDITION_TECHNOLOGY = 124;
|
||||
const ID_RESEARCH_ASTROPHYSICS = 124;
|
||||
const ID_RESEARCH_GRAVITON_TECHNOLOGY = 199;
|
||||
|
||||
const ID_SHIP_LIGHT_TRANSPORT = 202;
|
||||
const ID_SHIP_LARGE_TRANSPORT = 203;
|
||||
const ID_SHIP_LIGHT_FIGHTER = 204;
|
||||
const ID_SHIP_HEAVY_FIGHTER = 205;
|
||||
const ID_SHIP_CRUISER = 206;
|
||||
const ID_SHIP_BATTLESHIP = 207;
|
||||
const ID_SHIP_COLONY_SHIP = 208;
|
||||
const ID_SHIP_RECYCLER = 209;
|
||||
const ID_SHIP_SPY_DRONE = 210;
|
||||
const ID_SHIP_BOMBER = 211;
|
||||
const ID_SHIP_SOLAR_SATELLITE = 212;
|
||||
const ID_SHIP_DESTRUCTOR = 213;
|
||||
const ID_SHIP_DEATH_STAR = 214;
|
||||
const ID_SHIP_BATTLECRUISER = 215;
|
||||
const ID_SHIP_SUPERNOVA = 216;
|
||||
|
||||
const ID_DEFENSE_ROCKET_LAUNCHER = 401;
|
||||
const ID_DEFENSE_LIGHT_LASER = 402;
|
||||
const ID_DEFENSE_HEAVY_LASER = 403;
|
||||
const ID_DEFENSE_ION_CANNON = 404;
|
||||
const ID_DEFENSE_GAUSS_CANNON = 405;
|
||||
const ID_DEFENSE_PLASMA_TURRET = 406;
|
||||
const ID_DEFENSE_SMALL_SHIELD_DOME = 407;
|
||||
const ID_DEFENSE_LARGE_SHIELD_DOME = 408;
|
||||
|
||||
const ID_SPECIAL_ANTIBALLISTIC_MISSILE = 502;
|
||||
const ID_SPECIAL_INTERPLANETARY_MISSILE = 503;
|
||||
|
||||
const ID_COMBAT_SHIELDS = 'shield';
|
||||
const ID_COMBAT_FIREPOWER = 'attack';
|
||||
const ID_COMBAT_RAPID_FIRE = 'sd';
|
||||
|
||||
const ID_MISSION_ATTACK = 1;
|
||||
const ID_MISSION_GROUP_ATTACK = 2;
|
||||
const ID_MISSION_TRANSPORT = 3;
|
||||
const ID_MISSION_STATION = 4;
|
||||
const ID_MISSION_STATION_ALLY = 5;
|
||||
const ID_MISSION_SPY = 6;
|
||||
const ID_MISSION_SETTLE_COLONY = 7;
|
||||
const ID_MISSION_RECYCLE = 8;
|
||||
const ID_MISSION_DESTROY = 9;
|
||||
const ID_MISSION_MISSILES = 10;
|
||||
const ID_MISSION_EXPEDITION = 15;
|
||||
|
||||
public static function getFieldName($id)
|
||||
{
|
||||
$fieldsAlias = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
|
||||
if (!isset($fieldsAlias[$id])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $fieldsAlias[$id];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Block_Planet_ResearchLab
|
||||
extends Wootook_Empire_Block_Planet_BuilderAbstract
|
||||
{
|
||||
protected $_planet = null;
|
||||
|
||||
public function setPlanet(Wootook_Empire_Model_Planet $planet)
|
||||
{
|
||||
$this->_planet = $planet;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlanet()
|
||||
{
|
||||
if ($this->_planet === null) {
|
||||
$this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer()
|
||||
->getCurrentPlanet()
|
||||
;
|
||||
}
|
||||
return $this->_planet;
|
||||
}
|
||||
|
||||
public function _initChildBlocks()
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
|
||||
/** @var Wootook_Core_Block_Concat $parentBlock */
|
||||
$parentBlock = $this->getLayout()->getBlock('item-list.items');
|
||||
foreach ($types->getData(Legacies_Empire::TYPE_RESEARCH) as $itemId) {
|
||||
if (!$this->getPlanet()->getResearchLab()->checkAvailability($itemId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$block = $this->getItemBlock($itemId);
|
||||
$parentBlock->setPartial($block->getName(), $block);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Block_Planet_ResearchLab_Item
|
||||
extends Wootook_Empire_Block_Planet_Builder_ItemAbstract
|
||||
{
|
||||
public function getLevel()
|
||||
{
|
||||
return $this->getPlayer()->getElement($this->getItemId());
|
||||
}
|
||||
|
||||
public function getResourcesNeeded($level)
|
||||
{
|
||||
return $this->getPlanet()->getResearchLab()->getResourcesNeeded($this->getItemId(), $level);
|
||||
}
|
||||
|
||||
public function getQueuedLevel()
|
||||
{
|
||||
return $this->getPlanet()->getResearchLab()->getResearchLevelQueued($this->getItemId());
|
||||
}
|
||||
|
||||
public function getBuildingTime($level)
|
||||
{
|
||||
return $this->getPlanet()->getResearchLab()->getResearchTime($this->getItemId(), $level);
|
||||
}
|
||||
|
||||
public function getResourcesConfigForLevel($level)
|
||||
{
|
||||
$resources = $this->getResourcesNeeded($level);
|
||||
|
||||
$resourceConfig = array();
|
||||
foreach ($resources as $resourceId => $resourceValue) {
|
||||
$resourceConfig[$resourceId] = new Wootook_Object(array(
|
||||
'resource_id' => $resourceId,
|
||||
'value' => $resourceValue
|
||||
));
|
||||
|
||||
$amount = $this->getPlanet()->getResourceAmount($resourceId);
|
||||
if (Math::comp($amount, $resourceValue) < 0) {
|
||||
$resourceConfig[$resourceId]->setData('requirement', Math::sub($amount, $resourceValue));
|
||||
} else {
|
||||
$resourceConfig[$resourceId]->setData('overflow', Math::sub($amount, $resourceValue));
|
||||
}
|
||||
}
|
||||
return $resourceConfig;
|
||||
}
|
||||
|
||||
public function getResourcesConfigForNextLevel()
|
||||
{
|
||||
return $this->getResourcesConfigForLevel($this->getNextLevel());
|
||||
}
|
||||
|
||||
public function getBuildingTimeForNextLevel()
|
||||
{
|
||||
return $this->getBuildingTime($this->getNextLevel());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Block_Planet_ResearchLab_Queue
|
||||
extends Wootook_Empire_Block_Planet_Builder_QueueAbstract
|
||||
{
|
||||
public function getQueue()
|
||||
{
|
||||
return $this->getPlanet()->getResearchLab()->getBuilder();
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->getQueue()->count() == 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item
|
||||
extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract
|
||||
{
|
||||
protected $_itemIdField = 'research_id';
|
||||
|
||||
public function getLevel()
|
||||
{
|
||||
return $this->getPlayer()->getElement($this->getItemId());
|
||||
}
|
||||
|
||||
public function getResourcesNeeded($level)
|
||||
{
|
||||
return $this->getPlanet()->getResearchLab()->getResourcesNeeded($this->getItemId(), $this->getQueuedLevel() + 1);
|
||||
}
|
||||
|
||||
public function getItemQueuedLevel()
|
||||
{
|
||||
return $this->getItem()->getData('level');
|
||||
}
|
||||
|
||||
public function getQueuedLevel()
|
||||
{
|
||||
return $this->getPlanet()->getResearchLab()->getResearchLevelQueued($this->getItemId());
|
||||
}
|
||||
|
||||
public function getBuildingTime($level)
|
||||
{
|
||||
return $this->getPlanet()->getResearchLab()->getBuildingTime($this->getItemId(), $level);
|
||||
}
|
||||
|
||||
public function getBuildingRemainingTime()
|
||||
{
|
||||
$totalTime = $this->getPlanet()->getResearchLab()
|
||||
->getResearchTime($this->getItemId(), $this->getItemQueuedLevel());
|
||||
$item = $this->getItem();
|
||||
|
||||
return $item->getData('created_at') - $item->getData('updated_at') + $totalTime;
|
||||
}
|
||||
|
||||
public function getResourcesConfigForLevel($level)
|
||||
{
|
||||
$resources = $this->getResourcesNeeded($level);
|
||||
|
||||
$resourceConfig = array();
|
||||
foreach ($resources as $resourceId => $resourceValue) {
|
||||
$resourceConfig[$resourceId] = new Wootook_Object(array(
|
||||
'resource_id' => $resourceId,
|
||||
'value' => $resourceValue
|
||||
));
|
||||
|
||||
$amount = $this->getPlanet()->getResourceAmount($resourceId);
|
||||
if (Math::comp($amount, $resourceValue) < 0) {
|
||||
$resourceConfig[$resourceId]->setData('requirement', Math::sub($amount, $resourceValue));
|
||||
} else {
|
||||
$resourceConfig[$resourceId]->setData('overflow', Math::sub($amount, $resourceValue));
|
||||
}
|
||||
}
|
||||
return $resourceConfig;
|
||||
}
|
||||
|
||||
public function getResourcesConfigForNextLevel()
|
||||
{
|
||||
return $this->getResourcesConfigForLevel($this->getNextLevel());
|
||||
}
|
||||
|
||||
public function getBuildingTimeForNextLevel()
|
||||
{
|
||||
return $this->getBuildingTime($this->getNextLevel());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Block_Planet_Shipyard
|
||||
extends Wootook_Empire_Block_Planet_BuilderAbstract
|
||||
{
|
||||
protected $_planet = null;
|
||||
protected $_type = Legacies_Empire::TYPE_SHIP;
|
||||
|
||||
protected $_allowedTypes = array(
|
||||
Legacies_Empire::TYPE_SHIP,
|
||||
Legacies_Empire::TYPE_DEFENSE
|
||||
);
|
||||
|
||||
public function setPlanet(Wootook_Empire_Model_Planet $planet)
|
||||
{
|
||||
$this->_planet = $planet;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlanet()
|
||||
{
|
||||
if ($this->_planet === null) {
|
||||
$this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer()
|
||||
->getCurrentPlanet()
|
||||
;
|
||||
}
|
||||
return $this->_planet;
|
||||
}
|
||||
|
||||
public function setAllowedTypes($types)
|
||||
{
|
||||
if (is_array($types)) {
|
||||
$this->_allowedTypes = $types;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addAllowedType($type)
|
||||
{
|
||||
if (!in_array($type, $this->_allowedTypes)) {
|
||||
$this->_allowedTypes[] = $type;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAllowedTypes()
|
||||
{
|
||||
return $this->_allowedTypes;
|
||||
}
|
||||
|
||||
public function setType($type)
|
||||
{
|
||||
if (in_array($type, $this->_allowedTypes)) {
|
||||
$this->_type = $type;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
public function _initChildBlocks()
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
|
||||
/** @var Wootook_Core_Block_Concat $parentBlock */
|
||||
$parentBlock = $this->getLayout()->getBlock('item-list.items');
|
||||
foreach ($types->getData($this->getType()) as $itemId) {
|
||||
if (!$this->getPlanet()->getShipyard()->checkAvailability($itemId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$block = $this->getItemBlock($itemId);
|
||||
$parentBlock->setPartial($block->getName(), $block);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Block_Planet_Shipyard_Item
|
||||
extends Wootook_Empire_Block_Planet_Builder_ItemAbstract
|
||||
{
|
||||
public function getQty()
|
||||
{
|
||||
return $this->getPlanet()->getElement($this->getItemId());
|
||||
}
|
||||
|
||||
public function getResourcesNeeded($qty)
|
||||
{
|
||||
return $this->getPlanet()->getShipyard()->getResourcesNeeded($this->getItemId(), $qty);
|
||||
}
|
||||
|
||||
public function getBuildingTime($qty)
|
||||
{
|
||||
return $this->getPlanet()->getShipyard()->getBuildingTime($this->getItemId(), $qty);
|
||||
}
|
||||
|
||||
public function getMaximumBuildableElementsCount()
|
||||
{
|
||||
return $this->getPlanet()->getShipyard()->getMaximumBuildableElementsCount($this->getItemId());
|
||||
}
|
||||
|
||||
public function getResourcesConfigForQty($qty)
|
||||
{
|
||||
$resources = $this->getResourcesNeeded($qty);
|
||||
|
||||
$resourceConfig = array();
|
||||
foreach ($resources as $resourceId => $resourceValue) {
|
||||
$resourceConfig[$resourceId] = new Wootook_Object(array(
|
||||
'resource_id' => $resourceId,
|
||||
'value' => $resourceValue
|
||||
));
|
||||
|
||||
$amount = $this->getPlanet()->getResourceAmount($resourceId);
|
||||
if (Math::comp($amount, $resourceValue) < 0) {
|
||||
$resourceConfig[$resourceId]->setData('requirement', Math::sub($amount, $resourceValue));
|
||||
} else {
|
||||
$resourceConfig[$resourceId]->setData('overflow', Math::sub($amount, $resourceValue));
|
||||
}
|
||||
}
|
||||
return $resourceConfig;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Block_Planet_Shipyard_Queue
|
||||
extends Wootook_Empire_Block_Planet_Builder_QueueAbstract
|
||||
{
|
||||
public function getQueue()
|
||||
{
|
||||
return $this->getPlanet()->getShipyard()->getBuilder();
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->getQueue()->count() == 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Block_Planet_Shipyard_Queue_Item
|
||||
extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract
|
||||
{
|
||||
protected $_itemIdField = 'research_id';
|
||||
|
||||
public function getLevel()
|
||||
{
|
||||
return $this->getPlanet()->getElement($this->getItemId());
|
||||
}
|
||||
|
||||
public function getResourcesNeeded($level)
|
||||
{
|
||||
return $this->getPlanet()->getShipyard()->getResourcesNeeded($this->getItemId(), 1);
|
||||
}
|
||||
|
||||
public function getBuildingTime($qty)
|
||||
{
|
||||
return $this->getPlanet()->getShipyard()->getBuildingTime($this->getItemId(), $qty);
|
||||
}
|
||||
|
||||
public function getResourcesConfigForLevel($qty)
|
||||
{
|
||||
$resources = $this->getResourcesNeeded($qty);
|
||||
|
||||
$resourceConfig = array();
|
||||
foreach ($resources as $resourceId => $resourceValue) {
|
||||
$resourceConfig[$resourceId] = new Wootook_Object(array(
|
||||
'resource_id' => $resourceId,
|
||||
'value' => $resourceValue
|
||||
));
|
||||
|
||||
$amount = $this->getPlanet()->getResourceAmount($resourceId);
|
||||
if (Math::comp($amount, $resourceValue) < 0) {
|
||||
$resourceConfig[$resourceId]->setData('requirement', Math::sub($amount, $resourceValue));
|
||||
} else {
|
||||
$resourceConfig[$resourceId]->setData('overflow', Math::sub($amount, $resourceValue));
|
||||
}
|
||||
}
|
||||
return $resourceConfig;
|
||||
}
|
||||
|
||||
public function getResourcesConfigForNextLevel()
|
||||
{
|
||||
return $this->getResourcesConfigForLevel($this->getNextLevel());
|
||||
}
|
||||
|
||||
public function getBuildingTimeForNextLevel()
|
||||
{
|
||||
return $this->getBuildingTime($this->getNextLevel());
|
||||
}
|
||||
}
|
||||
37
src/application/code/core/Legacies/Empire/Exception.php
Normal file
37
src/application/code/core/Legacies/Empire/Exception.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
|
||||
interface Legacies_Empire_Exception {}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_CristalMine
|
||||
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
|
||||
{
|
||||
public function getProductionRatios($level, $produtionRatio, $planet, $player)
|
||||
{
|
||||
return array(
|
||||
Legacies_Empire::RESOURCE_CRISTAL => 10 + 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),
|
||||
Legacies_Empire::RESOURCE_ENERGY => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_DeuteriumSynthetiser
|
||||
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
|
||||
{
|
||||
public function getProductionRatios($level, $produtionRatio, $planet, $player)
|
||||
{
|
||||
return array(
|
||||
Legacies_Empire::RESOURCE_DEUTERIUM => 10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),
|
||||
Legacies_Empire::RESOURCE_ENERGY => -30 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_FusionReactor
|
||||
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
|
||||
{
|
||||
public function getProductionRatios($level, $produtionRatio, $planet, $player)
|
||||
{
|
||||
return array(
|
||||
Legacies_Empire::RESOURCE_DEUTERIUM => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),
|
||||
Legacies_Empire::RESOURCE_ENERGY => 50 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
|
||||
class Legacies_Empire_Model_Planet_Building_MetalMine
|
||||
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
|
||||
{
|
||||
public function getProductionRatios($level, $produtionRatio, $planet, $player)
|
||||
{
|
||||
return array(
|
||||
Legacies_Empire::RESOURCE_METAL => 20 + 30 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),
|
||||
Legacies_Empire::RESOURCE_ENERGY => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_NaniteFactory
|
||||
implements Wootook_Empire_Model_Planet_BuildingInterface
|
||||
{
|
||||
public static function buildingTimeListener($event)
|
||||
{
|
||||
$planet = $event->getData('planet');
|
||||
|
||||
if (!$planet->getId() || ($level = $planet->getElement(Legacies_Empire::ID_BUILDING_NANITE_FACTORY)) <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$time = $event->getData('time');
|
||||
|
||||
$speedFactor = pow(2, $level);
|
||||
$event->setData('time', $time / $speedFactor);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,272 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Research lab building, manages researches queue on each planet
|
||||
*
|
||||
* @access public
|
||||
* @category Empire
|
||||
* @category Planet
|
||||
* @package Legacies
|
||||
* @subpackage Legacies_Empire
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_ResearchLab
|
||||
implements Wootook_Empire_Model_Planet_BuildingInterface,
|
||||
Wootook_Empire_Model_Planet_QueueInterface
|
||||
{
|
||||
private $_eventPrefix = 'planet.laboratory.';
|
||||
|
||||
/**
|
||||
* Planet instance
|
||||
* @var Legacies_Empire_Model_Planet
|
||||
*/
|
||||
protected $_currentPlanet = null;
|
||||
|
||||
/**
|
||||
* Player instance
|
||||
* @var Woootook_Player_Model_Entity
|
||||
*/
|
||||
protected $_currentPlayer = null;
|
||||
|
||||
/**
|
||||
* construction queue
|
||||
* @var Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
|
||||
*/
|
||||
protected $_builder = null;
|
||||
|
||||
/**
|
||||
* Multiton instances
|
||||
* @var array
|
||||
*/
|
||||
protected static $_instances = array();
|
||||
|
||||
/**
|
||||
* Multiton factory. Retruns the planet's research lab instance or created it if
|
||||
* it doesn't yet exist.
|
||||
*
|
||||
* @param Legacies_Empire_Model_Planet $currentPlanet
|
||||
* @param Woootook_Player_Model_Entity $currentPlayer
|
||||
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
|
||||
*/
|
||||
public static function factory($currentPlanet, $currentPlayer)
|
||||
{
|
||||
if ($currentPlanet->getId()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isset(self::$_instances[$currentPlanet->getId()])) {
|
||||
self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentPlayer);
|
||||
}
|
||||
return self::$_instances[$currentPlanet->getId()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. Used for specific usage, use the factory for standard usage.
|
||||
*
|
||||
* @see Legacies_Empire_Model_Planet_Building_ResearchLab::factory()
|
||||
*
|
||||
* @param Legacies_Empire_Model_Planet $currentPlanet
|
||||
* @param Woootook_Player_Model_Entity $currentPlayer
|
||||
*/
|
||||
public function __construct($currentPlanet, $currentPlayer)
|
||||
{
|
||||
$this->_currentPlanet = $currentPlanet;
|
||||
$this->_currentPlayer = $currentPlayer;
|
||||
|
||||
$this->_builder = new Legacies_Empire_Model_Planet_Building_ResearchLab_Builder($currentPlanet, $currentPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$this->_currentPlanet->save();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append items to build to the construction list
|
||||
*
|
||||
* @param int $researchId
|
||||
* @param int|string $level
|
||||
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
|
||||
*/
|
||||
public function appendQueue($researchId, $level = null, Wootook_Core_DateTime $time = null)
|
||||
{
|
||||
if ($time === null) {
|
||||
$time = new Wootook_Core_DateTime();
|
||||
}
|
||||
|
||||
if ($level === null) {
|
||||
$level = $this->_currentPlayer->getElement($researchId) + 1;
|
||||
}
|
||||
|
||||
// Dispatch event
|
||||
Wootook::dispatchEvent($this->_eventPrefix . 'append-queue.before', array(
|
||||
'research_id' => $researchId,
|
||||
'level' => &$level,
|
||||
'time' => &$time,
|
||||
'laboratory' => $this,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer
|
||||
));
|
||||
|
||||
$this->_builder->appendQueue($researchId, $level, $time);
|
||||
|
||||
// Dispatch event
|
||||
Wootook::dispatchEvent($this->_eventPrefix . 'append-queue.after', array(
|
||||
'research_id' => $researchId,
|
||||
'level' => $level,
|
||||
'time' => $time,
|
||||
'laboratory' => $this,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer
|
||||
));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the contruction queue.
|
||||
*
|
||||
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
|
||||
*/
|
||||
public function updateQueue(Wootook_Core_DateTime $time = null)
|
||||
{
|
||||
if ($time === null) {
|
||||
$time = new Wootook_Core_DateTime();
|
||||
}
|
||||
|
||||
// Dispatch event
|
||||
Wootook::dispatchEvent($this->_eventPrefix . 'update-queue.before', array(
|
||||
'time' => &$time,
|
||||
'laboratory' => $this,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer
|
||||
));
|
||||
|
||||
$this->_builder->updateQueue($time);
|
||||
|
||||
// Dispatch event
|
||||
Wootook::dispatchEvent($this->_eventPrefix . 'update-queue.after', array(
|
||||
'time' => $time,
|
||||
'laboratory' => $this,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer
|
||||
));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the construction queue
|
||||
* @see Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBuilder()
|
||||
{
|
||||
return $this->_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a ship or defense type is actually buildable on the current
|
||||
* planet, depending on the technology and buildings requirements.
|
||||
*
|
||||
* @param int $resourceId
|
||||
* @return bool
|
||||
*/
|
||||
public function checkAvailability($researchId)
|
||||
{
|
||||
try {
|
||||
if (!$this->_builder->checkAvailability($researchId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Dispatch event
|
||||
Wootook::dispatchEvent($this->_eventPrefix . 'check-availability', array(
|
||||
'research_id' => $researchId,
|
||||
'laboratory' => $this,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer
|
||||
));
|
||||
} catch (Legacies_Core_Event_Break $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getResourcesNeeded($researchId, $level)
|
||||
{
|
||||
return $this->_builder->getResourcesNeeded($researchId, $level);
|
||||
}
|
||||
|
||||
public function getResearchTime($researchId, $level)
|
||||
{
|
||||
return $this->_builder->getBuildingTime($researchId, $level);
|
||||
}
|
||||
|
||||
public function getResearchLevelQueued($researchId)
|
||||
{
|
||||
$level = $this->_currentPlayer->getElement($researchId);
|
||||
foreach ($this->_builder as $item) {
|
||||
if ($item->getData('research_id') != $researchId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$level = $item->getData('level');
|
||||
}
|
||||
return $level;
|
||||
}
|
||||
|
||||
public static function planetUpdateListener($eventData)
|
||||
{
|
||||
if (isset($eventData['planet'])) {
|
||||
$planet = $eventData['planet'];
|
||||
|
||||
if ($planet === null || !$planet instanceof Legacies_Empire_Model_Planet || !$planet->getId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$time = null;
|
||||
if (isset($eventData['time'])) {
|
||||
$time = $eventData['time'];
|
||||
}
|
||||
|
||||
$researchLab = $planet->getResearchLab();
|
||||
if ($researchLab !== null) {
|
||||
$researchLab->updateQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,337 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
|
||||
extends Wootook_Empire_Model_BuilderAbstract
|
||||
{
|
||||
const FIELD_SERIALIZED = 'b_tech_id';
|
||||
const FIELD_DATETIME = 'b_tech';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $_maxLength = 0;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->_unserializeQueue($this->_currentPlanet->getData(self::FIELD_SERIALIZED));
|
||||
|
||||
$this->_maxLength = Wootook::getGameConfig('engine/core/lab_queue_size');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*/
|
||||
protected function _initItem(Array $params)
|
||||
{
|
||||
if (!isset($params['technology_id']) || !isset($params['level'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$technologyId = $params['technology_id'];
|
||||
$level = $params['level'];
|
||||
|
||||
if (!isset($params['created_at'])) {
|
||||
$createdAt = new Wootook_Core_DateTime();
|
||||
} else {
|
||||
$createdAt = $params['created_at'];
|
||||
}
|
||||
|
||||
if (!isset($params['started_at'])) {
|
||||
$startedAt = null;
|
||||
} else {
|
||||
$startedAt = $params['started_at'];
|
||||
}
|
||||
|
||||
if (!isset($params['updated_at'])) {
|
||||
$updatedAt = $createdAt;
|
||||
} else {
|
||||
$updatedAt = $params['updated_at'];
|
||||
}
|
||||
|
||||
return new Legacies_Empire_Model_Planet_Building_ResearchLab_Item(array(
|
||||
'technology_id' => $technologyId,
|
||||
'level' => $level,
|
||||
'created_at' => $createdAt,
|
||||
'started_at' => $startedAt,
|
||||
'updated_at' => $updatedAt
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a technology type is actually buildable on the current
|
||||
* planet, depending on the technology and buildings requirements.
|
||||
*
|
||||
* @param int|string $technologyId
|
||||
* @return bool
|
||||
*/
|
||||
public function checkAvailability($technologyId)
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
|
||||
if (!$types->is($technologyId, Legacies_Empire::TYPE_RESEARCH)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::checkAvailability($technologyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time needed to build $level of $technologyId
|
||||
*
|
||||
* @param int|string $technologyId
|
||||
* @param int $level
|
||||
*/
|
||||
public function getBuildingTime($technologyId, $level)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
|
||||
Math::setPrecision(50);
|
||||
$firstLevelTime = $prices[$technologyId][Legacies_Empire::BASE_BUILDING_TIME];
|
||||
$partialLevelTime = Math::mul($firstLevelTime, Math::pow($prices[$technologyId][Legacies_Empire::RESOURCE_MULTIPLIER], $level));
|
||||
$levelTime = Math::sub($partialLevelTime, $firstLevelTime);
|
||||
|
||||
$speedFactor = Wootook::getGameConfig('game/speed/general');
|
||||
if ($speedFactor == null) {
|
||||
$speedFactor = 1;
|
||||
}
|
||||
$baseTime = $levelTime / ($speedFactor * 3600);
|
||||
|
||||
Math::setPrecision();
|
||||
|
||||
$event = Wootook::dispatchEvent('planet.research-lab.technology.building-time', array(
|
||||
'time' => $baseTime,
|
||||
'base_time' => $baseTime,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer,
|
||||
'technology_id' => $technologyId,
|
||||
'level' => $level
|
||||
));
|
||||
|
||||
return $event->getData('time');
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* @see Legacies_Empire_Model_BuilderAbstract::getResourcesNeeded()
|
||||
*/
|
||||
public function getResourcesNeeded($technologyId, $level)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
|
||||
if (!isset($prices[$technologyId])) {
|
||||
return array();
|
||||
}
|
||||
$resourcesNeeded = array();
|
||||
foreach ($resources as $resourceId => $resourceConfig) {
|
||||
if (!isset($prices[$technologyId][$resourceId])) {
|
||||
continue;
|
||||
}
|
||||
if (Math::isPositive($prices[$technologyId][$resourceId])) {
|
||||
$firstLevelCost = $prices[$technologyId][$resourceId];
|
||||
$partialLevelCost = Math::mul($firstLevelCost, Math::pow($prices[$technologyId][Legacies_Empire::RESOURCE_MULTIPLIER], $level));
|
||||
$resourcesNeeded[$resourceId] = Math::sub($partialLevelCost, $firstLevelCost);
|
||||
}
|
||||
}
|
||||
|
||||
return $resourcesNeeded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the contruction queue.
|
||||
*
|
||||
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
|
||||
*/
|
||||
public function updateQueue(Wootook_Core_DateTime $time)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
|
||||
$startingTime = clone $this->_currentPlanet->getData(self::FIELD_DATETIME);
|
||||
|
||||
$elapsedTime = $time->getTimestamp() - $this->_currentPlanet->getData(self::FIELD_DATETIME)->getTimestamp();
|
||||
|
||||
foreach ($this->getQueue() as $element) {
|
||||
$elementTime = $element->getData('started_at');
|
||||
|
||||
if ($elementTime === null) {
|
||||
$element->setData('started_at', $startingTime->getTimestamp());
|
||||
$elementTime = $startingTime->getTimestamp();
|
||||
}
|
||||
|
||||
$level = $element->getData('level');
|
||||
$technologyId = $element->getData('technology_id');
|
||||
$buildTime = $this->getBuildingTime($technologyId, $level);
|
||||
$elapsedTime = $time->getTimestamp() - $elementTime;
|
||||
|
||||
if ($elapsedTime >= $buildTime) {
|
||||
$this->dequeue($element);
|
||||
|
||||
$currentTime = clone $startingTime;
|
||||
$currentTime->add($elapsedTime);
|
||||
|
||||
$this->_currentPlayer->setElement($technologyId, $level);
|
||||
$this->_currentPlanet->updateStorages($currentTime);
|
||||
$this->_currentPlanet->updateResourceProduction($currentTime);
|
||||
$this->_currentPlanet->updateBuildingFields();
|
||||
|
||||
Wootook::dispatchEvent('planet.research-lab.technology.level-update', array(
|
||||
'time' => $currentTime,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer,
|
||||
'technology_id' => $technologyId,
|
||||
'level' => $level
|
||||
));
|
||||
|
||||
$startingTime->set($elementTime + $buildTime);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_currentPlanet->setData(self::FIELD_SERIALIZED, $this->serialize());
|
||||
$this->_currentPlanet->setData(self::FIELD_DATETIME, $startingTime->now());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append items to build to the construction list
|
||||
*
|
||||
* @param int|string $technologyId
|
||||
* @param int $level
|
||||
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
|
||||
*/
|
||||
public function appendQueue($technologyId, $level, Wootook_Core_DateTime $time)
|
||||
{
|
||||
if ($this->_maxLength > 0 && $this->count() >= $this->_maxLength) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
|
||||
if (!Math::isPositive($level)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!$types->is($technologyId, Legacies_Empire::TYPE_RESEARCH)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!$this->checkAvailability($technologyId)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$resourcesNeeded = $this->getResourcesNeeded($technologyId, $level);
|
||||
$remainingAmounts = $this->_calculateResourceRemainingAmounts($resourcesNeeded);
|
||||
if ($remainingAmounts === false) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if ($this->count() == 0) {
|
||||
$this->_currentPlanet->setData(self::FIELD_DATETIME, $time);
|
||||
}
|
||||
|
||||
$this->enqueue(array(
|
||||
'technology_id' => $technologyId,
|
||||
'level' => $level,
|
||||
'created_at' => $time->getTimestamp()
|
||||
));
|
||||
|
||||
$this->_currentPlanet->setData(self::FIELD_SERIALIZED, $this->serialize());
|
||||
$this->_currentPlayer->setdata('b_tech_planet', $this->_currentPlanet->getId());
|
||||
|
||||
foreach ($remainingAmounts as $resourceId => $resourceAmount) {
|
||||
$this->_currentPlanet[$resourceId] = $resourceAmount;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dequeues the first item to build to the construction list and removes all
|
||||
* its successors of the same type.
|
||||
*
|
||||
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
|
||||
*/
|
||||
public function dequeueFirstItem()
|
||||
{
|
||||
$this->rewind();
|
||||
$item = $this->current();
|
||||
|
||||
return $this->dequeueItem($item->getIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Dequeues an item to build to the construction list and removes all its
|
||||
* successors of the same type.
|
||||
*
|
||||
* @param string $itemId
|
||||
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
|
||||
*/
|
||||
public function dequeueItem($itemId)
|
||||
{
|
||||
$item = $this->getItem($itemId);
|
||||
if (!$item) {
|
||||
return $this;
|
||||
}
|
||||
$technologyId = $item->getData('technology_id');
|
||||
|
||||
$keys = array_keys($this->_queue);
|
||||
$size = count($keys);
|
||||
$start = array_search($item->getIndex(), $keys);
|
||||
for ($i = $start; $i < $size; $i++) {
|
||||
$index = $keys[$i];
|
||||
if ($this->_queue[$index]->getData('technology_id') != $technologyId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$resourcesNeeded = $this->getResourcesNeeded($technologyId, $this->_queue[$index]->getData('level'));
|
||||
$reclaimedAmounts = $this->_calculateResourceReclaimedAmounts($resourcesNeeded);
|
||||
|
||||
$this->dequeue($this->_queue[$index]);
|
||||
|
||||
foreach ($reclaimedAmounts as $resourceId => $resourceAmount) {
|
||||
$this->_currentPlanet[$resourceId] = $resourceAmount;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_currentPlanet->setData(self::FIELD_SERIALIZED, $this->serialize());
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_ResearchLab_Item
|
||||
extends Wootook_Empire_Model_Builder_Item
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_RoboticFactory
|
||||
implements Wootook_Empire_Model_Planet_BuildingInterface
|
||||
{
|
||||
public static function buildingTimeListener($event)
|
||||
{
|
||||
$planet = $event->getData('planet');
|
||||
|
||||
if (!$planet->getId() || ($level = $planet->getElement(Legacies_Empire::ID_BUILDING_ROBOTIC_FACTORY)) <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$time = $event->getData('time');
|
||||
|
||||
$speedFactor = 1 + $level;
|
||||
$event->setData('time', $time / $speedFactor);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,275 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Shipyard building, manages ship and defenses building queue on each planet
|
||||
*
|
||||
* @access public
|
||||
* @category Empire
|
||||
* @category Planet
|
||||
* @package Legacies
|
||||
* @subpackage Legacies_Empire
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_Shipyard
|
||||
implements Wootook_Empire_Model_Planet_BuildingInterface,
|
||||
Wootook_Empire_Model_Planet_QueueInterface
|
||||
{
|
||||
private $_eventPrefix = 'planet.shipyard.';
|
||||
|
||||
/**
|
||||
* Planet instance
|
||||
* @var Legacies_Empire_Model_Planet
|
||||
*/
|
||||
protected $_currentPlanet = null;
|
||||
|
||||
/**
|
||||
* Player instance
|
||||
* @var Woootook_Player_Model_Entity
|
||||
*/
|
||||
protected $_currentPlayer = null;
|
||||
|
||||
/**
|
||||
* construction queue
|
||||
* @var array
|
||||
*/
|
||||
protected $_builder = null;
|
||||
|
||||
/**
|
||||
* Resource list
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_resourcesTypes = array(
|
||||
Legacies_Empire::RESOURCE_METAL,
|
||||
Legacies_Empire::RESOURCE_CRISTAL,
|
||||
Legacies_Empire::RESOURCE_DEUTERIUM,
|
||||
Legacies_Empire::RESOURCE_ENERGY
|
||||
);
|
||||
|
||||
/**
|
||||
* Multiton instances
|
||||
* @var array
|
||||
*/
|
||||
protected static $_instances = array();
|
||||
|
||||
/**
|
||||
* Multiton factory. Retruns the planet's shipyard instance or created it if
|
||||
* it doesn't yet exist.
|
||||
*
|
||||
* @param Legacies_Empire_Model_Planet $currentPlanet
|
||||
* @param Woootook_Player_Model_Entity $currentPlayer
|
||||
* @return Legacies_Empire_Model_Planet_Building_Shipyard
|
||||
*/
|
||||
public static function factory($currentPlanet, $currentPlayer)
|
||||
{
|
||||
if ($currentPlanet->getId()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isset(self::$_instances[$currentPlanet->getId()])) {
|
||||
self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentPlayer);
|
||||
}
|
||||
return self::$_instances[$currentPlanet->getId()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. Used for specific usage, use the factory for standard usage.
|
||||
*
|
||||
* @see Legacies_Empire_Model_Planet_Building_Shipyard::factory()
|
||||
*
|
||||
* @param Legacies_Empire_Model_Planet $currentPlanet
|
||||
* @param Woootook_Player_Model_Entity $currentPlayer
|
||||
*/
|
||||
public function __construct($currentPlanet, $currentPlayer)
|
||||
{
|
||||
$this->_currentPlanet = $currentPlanet;
|
||||
$this->_currentPlayer = $currentPlayer;
|
||||
|
||||
$this->_builder = new Legacies_Empire_Model_Planet_Building_Shipyard_Builder($currentPlanet, $currentPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return Legacies_Empire_Model_Planet_Building_Shipyard
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$this->_currentPlanet->save();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append items to build to the construction list
|
||||
*
|
||||
* @param int $shipId
|
||||
* @param int|string $qty
|
||||
* @return Legacies_Empire_Model_Planet_Building_Shipyard
|
||||
*/
|
||||
public function appendQueue($shipId, $qty, Wootook_Core_DateTime $time = null)
|
||||
{
|
||||
if ($time === null) {
|
||||
$time = new Wootook_Core_DateTime();
|
||||
}
|
||||
|
||||
// Dispatch event
|
||||
Wootook::dispatchEvent($this->_eventPrefix . 'append-queue.before', array(
|
||||
'ship_id' => $shipId,
|
||||
'qty' => &$qty,
|
||||
'time' => &$time,
|
||||
'shipyard' => $this,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer
|
||||
));
|
||||
|
||||
$this->_builder->appendQueue($shipId, $qty, $time);
|
||||
|
||||
// Dispatch event
|
||||
Wootook::dispatchEvent($this->_eventPrefix . 'append-queue.before', array(
|
||||
'ship_id' => $shipId,
|
||||
'qty' => $qty,
|
||||
'time' => $time,
|
||||
'shipyard' => $this,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer
|
||||
));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the contruction queue.
|
||||
*
|
||||
* @return Legacies_Empire_Model_Planet_Building_Shipyard
|
||||
*/
|
||||
public function updateQueue(Wootook_Core_DateTime $time = null)
|
||||
{
|
||||
if ($time === null) {
|
||||
$time = new Wootook_Core_DateTime();
|
||||
}
|
||||
|
||||
// Dispatch event
|
||||
Wootook::dispatchEvent($this->_eventPrefix . 'update-queue.before', array(
|
||||
'time' => &$time,
|
||||
'shipyard' => $this,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer
|
||||
));
|
||||
|
||||
$this->_builder->updateQueue($time);
|
||||
|
||||
// Dispatch event
|
||||
Wootook::dispatchEvent($this->_eventPrefix . 'update-queue.after', array(
|
||||
'time' => $time,
|
||||
'shipyard' => $this,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer
|
||||
));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the construction queue
|
||||
* @see Legacies_Empire_Model_Planet_Building_Shipyard_Builder
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBuilder()
|
||||
{
|
||||
return $this->_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a ship or defense type is actually buildable on the current
|
||||
* planet, depending on the technology and buildings requirements.
|
||||
*
|
||||
* @param int $shipId
|
||||
* @return bool
|
||||
*/
|
||||
public function checkAvailability($shipId)
|
||||
{
|
||||
try {
|
||||
// Dispatch event
|
||||
Wootook::dispatchEvent($this->_eventPrefix . 'check-availability', array(
|
||||
'ship_id' => $shipId,
|
||||
'shipyard' => $this,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer
|
||||
));
|
||||
} catch (Legacies_Core_Event_Break $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->_builder->checkAvailability($shipId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum quantity of elements that are possible to build on
|
||||
* the current planet.
|
||||
*
|
||||
* @param int $shipId
|
||||
* @return int|string
|
||||
*/
|
||||
public function getMaximumBuildableElementsCount($shipId)
|
||||
{
|
||||
return $this->_builder->getMaximumBuildableElementsCount($shipId);
|
||||
}
|
||||
|
||||
public function getResourcesNeeded($shipId, $qty)
|
||||
{
|
||||
return $this->_builder->getResourcesNeeded($shipId, $qty);
|
||||
}
|
||||
|
||||
public function getBuildingTime($shipId, $qty)
|
||||
{
|
||||
return $this->_builder->getBuildingTime($shipId, $qty);
|
||||
}
|
||||
|
||||
public static function planetUpdateListener($eventData)
|
||||
{
|
||||
if (isset($eventData['planet'])) {
|
||||
$planet = $eventData['planet'];
|
||||
|
||||
if ($planet === null || !$planet instanceof Legacies_Empire_Model_Planet || !$planet->getId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$time = null;
|
||||
if (isset($eventData['time'])) {
|
||||
$time = $eventData['time'];
|
||||
}
|
||||
|
||||
$shipyard = self::factory($planet, $planet->getPlayer());
|
||||
if ($shipyard !== null) {
|
||||
$shipyard->updateQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,339 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
|
||||
extends Wootook_Empire_Model_BuilderAbstract
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $_maxLength = 0;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->_unserializeQueue($this->_currentPlanet->getData('b_hangar_id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $buildingId
|
||||
* @param int $qty
|
||||
* @param int $time
|
||||
*/
|
||||
protected function _initItem(Array $params)
|
||||
{
|
||||
if (!isset($params['ship_id']) || !isset($params['qty'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$shipId = $params['ship_id'];
|
||||
$qty = $params['qty'];
|
||||
if (!isset($params['created_at'])) {
|
||||
$createdAt = new Wootook_Core_DateTime();
|
||||
} else {
|
||||
$createdAt = $params['created_at'];
|
||||
}
|
||||
if (!isset($params['updated_at'])) {
|
||||
$updatedAt = $createdAt;
|
||||
} else {
|
||||
$updatedAt = $params['updated_at'];
|
||||
}
|
||||
|
||||
return new Legacies_Empire_Model_Planet_Building_Shipyard_Item(array(
|
||||
'ship_id' => $shipId,
|
||||
'qty' => $qty,
|
||||
'created_at' => $createdAt,
|
||||
'updated_at' => $updatedAt
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a ship or defense type is actually buildable on the current
|
||||
* planet, depending on the technology and buildings requirements.
|
||||
*
|
||||
* @param int $shipId
|
||||
* @return bool
|
||||
*/
|
||||
public function checkAvailability($shipId)
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
|
||||
if (!$types->is($shipId, Legacies_Empire::TYPE_SHIP) && !$types->is($shipId, Legacies_Empire::TYPE_DEFENSE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::checkAvailability($shipId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum quantity of elements that are possible to build on
|
||||
* the current planet.
|
||||
*
|
||||
* @param int $shipId
|
||||
* @return int|string
|
||||
*/
|
||||
public function getMaximumBuildableElementsCount($shipId)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
|
||||
$qty = 0;
|
||||
foreach ($resources as $resourceId => $_) {
|
||||
if (isset($prices[$shipId]) && isset($prices[$shipId][$resourceId]) && Math::comp($prices[$shipId][$resourceId], 0) > 0) {
|
||||
$maxQty = Math::floor(Math::div($this->_currentPlanet->getData($resourceId), $prices[$shipId][$resourceId]));
|
||||
|
||||
if ($maxQty == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($qty == 0 || Math::comp($maxQty, $qty) < 0) {
|
||||
$qty = $maxQty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($qty == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$limitedElementsQty = array(
|
||||
Legacies_Empire::ID_DEFENSE_SMALL_SHIELD_DOME => array(
|
||||
'current' => $this->_currentPlanet[$fields[Legacies_Empire::ID_DEFENSE_SMALL_SHIELD_DOME]],
|
||||
'requested' => $this->_currentPlanet[$fields[Legacies_Empire::ID_DEFENSE_SMALL_SHIELD_DOME]],
|
||||
'limit' => 1
|
||||
),
|
||||
Legacies_Empire::ID_DEFENSE_LARGE_SHIELD_DOME => array(
|
||||
'current' => $this->_currentPlanet[$fields[Legacies_Empire::ID_DEFENSE_LARGE_SHIELD_DOME]],
|
||||
'requested' => $this->_currentPlanet[$fields[Legacies_Empire::ID_DEFENSE_LARGE_SHIELD_DOME]],
|
||||
'limit' => 1
|
||||
),
|
||||
Legacies_Empire::ID_SPECIAL_ANTIBALLISTIC_MISSILE => array(
|
||||
'current' => $this->_currentPlanet[$fields[Legacies_Empire::ID_SPECIAL_ANTIBALLISTIC_MISSILE]],
|
||||
'requested' => $this->_currentPlanet[$fields[Legacies_Empire::ID_SPECIAL_ANTIBALLISTIC_MISSILE]],
|
||||
'limit' => $this->_currentPlanet[$fields[Legacies_Empire::ID_BUILDING_MISSILE_SILO]] * 10
|
||||
),
|
||||
Legacies_Empire::ID_SPECIAL_INTERPLANETARY_MISSILE => array(
|
||||
'current' => $this->_currentPlanet[$fields[Legacies_Empire::ID_SPECIAL_INTERPLANETARY_MISSILE]],
|
||||
'requested' => $this->_currentPlanet[$fields[Legacies_Empire::ID_SPECIAL_INTERPLANETARY_MISSILE]],
|
||||
'limit' => $this->_currentPlanet[$fields[Legacies_Empire::ID_BUILDING_MISSILE_SILO]] * 5
|
||||
)
|
||||
);
|
||||
|
||||
if (in_array($shipId, array_keys($limitedElementsQty))) {
|
||||
foreach ($this->getQueue() as $element) {
|
||||
if ($element['ship_id'] != $shipId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$limitedElementsQty[$shipId]['requested'] = Math::add($limitedElementsQty[$shipId]['requested'], $element['qty']);
|
||||
if (Math::comp($limitedElementsQty[$shipId]['requested'], $limitedElementsQty[$shipId]['limit']) >= 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (Math::comp($limitedElementsQty[$shipId]['current'], $limitedElementsQty[$shipId]['limit']) >= 0) {
|
||||
return 0;
|
||||
}
|
||||
if (Math::comp($qty, $limitedElementsQty[$shipId]['limit']) >= 0) {
|
||||
return $limitedElementsQty[$shipId]['limit'];
|
||||
}
|
||||
}
|
||||
|
||||
return $qty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time needed to build $qty of $shipId
|
||||
*
|
||||
* @param int $shipId
|
||||
* @param int $qty
|
||||
*/
|
||||
public function getBuildingTime($shipId, $qty)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
|
||||
Math::setPrecision(50);
|
||||
$buildingTime = Math::mul($prices[$shipId][Legacies_Empire::BASE_BUILDING_TIME], $qty);
|
||||
|
||||
$speedFactor = Wootook::getGameConfig('game/speed/general');
|
||||
$baseTime = Math::div($buildingTime, $speedFactor);
|
||||
|
||||
Math::setPrecision();
|
||||
|
||||
$event = Wootook::dispatchEvent('planet.shipyard.building-time', array(
|
||||
'time' => $baseTime,
|
||||
'base_time' => $baseTime,
|
||||
'planet' => $this->_currentPlanet,
|
||||
'player' => $this->_currentPlayer,
|
||||
'ship_id' => $shipId,
|
||||
'qty' => $qty
|
||||
));
|
||||
|
||||
return $event->getData('time');
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* @see Legacies_Empire_Model_BuilderAbstract::getResourcesNeeded()
|
||||
*/
|
||||
public function getResourcesNeeded($shipId, $qty)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
|
||||
if (!isset($prices[$shipId])) {
|
||||
return array();
|
||||
}
|
||||
$resourcesNeeded = array();
|
||||
foreach ($resources as $resourceId => $resourceConfig) {
|
||||
if (!isset($prices[$shipId][$resourceId])) {
|
||||
continue;
|
||||
}
|
||||
if (Math::isPositive($prices[$shipId][$resourceId])) {
|
||||
$resourcesNeeded[$resourceId] = Math::mul($prices[$shipId][$resourceId], $qty);
|
||||
}
|
||||
}
|
||||
|
||||
return $resourcesNeeded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity set in parameter or the maximum buildable elements
|
||||
* if the quantity requested exeeds this number.
|
||||
*
|
||||
* @param int $shipId
|
||||
* @param int|string $qty
|
||||
* @return int|stirng
|
||||
*/
|
||||
protected function _checkMaximumQuantity($shipId, $qty)
|
||||
{
|
||||
return Math::min($qty, $this->getMaximumBuildableElementsCount($shipId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the contruction queue.
|
||||
*
|
||||
* @return Legacies_Empire_Model_Planet_Building_Shipyard
|
||||
*/
|
||||
public function updateQueue(Wootook_Core_DateTime $time)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
|
||||
$elapsedTime = $time->getTimestamp() - $this->_currentPlanet->getData('b_hangar')->getTimestamp();
|
||||
|
||||
foreach ($this->getQueue() as $element) {
|
||||
$shipId = $element->getData('ship_id');
|
||||
$qty = $element->getData('qty');
|
||||
$buildTime = $this->getBuildingTime($shipId, $qty);
|
||||
|
||||
if ($elapsedTime >= $buildTime) {
|
||||
$this->_currentPlanet[$fields[$shipId]] = Math::add($this->_currentPlanet[$fields[$shipId]], $qty);
|
||||
$elapsedTime -= $buildTime;
|
||||
$this->dequeue($element);
|
||||
continue;
|
||||
}
|
||||
|
||||
$timeRatio = $elapsedTime / $buildTime;
|
||||
$itemsBuilt = Math::mul($timeRatio, $qty);
|
||||
|
||||
$element->setData('updated_at', $time->getTimestamp());
|
||||
$element->setData('qty', Math::sub($qty, $itemsBuilt));
|
||||
$this->_currentPlanet->setData($fields[$shipId], Math::add($this->_currentPlanet->getData($fields[$shipId]), $itemsBuilt));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_currentPlanet->setData('b_hangar_id', $this->serialize());
|
||||
$this->_currentPlanet->setData('b_hangar', $time);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append items to build to the construction list
|
||||
*
|
||||
* @param int $shipId
|
||||
* @param int|string $qty
|
||||
* @return Legacies_Empire_Model_Planet_Building_Shipyard
|
||||
*/
|
||||
public function appendQueue($shipId, $qty, Wootook_Core_DateTime $time)
|
||||
{
|
||||
if ($this->_maxLength > 0 && $this->count() >= $this->_maxLength) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!Math::isPositive($qty)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
if (!$types->is($shipId, Legacies_Empire::TYPE_SHIP) && !$types->is($shipId, Legacies_Empire::TYPE_DEFENSE)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!$this->checkAvailability($shipId)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (MAX_FLEET_OR_DEFS_PER_ROW > 0) {
|
||||
$qty = Math::min($this->_checkMaximumQuantity($shipId, $qty), MAX_FLEET_OR_DEFS_PER_ROW);
|
||||
} else {
|
||||
$qty = $this->_checkMaximumQuantity($shipId, $qty);
|
||||
}
|
||||
|
||||
if (!Math::isPositive($qty)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$resourcesNeeded = $this->getResourcesNeeded($shipId, $qty);
|
||||
$remainingAmounts = $this->_calculateResourceRemainingAmounts($resourcesNeeded);
|
||||
if ($remainingAmounts === false) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->enqueue(array(
|
||||
'ship_id' => $shipId,
|
||||
'qty' => $qty,
|
||||
'created_at' => $time->getTimestamp(),
|
||||
'updated_at' => $time->getTimestamp()
|
||||
));
|
||||
$this->_currentPlanet->setData('b_hangar_id', $this->serialize());
|
||||
|
||||
foreach ($remainingAmounts as $resourceId => $resourceAmount) {
|
||||
$this->_currentPlanet[$resourceId] = $resourceAmount;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Building_Shipyard_Item
|
||||
extends Wootook_Empire_Model_Builder_Item
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
class Legacies_Empire_Model_Planet_Building_SolarPlant
|
||||
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
|
||||
{
|
||||
public function getProductionRatios($level, $produtionRatio, $planet, $player)
|
||||
{
|
||||
return array(
|
||||
Legacies_Empire::RESOURCE_ENERGY => 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
|
||||
class Legacies_Empire_Model_Planet_Ship_LargeTransport
|
||||
extends Wootook_Empire_Model_Planet_ShipAbstract
|
||||
{
|
||||
const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE = 4;
|
||||
|
||||
public function getBaseSpeed(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
|
||||
return $prices[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY];
|
||||
}
|
||||
|
||||
public function getSpeedMultiplier(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
return pow(1.1, $player->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
|
||||
class Legacies_Empire_Model_Planet_Ship_LightTransport
|
||||
extends Wootook_Empire_Model_Planet_ShipAbstract
|
||||
{
|
||||
const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE = 4;
|
||||
|
||||
public function getBaseSpeed(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
|
||||
if ($player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE) {
|
||||
return $prices[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY];
|
||||
} else {
|
||||
return $prices[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_SECONDARY];
|
||||
}
|
||||
}
|
||||
|
||||
public function getSpeedMultiplier(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
if ($player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE) {
|
||||
return pow(1.1, $player->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE));
|
||||
} else {
|
||||
return pow(1.2, $player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Ship_SolarSatellite
|
||||
extends Wootook_Empire_Model_Planet_ShipAbstract
|
||||
implements Wootook_Empire_Model_Planet_ResourceProductionInterface
|
||||
{
|
||||
public function getProductionRatios($quantity, $produtionRatio, $planet, $player)
|
||||
{
|
||||
return array(
|
||||
Legacies_Empire::RESOURCE_ENERGY => ((floatval($planet->getData('temp_max')) / 4) + 20) * (0.1 * $produtionRatio) * floatval($quantity)
|
||||
);
|
||||
}
|
||||
|
||||
public function getBaseSpeed(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getSpeedMultiplier(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getActualSpeed(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBaseConsumption(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Legacies_Empire_Model_Planet_Ship_Supernova
|
||||
extends Wootook_Empire_Model_Planet_ShipAbstract
|
||||
implements Wootook_Empire_Model_Planet_ResourceProductionInterface
|
||||
{
|
||||
const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE = 20;
|
||||
const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY = 15;
|
||||
|
||||
public function getProductionRatios($quantity, $produtionRatio, $planet, $player)
|
||||
{
|
||||
return array(
|
||||
Legacies_Empire::RESOURCE_ENERGY => ((floatval($planet->getData('temp_max')) / 4) + 20) * (0.1 * $produtionRatio) * floatval($quantity) * -1250
|
||||
);
|
||||
}
|
||||
|
||||
public function getBaseSpeed(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
|
||||
if ($player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE &&
|
||||
$player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY) {
|
||||
return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_PRIMARY];
|
||||
} else {
|
||||
return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_SECONDARY];
|
||||
}
|
||||
}
|
||||
|
||||
public function getSpeedMultiplier(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
if ($player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE &&
|
||||
$player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY) {
|
||||
return pow(1.2, $player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE));
|
||||
} else {
|
||||
return pow(1.3, $player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE)) *
|
||||
pow(1.1, $player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY));
|
||||
}
|
||||
}
|
||||
|
||||
public function getBaseConsumption(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,853 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
$this->setSetupConnection('core_setup');
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('aks')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(50) NULL,
|
||||
`teilnehmer` TEXT NULL,
|
||||
`flotten` TEXT NULL,
|
||||
`ankunft` INT UNSIGNED NULL,
|
||||
`galaxy` TINYINT UNSIGNED NULL,
|
||||
`system` SMALLINT UNSIGNED NULL,
|
||||
`planet` TINYINT UNSIGNED NULL,
|
||||
`eingeladen` INT UNSIGNED NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('alliance')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`ally_name` VARCHAR(32) NOT NULL,
|
||||
`ally_tag` VARCHAR(8) NOT NULL,
|
||||
`ally_owner` BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`ally_register_time` TIMESTAMP NOT NULL,
|
||||
`ally_description` TEXT NULL,
|
||||
`ally_web` VARCHAR(255) NULL,
|
||||
`ally_text` TEXT NULL,
|
||||
`ally_image` VARCHAR(255) NULL,
|
||||
`ally_request` TEXT NULL,
|
||||
`ally_request_waiting` TEXT NULL,
|
||||
`ally_request_notallow` BOOL NOT NULL DEFAULT FALSE,
|
||||
`ally_owner_range` VARCHAR(32) NULL,
|
||||
`ally_ranks` TEXT NULL,
|
||||
`ally_members` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('annonce')} (
|
||||
`id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`user` TEXT NOT NULL,
|
||||
`galaxie` TINYINT UNSIGNED NOT NULL,
|
||||
`systeme` SMALLINT UNSIGNED NOT NULL,
|
||||
`metala` DECIMAL(65,0) NOT NULL,
|
||||
`cristala` DECIMAL(65,0) NOT NULL,
|
||||
`deuta` DECIMAL(65,0) NOT NULL,
|
||||
`metals` DECIMAL(65,0) NOT NULL,
|
||||
`cristals` DECIMAL(65,0) NOT NULL,
|
||||
`deuts` DECIMAL(65,0) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('banned')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`who` BIGINT UNSIGNED NOT NULL,
|
||||
`theme` TEXT NOT NULL,
|
||||
`who2` BIGINT UNSIGNED NOT NULL,
|
||||
`time` TIMESTAMP NOT NULL,
|
||||
`longer` INT UNSIGNED NOT NULL DEFAULT 3600,
|
||||
`author` BIGINT UNSIGNED NOT NULL,
|
||||
`email` VARCHAR(100) NOT NULL,
|
||||
KEY `ID` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('buddy')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`sender` BIGINT UNSIGNED NOT NULL,
|
||||
`owner` BIGINT UNSIGNED NOT NULL,
|
||||
`active` BOOL NOT NULL DEFAULT TRUE,
|
||||
`text` TEXT,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('chat')} (
|
||||
`messageid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`user` VARCHAR(255) NOT NULL,
|
||||
`message` TEXT NOT NULL,
|
||||
`timestamp` TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (`messageid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('declared')} (
|
||||
`declarator` TEXT NOT NULL,
|
||||
`declared_1` TEXT NOT NULL,
|
||||
`declared_2` TEXT NOT NULL,
|
||||
`declared_3` TEXT NOT NULL,
|
||||
`reason` TEXT NOT NULL,
|
||||
`declarator_name` TEXT NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('fleets')} (
|
||||
`fleet_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`fleet_owner` BIGINT UNSIGNED NOT NULL,
|
||||
`fleet_mission` TINYINT UNSIGNED NOT NULL,
|
||||
`fleet_amount` DECIMAL(65,0) NOT NULL,
|
||||
`fleet_array` TEXT NULL,
|
||||
`fleet_start_time` TIMESTAMP NOT NULL,
|
||||
`fleet_start_galaxy` TINYINT UNSIGNED NOT NULL,
|
||||
`fleet_start_system` SMALLINT UNSIGNED NOT NULL,
|
||||
`fleet_start_planet` TINYINT UNSIGNED NOT NULL,
|
||||
`fleet_start_type` TINYINT UNSIGNED NOT NULL,
|
||||
`fleet_end_time` TIMESTAMP NOT NULL,
|
||||
`fleet_end_stay` TIMESTAMP NOT NULL,
|
||||
`fleet_end_galaxy` TINYINT UNSIGNED NOT NULL,
|
||||
`fleet_end_system` SMALLINT UNSIGNED NOT NULL,
|
||||
`fleet_end_planet` TINYINT UNSIGNED NOT NULL,
|
||||
`fleet_end_type` TINYINT UNSIGNED NOT NULL,
|
||||
`fleet_taget_owner` BIGINT UNSIGNED NOT NULL,
|
||||
`fleet_resource_metal` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`fleet_resource_crystal` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`fleet_resource_deuterium` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`fleet_target_owner` BIGINT UNSIGNED NOT NULL,
|
||||
`fleet_group` BIGINT UNSIGNED NOT NULL,
|
||||
`fleet_mess` BIGINT UNSIGNED NOT NULL,
|
||||
`start_time` INT,
|
||||
PRIMARY KEY (`fleet_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('galaxy')} (
|
||||
`galaxy` SMALLINT UNSIGNED NOT NULL,
|
||||
`system` SMALLINT UNSIGNED NOT NULL,
|
||||
`planet` TINYINT UNSIGNED NOT NULL,
|
||||
`id_planet` BIGINT UNSIGNED NOT NULL,
|
||||
`metal` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`crystal` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`id_luna` BIGINT UNSIGNED NULL,
|
||||
`luna` BOOL NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY (`galaxy`, `system`, `planet`),
|
||||
KEY `galaxy` (`galaxy`),
|
||||
KEY `system` (`system`),
|
||||
KEY `planet` (`planet`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('iraks')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`zeit` TIMESTAMP NOT NULL,
|
||||
`galaxy` TINYINT UNSIGNED NOT NULL,
|
||||
`system` SMALLINT UNSIGNED NOT NULL,
|
||||
`planet` TINYINT UNSIGNED NOT NULL,
|
||||
`galaxy_angreifer` TINYINT UNSIGNED NOT NULL,
|
||||
`system_angreifer` SMALLINT UNSIGNED NOT NULL,
|
||||
`planet_angreifer` TINYINT UNSIGNED NOT NULL,
|
||||
`owner` BIGINT UNSIGNED NOT NULL,
|
||||
`zielid` BIGINT UNSIGNED NOT NULL,
|
||||
`anzahl` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`primaer` SMALLINT UNSIGNED,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('lunas')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_luna` BIGINT UNSIGNED NOT NULL,
|
||||
`name` VARCHAR(100) NOT NULL DEFAULT 'Lune',
|
||||
`image` VARCHAR(50) NOT NULL DEFAULT 'mond',
|
||||
`destruyed` BOOL NOT NULL DEFAULT FALSE,
|
||||
`id_owner` BIGINT UNSIGNED NOT NULL,
|
||||
`galaxy` TINYINT UNSIGNED NOT NULL,
|
||||
`system` SMALLINT UNSIGNED NOT NULL,
|
||||
`lunapos` TINYINT UNSIGNED NOT NULL,
|
||||
`temp_min` TINYINT NOT NULL DEFAULT 0,
|
||||
`temp_max` TINYINT NOT NULL DEFAULT 0,
|
||||
`diameter` INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('messages')} (
|
||||
`message_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`message_owner` BIGINT UNSIGNED NOT NULL,
|
||||
`message_sender` BIGINT UNSIGNED NOT NULL,
|
||||
`message_time` TIMESTAMP NOT NULL,
|
||||
`message_type` TINYINT UNSIGNED NOT NULL,
|
||||
`message_from` VARCHAR(50),
|
||||
`message_subject` VARCHAR(150),
|
||||
`message_text` TEXT,
|
||||
PRIMARY KEY (`message_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('multi')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`player` BIGINT UNSIGNED NOT NULL,
|
||||
`sharer` BIGINT UNSIGNED NOT NULL,
|
||||
`reason` TEXT NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('notes')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`owner` BIGINT UNSIGNED NOT NULL,
|
||||
`time` TIMESTAMP NOT NULL,
|
||||
`priority` TINYINT UNSIGNED NOT NULL,
|
||||
`title` VARCHAR(32) NOT NULL,
|
||||
`TEXT` TEXT NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('planets')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(100) NOT NULL,
|
||||
`id_owner` BIGINT UNSIGNED NOT NULL,
|
||||
`id_level` TINYINT UNSIGNED NOT NULL,
|
||||
`galaxy` TINYINT UNSIGNED NOT NULL,
|
||||
`system` SMALLINT UNSIGNED NOT NULL,
|
||||
`planet` TINYINT UNSIGNED NOT NULL,
|
||||
`last_update` DATETIME NOT NULL,
|
||||
`planet_type` TINYINT UNSIGNED NOT NULL,
|
||||
`destruyed` BOOL NOT NULL DEFAULT FALSE,
|
||||
`b_building` INT UNSIGNED NOT NULL,
|
||||
`b_building_id` TEXT NOT NULL,
|
||||
`b_tech` INT UNSIGNED NOT NULL,
|
||||
`b_tech_id` SMALLINT UNSIGNED NOT NULL,
|
||||
`b_hangar` INT UNSIGNED NOT NULL,
|
||||
`b_hangar_id` TEXT NOT NULL,
|
||||
`b_hangar_plus` SMALLINT UNSIGNED NOT NULL,
|
||||
`image` VARCHAR(50) NOT NULL DEFAULT 'normaltempplanet01',
|
||||
`diameter` INT UNSIGNED NOT NULL DEFAULT 12800,
|
||||
`points` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`ranks` BIGINT UNSIGNED NOT NULL,
|
||||
`field_current` INT UNSIGNED NOT NULL DEFAULT 163,
|
||||
`field_max` INT UNSIGNED NOT NULL DEFAULT 163,
|
||||
`temp_min` INT NOT NULL DEFAULT 0,
|
||||
`temp_max` INT NOT NULL DEFAULT 0,
|
||||
`metal` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`metal_perhour` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`metal_max` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`cristal` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`cristal_perhour` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`cristal_max` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`deuterium` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`deuterium_perhour` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`deuterium_max` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`energy_used` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`energy_max` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`metal_mine` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`cristal_mine` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`deuterium_sintetizer` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`solar_plant` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`fusion_plant` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`robot_factory` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`nano_factory` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`hangar` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`metal_store` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`cristal_store` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`deuterium_store` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`laboratory` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`terraformer` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`ally_deposit` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`silo` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`mondbasis` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`phalanx` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`sprungtor` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`small_ship_cargo` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`big_ship_cargo` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`light_hunter` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`heavy_hunter` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`crusher` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`battle_ship` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`colonizer` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`recycler` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`spy_sonde` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`bomber_ship` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`solar_satelit` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`destructor` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`dearth_star` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`battleship` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`misil_launcher` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`small_laser` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`big_laser` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`gauss_canyon` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`ionic_canyon` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`buster_canyon` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`small_protection_shield` ENUM('0','1') NOT NULL DEFAULT 0,
|
||||
`big_protection_shield` ENUM('0','1') NOT NULL DEFAULT 0,
|
||||
`interceptor_misil` SMALLINT NOT NULL DEFAULT 0,
|
||||
`interplanetary_misil` SMALLINT NOT NULL DEFAULT 0,
|
||||
`metal_mine_porcent` TINYINT NOT NULL DEFAULT 10,
|
||||
`cristal_mine_porcent` TINYINT NOT NULL DEFAULT 10,
|
||||
`deuterium_sintetizer_porcent` TINYINT NOT NULL DEFAULT 10,
|
||||
`solar_plant_porcent` TINYINT NOT NULL DEFAULT 10,
|
||||
`fusion_plant_porcent` TINYINT NOT NULL DEFAULT 10,
|
||||
`solar_satelit_porcent` TINYINT NOT NULL DEFAULT 10,
|
||||
`last_jump_time` TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('rw')} (
|
||||
`id_owner1` BIGINT UNSIGNED NOT NULL,
|
||||
`id_owner2` BIGINT UNSIGNED NOT NULL,
|
||||
`rid` VARCHAR(72) NOT NULL,
|
||||
`raport` LONGTEXT NOT NULL,
|
||||
`a_zestrzelona` TINYINT UNSIGNED NOT NULL,
|
||||
`time` TIMESTAMP NOT NULL,
|
||||
KEY (`rid`),
|
||||
UNIQUE KEY `id_owner1` (`id_owner1`,`rid`),
|
||||
UNIQUE KEY `id_owner2` (`id_owner2`,`rid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('statpoints')} (
|
||||
`id_owner` BIGINT UNSIGNED NOT NULL,
|
||||
`id_ally` BIGINT UNSIGNED NOT NULL,
|
||||
`stat_type` TINYINT UNSIGNED NOT NULL,
|
||||
`stat_code` TINYINT UNSIGNED NOT NULL,
|
||||
`tech_rank` BIGINT UNSIGNED NOT NULL,
|
||||
`tech_old_rank` BIGINT UNSIGNED NOT NULL,
|
||||
`tech_points` DECIMAL(65,0) NOT NULL,
|
||||
`tech_count` BIGINT UNSIGNED NOT NULL,
|
||||
`build_rank` BIGINT UNSIGNED NOT NULL,
|
||||
`build_old_rank` BIGINT UNSIGNED NOT NULL,
|
||||
`build_points` DECIMAL(65,0) NOT NULL,
|
||||
`build_count` BIGINT UNSIGNED NOT NULL,
|
||||
`defs_rank` BIGINT UNSIGNED NOT NULL,
|
||||
`defs_old_rank` BIGINT UNSIGNED NOT NULL,
|
||||
`defs_points` DECIMAL(65,0) NOT NULL,
|
||||
`defs_count` BIGINT UNSIGNED NOT NULL,
|
||||
`fleet_rank` BIGINT UNSIGNED NOT NULL,
|
||||
`fleet_old_rank` BIGINT UNSIGNED NOT NULL,
|
||||
`fleet_points` DECIMAL(65,0) NOT NULL,
|
||||
`fleet_count` BIGINT UNSIGNED NOT NULL,
|
||||
`total_rank` BIGINT UNSIGNED NOT NULL,
|
||||
`total_old_rank` BIGINT UNSIGNED NOT NULL,
|
||||
`total_points` DECIMAL(65,0) NOT NULL,
|
||||
`total_count` BIGINT UNSIGNED NOT NULL,
|
||||
`stat_date` TIMESTAMP NOT NULL,
|
||||
KEY (`tech_points`),
|
||||
KEY (`build_points`),
|
||||
KEY (`defs_points`),
|
||||
KEY (`fleet_points`),
|
||||
KEY (`total_points`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('users')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`username` VARCHAR(100) NOT NULL, -- FIXME
|
||||
`password` VARCHAR(64) NOT NULL, -- FIXME
|
||||
`email` VARCHAR(200) NOT NULL, -- FIXME
|
||||
`email_2` VARCHAR(200) NOT NULL, -- FIXME
|
||||
`lang` VARCHAR(3) NOT NULL DEFAULT 'fr',
|
||||
`authlevel` TINYINT UNSIGNED NOT NULL DEFAULT 0, -- FIXME
|
||||
`sex` ENUM('M','F') NULL DEFAULT NULL,
|
||||
`avatar` VARCHAR(255) NULL DEFAULT NULL,
|
||||
`sign` TEXT NULL,
|
||||
`id_planet` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
`galaxy` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`system` SMALLINT UNSIGNED NOT NULL, -- FIXME
|
||||
`planet` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`current_planet` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
`user_lastip` VARCHAR(16) NOT NULL, -- FIXME
|
||||
`ip_at_reg` VARCHAR(16) NOT NULL, -- FIXME
|
||||
`user_agent` TEXT NOT NULL, -- FIXME
|
||||
`current_page` TEXT NOT NULL, -- FIXME
|
||||
`register_time` TIMESTAMP NOT NULL, -- FIXME
|
||||
`onlinetime` TIMESTAMP NOT NULL, -- FIXME
|
||||
`dpath` VARCHAR(255) NOT NULL, -- FIXME
|
||||
`design` TINYINT NOT NULL DEFAULT 1, -- FIXME
|
||||
`noipcheck` BOOL NOT NULL DEFAULT TRUE, -- FIXME
|
||||
`planet_sort` TINYINT NOT NULL DEFAULT 0, -- FIXME
|
||||
`planet_sort_order` TINYINT NOT NULL DEFAULT 0, -- FIXME
|
||||
`spio_anz` TINYINT UNSIGNED NOT NULL DEFAULT 1, -- FIXME
|
||||
`settings_tooltiptime` TINYINT UNSIGNED NOT NULL DEFAULT 5, -- FIXME
|
||||
`settings_fleetactions` TINYINT UNSIGNED NOT NULL DEFAULT 0, -- FIXME
|
||||
`settings_allylogo` TINYINT UNSIGNED NOT NULL DEFAULT 0, -- FIXME
|
||||
`settings_esp` TINYINT UNSIGNED NOT NULL DEFAULT 1, -- FIXME
|
||||
`settings_wri` TINYINT UNSIGNED NOT NULL DEFAULT 1, -- FIXME
|
||||
`settings_bud` TINYINT UNSIGNED NOT NULL DEFAULT 1, -- FIXME
|
||||
`settings_mis` TINYINT UNSIGNED NOT NULL DEFAULT 1, -- FIXME
|
||||
`settings_rep` TINYINT UNSIGNED NOT NULL DEFAULT 0, -- FIXME
|
||||
`urlaubs_modus` TINYINT UNSIGNED NOT NULL DEFAULT 0, -- FIXME
|
||||
`urlaubs_until` TIMESTAMP NOT NULL, -- FIXME
|
||||
`db_deaktjava` BOOL NOT NULL DEFAULT FALSE, -- FIXME
|
||||
`new_message` TINYINT UNSIGNED NOT NULL DEFAULT 0, -- FIXME
|
||||
`fleet_shortcut` TEXT NULL,
|
||||
`b_tech_planet` INT NOT NULL, -- FIXME
|
||||
`spy_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`computer_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`military_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`defence_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`shield_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`energy_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`hyperspace_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`combustion_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`impulse_motor_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`hyperspace_motor_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`laser_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`ionic_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`buster_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`intergalactic_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`expedition_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`graviton_tech` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`ally_id` BIGINT UNSIGNED NOT NULL,
|
||||
`ally_name` VARCHAR(32) NULL, -- FIXME
|
||||
`ally_request` BOOL NOT NULL DEFAULT FALSE, -- FIXME
|
||||
`ally_request_text` TEXT NULL, -- FIXME
|
||||
`ally_register_time` TIMESTAMP NOT NULL, -- FIXME
|
||||
`ally_rank_id` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
`current_luna` INT NOT NULL, -- FIXME
|
||||
`kolorminus` VARCHAR(11) NOT NULL DEFAULT 'red',
|
||||
`kolorplus` VARCHAR(11) NOT NULL DEFAULT '#00FF00',
|
||||
`kolorpoziom` VARCHAR(11) NOT NULL DEFAULT 'yellow',
|
||||
`rpg_geologue` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_amiral` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_ingenieur` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_technocrate` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_espion` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_constructeur` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_scientifique` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_commandant` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_points` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_stockeur` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_defenseur` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_destructeur` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_general` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_bunker` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_raideur` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`rpg_empereur` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`lvl_minier` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
`lvl_raid` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
`xpraid` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
`xpminier` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
`raids` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
`p_infligees` DECIMAL(65,0) NOT NULL, -- FIXME
|
||||
`mnl_alliance` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`mnl_joueur` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`mnl_attaque` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`mnl_spy` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`mnl_exploit` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`mnl_transport` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`mnl_expedition` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`mnl_general` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`mnl_buildlist` TINYINT UNSIGNED NOT NULL, -- FIXME
|
||||
`bana` BOOL NOT NULL DEFAULT FALSE, -- FIXME
|
||||
`multi_validated` BOOL NOT NULL DEFAULT FALSE, -- FIXME
|
||||
`banaday` TIMESTAMP NULL DEFAULT NULL, -- FIXME
|
||||
`raids1` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
`raidswin` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
`raidsloose` BIGINT UNSIGNED NOT NULL, -- FIXME
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY (`username`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
/*
|
||||
* Galaxy positions generation
|
||||
*/
|
||||
$galaxyCount = Wootook::getConfig('engine/universe/galaxies');
|
||||
$systemCount = Wootook::getConfig('engine/universe/systems');
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT INTO {$this->getTableName('galaxy')}
|
||||
(`galaxy`, `system`, `planet`, `id_planet`, `metal`, `crystal`, `id_luna`, `luna`)
|
||||
SELECT
|
||||
_increment.galaxy AS `galaxy`,
|
||||
_increment.system AS `system`,
|
||||
0 AS `planet`,
|
||||
0 AS `id_planet`,
|
||||
0 AS `metal`,
|
||||
0 AS `crystal`,
|
||||
0 AS `id_luna`,
|
||||
0 AS `luna`
|
||||
FROM (
|
||||
SELECT
|
||||
(1 + _galaxy_10e0.galaxy + _galaxy_10e1.galaxy + _galaxy_10e2.galaxy + _galaxy_10e3.galaxy + _galaxy_10e4.galaxy) AS galaxy,
|
||||
(1 + _system_10e0.system + _system_10e1.system + _system_10e2.system + _system_10e3.system + _system_10e4.system) AS system
|
||||
FROM (
|
||||
SELECT 0 AS system
|
||||
UNION ALL
|
||||
SELECT 1 AS system
|
||||
UNION ALL
|
||||
SELECT 2 AS system
|
||||
UNION ALL
|
||||
SELECT 3 AS system
|
||||
UNION ALL
|
||||
SELECT 4 AS system
|
||||
UNION ALL
|
||||
SELECT 5 AS system
|
||||
UNION ALL
|
||||
SELECT 6 AS system
|
||||
UNION ALL
|
||||
SELECT 7 AS system
|
||||
UNION ALL
|
||||
SELECT 8 AS system
|
||||
UNION ALL
|
||||
SELECT 9 AS system
|
||||
) AS _system_10e0
|
||||
SQL_EOF;
|
||||
|
||||
if ($systemCount > 10) {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (
|
||||
SELECT 0 AS system
|
||||
UNION ALL
|
||||
SELECT 10 AS system
|
||||
UNION ALL
|
||||
SELECT 20 AS system
|
||||
UNION ALL
|
||||
SELECT 30 AS system
|
||||
UNION ALL
|
||||
SELECT 40 AS system
|
||||
UNION ALL
|
||||
SELECT 50 AS system
|
||||
UNION ALL
|
||||
SELECT 60 AS system
|
||||
UNION ALL
|
||||
SELECT 70 AS system
|
||||
UNION ALL
|
||||
SELECT 80 AS system
|
||||
UNION ALL
|
||||
SELECT 90 AS system
|
||||
) AS _system_10e1
|
||||
SQL_EOF;
|
||||
} else {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (SELECT 0 AS system) AS _system_10e1
|
||||
SQL_EOF;
|
||||
}
|
||||
|
||||
if ($systemCount > 100) {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (
|
||||
SELECT 0 AS system
|
||||
UNION ALL
|
||||
SELECT 100 AS system
|
||||
UNION ALL
|
||||
SELECT 200 AS system
|
||||
UNION ALL
|
||||
SELECT 300 AS system
|
||||
UNION ALL
|
||||
SELECT 400 AS system
|
||||
UNION ALL
|
||||
SELECT 500 AS system
|
||||
UNION ALL
|
||||
SELECT 600 AS system
|
||||
UNION ALL
|
||||
SELECT 700 AS system
|
||||
UNION ALL
|
||||
SELECT 800 AS system
|
||||
UNION ALL
|
||||
SELECT 900 AS system
|
||||
) AS _system_10e2
|
||||
SQL_EOF;
|
||||
} else {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (SELECT 0 AS system) AS _system_10e2
|
||||
SQL_EOF;
|
||||
}
|
||||
|
||||
if ($systemCount > 1000) {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (
|
||||
SELECT 0 AS system
|
||||
UNION ALL
|
||||
SELECT 1000 AS system
|
||||
UNION ALL
|
||||
SELECT 2000 AS system
|
||||
UNION ALL
|
||||
SELECT 3000 AS system
|
||||
UNION ALL
|
||||
SELECT 4000 AS system
|
||||
UNION ALL
|
||||
SELECT 5000 AS system
|
||||
UNION ALL
|
||||
SELECT 6000 AS system
|
||||
UNION ALL
|
||||
SELECT 7000 AS system
|
||||
UNION ALL
|
||||
SELECT 8000 AS system
|
||||
UNION ALL
|
||||
SELECT 9000 AS system
|
||||
) AS _system_10e3
|
||||
SQL_EOF;
|
||||
} else {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (SELECT 0 AS system) AS _system_10e3
|
||||
SQL_EOF;
|
||||
}
|
||||
|
||||
if ($systemCount > 10000) {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (
|
||||
SELECT 0 AS system
|
||||
UNION ALL
|
||||
SELECT 10000 AS system
|
||||
UNION ALL
|
||||
SELECT 20000 AS system
|
||||
UNION ALL
|
||||
SELECT 30000 AS system
|
||||
UNION ALL
|
||||
SELECT 40000 AS system
|
||||
UNION ALL
|
||||
SELECT 50000 AS system
|
||||
UNION ALL
|
||||
SELECT 60000 AS system
|
||||
UNION ALL
|
||||
SELECT 70000 AS system
|
||||
UNION ALL
|
||||
SELECT 80000 AS system
|
||||
UNION ALL
|
||||
SELECT 90000 AS system
|
||||
) AS _system_10e4
|
||||
SQL_EOF;
|
||||
} else {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (SELECT 0 AS system) AS _system_10e4
|
||||
SQL_EOF;
|
||||
}
|
||||
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (
|
||||
SELECT 0 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 1 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 2 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 3 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 4 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 5 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 6 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 7 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 8 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 9 AS galaxy
|
||||
) AS _galaxy_10e0
|
||||
SQL_EOF;
|
||||
|
||||
if ($systemCount > 10) {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (
|
||||
SELECT 0 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 10 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 20 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 30 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 40 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 50 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 60 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 70 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 80 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 90 AS galaxy
|
||||
) AS _galaxy_10e1
|
||||
SQL_EOF;
|
||||
} else {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (SELECT 0 AS galaxy) AS _galaxy_10e1
|
||||
SQL_EOF;
|
||||
}
|
||||
|
||||
if ($systemCount > 100) {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (
|
||||
SELECT 0 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 100 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 200 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 300 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 400 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 500 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 600 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 700 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 800 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 900 AS galaxy
|
||||
) AS _galaxy_10e2
|
||||
SQL_EOF;
|
||||
} else {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (SELECT 0 AS galaxy) AS _galaxy_10e2
|
||||
SQL_EOF;
|
||||
}
|
||||
|
||||
if ($systemCount > 1000) {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (
|
||||
SELECT 0 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 1000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 2000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 3000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 4000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 5000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 6000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 7000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 8000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 9000 AS galaxy
|
||||
) AS _galaxy_10e3
|
||||
SQL_EOF;
|
||||
} else {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (SELECT 0 AS galaxy) AS _galaxy_10e3
|
||||
SQL_EOF;
|
||||
}
|
||||
|
||||
if ($systemCount > 10000) {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (
|
||||
SELECT 0 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 10000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 20000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 30000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 40000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 50000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 60000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 70000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 80000 AS galaxy
|
||||
UNION ALL
|
||||
SELECT 90000 AS galaxy
|
||||
) AS _galaxy_10e4
|
||||
SQL_EOF;
|
||||
} else {
|
||||
$sql .= <<<SQL_EOF
|
||||
CROSS JOIN (SELECT 0 AS galaxy) AS _galaxy_10e4
|
||||
SQL_EOF;
|
||||
}
|
||||
|
||||
$sql .= <<<SQL_EOF
|
||||
) _increment
|
||||
|
||||
WHERE _increment.galaxy<={$galaxyCount}
|
||||
AND _increment.system<={$systemCount}
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license Modified BSD
|
||||
* @see https://github.com/gplanchat/one.platform
|
||||
*
|
||||
* Copyright (c) 2009-2010, Grégory PLANCHAT <g.planchat at gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of Grégory PLANCHAT nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing One.Platform.
|
||||
*
|
||||
*/
|
||||
|
||||
$this->setSetupConnection('core_setup');
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('aks')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('alliance')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('annonce')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('banned')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('buddy')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('chat')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('declared')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('fleets')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('galaxy')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('iraks')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('lunas')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('messages')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('multi')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('notes')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('planets')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('rw')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('statpoints')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('users')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
37
src/application/code/core/Legacies/Exception.php
Normal file
37
src/application/code/core/Legacies/Exception.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
|
||||
interface Legacies_Exception {}
|
||||
7
src/application/code/core/Legacies/Stats/Block/View.php
Normal file
7
src/application/code/core/Legacies/Stats/Block/View.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Legacies_Stats_Block_View
|
||||
extends Wootook_Core_Block_Template
|
||||
{
|
||||
|
||||
}
|
||||
786
src/application/code/core/Wootook.php
Normal file
786
src/application/code/core/Wootook.php
Normal file
|
|
@ -0,0 +1,786 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 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/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Bootstrap class, used to access main and global functionalities
|
||||
*
|
||||
* @package Wootook
|
||||
* @category core
|
||||
*/
|
||||
class Wootook
|
||||
{
|
||||
/**
|
||||
* Static list of application event listeners
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_listeners = array();
|
||||
|
||||
/**
|
||||
* Static list of all locale translators
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_translators = array();
|
||||
|
||||
/**
|
||||
* HTTP request management object
|
||||
*
|
||||
* @var Legacies_Core_Controller_Request_Http
|
||||
*/
|
||||
private static $_request = null;
|
||||
|
||||
/**
|
||||
* HTTP response management object
|
||||
*
|
||||
* @var Legacies_Core_Controller_Response
|
||||
*/
|
||||
private static $_response = null;
|
||||
|
||||
/**
|
||||
* The current timestamp
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $_now = null;
|
||||
|
||||
/**
|
||||
* Default locale identifier
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_defaultLocale = 'fr_FR';
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @var Wootook_Core_Config_Adapter_Abstract
|
||||
*/
|
||||
private static $_config = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @var Wootook_Core_Config_Adapter_Abstract
|
||||
*/
|
||||
private static $_globalConfig = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @var array
|
||||
*/
|
||||
private static $_websiteConfigs = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @var array
|
||||
*/
|
||||
private static $_gameConfigs = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @var array
|
||||
*/
|
||||
private static $_ignoreDatabaseConfig = false;
|
||||
|
||||
private static $_defaultWebsite = null;
|
||||
private static $_defaultGame = null;
|
||||
|
||||
private static $_websitesById = array();
|
||||
private static $_websitesByCode = array();
|
||||
private static $_gamesById = array();
|
||||
private static $_gamesByCode = array();
|
||||
|
||||
public static $isInstalled = true;
|
||||
|
||||
/**
|
||||
* Registers an event listener to be called later in the application.
|
||||
*
|
||||
* @param string $event The event identifier
|
||||
* @param callback $listener The event callback to be called
|
||||
*/
|
||||
public static function registerListener($event, $listener)
|
||||
{
|
||||
if (!isset(self::$_listeners[$event])) {
|
||||
self::$_listeners[$event] = array();
|
||||
}
|
||||
self::$_listeners[$event][] = $listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all event listeners
|
||||
*/
|
||||
public static function clearAllListeners()
|
||||
{
|
||||
self::$_listeners = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear a specific event's listeners
|
||||
*
|
||||
* @param unknown_type $event
|
||||
*/
|
||||
public static function clearEventListeners($event)
|
||||
{
|
||||
if (isset(self::$_listeners[$event])) {
|
||||
self::$_listeners[$event] = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an event, calls all callbacks that were previously registered
|
||||
*
|
||||
* @param string $event The event identifier
|
||||
* @param array $params The event params
|
||||
*/
|
||||
public static function dispatchEvent($event, $params)
|
||||
{
|
||||
$eventObject = new Wootook_Core_Event($params);
|
||||
|
||||
if (!isset(self::$_listeners[$event])) {
|
||||
return $eventObject;
|
||||
}
|
||||
|
||||
foreach (self::$_listeners[$event] as $listener) {
|
||||
call_user_func($listener, $eventObject);
|
||||
}
|
||||
|
||||
return $eventObject;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @param unknown_type $namespace
|
||||
* @return Legacies_Core_Model_Session
|
||||
*/
|
||||
public static function getSession($namespace)
|
||||
{
|
||||
return Wootook_Core_Model_Session::factory($namespace);
|
||||
}
|
||||
|
||||
public static function getTranslator($locale = null)
|
||||
{
|
||||
if ($locale === null) {
|
||||
$locale = self::getLocale();
|
||||
}
|
||||
|
||||
if (!isset($translator[$locale])) {
|
||||
$path = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'locale';
|
||||
$translator[$locale] = new Wootook_Core_Model_Translator($path, $locale);
|
||||
}
|
||||
return $translator[$locale];
|
||||
}
|
||||
|
||||
public static function translate($locale, $message, Array $args)
|
||||
{
|
||||
return self::getTranslator($locale)->translateArgs($message, $args);
|
||||
}
|
||||
|
||||
public static function __($message, $_ = null)
|
||||
{
|
||||
$args = func_get_args();
|
||||
array_shift($args);
|
||||
|
||||
return self::getTranslator(self::getLocale())->translateArgs($message, $args);
|
||||
}
|
||||
|
||||
public static function getLocale()
|
||||
{
|
||||
$availableLocales = self::getWebsiteConfig('locales');
|
||||
if ($availableLocales !== null) {
|
||||
return self::getPreferredLocale($availableLocales->toArray());
|
||||
}
|
||||
return self::getPreferredLocale();
|
||||
}
|
||||
|
||||
public static function setDefaultLocale($locale)
|
||||
{
|
||||
$oldLocale = self::$_defaultLocale;
|
||||
self::$_defaultLocale = $locale;
|
||||
|
||||
return $oldLocale;
|
||||
}
|
||||
|
||||
public static function getDefaultLocale()
|
||||
{
|
||||
return self::$_defaultLocale;
|
||||
}
|
||||
|
||||
public static function getPreferredLocale($availableLocales = array())
|
||||
{
|
||||
if (empty($availableLocales)) {
|
||||
return self::getDefaultLocale();
|
||||
}
|
||||
|
||||
$userLocale = Wootook_Player_Model_Session::getSingleton()->getData('locale');
|
||||
if ($userLocale !== null) {
|
||||
return $userLocale;
|
||||
}
|
||||
|
||||
$locales = array();
|
||||
|
||||
if (($accept = self::getRequest()->getServer('HTTP_ACCEPT_LANGUAGE')) !== null) {
|
||||
// break up string into pieces (languages and q factors)
|
||||
preg_match_all('/([a-z]{1,8}(?:-([a-z]{1,8}))?)\s*(?:;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $accept, $matches);
|
||||
|
||||
$length = count($matches[1]);
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$locale = $matches[1][$i];
|
||||
if (!empty($matches[2][$i])) {
|
||||
$locale .= '_' . strtoupper($matches[2][$i]);
|
||||
}
|
||||
$locales[$locale] = !empty($matches[3][$i]) ? min(max(floatval($matches[3][$i]), 0), 1) : 1;
|
||||
}
|
||||
|
||||
arsort($locales, SORT_NUMERIC);
|
||||
}
|
||||
|
||||
if (empty($locales)) {
|
||||
return self::getDefaultLocale();
|
||||
}
|
||||
|
||||
$preferredLocale = key($locales);
|
||||
$preferredPriority = current($locales);
|
||||
foreach ($locales as $locale => $piority) {
|
||||
if (!in_array($locale, $availableLocales)) {
|
||||
continue;
|
||||
}
|
||||
if ($preferredPriority < $piority) {
|
||||
$preferredPriority = $piority;
|
||||
$preferredLocale = $locale;
|
||||
}
|
||||
}
|
||||
|
||||
Wootook_Player_Model_Session::getSingleton()->setData('locale', $preferredLocale);
|
||||
|
||||
return $preferredLocale;
|
||||
}
|
||||
|
||||
public static function now()
|
||||
{
|
||||
if (self::$_now === null) {
|
||||
self::$_now = time();
|
||||
}
|
||||
return new Wootook_Core_DateTime(self::$_now);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Wootook_Core_Controller_Request_Http
|
||||
*/
|
||||
public static function getRequest()
|
||||
{
|
||||
if (self::$_request === null) {
|
||||
self::$_request = new Wootook_Core_Controller_Request_Http();
|
||||
}
|
||||
return self::$_request;
|
||||
}
|
||||
|
||||
public static function setRequest($request)
|
||||
{
|
||||
self::$_request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Wootook_Core_Controller_Response_Http
|
||||
*/
|
||||
public static function getResponse()
|
||||
{
|
||||
if (self::$_response === null) {
|
||||
self::$_response = new Wootook_Core_Controller_Response_Http();
|
||||
}
|
||||
return self::$_response;
|
||||
}
|
||||
|
||||
public static function setResponse($response)
|
||||
{
|
||||
self::$_response = $response;
|
||||
}
|
||||
|
||||
public static function loadConfig($filename = null)
|
||||
{
|
||||
self::$_websiteConfigs = array();
|
||||
self::$_gameConfigs = array();
|
||||
|
||||
self::$_config = new Wootook_Core_Config_Adapter_Array();
|
||||
try {
|
||||
self::$_config->load(APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'system.php');
|
||||
|
||||
if ($filename === null) {
|
||||
$filename = APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'local.php';
|
||||
}
|
||||
|
||||
if (is_string($filename)) {
|
||||
if (!self::$isInstalled) {
|
||||
throw new Wootook_Core_Exception_DataAccessException();
|
||||
}
|
||||
$localConfig = new Wootook_Core_Config_Adapter_Array($filename);
|
||||
self::$_config->merge($localConfig);
|
||||
} else if (is_array($filename)) {
|
||||
$localConfig = new Wootook_Core_Config_Node($filename);
|
||||
self::$_config->merge($localConfig);
|
||||
} else if ($filename instanceof Wootook_Core_Config_Node) {
|
||||
self::$_config->merge($filename);
|
||||
} else {
|
||||
throw new Wootook_Core_Exception_DataAccessException();
|
||||
}
|
||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||
self::$_globalConfig = new Wootook_Core_Config_Node(array(), self::$_config);
|
||||
self::$_ignoreDatabaseConfig = true;
|
||||
return self::$_config;
|
||||
}
|
||||
|
||||
self::$_globalConfig = clone self::$_config['default'];
|
||||
if (isset(self::$_config['global'])) {
|
||||
self::$_globalConfig->merge(self::$_config['global']);
|
||||
}
|
||||
|
||||
self::_appendDatabaseConfig(self::$_globalConfig);
|
||||
|
||||
return self::$_config;
|
||||
}
|
||||
|
||||
private static function _appendDatabaseConfig(Wootook_Core_Config_Node $config, $type = 'global', $model = null)
|
||||
{
|
||||
if (self::$_ignoreDatabaseConfig) {
|
||||
return $config;
|
||||
}
|
||||
|
||||
$adapter = Wootook_Core_Database::getConnection('core_read');
|
||||
$select = $adapter->select('core_config');
|
||||
|
||||
switch ($type) {
|
||||
case 'website':
|
||||
$select->where('website_id = :website_id');
|
||||
$statement = $adapter->prepare($select);
|
||||
$statement->execute(array('website_id' => $model->getId()));
|
||||
break;
|
||||
|
||||
case 'game':
|
||||
$select->where('game_id = :game_id');
|
||||
$statement = $adapter->prepare($select);
|
||||
$statement->execute(array('game_id' => $model->getId()));
|
||||
break;
|
||||
|
||||
default:
|
||||
$select->where('website_id = 0');
|
||||
$select->where('game_id = 0');
|
||||
$statement = $adapter->prepare($select);
|
||||
$statement->execute();
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($statement->fetch() as $row) {
|
||||
$config->setConfig($row['config_path'], $row['config_value']);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function getWebsite($websiteId)
|
||||
{
|
||||
if (is_numeric($websiteId)) {
|
||||
if (isset(self::$_websitesById[$websiteId])) {
|
||||
return self::$_websitesById[$websiteId];
|
||||
}
|
||||
$website = new Wootook_Core_Model_Website();
|
||||
try {
|
||||
$website->load($websiteId);
|
||||
$websiteCode = $website->getData('code');
|
||||
|
||||
self::$_websitesById[$websiteId] = $website;
|
||||
self::$_websitesByCode[$websiteCode] = $website;
|
||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||
throw new Wootook_Core_Exception_WebsiteError('Could not load website entity.', null, $e);
|
||||
}
|
||||
|
||||
return $website;
|
||||
} else {
|
||||
if (isset(self::$_websitesByCode[$websiteId])) {
|
||||
return self::$_websitesByCode[$websiteId];
|
||||
}
|
||||
$website = new Wootook_Core_Model_Website();
|
||||
try {
|
||||
$website->load($websiteId, 'code');
|
||||
$websiteId = $website->getId();
|
||||
$websiteCode = $website->getData('code');
|
||||
|
||||
self::$_websitesById[$websiteId] = $website;
|
||||
self::$_websitesByCode[$websiteCode] = $website;
|
||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||
throw new Wootook_Core_Exception_WebsiteError('Could not load website entity.', null, $e);
|
||||
}
|
||||
|
||||
return $website;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getGame($gameId)
|
||||
{
|
||||
if (is_numeric($gameId)) {
|
||||
if (isset(self::$_gamesById[$gameId])) {
|
||||
return self::$_gamesById[$gameId];
|
||||
}
|
||||
$game = new Wootook_Core_Model_Game();
|
||||
try {
|
||||
$game->load($gameId);
|
||||
$gameCode = $game->getData('code');
|
||||
|
||||
self::$_gamesById[$gameId] = $game;
|
||||
self::$_gamesByCode[$gameCode] = $game;
|
||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||
throw new Wootook_Core_Exception_GameError('Could not load game entity.', null, $e);
|
||||
}
|
||||
|
||||
return $game;
|
||||
} else {
|
||||
if (isset(self::$_gamesByCode[$gameId])) {
|
||||
return self::$_gamesByCode[$gameId];
|
||||
}
|
||||
$game = new Wootook_Core_Model_Game();
|
||||
try {
|
||||
$game->load($gameId, 'code');
|
||||
$gameId = $game->getId();
|
||||
$gameCode = $game->getData('code');
|
||||
|
||||
self::$_gamesById[$gameId] = $game;
|
||||
self::$_gamesByCode[$gameCode] = $game;
|
||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||
throw new Wootook_Core_Exception_GameError('Could not load game entity.', null, $e);
|
||||
}
|
||||
|
||||
return $game;
|
||||
}
|
||||
}
|
||||
|
||||
public static function addWebsite(Wootook_Core_Model_Website $website)
|
||||
{
|
||||
$websiteId = $website->getId();
|
||||
$websiteKey = $website->getData('code');
|
||||
self::$_websitesById[$websiteId] = $website;
|
||||
self::$_websitesByCode[$websiteKey] = $website;
|
||||
}
|
||||
|
||||
public static function addGame(Wootook_Core_Model_Game $game)
|
||||
{
|
||||
$gameId = $game->getId();
|
||||
$gameKey = $game->getData('code');
|
||||
self::$_gamesById[$gameId] = $game;
|
||||
self::$_gamesByCode[$gameKey] = $game;
|
||||
}
|
||||
|
||||
public static function setDefaultWebsite(Wootook_Core_Model_Website $website)
|
||||
{
|
||||
self::$_defaultWebsite = $website;
|
||||
}
|
||||
|
||||
public static function getDefaultWebsite()
|
||||
{
|
||||
if (self::$_defaultWebsite === null) {
|
||||
self::$_defaultWebsite = new Wootook_Core_Model_Website();
|
||||
self::$_defaultWebsite->setId(1)->setData('code', Wootook_Core_Model_Website::DEFAULT_CODE);
|
||||
}
|
||||
return self::$_defaultWebsite;
|
||||
}
|
||||
|
||||
public static function getDefaultGame()
|
||||
{
|
||||
if (self::$_defaultGame === null) {
|
||||
self::$_defaultGame = new Wootook_Core_Model_Game();
|
||||
self::$_defaultGame->setId(1)->setData('code', Wootook_Core_Model_Game::DEFAULT_CODE);
|
||||
}
|
||||
return self::$_defaultGame;
|
||||
}
|
||||
|
||||
public static function setDefaultGame(Wootook_Core_Model_Game $game)
|
||||
{
|
||||
self::$_defaultGame = $game;
|
||||
}
|
||||
|
||||
private static function _initWebsiteConfig($websiteId)
|
||||
{
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
if (!self::$isInstalled) {
|
||||
if (isset(self::$_config['default'])) {
|
||||
self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE] = clone self::$_config['default'];
|
||||
} else {
|
||||
self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE] = new Wootook_Core_Config_Node(array(), self::$_config);
|
||||
}
|
||||
if (isset(self::$_config['install'])) {
|
||||
self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE]->merge(self::$_config['install']);
|
||||
}
|
||||
|
||||
return self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE];
|
||||
}
|
||||
|
||||
try {
|
||||
$website = self::getWebsite($websiteId);
|
||||
} catch (Wootook_Core_Exception_RuntimeException $e) {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
|
||||
return null;
|
||||
}
|
||||
$websiteKey = $website->getData('code');
|
||||
$websiteId = $website->getId();
|
||||
|
||||
if (!isset(self::$_websiteConfigs[$websiteKey])) {
|
||||
self::$_websiteConfigs[$websiteKey] = clone self::$_config['default'];
|
||||
if ($websiteId != 0 && isset(self::$_config['frontend'])) {
|
||||
self::$_websiteConfigs[$websiteKey]->merge(self::$_config['frontend']);
|
||||
} else if ($websiteId == 0 && isset(self::$_config['backend'])) {
|
||||
self::$_websiteConfigs[$websiteKey]->merge(self::$_config['backend']);
|
||||
}
|
||||
|
||||
$websiteConfig = self::$_config->getConfig("website/{$websiteKey}");
|
||||
if ($websiteConfig !== null) {
|
||||
self::$_websiteConfigs[$websiteKey]->merge($websiteConfig);
|
||||
}
|
||||
|
||||
self::_appendDatabaseConfig(self::$_websiteConfigs[$websiteKey], 'website', $website);
|
||||
}
|
||||
|
||||
return self::$_websiteConfigs[$websiteKey];
|
||||
}
|
||||
|
||||
private static function _initGameConfig($gameId)
|
||||
{
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
if (!self::$isInstalled) {
|
||||
if (isset(self::$_config['default'])) {
|
||||
self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE] = clone self::$_config['default'];
|
||||
} else {
|
||||
self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE] = new Wootook_Core_Config_Node(array(), self::$_config);
|
||||
}
|
||||
if (isset(self::$_config['install'])) {
|
||||
self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE]->merge(self::$_config['install']);
|
||||
}
|
||||
|
||||
return self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE];
|
||||
}
|
||||
|
||||
try {
|
||||
$game = self::getGame($gameId);
|
||||
} catch (Wootook_Core_Exception_RuntimeException $e) {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
|
||||
return null;
|
||||
}
|
||||
|
||||
$gameKey = $game->getData('code');
|
||||
$gameId = $game->getId();
|
||||
$websiteId = $game->getData('website_id');
|
||||
|
||||
if (!isset(self::$_gameConfigs[$gameKey])) {
|
||||
$websiteConfig = self::_initWebsiteConfig($websiteId);
|
||||
if ($websiteConfig === null) {
|
||||
return null;
|
||||
}
|
||||
self::$_gameConfigs[$gameKey] = clone $websiteConfig;
|
||||
|
||||
$gameConfig = self::$_config->getConfig("game/{$gameKey}");
|
||||
if ($gameConfig !== null) {
|
||||
self::$_gameConfigs[$gameKey]->merge($gameConfig);
|
||||
}
|
||||
|
||||
self::_appendDatabaseConfig(self::$_gameConfigs[$gameKey], 'game', $game);
|
||||
}
|
||||
|
||||
return self::$_gameConfigs[$gameKey];
|
||||
}
|
||||
|
||||
public static function getConfig($path = null)
|
||||
{
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
|
||||
if ($path !== null) {
|
||||
return self::$_globalConfig->getConfig($path);
|
||||
}
|
||||
return self::$_globalConfig;
|
||||
}
|
||||
|
||||
public static function getWebsiteConfig($path = null, $websiteKey = null)
|
||||
{
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
|
||||
if ($websiteKey === null) {
|
||||
//$websiteKey = Wootook_Core_Model_Website::DEFAULT_CODE;
|
||||
$websiteKey = self::getDefaultWebsite()->getData('code');
|
||||
}
|
||||
|
||||
$config = self::_initWebsiteConfig($websiteKey);
|
||||
if ($config === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($path !== null) {
|
||||
return $config->getConfig($path);
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function getGameConfig($path = null, $gameKey = null)
|
||||
{
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
|
||||
if ($gameKey === null) {
|
||||
//$gameKey = Wootook_Core_Model_Game::DEFAULT_CODE;
|
||||
$gameKey = self::getDefaultGame()->getData('code');
|
||||
}
|
||||
|
||||
$config = self::_initGameConfig($gameKey);
|
||||
if ($config === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($path !== null) {
|
||||
return $config->getConfig($path);
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function setConfig($path, $value, $websiteId = null, $gameId = null)
|
||||
{
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
|
||||
if (!self::$_ignoreDatabaseConfig) {
|
||||
$updater = new Wootook_Core_Model_Config();
|
||||
$updater->setPath($path)->setValue($value);
|
||||
if ($websiteId !== null) {
|
||||
$updater->setWebsiteId($websiteId);
|
||||
if ($gameId !== null) {
|
||||
$updater->setGameId($gameId);
|
||||
self::$_gameConfigs[$gameId]->setConfig($path, $value);
|
||||
} else {
|
||||
self::$_websiteConfigs[$websiteId]->setConfig($path, $value);
|
||||
}
|
||||
} else {
|
||||
self::$_globalConfig->setConfig($path, $value);
|
||||
}
|
||||
$updater->save();
|
||||
} else if ($websiteId !== null) {
|
||||
if ($gameId !== null) {
|
||||
self::$_gameConfigs[$gameId]->setConfig($path, $value);
|
||||
} else {
|
||||
self::$_websiteConfigs[$websiteId]->setConfig($path, $value);
|
||||
}
|
||||
} else {
|
||||
self::$_globalConfig->setConfig($path, $value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getBaseUrl($domain = 'base')
|
||||
{
|
||||
$urlConfig = self::getGameConfig('web/url');
|
||||
if (!$urlConfig instanceof Wootook_Core_Config_Node) {
|
||||
return null;
|
||||
}
|
||||
if (!is_string($domain) || !isset($urlConfig->$domain)) {
|
||||
return $urlConfig->base;
|
||||
}
|
||||
return $urlConfig->$domain;
|
||||
}
|
||||
|
||||
public static function getBasePath($domain = 'base')
|
||||
{
|
||||
$pathConfig = self::getGameConfig('system/path');
|
||||
if (!$pathConfig instanceof Wootook_Core_Config_Node) {
|
||||
return null;
|
||||
}
|
||||
if (!is_string($domain) || !isset($pathConfig->$domain)) {
|
||||
return $pathConfig->base;
|
||||
}
|
||||
return $pathConfig->$domain;
|
||||
}
|
||||
|
||||
public static function getUrl($uri, Array $params = array())
|
||||
{
|
||||
$baseUrl = self::getBaseUrl();
|
||||
|
||||
$serializedParams = array();
|
||||
foreach ($params as $paramKey => $paramValue) {
|
||||
if ($paramValue) {
|
||||
$serializedParams[] = "{$paramKey}={$paramValue}";
|
||||
}
|
||||
}
|
||||
|
||||
if (count($serializedParams) > 0) {
|
||||
return $baseUrl . $uri . '?' . implode('&', $serializedParams);
|
||||
}
|
||||
return $baseUrl . $uri;
|
||||
}
|
||||
|
||||
public static function getStaticUrl($uri, Array $params = array())
|
||||
{
|
||||
$baseUrl = self::getBaseUrl('static');
|
||||
|
||||
$serializedParams = array();
|
||||
foreach ($params as $paramKey => $paramValue) {
|
||||
if ($paramValue) {
|
||||
$serializedParams[] = "{$paramKey}={$paramValue}";
|
||||
}
|
||||
}
|
||||
|
||||
if (count($serializedParams) > 0) {
|
||||
return $baseUrl . $uri . '?' . implode('&', $serializedParams);
|
||||
}
|
||||
return $baseUrl . $uri;
|
||||
}
|
||||
|
||||
public static function fileExists($path)
|
||||
{
|
||||
if ($path === null || empty($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->sleep();
|
||||
if (($fp = @fopen($path, 'r', true)) === false) {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
|
||||
return false;
|
||||
}
|
||||
fclose($fp);
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
155
src/application/code/core/Wootook/Core/App.php
Normal file
155
src/application/code/core/Wootook/Core/App.php
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_App
|
||||
{
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @var Wootook_Core_Config_Adapter_Abstract
|
||||
*/
|
||||
private $_globalConfig = null;
|
||||
|
||||
public function __construct($websiteCode, $gameCode)
|
||||
{
|
||||
$this->_globalConfig = Wootook::getConfig();
|
||||
}
|
||||
|
||||
protected function _resolveClassType(&$namespaces, $module, $class)
|
||||
{
|
||||
$class = str_replace(' ', '', ucwords(str_replace('-', ' ', $class)));
|
||||
$class = str_replace(' ', '_', ucwords(str_replace('.', ' ', $class)));
|
||||
|
||||
if (isset($namespaces[$module])) {
|
||||
foreach ($namespaces[$module] as $namespace => $path) {
|
||||
$className = $namespace . $class;
|
||||
$fileName = $path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
|
||||
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->sleep();
|
||||
if (!($fp = @fopen($fileName, 'r', true))) {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
|
||||
continue;
|
||||
}
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
|
||||
fclose($fp);
|
||||
|
||||
if (!class_exists($className, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $className;
|
||||
}
|
||||
}
|
||||
|
||||
Wootook_Core_ErrorProfiler::getSingleton()
|
||||
->addException(new Wootook_Core_Exception_LayoutException(sprintf('Class type "%s" could not be resolved.', $type)));
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function _newInstance($className, Array $constructorParams)
|
||||
{
|
||||
if ($className === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (empty($constructorParams)) {
|
||||
return new $className;
|
||||
} else {
|
||||
$reflection = new ReflectionClass($className);
|
||||
return $reflection->newInstanceArgs($constructorParams);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _parseIdentifier($identifier, &$module, &$class)
|
||||
{
|
||||
$offset = strpos($identifier, '/');
|
||||
if ($offset === false) {
|
||||
$module = $identifier;
|
||||
$class = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$module = substr($type, 0, $offset);
|
||||
$class = substr($type, $offset + 1);
|
||||
}
|
||||
|
||||
public function block($identifier)
|
||||
{
|
||||
$this->_parseIdentifier($identifier, $module, $class);
|
||||
|
||||
return $this->getBlock($module, $class);
|
||||
}
|
||||
|
||||
public function model($identifier)
|
||||
{
|
||||
$this->_parseIdentifier($identifier, $module, $class);
|
||||
|
||||
return $this->getModel($module, $class);
|
||||
}
|
||||
|
||||
public function resource($identifier)
|
||||
{
|
||||
$this->_parseIdentifier($identifier, $module, $class);
|
||||
|
||||
return $this->getResource($module, $class);
|
||||
}
|
||||
|
||||
public function helper($identifier)
|
||||
{
|
||||
$this->_parseIdentifier($identifier, $module, $class);
|
||||
|
||||
if ($class === null) {
|
||||
$class = 'data';
|
||||
}
|
||||
|
||||
return $this->getResource($module, $class);
|
||||
}
|
||||
|
||||
public function getBlock($module, $class, Array $constructorParams = array())
|
||||
{
|
||||
$className = $this->_resolveClassType($this->_globalConfig->blocks, $module, $class);
|
||||
|
||||
return $this->_newInstance($className, $constructorParams);
|
||||
}
|
||||
|
||||
public function getModel($module, $class)
|
||||
{
|
||||
$className = $this->_resolveClassType($this->_globalConfig->models, $module, $class);
|
||||
|
||||
return $this->_newInstance($className, $constructorParams);
|
||||
}
|
||||
|
||||
public function getResource($module, $class)
|
||||
{
|
||||
$className = $this->_resolveClassType($this->_globalConfig->resources, $module, $class);
|
||||
|
||||
return $this->_newInstance($className, $constructorParams);
|
||||
}
|
||||
|
||||
public function getHelper($module, $class)
|
||||
{
|
||||
$className = $this->_resolveClassType($this->_globalConfig->helpers, $module, $class);
|
||||
|
||||
return $this->_newInstance($className, $constructorParams);
|
||||
}
|
||||
|
||||
public function getBlockSingleton($module, $class)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getModelSingleton($module, $class)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getResourceSingleton($module, $class)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getHelperSingleton($module, $class)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
14
src/application/code/core/Wootook/Core/Block/Concat.php
Normal file
14
src/application/code/core/Wootook/Core/Block/Concat.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Concat
|
||||
extends Wootook_Core_View
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
$content = '';
|
||||
foreach ($this->_partials as $partial) {
|
||||
$content .= $partial->render();
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
10
src/application/code/core/Wootook/Core/Block/Deprecated.php
Normal file
10
src/application/code/core/Wootook/Core/Block/Deprecated.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Deprecated
|
||||
extends Wootook_Core_Block_Template
|
||||
{
|
||||
public function getScriptPath()
|
||||
{
|
||||
return $this->getLayout()->getScriptPath();
|
||||
}
|
||||
}
|
||||
11
src/application/code/core/Wootook/Core/Block/Html/Form.php
Normal file
11
src/application/code/core/Wootook/Core/Block/Html/Form.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Html_Form
|
||||
extends Wootook_Core_Block_Template
|
||||
{
|
||||
public function getFormKey()
|
||||
{
|
||||
$session = Wootook::getSession('security');
|
||||
return $session->getFormKey(true);
|
||||
}
|
||||
}
|
||||
287
src/application/code/core/Wootook/Core/Block/Html/Head.php
Normal file
287
src/application/code/core/Wootook/Core/Block/Html/Head.php
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Html_Head
|
||||
extends Wootook_Core_Block_Template
|
||||
{
|
||||
const TYPE_GLOBAL_CSS = 'global_css';
|
||||
const TYPE_GLOBAL_JS = 'global_js';
|
||||
|
||||
const TYPE_SKIN_CSS = 'skin_css';
|
||||
const TYPE_SKIN_JS = 'skin_js';
|
||||
|
||||
const TYPE_INLINE_CSS = 'inline_css';
|
||||
const TYPE_INLINE_JS = 'inline_js';
|
||||
|
||||
const TITLE_CONCAT_BEFORE = 'BEFORE';
|
||||
const TITLE_CONCAT_AFTER = 'AFTER';
|
||||
const TITLE_OVERWRITE = 'OVERWRITE';
|
||||
|
||||
protected $_items = array();
|
||||
|
||||
protected $_title = null;
|
||||
protected $_titleDefaultConcat = self::TITLE_CONCAT_AFTER;
|
||||
protected $_titleSeparator = ' ¤ ';
|
||||
|
||||
protected $_titleConcatTypes = array(
|
||||
self::TITLE_CONCAT_AFTER,
|
||||
self::TITLE_CONCAT_BEFORE,
|
||||
self::TITLE_OVERWRITE
|
||||
);
|
||||
|
||||
public function setTitleSeparator($separator)
|
||||
{
|
||||
$this->_titleSeparator = $separator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitleSeparator()
|
||||
{
|
||||
return $this->_titleSeparator;
|
||||
}
|
||||
|
||||
public function setTitleDefaultConcat($defaultConcat)
|
||||
{
|
||||
if (in_array($concatType, $this->_titleConcatTypes)) {
|
||||
$this->_titleDefaultConcat = $defaultConcat;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitleDefaultConcat()
|
||||
{
|
||||
return $this->_titleDefaultConcat;
|
||||
}
|
||||
|
||||
public function setTitle($title, $concatType = self::TITLE_CONCAT_AFTER)
|
||||
{
|
||||
if (!in_array($concatType, $this->_titleConcatTypes)) {
|
||||
$concatType = $this->getTitleDefaultConcat();
|
||||
}
|
||||
|
||||
if ($concatType == self::TITLE_OVERWRITE || $this->_title === null) {
|
||||
$this->_title = $title;
|
||||
} else if ($concatType == self::TITLE_CONCAT_BEFORE) {
|
||||
$this->_title = $title . $this->getTitleSeparator() . $this->_title;
|
||||
} else if ($concatType == self::TITLE_CONCAT_AFTER) {
|
||||
$this->_title .= $this->getTitleSeparator() . $title;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
public function addItem($type, Array $options = array())
|
||||
{
|
||||
if (!isset($this->_items[$type])) {
|
||||
$this->_items[$type] = array();
|
||||
}
|
||||
$this->_items[$type][] = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addJs($script, $type = 'text/javascript', Array $options = array(), $theme = null, $package = null)
|
||||
{
|
||||
$options['type'] = $type;
|
||||
$options['path'] = $script;
|
||||
$options['theme'] = $theme;
|
||||
$options['package'] = $package;
|
||||
|
||||
$this->addItem(self::TYPE_GLOBAL_JS, $options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addCss($stylesheet, $type = 'text/css', $condition = null, Array $options = array(), $theme = null, $package = null)
|
||||
{
|
||||
$options['type'] = $type;
|
||||
$options['path'] = $stylesheet;
|
||||
$options['condition'] = $condition;
|
||||
$options['theme'] = $theme;
|
||||
$options['package'] = $package;
|
||||
|
||||
$this->addItem(self::TYPE_GLOBAL_CSS, $options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addSkinJs($script, $type = 'text/javascript', Array $options = array(), $theme = null, $package = null)
|
||||
{
|
||||
$options['type'] = $type;
|
||||
$options['path'] = $script;
|
||||
$options['theme'] = $theme;
|
||||
$options['package'] = $package;
|
||||
|
||||
$this->addItem(self::TYPE_SKIN_JS, $options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addSkinCss($stylesheet, $type = 'text/css', $condition = null, Array $options = array(), $theme = null, $package = null)
|
||||
{
|
||||
$options['type'] = $type;
|
||||
$options['path'] = $stylesheet;
|
||||
$options['condition'] = $condition;
|
||||
$options['theme'] = $theme;
|
||||
$options['package'] = $package;
|
||||
|
||||
$this->addItem(self::TYPE_SKIN_CSS, $options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addInlineJs($content, $type = 'text/javascript', Array $options = array())
|
||||
{
|
||||
$options['type'] = $type;
|
||||
$options['content'] = $content;
|
||||
|
||||
$this->addItem(self::TYPE_INLINE_JS, $options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addInlineCss($content, $type = 'text/css', Array $options = array())
|
||||
{
|
||||
$options['type'] = $type;
|
||||
$options['content'] = $content;
|
||||
|
||||
$this->addItem(self::TYPE_INLINE_CSS, $options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCss()
|
||||
{
|
||||
if (isset($this->_items[self::TYPE_GLOBAL_CSS])) {
|
||||
return $this->_items[self::TYPE_GLOBAL_CSS];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getSkinCss()
|
||||
{
|
||||
if (isset($this->_items[self::TYPE_SKIN_CSS])) {
|
||||
return $this->_items[self::TYPE_SKIN_CSS];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getInlineCss()
|
||||
{
|
||||
if (isset($this->_items[self::TYPE_INLINE_CSS])) {
|
||||
return $this->_items[self::TYPE_INLINE_CSS];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getJs()
|
||||
{
|
||||
if (isset($this->_items[self::TYPE_GLOBAL_JS])) {
|
||||
return $this->_items[self::TYPE_GLOBAL_JS];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getSkinJs()
|
||||
{
|
||||
if (isset($this->_items[self::TYPE_SKIN_JS])) {
|
||||
return $this->_items[self::TYPE_SKIN_JS];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getInlineJs()
|
||||
{
|
||||
if (isset($this->_items[self::TYPE_INLINE_JS])) {
|
||||
return $this->_items[self::TYPE_INLINE_JS];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function renderCss()
|
||||
{
|
||||
$render = '';
|
||||
foreach ($this->getCss() as $css) {
|
||||
if (!isset($css['media'])) {
|
||||
$css['media'] = 'all';
|
||||
}
|
||||
$url = $this->getStaticUrl($css['path'], array());
|
||||
$render .=<<<HTML_EOF
|
||||
<link rel="stylesheet" type="{$css['type']}" src="{$url}" media="{$css['media']}" />
|
||||
HTML_EOF;
|
||||
}
|
||||
}
|
||||
|
||||
public function renderSkinCss()
|
||||
{
|
||||
$render = '';
|
||||
foreach ($this->getSkinCss() as $css) {
|
||||
if (!isset($css['media'])) {
|
||||
$css['media'] = 'all';
|
||||
}
|
||||
$url = $this->getSkinUrl($css['path'], array(), $css['theme'], $css['package']);
|
||||
$render .=<<<HTML_EOF
|
||||
<link rel="stylesheet" type="{$css['type']}" src="{$url}" media="{$css['media']}" />
|
||||
HTML_EOF;
|
||||
}
|
||||
}
|
||||
|
||||
public function renderInlineCss()
|
||||
{
|
||||
foreach ($this->getInlineCss() as $css) {
|
||||
if (!isset($css['media'])) {
|
||||
$css['media'] = 'all';
|
||||
}
|
||||
$render .=<<<HTML_EOF
|
||||
<style type="{$css['type']}">/*<![CDATA[*/{$css['content']}/*]]>*/</style>
|
||||
HTML_EOF;
|
||||
}
|
||||
return $render;
|
||||
}
|
||||
|
||||
public function renderJs()
|
||||
{
|
||||
$render = '';
|
||||
foreach ($this->getJs() as $js) {
|
||||
if (!isset($js['type'])) {
|
||||
$js['type'] = 'text/javascript';
|
||||
}
|
||||
$url = $this->getStaticUrl($js['path']);
|
||||
$render .=<<<HTML_EOF
|
||||
<script type="{$js['type']}" src="{$url}"></script>
|
||||
HTML_EOF;
|
||||
}
|
||||
return $render;
|
||||
}
|
||||
|
||||
public function renderSkinJs()
|
||||
{
|
||||
$render = '';
|
||||
foreach ($this->getJs() as $js) {
|
||||
if (!isset($js['type'])) {
|
||||
$js['type'] = 'text/javascript';
|
||||
}
|
||||
$url = $this->getSkinUrl($js['path'], array(), $js['theme'], $js['package']);
|
||||
$render .=<<<HTML_EOF
|
||||
<script type="{$js['type']}" src="{$url}"></script>
|
||||
HTML_EOF;
|
||||
}
|
||||
return $render;
|
||||
}
|
||||
|
||||
public function renderInlineJs()
|
||||
{
|
||||
foreach ($this->getInlineJs() as $js) {
|
||||
$render .=<<<HTML_EOF
|
||||
<script type="{$js['type']}">/*<![CDATA[*/{$js['content']}/*]]>*/</script>
|
||||
HTML_EOF;
|
||||
}
|
||||
return $render;
|
||||
}
|
||||
}
|
||||
101
src/application/code/core/Wootook/Core/Block/Html/Navigation.php
Normal file
101
src/application/code/core/Wootook/Core/Block/Html/Navigation.php
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Html_Navigation
|
||||
extends Wootook_Core_Block_Template
|
||||
{
|
||||
public function addLink($name, $label, $title, $uri, Array $params = array(), Array $classes = array(), $template = null, Array $attributes = array())
|
||||
{
|
||||
$explodedPath = explode('/', $name);
|
||||
$baseName = array_pop($explodedPath);
|
||||
$parent = $this->_getNode($explodedPath);
|
||||
|
||||
$child = $this->getLayout()
|
||||
->createBlock('core/html.navigation.link', $this->getNameInLayout() . '.' . $baseName, array(
|
||||
'url' => array(
|
||||
'uri' => $uri,
|
||||
'params' => $params
|
||||
),
|
||||
'label' => $label,
|
||||
'title' => $title,
|
||||
'classes' => $classes,
|
||||
'attributes' => $attributes
|
||||
));
|
||||
$parent->setPartial($baseName, $child);
|
||||
|
||||
if ($template !== null) {
|
||||
$child->setTemplate($template);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addExternalLink($name, $label, $title, $url, Array $classes = array(), $template = null, Array $attributes = array())
|
||||
{
|
||||
$explodedPath = explode('/', $name);
|
||||
$baseName = array_pop($explodedPath);
|
||||
$parent = $this->_getNode($explodedPath);
|
||||
|
||||
$child = $this->getLayout()
|
||||
->createBlock('core/html.navigation.link', $this->getNameInLayout() . '.' . $baseName, array(
|
||||
'url' => $url,
|
||||
'label' => $label,
|
||||
'title' => $title,
|
||||
'classes' => $classes,
|
||||
'attributes' => $attributes
|
||||
));
|
||||
$parent->setPartial($baseName, $child);
|
||||
|
||||
if ($template !== null) {
|
||||
$child->setTemplate($template);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addPopupLink($name, $label, $title, $uri, Array $params = array(), Array $classes = array(), $template = null, Array $attributes = array())
|
||||
{
|
||||
$uri = $this->getStaticUrl($uri, $params);
|
||||
|
||||
$attributes['onclick'] = "f('{$params}', '{$label}');return false;";
|
||||
|
||||
return $this->addLink($name, $label, $title, null, array(), $classes, $template, $attributes);
|
||||
}
|
||||
|
||||
public function setNodeTitle($path, $title)
|
||||
{
|
||||
return $this->getNode($path)->setTitle($title);
|
||||
}
|
||||
|
||||
public function setNodeTemplate($path, $template)
|
||||
{
|
||||
return $this->getNode($path)->setTemplate($template);
|
||||
}
|
||||
|
||||
public function getNode($path)
|
||||
{
|
||||
return $this->_getNode(explode('/', $path));
|
||||
}
|
||||
|
||||
protected function _getNode($explodedPath)
|
||||
{
|
||||
$name = array_shift($explodedPath);
|
||||
|
||||
if ($this->hasPartial($name)) {
|
||||
$child = $this->getPartial($name);
|
||||
} else {
|
||||
$child = $this->getLayout()
|
||||
->createBlock('core/html.navigation.node', $this->getNameInLayout() . '.' . $name);
|
||||
|
||||
$this->setPartial($name, $child);
|
||||
}
|
||||
|
||||
if ($child instanceof Wootook_Core_Block_Html_Navigation_Link) {
|
||||
throw new Wootook_Core_Exception_RuntimeException('Node is a link. Could not append a child node to a link node.');
|
||||
}
|
||||
|
||||
if (count($explodedPath) == 0) {
|
||||
return $child;
|
||||
}
|
||||
return $child->_getNode($explodedPath);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Html_Navigation_Link
|
||||
extends Wootook_Core_Block_Template
|
||||
{
|
||||
protected $_label = '';
|
||||
protected $_title = '';
|
||||
protected $_uri = null;
|
||||
protected $_url = null;
|
||||
protected $_params = array();
|
||||
protected $_classes = array('link');
|
||||
protected $_attributes = array();
|
||||
|
||||
public function getTemplate()
|
||||
{
|
||||
if ($this->_template !== null) {
|
||||
return $this->_template;
|
||||
}
|
||||
return 'page/html/navigation/link.phtml';
|
||||
}
|
||||
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->_label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->_label;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->_title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
public function setUrl($uri, $params = array())
|
||||
{
|
||||
if ($uri === null) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->_uri = $uri;
|
||||
$this->_params = $params;
|
||||
$this->_url = $this->getStaticUrl($uri, $params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setExternalUrl($url)
|
||||
{
|
||||
$this->_url = $url;
|
||||
$this->_uri = null;
|
||||
$this->_params = array();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLinkUrl($moreParams = array())
|
||||
{
|
||||
if (empty($moreParams) || $this->_uri === null) {
|
||||
return $this->_url;
|
||||
}
|
||||
$params = array_merge($this->_params, $moreParams);
|
||||
return $this->getStaticUrl($this->_uri, $params);
|
||||
}
|
||||
|
||||
public function setAttribute($attributeName, $attributeValue)
|
||||
{
|
||||
$this->_attributes[$attributeName] = $attributeValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAttribute($attributeName)
|
||||
{
|
||||
if ($this->hasAttribute($attributeName)) {
|
||||
return $this->_attributes[$attributeName];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function hasAttribute($attributeName)
|
||||
{
|
||||
if (isset($this->_attributes[$attributeName])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function unsetAttribute($attributeName)
|
||||
{
|
||||
if ($this->hasAttribute($attributeName)) {
|
||||
unset($this->_attributes[$attributeName]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->_attributes;
|
||||
}
|
||||
|
||||
public function addClass($class)
|
||||
{
|
||||
$this->_classes[] = $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function clearClasses()
|
||||
{
|
||||
$this->_classes = array();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function renderClasses(Array $moreClasses = array())
|
||||
{
|
||||
$classes = array_merge($this->_classes, $moreClasses);
|
||||
return implode(' ', $classes);
|
||||
}
|
||||
|
||||
public function __construct(Array $data = array())
|
||||
{
|
||||
if (isset($data['label'])) {
|
||||
$this->setLabel($data['label']);
|
||||
unset($data['label']);
|
||||
}
|
||||
|
||||
if (isset($data['title'])) {
|
||||
$this->setTitle($data['title']);
|
||||
unset($data['title']);
|
||||
}
|
||||
|
||||
if (isset($data['url'])) {
|
||||
if (is_array($data['url']) && isset($data['url']['uri'])) {
|
||||
if (isset($data['url']['params'])) {
|
||||
$this->setUrl($data['url']['uri'], $data['url']['params']);
|
||||
} else {
|
||||
$this->setUrl($data['url']['uri']);
|
||||
}
|
||||
} else {
|
||||
$this->setExternalUrl($data['url']);
|
||||
}
|
||||
unset($data['url']);
|
||||
}
|
||||
|
||||
if (isset($data['classes'])) {
|
||||
$classes = (array) $data['classes'];
|
||||
unset($data['classes']);
|
||||
|
||||
foreach ($classes as $class) {
|
||||
$this->addClass(trim($class));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['attributes'])) {
|
||||
$attributes = (array) $data['attributes'];
|
||||
unset($data['attributes']);
|
||||
|
||||
foreach ($attributes as $attributeName => $attributeValue) {
|
||||
$this->setAttribute($attributeName, $attributeValue);
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Html_Navigation_Node
|
||||
extends Wootook_Core_Block_Html_Navigation
|
||||
{
|
||||
protected $_title = '';
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->_title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
public function getTemplate()
|
||||
{
|
||||
if ($this->_template !== null) {
|
||||
return $this->_template;
|
||||
}
|
||||
return 'page/html/navigation/node.phtml';
|
||||
}
|
||||
}
|
||||
19
src/application/code/core/Wootook/Core/Block/Html/Page.php
Normal file
19
src/application/code/core/Wootook/Core/Block/Html/Page.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Html_Page
|
||||
extends Wootook_Core_Block_Template
|
||||
{
|
||||
protected $_bodyClasses = array();
|
||||
|
||||
public function getBodyClasses()
|
||||
{
|
||||
return implode(' ', $this->_bodyClasses);
|
||||
}
|
||||
|
||||
public function addBodyClass($class)
|
||||
{
|
||||
$this->_bodyClasses[] = $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
src/application/code/core/Wootook/Core/Block/Messages.php
Normal file
43
src/application/code/core/Wootook/Core/Block/Messages.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Messages
|
||||
extends Wootook_Core_Block_Template
|
||||
{
|
||||
protected $_storages = array();
|
||||
|
||||
public function prepareMessages($namespace)
|
||||
{
|
||||
$this->_storages[] = $namespace;
|
||||
}
|
||||
|
||||
public function renderGroupedHtml()
|
||||
{
|
||||
$messages = array();
|
||||
|
||||
foreach ($this->_storages as $namespace) {
|
||||
$session = Wootook::getSession($namespace);
|
||||
|
||||
foreach ($session->getMessages() as $messageLevel => $messageList) {
|
||||
if (!isset($messages[$messageLevel])) {
|
||||
$messages[$messageLevel] = $messageList;
|
||||
} else {
|
||||
$messages[$messageLevel] += $messageList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rsort($messages, SORT_NUMERIC);
|
||||
|
||||
$output = '<div class="messages">';
|
||||
foreach ($messages as $messageLevel => $messageList) {
|
||||
$output .= "<ul class=\"{$messageLevel}\">";
|
||||
foreach ($messageList as $message) {
|
||||
$output .= "<li>{$message}</li>";
|
||||
}
|
||||
$output .= '</ul>';
|
||||
}
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
46
src/application/code/core/Wootook/Core/Block/Template.php
Normal file
46
src/application/code/core/Wootook/Core/Block/Template.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Template
|
||||
extends Wootook_Core_View
|
||||
{
|
||||
protected function _getTemplatePath($file)
|
||||
{
|
||||
if ($this->getScriptPath() == '') {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()
|
||||
->addException(new Wootook_Core_Exception_RuntimeException("No script path defined in block {$this->getNameInLayout()}."));
|
||||
return null;
|
||||
}
|
||||
|
||||
$pattern = "{$this->getScriptPath()}/%s/%s/scripts/{$file}";
|
||||
if (($layout = $this->getLayout()) !== null) {
|
||||
$package = $this->getLayout()->getPackage();
|
||||
$theme = $this->getLayout()->getTheme();
|
||||
|
||||
if ($package !== Wootook_Core_Layout::DEFAULT_PACKAGE) {
|
||||
if ($theme !== Wootook_Core_Layout::DEFAULT_THEME) {
|
||||
$path = sprintf($pattern, $package, $theme);
|
||||
if (Wootook::fileExists($path)) {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
$path = sprintf($pattern, $package, Wootook_Core_Layout::DEFAULT_THEME);
|
||||
if (Wootook::fileExists($path)) {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()
|
||||
->addException(new Wootook_Core_Exception_RuntimeException("No layout defined."));
|
||||
}
|
||||
|
||||
$path = sprintf($pattern, Wootook_Core_Layout::DEFAULT_PACKAGE, Wootook_Core_Layout::DEFAULT_THEME);
|
||||
if (Wootook::fileExists($path)) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
Wootook_Core_ErrorProfiler::getSingleton()
|
||||
->addException(new Wootook_Core_Exception_RuntimeException("Template '{$file}' could not be found."));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
28
src/application/code/core/Wootook/Core/Block/Text.php
Normal file
28
src/application/code/core/Wootook/Core/Block/Text.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Block_Text
|
||||
extends Wootook_Core_View
|
||||
{
|
||||
protected $_content = null;
|
||||
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->_content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return $this->_content;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$content = $this->getContent();
|
||||
if (empty($content)) {
|
||||
return null;
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Config_Adapter_Abstract
|
||||
extends Wootook_Core_Config_Node
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Config_Adapter_Array
|
||||
extends Wootook_Core_Config_Adapter_Abstract
|
||||
{
|
||||
public function __construct($filename = null)
|
||||
{
|
||||
if ($filename !== null) {
|
||||
$this->load($filename);
|
||||
}
|
||||
}
|
||||
|
||||
public function load($filename)
|
||||
{
|
||||
if (!file_exists($filename)) {
|
||||
throw new Wootook_Core_Exception_DataAccessException(sprintf('Could not load config file "%s"', $filename));
|
||||
}
|
||||
$data = include $filename;
|
||||
|
||||
if (!is_array($data)) {
|
||||
throw new Wootook_Core_Exception_DataAccessException('Configuration file could not be loaded.');
|
||||
}
|
||||
|
||||
$this->_init($data);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function save($filename)
|
||||
{
|
||||
file_put_contents($filename, '<' . '?p' . 'hp return ' . var_export($this->toArray(), true) . ';');
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
217
src/application/code/core/Wootook/Core/Config/Node.php
Normal file
217
src/application/code/core/Wootook/Core/Config/Node.php
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Config_Node
|
||||
implements ArrayAccess
|
||||
{
|
||||
protected $_children = array();
|
||||
|
||||
protected $_parent = null;
|
||||
|
||||
protected static $_attributeNameCache = array();
|
||||
|
||||
public function __construct(Array $data = array(), $parent = null)
|
||||
{
|
||||
$this->_init($data, $parent);
|
||||
}
|
||||
|
||||
public function setData(Array $data = array())
|
||||
{
|
||||
$this->_init($data);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _init(Array $data, $parent = null)
|
||||
{
|
||||
if ($parent !== null) {
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
$this->_children = array();
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$this->offsetSet($key, new self($value, $this));
|
||||
} else {
|
||||
$this->offsetSet($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
public function setConfig($path, $value)
|
||||
{
|
||||
$explodedPath = explode('/', $path);
|
||||
|
||||
$length = count($explodedPath);
|
||||
$currentNode = $this;
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
if ($i < ($length - 1)) {
|
||||
if (!$currentNode->offsetExists($explodedPath[$i])) {
|
||||
$newNode = new Wootook_Core_Config_Node(array(), $currentNode);
|
||||
$currentNode->offsetSet($explodedPath[$i], $newNode);
|
||||
}
|
||||
} else if (is_array($value)) {
|
||||
$currentNode->offsetSet($explodedPath[$i], new self($value, $this));
|
||||
break;
|
||||
} else {
|
||||
$currentNode->offsetSet($explodedPath[$i], $value);
|
||||
break;
|
||||
}
|
||||
|
||||
$currentNode = $currentNode->offsetGet($explodedPath[$i]);
|
||||
|
||||
if (!$currentNode instanceof Wootook_Core_Config_Node) {
|
||||
throw new Wootook_Core_Exception_RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConfig($path)
|
||||
{
|
||||
$explodedPath = explode('/', $path);
|
||||
|
||||
$length = count($explodedPath);
|
||||
$currentNode = $this;
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
if (!$currentNode instanceof Wootook_Core_Config_Node) {
|
||||
throw new Wootook_Core_Exception_RuntimeException();
|
||||
}
|
||||
if (!$currentNode->offsetExists($explodedPath[$i])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$currentNode = $currentNode->offsetGet($explodedPath[$i]);
|
||||
}
|
||||
|
||||
return $currentNode;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
$result = array();
|
||||
foreach ($this->_children as $key => $child) {
|
||||
if ($child instanceof self) {
|
||||
$result[$key] = $child->toArray();
|
||||
} else if ($child instanceof Wootook_Core_Config_Leaf) {
|
||||
$result[$key] = $child->getValue();
|
||||
} else {
|
||||
$result[$key] = $child;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->_children = array();
|
||||
$this->_parent = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function merge(self $node)
|
||||
{
|
||||
foreach ($node->_children as $offset => $value) {
|
||||
if ($value instanceof self) {
|
||||
if (!$this->offsetExists($offset)) {
|
||||
$this->offsetSet($offset, new self(array(), $this));
|
||||
}
|
||||
$this->offsetGet($offset)->merge($value);
|
||||
} else {
|
||||
$this->offsetSet($offset, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _resolveAttributeName($key)
|
||||
{
|
||||
if (is_numeric($key)) {
|
||||
return $key;
|
||||
}
|
||||
if (!isset(self::$_attributeNameCache[$key])) {
|
||||
self::$_attributeNameCache[$key] = strtolower(preg_replace('#([A-Z])#', '-\\1', $key));
|
||||
}
|
||||
return self::$_attributeNameCache[$key];
|
||||
}
|
||||
|
||||
public function __get($offset)
|
||||
{
|
||||
return $this->offsetGet($this->_resolveAttributeName($offset));
|
||||
}
|
||||
|
||||
public function __set($offset, $value)
|
||||
{
|
||||
return $this->offsetSet($this->_resolveAttributeName($offset), $value);
|
||||
}
|
||||
|
||||
public function __isset($offset)
|
||||
{
|
||||
return $this->offsetExists($this->_resolveAttributeName($offset));
|
||||
}
|
||||
|
||||
public function __unset($offset)
|
||||
{
|
||||
return $this->offsetUnset($this->_resolveAttributeName($offset));
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$clone = new self();
|
||||
|
||||
foreach ($this->_children as $childName => $childNode) {
|
||||
if ($childNode instanceof self) {
|
||||
$childNode = clone $childNode;
|
||||
$childNode->_parent = $clone;
|
||||
}
|
||||
|
||||
$clone->offsetSet($childName, $childNode);
|
||||
}
|
||||
|
||||
return $clone;
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
if ($this->offsetExists($offset)) {
|
||||
return $this->_children[$offset];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if ($offset === null) {
|
||||
$this->_children[] = $value;
|
||||
} else {
|
||||
$this->_children[$offset] = $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
if (isset($this->_children[$offset])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
if ($this->offsetExists($offset)) {
|
||||
unset($this->_children[$offset]);
|
||||
}
|
||||
}
|
||||
}
|
||||
143
src/application/code/core/Wootook/Core/Controller/Action.php
Normal file
143
src/application/code/core/Wootook/Core/Controller/Action.php
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Controller_Action
|
||||
{
|
||||
private $_request = null;
|
||||
private $_response = null;
|
||||
|
||||
private $_layout = null;
|
||||
|
||||
public function __construct(Wootook_Core_Controller_Request_Http $request, Wootook_Core_Controller_Response_Http $response)
|
||||
{
|
||||
$this->setRequest($request);
|
||||
$this->setResponse($response);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
}
|
||||
|
||||
public function preDispatch()
|
||||
{
|
||||
}
|
||||
|
||||
public function postDispatch()
|
||||
{
|
||||
}
|
||||
|
||||
public function setRequest(Wootook_Core_Controller_Request_Http $request)
|
||||
{
|
||||
$this->_request = $request;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setResponse(Wootook_Core_Controller_Response_Http $response)
|
||||
{
|
||||
$this->_response = $response;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Wootook_Core_Controller_Request_Http
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->_request;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Wootook_Core_Controller_Response_Http
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->_response;
|
||||
}
|
||||
|
||||
protected function _forward($action, $controller = null, $module = null)
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$request->setActionName($action);
|
||||
if ($controller !== null) {
|
||||
$request->setControllerName($controller);
|
||||
if ($module != null) {
|
||||
$request->setModuleName($module);
|
||||
}
|
||||
}
|
||||
$this->getResponse()->setIsDispatched(false);
|
||||
}
|
||||
|
||||
protected function _redirect($uri, Array $params = array(), $code = Wootook_Core_Controller_Response_Http::REDIRECT_FOUND)
|
||||
{
|
||||
$this->getResponse()
|
||||
->setIsDispatched(false)
|
||||
->setRedirect(Wootook::getUrl($uri, $params), $code);
|
||||
|
||||
Wootook_Core_ErrorProfiler::unregister(true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _redirectUrl($url, $code = Wootook_Core_Controller_Response_Http::REDIRECT_FOUND)
|
||||
{
|
||||
$this->getResponse()->setRedirect($url, $code);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _buildLayoutHandle()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$module = $request->getModuleName();
|
||||
$controller = $request->getControllerName();
|
||||
$action = $request->getActionName();
|
||||
|
||||
return "{$module}.{$controller}.{$action}";
|
||||
}
|
||||
|
||||
public function loadLayout($handle = null)
|
||||
{
|
||||
if ($this->_layout === null) {
|
||||
$this->_layout = $this->_initLayout();
|
||||
}
|
||||
|
||||
if ($handle === null) {
|
||||
$handle = $this->_buildLayoutHandle();
|
||||
}
|
||||
$this->_layout->load($handle);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _initLayout()
|
||||
{
|
||||
return new Wootook_Core_Layout(Wootook_Core_Layout::DOMAIN_FRONTEND);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Wootook_Core_Layout
|
||||
*/
|
||||
public function getLayout()
|
||||
{
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
public function renderLayout()
|
||||
{
|
||||
try {
|
||||
$content = $this->getLayout()->render();
|
||||
} catch (Wootook_Core_Exception_LayoutException $e) {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
|
||||
return $this;
|
||||
}
|
||||
$this->getResponse()->setBody($content);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
190
src/application/code/core/Wootook/Core/Controller/Front.php
Normal file
190
src/application/code/core/Wootook/Core/Controller/Front.php
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Controller_Front
|
||||
{
|
||||
const ROUTE_DEFAULT = 'default';
|
||||
const ROUTE_ERROR = 'error';
|
||||
|
||||
protected $_routes = array(
|
||||
self::ROUTE_ERROR => array(
|
||||
'modules' => array(
|
||||
'core' => array(
|
||||
'class' => 'Wootook_Core_',
|
||||
'path' => 'Wootook/Core'
|
||||
)
|
||||
),
|
||||
'defaults' => array(
|
||||
'module' => 'core',
|
||||
'controller' => 'error',
|
||||
'action' => 'no-route'
|
||||
)
|
||||
),
|
||||
self::ROUTE_DEFAULT => array(
|
||||
'modules' => array(
|
||||
'core' => array(
|
||||
'class' => 'Wootook_Core_',
|
||||
'path' => 'Wootook/Core'
|
||||
),
|
||||
'admin' => array(
|
||||
'class' => 'Wootook_Admin_',
|
||||
'path' => 'Wootook/Admin'
|
||||
),
|
||||
'player' => array(
|
||||
'class' => 'Wootook_Player_',
|
||||
'path' => 'Wootook/Player'
|
||||
),
|
||||
'empire' => array(
|
||||
'class' => 'Wootook_Empire_',
|
||||
'path' => 'Wootook/Empire'
|
||||
)
|
||||
),
|
||||
'defaults' => array(
|
||||
'module' => 'core',
|
||||
'controller' => 'index',
|
||||
'action' => 'index'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
protected $_request = null;
|
||||
protected $_response = null;
|
||||
|
||||
public function __construct(Wootook_Core_Controller_Request_Abstract $request,
|
||||
Wootook_Core_Controller_Response_Abstract $response)
|
||||
{
|
||||
$this->_request = $request;
|
||||
$this->_response = $response;
|
||||
}
|
||||
|
||||
protected function _setNoRouteAction(&$route, &$moduleKey, &$controllerKey, &$actionKey)
|
||||
{
|
||||
$route = self::ROUTE_ERROR;
|
||||
$moduleKey = $this->_routes[self::ROUTE_ERROR]['defaults']['module'];
|
||||
$controllerKey = $this->_routes[self::ROUTE_ERROR]['defaults']['controller'];
|
||||
$actionKey = $this->_routes[self::ROUTE_ERROR]['defaults']['action'];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _setDefaultRouteAction(&$route, &$moduleKey, &$controllerKey, &$actionKey)
|
||||
{
|
||||
$route = self::ROUTE_DEFAULT;
|
||||
$moduleKey = $this->_routes[self::ROUTE_DEFAULT]['defaults']['module'];
|
||||
$controllerKey = $this->_routes[self::ROUTE_DEFAULT]['defaults']['controller'];
|
||||
$actionKey = $this->_routes[self::ROUTE_DEFAULT]['defaults']['action'];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _camelizeClass($string)
|
||||
{
|
||||
return str_replace(' ', '_', ucwords(str_replace('-', ' ', $string)));
|
||||
}
|
||||
|
||||
protected function _camelizeMethod($string)
|
||||
{
|
||||
return lcfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $string))));
|
||||
}
|
||||
|
||||
protected function _getControllerClass($modulePrefix, $controllerKey)
|
||||
{
|
||||
return $modulePrefix . $this->_camelizeClass($controllerKey) . 'Controller';
|
||||
}
|
||||
|
||||
protected function _getControllerPath($modulePath, $controllerKey)
|
||||
{
|
||||
return $modulePath . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR
|
||||
. $this->_camelizeClass($controllerKey) . 'Controller.php';
|
||||
}
|
||||
|
||||
protected function _getActionMethod($actionKey)
|
||||
{
|
||||
return $this->_camelizeMethod($actionKey) . 'Action';
|
||||
}
|
||||
|
||||
public function dispatch($route = null)
|
||||
{
|
||||
if ($route == null) {
|
||||
$route = self::ROUTE_DEFAULT;
|
||||
}
|
||||
|
||||
if (!isset($this->_routes[$route])) {
|
||||
$route = self::ROUTE_DEFAULT;
|
||||
}
|
||||
|
||||
$loop = 0;
|
||||
while ($loop++ < 100) {
|
||||
$moduleKey = $this->_request->getModuleName();
|
||||
$controllerKey = $this->_request->getControllerName();
|
||||
$actionKey = $this->_request->getActionName();
|
||||
|
||||
if (empty($moduleKey)) {
|
||||
$this->_setDefaultRouteAction($route, $moduleKey, $controllerKey, $actionKey);
|
||||
}
|
||||
|
||||
if (!isset($this->_routes[$route]['modules'][$moduleKey])) {
|
||||
$this->_setNoRouteAction($route, $moduleKey, $controllerKey, $actionKey);
|
||||
}
|
||||
|
||||
if (empty($controllerKey)) {
|
||||
$controllerKey = $this->_routes[$route]['defaults']['controller'];
|
||||
}
|
||||
|
||||
$controllerClass = $this->_getControllerClass($this->_routes[$route]['modules'][$moduleKey]['class'], $controllerKey);
|
||||
$controllerPath = $this->_getControllerPath($this->_routes[$route]['modules'][$moduleKey]['path'], $controllerKey);
|
||||
|
||||
if (!class_exists($controllerClass, false) && Wootook::fileExists($controllerPath)) {
|
||||
include_once $controllerPath;
|
||||
}
|
||||
|
||||
if (!class_exists($controllerClass, false)) {
|
||||
$this->_setNoRouteAction($route, $moduleKey, $controllerKey, $actionKey);
|
||||
|
||||
$controllerClass = $this->_getControllerClass($this->_routes[$route]['modules'][$moduleKey]['class'], $controllerKey);
|
||||
$controllerPath = $this->_getControllerPath($this->_routes[$route]['modules'][$moduleKey]['path'], $controllerKey);
|
||||
|
||||
include_once $controllerPath;
|
||||
}
|
||||
|
||||
if (empty($actionKey)) {
|
||||
$actionKey = $this->_routes[$route]['defaults']['action'];
|
||||
}
|
||||
|
||||
$actionMethod = $this->_getActionMethod($actionKey);
|
||||
if (!method_exists($controllerClass, $actionMethod)) {
|
||||
$this->_setNoRouteAction($route, $moduleKey, $controllerKey, $actionKey);
|
||||
|
||||
$controllerClass = $this->_getControllerClass($this->_routes[$route]['modules'][$moduleKey]['class'], $controllerKey);
|
||||
$controllerPath = $this->_getControllerPath($this->_routes[$route]['modules'][$moduleKey]['path'], $controllerKey);
|
||||
|
||||
include_once $controllerPath;
|
||||
|
||||
$actionMethod = $this->_getActionMethod($actionKey);
|
||||
}
|
||||
|
||||
$controller = new $controllerClass($this->_request, $this->_response);
|
||||
$controller->init();
|
||||
|
||||
$this->_response->setIsDispatched();
|
||||
|
||||
$controller->preDispatch();
|
||||
if (!$this->_response->isDispatched()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$controller->$actionMethod();
|
||||
$controller->postDispatch();
|
||||
|
||||
if ($this->_response->isDispatched()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
$this->_response->render();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Controller_Request_Abstract
|
||||
extends Wootook_Object
|
||||
{
|
||||
public function setParam($key, $value)
|
||||
{
|
||||
return $this->setData($key, $value);
|
||||
}
|
||||
|
||||
public function getParam($key, $default = null)
|
||||
{
|
||||
if ($this->hasData($key)) {
|
||||
return $this->getData($key);
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
abstract public function getModuleName();
|
||||
abstract public function getControllerName();
|
||||
abstract public function getActionName();
|
||||
|
||||
abstract public function setModuleName($name);
|
||||
abstract public function setControllerName($name);
|
||||
abstract public function setActionName($name);
|
||||
}
|
||||
|
|
@ -0,0 +1,280 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Controller_Request_Http
|
||||
extends Wootook_Core_Controller_Request_Abstract
|
||||
{
|
||||
protected $_baseUrl = null;
|
||||
|
||||
protected $_actionKey = 'action';
|
||||
protected $_controllerKey = 'controller';
|
||||
protected $_moduleKey = 'module';
|
||||
|
||||
public function __construct(Array $options = array())
|
||||
{
|
||||
parent::__construct($options);
|
||||
|
||||
$this->_baseUrl = Wootook::getBaseUrl();
|
||||
$baseUri = substr($this->_baseUrl, strpos($this->_baseUrl, '/', 8)); // Get the path from the DocumentRoot
|
||||
|
||||
$params = '';
|
||||
if (($offset = strpos($this->getServer('REQUEST_URI'), $baseUri)) !== false) {
|
||||
$path = substr($this->getServer('REQUEST_URI'), $offset + strlen($baseUri));
|
||||
|
||||
$moduleOffset = strpos($path, '/');
|
||||
if ($moduleOffset !== false) {
|
||||
$this->setModuleName(substr($path, 0, $moduleOffset));
|
||||
|
||||
$controllerOffset = strpos($path, '/', $moduleOffset + 1);
|
||||
if ($controllerOffset !== false) {
|
||||
$this->setControllerName(substr($path, $moduleOffset + 1, $controllerOffset - $moduleOffset - 1));
|
||||
|
||||
$actionOffset = strpos($path, '/', $controllerOffset + 1);
|
||||
if ($actionOffset !== false) {
|
||||
$this->setActionName(substr($path, $controllerOffset + 1, $actionOffset - $controllerOffset - 1));
|
||||
|
||||
$params = substr($path, $actionOffset);
|
||||
} else if ($controllerOffset !== false) {
|
||||
$this->setActionName(substr($path, $controllerOffset + 1));
|
||||
}
|
||||
} else if ($moduleOffset !== false) {
|
||||
$this->setControllerName(substr($path, $moduleOffset + 1));
|
||||
}
|
||||
} else {
|
||||
$this->setModuleName($path);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params)) {
|
||||
$paramOffset = 0;
|
||||
$valueOffset = 0;
|
||||
while (true) {
|
||||
$paramOffset = strpos($params, '/', $valueOffset + 1);
|
||||
if ($paramOffset === false) {
|
||||
break;
|
||||
}
|
||||
$paramKey = substr($params, $valueOffset + 1, $paramOffset - $valueOffset - 1);
|
||||
|
||||
$valueOffset = strpos($params, '/', $paramOffset + 1);
|
||||
if ($valueOffset === false) {
|
||||
$this->setParam($paramKey, substr($params, $paramOffset + 1));
|
||||
break;
|
||||
}
|
||||
$this->setParam($paramKey, substr($params, $paramOffset + 1, $valueOffset - $paramOffset - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setParam($key, $value)
|
||||
{
|
||||
return $this->setData($key, $value);
|
||||
}
|
||||
|
||||
public function getParam($key, $default = null)
|
||||
{
|
||||
if ($this->hasData($key)) {
|
||||
return $this->getData($key);
|
||||
}
|
||||
if (isset($_POST[$key])) {
|
||||
return $_POST[$key];
|
||||
}
|
||||
if (isset($_GET[$key])) {
|
||||
return $_GET[$key];
|
||||
}
|
||||
if (isset($_FILES[$key])) {
|
||||
return $_FILES[$key];
|
||||
}
|
||||
if (isset($_COOKIE[$key])) {
|
||||
return $_COOKIE[$key];
|
||||
}
|
||||
if (isset($_SERVER[$key])) {
|
||||
return $_SERVER[$key];
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function getQuery($key, $default = null)
|
||||
{
|
||||
if (!isset($_GET[$key])) {
|
||||
return $default;
|
||||
}
|
||||
return $_GET[$key];
|
||||
}
|
||||
|
||||
public function getFile($key, $default = null)
|
||||
{
|
||||
if (!isset($_FILES[$key])) {
|
||||
return $default;
|
||||
}
|
||||
return $_FILES[$key];
|
||||
}
|
||||
|
||||
public function getCookie($key, $default = null)
|
||||
{
|
||||
if (!isset($_COOKIE[$key])) {
|
||||
return $default;
|
||||
}
|
||||
return unserialize(stripslashes($_COOKIE[$key]));
|
||||
}
|
||||
|
||||
public function getRawCookie($key, $default = null)
|
||||
{
|
||||
if (!isset($_COOKIE[$key])) {
|
||||
return $default;
|
||||
}
|
||||
return $_COOKIE[$key];
|
||||
}
|
||||
|
||||
public function getPost($key, $default = null)
|
||||
{
|
||||
if (!isset($_POST[$key])) {
|
||||
return $default;
|
||||
}
|
||||
return $_POST[$key];
|
||||
}
|
||||
|
||||
public function getServer($key, $default = null)
|
||||
{
|
||||
if (!isset($_SERVER[$key])) {
|
||||
return $default;
|
||||
}
|
||||
return $_SERVER[$key];
|
||||
}
|
||||
|
||||
public function getAllQueryData()
|
||||
{
|
||||
return $_GET;
|
||||
}
|
||||
|
||||
public function getAllFilesData()
|
||||
{
|
||||
return $_FILES;
|
||||
}
|
||||
|
||||
public function getAllCookieData()
|
||||
{
|
||||
$data = array();
|
||||
foreach ($_COOKIE as $key => $value) {
|
||||
$data[$key] = unserialize(stripslashes($value));
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getAllRawCookieData()
|
||||
{
|
||||
return $_COOKIE;
|
||||
}
|
||||
|
||||
public function getAllPostData()
|
||||
{
|
||||
return $_POST;
|
||||
}
|
||||
|
||||
public function getAllServerData()
|
||||
{
|
||||
return $_SERVER;
|
||||
}
|
||||
|
||||
public function isPost()
|
||||
{
|
||||
if (strtoupper($this->getServer('REQUEST_METHOD')) == 'POST') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isPut()
|
||||
{
|
||||
if (strtoupper($this->getServer('REQUEST_METHOD')) == 'PUT') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isHead()
|
||||
{
|
||||
if (strtoupper($this->getServer('REQUEST_METHOD')) == 'HEAD') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isGet()
|
||||
{
|
||||
if (strtoupper($this->getServer('REQUEST_METHOD')) == 'GET') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getModuleKey()
|
||||
{
|
||||
return $this->_moduleKey;
|
||||
}
|
||||
|
||||
public function setModuleKey($key)
|
||||
{
|
||||
$this->_moduleKey = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getModuleName()
|
||||
{
|
||||
return $this->getParam($this->getModuleKey());
|
||||
}
|
||||
|
||||
public function setModuleName($name)
|
||||
{
|
||||
if ($name === null || is_string($name)) {
|
||||
return $this->setParam($this->getModuleKey(), $name);
|
||||
}
|
||||
}
|
||||
|
||||
public function getControllerKey()
|
||||
{
|
||||
return $this->_controllerKey;
|
||||
}
|
||||
|
||||
public function setControllerKey($key)
|
||||
{
|
||||
$this->_controllerKey = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getControllerName()
|
||||
{
|
||||
return $this->getParam($this->getControllerKey());
|
||||
}
|
||||
|
||||
public function setControllerName($name)
|
||||
{
|
||||
if ($name === null || is_string($name)) {
|
||||
return $this->setParam($this->getControllerKey(), $name);
|
||||
}
|
||||
}
|
||||
|
||||
public function getActionKey()
|
||||
{
|
||||
return $this->_actionKey;
|
||||
}
|
||||
|
||||
public function setActionKey($key)
|
||||
{
|
||||
$this->_actionKey = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActionName()
|
||||
{
|
||||
return $this->getParam($this->getActionKey());
|
||||
}
|
||||
|
||||
public function setActionName($name)
|
||||
{
|
||||
if ($name === null || is_string($name)) {
|
||||
return $this->setParam($this->getActionKey(), $name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Controller_Response_Abstract
|
||||
extends Wootook_Object
|
||||
{
|
||||
protected $_isDispatched = false;
|
||||
|
||||
public function setIsDispatched($dispatched = true)
|
||||
{
|
||||
$this->_isDispatched = $dispatched;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isDispatched()
|
||||
{
|
||||
return $this->_isDispatched;
|
||||
}
|
||||
|
||||
abstract public function render($send = true);
|
||||
}
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Controller_Response_Http
|
||||
extends Wootook_Core_Controller_Response_Abstract
|
||||
{
|
||||
const REDIRECT_MOVED_PERMANENTLY = 301;
|
||||
const REDIRECT_FOUND = 302;
|
||||
const REDIRECT_SEE_OTHER = 303;
|
||||
const REDIRECT_TEMPORARY = 307;
|
||||
|
||||
protected static $_redirectCodes = array(
|
||||
self::REDIRECT_MOVED_PERMANENTLY => 'Moved Permanently',
|
||||
self::REDIRECT_FOUND => 'Found',
|
||||
self::REDIRECT_SEE_OTHER => 'See Other',
|
||||
self::REDIRECT_TEMPORARY => 'Temporary Redirect'
|
||||
);
|
||||
|
||||
public function setBody($data)
|
||||
{
|
||||
$this->clearBody();
|
||||
|
||||
return $this->appendBody($data);
|
||||
}
|
||||
|
||||
public function appendBody($data)
|
||||
{
|
||||
if (!isset($this->_data['body']) || !is_array($this->_data['body'])) {
|
||||
$this->clearBody();
|
||||
}
|
||||
$this->_data['body'][] = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function clearBody()
|
||||
{
|
||||
$this->_data['body'] = array();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sendBody()
|
||||
{
|
||||
if (!isset($this->_data['body']) || empty($this->_data['body'])) {
|
||||
return '';
|
||||
}
|
||||
return implode('', $this->_data['body']);
|
||||
}
|
||||
|
||||
public function clearHeaders()
|
||||
{
|
||||
$this->_data['headers'] = array();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function clearRawHeaders()
|
||||
{
|
||||
$this->_data['raw_headers'] = array();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function clearAllHeaders()
|
||||
{
|
||||
$this->clearHeaders();
|
||||
$this->clearRawHeaders();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHeader($name, $value)
|
||||
{
|
||||
if (!isset($this->_data['headers']) || !is_array($this->_data['headers'])) {
|
||||
$this->clearHeaders();
|
||||
}
|
||||
$this->_data['headers'][$name] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRawHeader($value)
|
||||
{
|
||||
if (!isset($this->_data['raw_headers']) || !is_array($this->_data['raw_headers'])) {
|
||||
$this->clearRawHeaders();
|
||||
}
|
||||
$this->_data['raw_headers'][] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sendHeaders()
|
||||
{
|
||||
if (isset($this->_data['raw_headers'])) {
|
||||
foreach ($this->_data['raw_headers'] as $header) {
|
||||
header($header);
|
||||
}
|
||||
}
|
||||
if (isset($this->_data['headers'])) {
|
||||
foreach ($this->_data['headers'] as $headerName => $headerValue) {
|
||||
header("{$headerName}: {$headerValue}");
|
||||
}
|
||||
}
|
||||
$this->clearAllHeaders();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setIsRedirect($value = null)
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->_data['is_redirect'] = $value;
|
||||
}
|
||||
return $this->_data['is_redirect'];
|
||||
}
|
||||
|
||||
public function setCookie($name, $value, $lifetime = null, $path = null, $domain = null)
|
||||
{
|
||||
return $this->setRawCookie($name, serialize($value), $lifetime, $path, $domain);
|
||||
}
|
||||
|
||||
public function unsetCookie($name, $path = null, $domain = null)
|
||||
{
|
||||
return $this->setRawCookie($name, null, 0, $path, $domain);
|
||||
}
|
||||
|
||||
public function setRawCookie($name, $value, $lifetime = null, $path = null, $domain = null)
|
||||
{
|
||||
$date = new Wootook_Core_DateTime();
|
||||
$date->add($lifetime);
|
||||
|
||||
setcookie($name, $value, $date->getTimestamp(), $path, $domain);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRedirect($url, $code = self::REDIRECT_FOUND)
|
||||
{
|
||||
if (!in_array($code, self::$_redirectCodes)) {
|
||||
$code = self::REDIRECT_FOUND;
|
||||
}
|
||||
|
||||
$statusText = self::$_redirectCodes[$code];
|
||||
$this->setRawHeader("HTTP/1.1 {$code} {$statusText}")
|
||||
->setHeader('Location', $url)
|
||||
->setIsRedirect(true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render($send = true)
|
||||
{
|
||||
if ($send) {
|
||||
$this->sendHeaders();
|
||||
echo $this->sendBody();
|
||||
} else {
|
||||
return $this->sendBody();
|
||||
}
|
||||
}
|
||||
}
|
||||
138
src/application/code/core/Wootook/Core/Database.php
Normal file
138
src/application/code/core/Wootook/Core/Database.php
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Database
|
||||
extends PDO
|
||||
{
|
||||
const DEFAULT_CONNECTION_NAME = 'default';
|
||||
|
||||
protected static $_connections = array();
|
||||
protected static $_connectionAliases = array();
|
||||
|
||||
protected $_tablePrefix = null;
|
||||
protected $_dsn = null;
|
||||
protected $_username = null;
|
||||
protected $_password = null;
|
||||
|
||||
public static $options = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getSingleton()
|
||||
{
|
||||
return self::getConnection(self::DEFAULT_CONNECTION_NAME);
|
||||
}
|
||||
|
||||
public function quoteIdentifier($identifier)
|
||||
{
|
||||
return "`$identifier`";
|
||||
}
|
||||
|
||||
public static function getConnection($connectionName)
|
||||
{
|
||||
if (empty($connectionName) || $connectionName === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isset(self::$_connections[$connectionName])) {
|
||||
if (isset(self::$_connectionAliases[$connectionName])) {
|
||||
return self::$_connectionAliases[$connectionName];
|
||||
}
|
||||
|
||||
$connectionConfig = Wootook::getConfig("resource/database/{$connectionName}");
|
||||
if ($connectionConfig === null) {
|
||||
return null;
|
||||
}
|
||||
if ($alias = $connectionConfig->use) {
|
||||
self::$_connectionAliases[$connectionName] = self::getConnection($alias);
|
||||
|
||||
return self::$_connectionAliases[$connectionName];
|
||||
}
|
||||
|
||||
self::$_connections[$connectionName] = self::_initConnection($connectionName,
|
||||
$connectionConfig->engine, $connectionConfig->params, $connectionConfig->options);
|
||||
}
|
||||
|
||||
return self::$_connections[$connectionName];
|
||||
}
|
||||
|
||||
private static function _initConnection($connectionName, $engine, $params, $options = array())
|
||||
{
|
||||
if (is_array($params)) {
|
||||
$params = new Wootook_Core_Config_Node($params);
|
||||
} else if (!$params instanceof Wootook_Core_Config_Node) {
|
||||
$params = new Wootook_Core_Config_Node(array());
|
||||
}
|
||||
|
||||
if ($options instanceof Wootook_Core_Config_Node) {
|
||||
$options = $options->toArray();
|
||||
} else if (!is_array($options)) {
|
||||
$options = array();
|
||||
}
|
||||
|
||||
$hostname = $params->hostname;
|
||||
$username = $params->username;
|
||||
$password = $params->password;
|
||||
$database = $params->database;
|
||||
|
||||
if (empty($params->hostname) || empty($params->username) || empty($params->database)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$dsn = "mysql:dbname={$params->database};host={$params->hostname}";
|
||||
if (is_numeric($params->port)) {
|
||||
$dsn .= ";port={$params->port}";
|
||||
}
|
||||
|
||||
$event = Wootook::dispatchEvent('database.prepare-options', array(
|
||||
'name' => $connectionName,
|
||||
'options' => array_merge(self::$options, $options)
|
||||
));
|
||||
|
||||
$options = $event->getData('options');
|
||||
|
||||
$connection = new self($dsn, $params->username, $params->password, $options);
|
||||
$connection->_dsn = $dsn;
|
||||
$connection->_username = $username;
|
||||
|
||||
if (defined('DEBUG')) {
|
||||
$connection->_password = $password;
|
||||
}
|
||||
|
||||
if (($prefix = Wootook::getConfig("resource/database/{$connectionName}/table_prefix")) !== null) {
|
||||
$connection->setTablePrefix($prefix);
|
||||
}
|
||||
|
||||
Wootook::dispatchEvent('database.init', array(
|
||||
'name' => $connectionName,
|
||||
'handler' => $connection
|
||||
));
|
||||
|
||||
return $connection;
|
||||
}
|
||||
|
||||
public function setTablePrefix($prefix)
|
||||
{
|
||||
$this->_tablePrefix = $prefix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTablePrefix()
|
||||
{
|
||||
return $this->_tablePrefix;
|
||||
}
|
||||
|
||||
public function getTable($name)
|
||||
{
|
||||
return $this->getTablePrefix() . $name;
|
||||
}
|
||||
|
||||
public function select($tableName = null)
|
||||
{
|
||||
return new Wootook_Core_Database_Sql_Mysql_Select($this, $tableName);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Database_Orm_DataMapper
|
||||
extends Wootook_Core_PluginLoader_Abstract
|
||||
{
|
||||
protected $_rules = array();
|
||||
|
||||
protected $_alias = array();
|
||||
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->registerNamespace('Wootook_Core_Database_Orm_DataMapper_');
|
||||
|
||||
if (!is_array($config) || !$config instanceof Wootook_Core_Config_Node) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($config as $field => $typeConfig) {
|
||||
if (is_string($typeConfig)) {
|
||||
$this->addRule($field, $typeConfig);
|
||||
} else if (is_array($typeConfig) && isset($typeConfig['type'])) {
|
||||
if (isset($typeConfig['alias'])) {
|
||||
$this->addRule($field, $typeConfig['type'], $typeConfig['alias']);
|
||||
} else {
|
||||
$this->addRule($field, $typeConfig['type']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addRule($field, $type, $alias = null)
|
||||
{
|
||||
if (($instance = $this->load($type)) !== null) {
|
||||
$this->_rules[$field] = $instance;
|
||||
}
|
||||
|
||||
if ($alias === null) {
|
||||
$alias = $field;
|
||||
}
|
||||
|
||||
$this->_alias[$field] = $alias;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeRule($field)
|
||||
{
|
||||
unset($this->_rules[$field]);
|
||||
unset($this->_alias[$field]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _load($className, $useSingleton)
|
||||
{
|
||||
$reflection = new ReflectionClass($className);
|
||||
if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) {
|
||||
$method = $reflection->getMethod('getSingleton');
|
||||
return $method->invoke(null);
|
||||
}
|
||||
|
||||
try {
|
||||
return $reflection->newInstance();
|
||||
} catch (ReflectionException $e) {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()
|
||||
->addException($e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Wootook_Core_Database_Resource $entity
|
||||
* @param Array $datas
|
||||
* @return Array
|
||||
*/
|
||||
public function encode(Wootook_Core_Database_Resource $entity, Array $datas = array())
|
||||
{
|
||||
$aliasTable = array_flip($this->_alias);
|
||||
foreach ($entity->getAllDatas() as $aliasedField => $decodedValue) {
|
||||
if (!isset($aliasTable[$aliasedField])) {
|
||||
$field = $aliasedField;
|
||||
} else {
|
||||
$field = $aliasTable[$aliasedField];
|
||||
}
|
||||
|
||||
if (isset($this->_rules[$field])) {
|
||||
$datas[$field] = $this->_rules[$field]->encode($decodedValue);
|
||||
} else {
|
||||
$datas[$field] = $decodedValue;
|
||||
}
|
||||
}
|
||||
|
||||
return $datas;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Wootook_Core_Database_Resource $entity
|
||||
* @param Array $datas
|
||||
* @return Wootook_Core_Database_Resource
|
||||
*/
|
||||
public function decode(Wootook_Core_Database_Resource $entity, Array $datas = array())
|
||||
{
|
||||
foreach ($datas as $field => $encodedValue) {
|
||||
if (isset($this->_rules[$field])) {
|
||||
$entity->setData($this->_alias[$field], $this->_rules[$field]->decode($encodedValue));
|
||||
} else {
|
||||
$entity->setData($field, $encodedValue);
|
||||
}
|
||||
}
|
||||
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Database_Orm_DataMapper_Array
|
||||
extends Wootook_Core_Database_Orm_DataMapper_FieldAbstract
|
||||
{
|
||||
public function encode($value)
|
||||
{
|
||||
return serialize($value);
|
||||
}
|
||||
|
||||
public function decode($value)
|
||||
{
|
||||
return unserialize($value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Database_Orm_DataMapper_Config
|
||||
extends Wootook_Core_Database_Orm_DataMapper_Array
|
||||
{
|
||||
public function encode($value)
|
||||
{
|
||||
return parent::encode($value->toArray());
|
||||
}
|
||||
|
||||
public function decode($value)
|
||||
{
|
||||
return new Wootook_Core_Config_Node(parent::decode($value));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Database_Orm_DataMapper_DateTime
|
||||
extends Wootook_Core_Database_Orm_DataMapper_FieldAbstract
|
||||
{
|
||||
const DATE_FORMAT_MYSQL = 'Y-m-d G:i:s';
|
||||
|
||||
protected $_format = self::DATE_FORMAT_MYSQL;
|
||||
|
||||
public function setFormat($format = null)
|
||||
{
|
||||
if ($format === null) {
|
||||
$this->_format = self::DATE_FORMAT_MYSQL;
|
||||
} else {
|
||||
$this->_format = $format;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFormat()
|
||||
{
|
||||
return $this->_format;
|
||||
}
|
||||
|
||||
public function encode($value)
|
||||
{
|
||||
if (!$value instanceof Wootook_Core_DateTime) {
|
||||
$value = new Wootook_Core_DateTime($value);
|
||||
}
|
||||
|
||||
return $value->toString($this->getFormat());
|
||||
}
|
||||
|
||||
public function decode($value)
|
||||
{
|
||||
return new Wootook_Core_DateTime($value, $this->getFormat());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Database_Orm_DataMapper_FieldAbstract
|
||||
{
|
||||
abstract public function encode($value);
|
||||
|
||||
abstract public function decode($value);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue