mirror of
https://github.com/YunoHost-Apps/spip_ynh.git
synced 2024-09-03 20:25:59 +02:00
Dellete source + DL and extract source SPIP
This commit is contained in:
parent
2974ce8afd
commit
1de0cc07b4
4012 changed files with 16 additions and 389370 deletions
|
@ -2,6 +2,15 @@
|
|||
|
||||
## Spip for YunoHost
|
||||
|
||||
Version 1.0.1 (04/01/15)
|
||||
|
||||
- Delete SPIP sources
|
||||
- Fix install script for download and extract SPIP
|
||||
|
||||
Version 1.0.0 (28/12/15)
|
||||
|
||||
- Create script install
|
||||
|
||||
### Configuration
|
||||
|
||||
1. Start url https://domaine.tld/spip/ecrire
|
||||
|
|
|
@ -29,12 +29,12 @@ db_user=spip
|
|||
sudo yunohost app initdb $db_user -p $db_pwd
|
||||
sudo yunohost app setting spip mysqlpwd -v $db_pwd
|
||||
|
||||
# Copy files to the right place
|
||||
final_path=/var/www/spip
|
||||
sudo mkdir -p $final_path
|
||||
sudo cp -a ../sources/* $final_path
|
||||
# Download and extract files to the right place
|
||||
final_path=/var/www
|
||||
wget http://files.spip.org/spip/stable/spip-3.0.zip
|
||||
unzip spip-3.0.zip -d $final_path
|
||||
|
||||
# Set permissions to roundcube directory
|
||||
# Set permissions to spip directory
|
||||
sudo chown -R www-data: $final_path
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,674 +0,0 @@
|
|||
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>.
|
|
@ -1,3 +0,0 @@
|
|||
Vous pouvez effacer ce fichier sans dommages.
|
||||
|
||||
You can safely remove this file.
|
|
@ -1,15 +0,0 @@
|
|||
|
||||
###### Installation de SPIP #####
|
||||
|
||||
Rendez-vous avec votre navigateur sur la page ecrire/
|
||||
pour commencer l'installation de votre site SPIP.
|
||||
|
||||
Votre serveur Web doit offrir php (version > 5.1.0) et MySQL ou SQLite.
|
||||
|
||||
Pour permettre a SPIP de gerer de belles adresses (URL),
|
||||
vous devrez probablement renommer le fichier htaccess.txt
|
||||
en .htaccess a la racine du site (apres avoir, si necessaire,
|
||||
edite la ligne RewriteBase ; voir les commentaires).
|
||||
|
||||
################################# http://www.spip.net/
|
||||
|
|
@ -1,334 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ecran_securite.php
|
||||
* ------------------
|
||||
*/
|
||||
|
||||
define('_ECRAN_SECURITE', '1.2.2'); // 2014-12-01
|
||||
|
||||
/*
|
||||
* Documentation : http://www.spip.net/fr_article4200.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test utilisateur
|
||||
*/
|
||||
if (isset($_GET['test_ecran_securite']))
|
||||
$ecran_securite_raison = 'test '._ECRAN_SECURITE;
|
||||
|
||||
/*
|
||||
* Détecteur de robot d'indexation
|
||||
*/
|
||||
if (!defined('_IS_BOT'))
|
||||
define('_IS_BOT',
|
||||
isset($_SERVER['HTTP_USER_AGENT'])
|
||||
AND preg_match(
|
||||
// mots generiques
|
||||
',bot|slurp|crawler|spider|webvac|yandex|'
|
||||
// MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot
|
||||
. 'MSIE 6\.0|'
|
||||
// UA plus cibles
|
||||
. '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti'
|
||||
. ',i',(string) $_SERVER['HTTP_USER_AGENT'])
|
||||
);
|
||||
|
||||
/*
|
||||
* Interdit de passer une variable id_article (ou id_xxx) qui ne
|
||||
* soit pas numérique (ce qui bloque l'exploitation de divers trous
|
||||
* de sécurité, dont celui de toutes les versions < 1.8.2f)
|
||||
* (sauf pour id_table, qui n'est pas numérique jusqu'à [5743])
|
||||
* (id_base est une variable de la config des widgets de WordPress)
|
||||
*/
|
||||
foreach ($_GET as $var => $val)
|
||||
if ($_GET[$var] AND strncmp($var,"id_",3)==0
|
||||
AND !in_array($var, array('id_table','id_base')))
|
||||
$_GET[$var] = is_array($_GET[$var])?@array_map('intval',$_GET[$var]):intval($_GET[$var]);
|
||||
foreach ($_POST as $var => $val)
|
||||
if ($_POST[$var] AND strncmp($var,"id_",3)==0
|
||||
AND !in_array($var, array('id_table','id_base')))
|
||||
$_POST[$var] = is_array($_POST[$var])?@array_map('intval',$_POST[$var]):intval($_POST[$var]);
|
||||
foreach ($GLOBALS as $var => $val)
|
||||
if ($GLOBALS[$var] AND strncmp($var,"id_",3)==0
|
||||
AND !in_array($var, array('id_table','id_base')))
|
||||
$GLOBALS[$var] = is_array($GLOBALS[$var])?@array_map('intval',$GLOBALS[$var]):intval($GLOBALS[$var]);
|
||||
|
||||
/*
|
||||
* Interdit la variable $cjpeg_command, qui était utilisée sans
|
||||
* précaution dans certaines versions de dev (1.8b2 -> 1.8b5)
|
||||
*/
|
||||
$cjpeg_command='';
|
||||
|
||||
/*
|
||||
* Contrôle de quelques variables (XSS)
|
||||
*/
|
||||
foreach(array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre') as $var) {
|
||||
if (isset($_GET[$var]))
|
||||
$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,',' ',(string)$_GET[$var]);
|
||||
if (isset($_POST[$var]))
|
||||
$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,',' ',(string)$_POST[$var]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Filtre l'accès à spip_acces_doc (injection SQL en 1.8.2x)
|
||||
*/
|
||||
if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
|
||||
$file = addslashes((string)$_GET['file']);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pas d'inscription abusive
|
||||
*/
|
||||
if (isset($_REQUEST['mode']) AND isset($_REQUEST['page'])
|
||||
AND !in_array($_REQUEST['mode'],array("6forum","1comite"))
|
||||
AND $_REQUEST['page'] == "identifiants")
|
||||
$ecran_securite_raison = "identifiants";
|
||||
|
||||
/*
|
||||
* Agenda joue à l'injection php
|
||||
*/
|
||||
if (isset($_REQUEST['partie_cal'])
|
||||
AND $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal']))
|
||||
$ecran_securite_raison = "partie_cal";
|
||||
if (isset($_REQUEST['echelle'])
|
||||
AND $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle']))
|
||||
$ecran_securite_raison = "echelle";
|
||||
|
||||
/*
|
||||
* Espace privé
|
||||
*/
|
||||
if (isset($_REQUEST['exec'])
|
||||
AND !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec']))
|
||||
$ecran_securite_raison = "exec";
|
||||
if (isset($_REQUEST['cherche_auteur'])
|
||||
AND preg_match(',[<],', (string)$_REQUEST['cherche_auteur']))
|
||||
$ecran_securite_raison = "cherche_auteur";
|
||||
if (isset($_REQUEST['exec'])
|
||||
AND $_REQUEST['exec'] == 'auteurs'
|
||||
AND preg_match(',[<],', (string)$_REQUEST['recherche']))
|
||||
$ecran_securite_raison = "recherche";
|
||||
if (isset($_REQUEST['action'])
|
||||
AND $_REQUEST['action'] == 'configurer') {
|
||||
if (@file_exists('inc_version.php')
|
||||
OR @file_exists('ecrire/inc_version.php')) {
|
||||
function action_configurer() {
|
||||
include_spip('inc/autoriser');
|
||||
if(!autoriser('configurer', _request('configuration'))) {
|
||||
include_spip('inc/minipres');
|
||||
echo minipres(_T('info_acces_interdit'));
|
||||
exit;
|
||||
}
|
||||
require _DIR_RESTREINT.'action/configurer.php';
|
||||
action_configurer_dist();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Bloque les requêtes contenant %00 (manipulation d'include)
|
||||
*/
|
||||
if (strpos(
|
||||
@get_magic_quotes_gpc() ?
|
||||
stripslashes(serialize($_REQUEST)) : serialize($_REQUEST),
|
||||
chr(0)
|
||||
) !== false)
|
||||
$ecran_securite_raison = "%00";
|
||||
|
||||
/*
|
||||
* Bloque les requêtes fond=formulaire_
|
||||
*/
|
||||
if (isset($_REQUEST['fond'])
|
||||
AND preg_match(',^formulaire_,i', $_REQUEST['fond']))
|
||||
$ecran_securite_raison = "fond=formulaire_";
|
||||
|
||||
/*
|
||||
* Bloque les requêtes du type ?GLOBALS[type_urls]=toto (bug vieux php)
|
||||
*/
|
||||
if (isset($_REQUEST['GLOBALS']))
|
||||
$ecran_securite_raison = "GLOBALS[GLOBALS]";
|
||||
|
||||
/*
|
||||
* Bloque les requêtes des bots sur:
|
||||
* les agenda
|
||||
* les paginations entremélées
|
||||
*/
|
||||
if (_IS_BOT AND (
|
||||
(isset($_REQUEST['echelle']) AND isset($_REQUEST['partie_cal']) AND isset($_REQUEST['type']))
|
||||
OR (strpos((string)$_SERVER['REQUEST_URI'],'debut_') AND preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
|
||||
)
|
||||
)
|
||||
$ecran_securite_raison = "robot agenda/double pagination";
|
||||
|
||||
/*
|
||||
* Bloque une vieille page de tests de CFG (<1.11)
|
||||
* Bloque un XSS sur une page inexistante
|
||||
*/
|
||||
if (isset($_REQUEST['page'])) {
|
||||
if ($_REQUEST['page']=='test_cfg')
|
||||
$ecran_securite_raison = "test_cfg";
|
||||
if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page']))
|
||||
$ecran_securite_raison = "xsspage";
|
||||
if ($_REQUEST['page'] == '404'
|
||||
AND isset($_REQUEST['erreur']))
|
||||
$ecran_securite_raison = "xss404";
|
||||
}
|
||||
|
||||
/*
|
||||
* XSS par array
|
||||
*/
|
||||
foreach (array('var_login') as $var)
|
||||
if (isset($_REQUEST[$var]) AND is_array($_REQUEST[$var]))
|
||||
$ecran_securite_raison = "xss ".$var;
|
||||
|
||||
/*
|
||||
* Parade antivirale contre un cheval de troie
|
||||
*/
|
||||
if (!function_exists('tmp_lkojfghx')) {
|
||||
function tmp_lkojfghx() {}
|
||||
function tmp_lkojfghx2($a=0, $b=0, $c=0, $d=0) {
|
||||
// si jamais on est arrivé ici sur une erreur php
|
||||
// et qu'un autre gestionnaire d'erreur est défini, l'appeller
|
||||
if ($b&&$GLOBALS['tmp_xhgfjokl'])
|
||||
call_user_func($GLOBALS['tmp_xhgfjokl'],$a,$b,$c,$d);
|
||||
}
|
||||
}
|
||||
if (isset($_POST['tmp_lkojfghx3']))
|
||||
$ecran_securite_raison = "gumblar";
|
||||
|
||||
/*
|
||||
* Outils XML mal sécurisés < 2.0.9
|
||||
*/
|
||||
if (isset($_REQUEST['transformer_xml']))
|
||||
$ecran_securite_raison = "transformer_xml";
|
||||
|
||||
/*
|
||||
* Sauvegarde mal securisée < 2.0.9
|
||||
*/
|
||||
if (isset($_REQUEST['nom_sauvegarde'])
|
||||
AND strstr((string)$_REQUEST['nom_sauvegarde'], '/'))
|
||||
$ecran_securite_raison = 'nom_sauvegarde manipulee';
|
||||
if (isset($_REQUEST['znom_sauvegarde'])
|
||||
AND strstr((string)$_REQUEST['znom_sauvegarde'], '/'))
|
||||
$ecran_securite_raison = 'znom_sauvegarde manipulee';
|
||||
|
||||
|
||||
/*
|
||||
* op permet des inclusions arbitraires ;
|
||||
* on vérifie 'page' pour ne pas bloquer ... drupal
|
||||
*/
|
||||
if (isset($_REQUEST['op']) AND isset($_REQUEST['page'])
|
||||
AND $_REQUEST['op'] !== preg_replace('/[^\-\w]/', '', $_REQUEST['op']))
|
||||
$ecran_securite_raison = 'op';
|
||||
|
||||
/*
|
||||
* Forms & Table ne se méfiait pas assez des uploads de fichiers
|
||||
*/
|
||||
if (count($_FILES)){
|
||||
foreach($_FILES as $k=>$v){
|
||||
if (preg_match(',^fichier_\d+$,',$k)
|
||||
AND preg_match(',\.php,i',$v['name']))
|
||||
unset($_FILES[$k]);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* et Contact trop laxiste avec une variable externe
|
||||
* on bloque pas le post pour eviter de perdre des donnees mais on unset la variable et c'est tout
|
||||
*/
|
||||
if (isset($_REQUEST['pj_enregistrees_nom']) AND $_REQUEST['pj_enregistrees_nom']){
|
||||
unset($_REQUEST['pj_enregistrees_nom']);
|
||||
unset($_GET['pj_enregistrees_nom']);
|
||||
unset($_POST['pj_enregistrees_nom']);
|
||||
}
|
||||
|
||||
/*
|
||||
* reinstall=oui un peu trop permissif
|
||||
*/
|
||||
if (isset($_REQUEST['reinstall'])
|
||||
AND $_REQUEST['reinstall'] == 'oui')
|
||||
$ecran_securite_raison = 'reinstall=oui';
|
||||
|
||||
/*
|
||||
* Échappement xss referer
|
||||
*/
|
||||
if (isset($_SERVER['HTTP_REFERER']))
|
||||
$_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##');
|
||||
|
||||
/*
|
||||
* Réinjection des clés en html dans l'admin r19561
|
||||
*/
|
||||
if (strpos($_SERVER['REQUEST_URI'],"ecrire/")!==false){
|
||||
$zzzz=implode("",array_keys($_REQUEST));
|
||||
if (strlen($zzzz)!=strcspn($zzzz,'<>"\''))
|
||||
$ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
|
||||
}
|
||||
|
||||
/*
|
||||
* Injection par connect
|
||||
*/
|
||||
if (isset($_REQUEST['connect'])
|
||||
AND
|
||||
// cas qui permettent de sortir d'un commentaire PHP
|
||||
(strpos($_REQUEST['connect'], "?")!==false
|
||||
OR strpos($_REQUEST['connect'], "<")!==false
|
||||
OR strpos($_REQUEST['connect'], ">")!==false
|
||||
OR strpos($_REQUEST['connect'], "\n")!==false
|
||||
OR strpos($_REQUEST['connect'], "\r")!==false)
|
||||
) {
|
||||
$ecran_securite_raison = "malformed connect argument";
|
||||
}
|
||||
|
||||
/*
|
||||
* S'il y a une raison de mourir, mourons
|
||||
*/
|
||||
if (isset($ecran_securite_raison)) {
|
||||
header("HTTP/1.0 403 Forbidden");
|
||||
header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Pragma: no-cache");
|
||||
header("Content-Type: text/html");
|
||||
die("<html><title>Error 403: Forbidden</title><body><h1>Error 403</h1><p>You are not authorized to view this page ($ecran_securite_raison)</p></body></html>");
|
||||
}
|
||||
|
||||
/*
|
||||
* Fin sécurité
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Bloque les bots quand le load déborde
|
||||
*/
|
||||
if (!defined('_ECRAN_SECURITE_LOAD'))
|
||||
define('_ECRAN_SECURITE_LOAD', 4);
|
||||
|
||||
if (
|
||||
defined('_ECRAN_SECURITE_LOAD')
|
||||
AND _ECRAN_SECURITE_LOAD>0
|
||||
AND _IS_BOT
|
||||
AND $_SERVER['REQUEST_METHOD'] === 'GET'
|
||||
AND (
|
||||
(function_exists('sys_getloadavg')
|
||||
AND $load = sys_getloadavg()
|
||||
AND is_array($load)
|
||||
AND $load = array_shift($load)
|
||||
)
|
||||
OR
|
||||
(@is_readable('/proc/loadavg')
|
||||
AND $load = file_get_contents('/proc/loadavg')
|
||||
AND $load = floatval($load)
|
||||
)
|
||||
)
|
||||
AND $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite
|
||||
AND rand(0, $load*$load) > _ECRAN_SECURITE_LOAD*_ECRAN_SECURITE_LOAD
|
||||
) {
|
||||
header("HTTP/1.0 503 Service Unavailable");
|
||||
header("Retry-After: 300");
|
||||
header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Pragma: no-cache");
|
||||
header("Content-Type: text/html");
|
||||
die("<html><title>Status 503: Site temporarily unavailable</title><body><h1>Status 503</h1><p>Site temporarily unavailable (load average $load)</p></body></html>");
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,3 +0,0 @@
|
|||
Vous pouvez effacer ce fichier sans dommages.
|
||||
|
||||
You can safely remove this file.
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// mise a jour des donnees si envoi via formulaire
|
||||
// http://doc.spip.org/@enregistre_modif_plugin
|
||||
function enregistre_modif_plugin(){
|
||||
include_spip('inc/plugin');
|
||||
// recuperer les plugins dans l'ordre des $_POST
|
||||
$test = array();
|
||||
foreach(liste_plugin_files() as $file){
|
||||
$test['s'.substr(md5(_DIR_PLUGINS.$file),0,16)] = $file;
|
||||
}
|
||||
if (defined('_DIR_PLUGINS_SUPPL'))
|
||||
foreach(liste_plugin_files(_DIR_PLUGINS_SUPPL) as $file){
|
||||
$test['s'.substr(md5(_DIR_PLUGINS_SUPPL.$file),0,16)] = $file;
|
||||
}
|
||||
|
||||
$plugin=array();
|
||||
|
||||
foreach($_POST as $choix=>$val){
|
||||
if (isset($test[$choix])&&$val=='O')
|
||||
$plugin[]=$test[$choix];
|
||||
}
|
||||
|
||||
spip_log("Changement des plugins actifs par l'auteur " . $GLOBALS['visiteur_session']['id_auteur'] . ": " . join(',', $plugin));
|
||||
ecrire_plugin_actifs($plugin);
|
||||
|
||||
// Chaque fois que l'on valide des plugins, on memorise la liste de ces plugins comme etant "interessants", avec un score initial, qui sera decremente a chaque tour : ainsi un plugin active pourra reter visible a l'ecran, jusqu'a ce qu'il tombe dans l'oubli.
|
||||
$plugins_interessants = @unserialize($GLOBALS['meta']['plugins_interessants']);
|
||||
if (!is_array($plugins_interessants))
|
||||
$plugins_interessants = array();
|
||||
|
||||
$plugins_interessants2 = array();
|
||||
|
||||
foreach($plugins_interessants as $plug => $score)
|
||||
if ($score > 1)
|
||||
$plugins_interessants2[$plug] = $score-1;
|
||||
foreach ($plugin as $plug)
|
||||
$plugins_interessants2[$plug] = 10; // score initial
|
||||
ecrire_meta('plugins_interessants', serialize($plugins_interessants2));
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@action_activer_plugins_dist
|
||||
function action_activer_plugins_dist() {
|
||||
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$securiser_action();
|
||||
|
||||
if (!autoriser('configurer', '_plugins'))
|
||||
die('erreur');
|
||||
// forcer la maj des meta pour les cas de modif de numero de version base via phpmyadmin
|
||||
lire_metas();
|
||||
enregistre_modif_plugin();
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
function action_ajouter_lien_dist($arg=null){
|
||||
if (is_null($arg)){
|
||||
$securiser_action = charger_fonction('securiser_action','inc');
|
||||
$arg = $securiser_action();
|
||||
}
|
||||
|
||||
$arg = explode("-",$arg);
|
||||
list($objet_source,$ids,$objet_lie,$idl) = $arg;
|
||||
|
||||
include_spip('action/editer_liens');
|
||||
objet_associer(array($objet_source=>$ids), array($objet_lie=>$idl));
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Annuler un travail
|
||||
* @return void
|
||||
*/
|
||||
function action_annuler_job_dist(){
|
||||
$securiser_action = charger_fonction('securiser_action','inc');
|
||||
$id_job = $securiser_action();
|
||||
|
||||
if ($id_job = intval($id_job)
|
||||
AND autoriser('annuler','job',$id_job)
|
||||
){
|
||||
job_queue_remove($id_job);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Retour d'authentification pour les SSO
|
||||
*/
|
||||
function action_auth_dist() {
|
||||
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
|
||||
if (!preg_match(",^(\w+)[/](.+)$,", $arg, $r)) {
|
||||
spip_log("action_auth_dist $arg pas compris");
|
||||
}
|
||||
else {
|
||||
$auth_methode = $r[1];
|
||||
$login = $r[2];
|
||||
include_spip('inc/auth');
|
||||
$res = auth_terminer_identifier_login($auth_methode, $login);
|
||||
|
||||
if (is_string($res)){ // Erreur
|
||||
$redirect = _request('redirect');
|
||||
$redirect = parametre_url($redirect,'var_erreur',$res,'&');
|
||||
include_spip('inc/headers');
|
||||
redirige_par_entete($redirect);
|
||||
}
|
||||
|
||||
// sinon on loge l'auteur identifie, et on finit (redirection automatique)
|
||||
auth_loger($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Calculer la taille du cache ou du cache image pour l'afficher en ajax sur la page d'admin de SPIP
|
||||
*
|
||||
* @param string|null $arg
|
||||
*/
|
||||
function action_calculer_taille_cache_dist($arg=null){
|
||||
if (is_null($arg)){
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
}
|
||||
include_spip('inc/filtres');
|
||||
|
||||
if ($arg=='images'){
|
||||
$taille = calculer_taille_dossier(_DIR_VAR);
|
||||
$res = _T('ecrire:taille_cache_image',
|
||||
array(
|
||||
'dir' => joli_repertoire(_DIR_VAR),
|
||||
'taille' => "<b>".(taille_en_octets($taille) > 0 ? taille_en_octets($taille) : "0 octet")."</b>"
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
include_spip('inc/invalideur');
|
||||
$taille =
|
||||
calculer_taille_dossier(_DIR_CACHE_XML)
|
||||
+calculer_taille_dossier(_DIR_CACHE.'skel/')
|
||||
+calculer_taille_dossier(_DIR_CACHE.'wheels/')
|
||||
+calculer_taille_dossier(_DIR_CACHE.'contextes/')
|
||||
;
|
||||
$taille += intval(taille_du_cache());
|
||||
if ($taille<=150000){
|
||||
$res = _T('taille_cache_vide');
|
||||
}
|
||||
elseif ($taille<=1024*1024){
|
||||
$res = _T('taille_cache_moins_de',array('octets'=>taille_en_octets(1024*1024)));
|
||||
}
|
||||
else {
|
||||
$res = _T('taille_cache_octets',array('octets'=>taille_en_octets($taille)));
|
||||
}
|
||||
$res = "<b>$res</b>";
|
||||
}
|
||||
|
||||
$res = "<p>$res</p>";
|
||||
ajax_retour($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculer la taille d'un dossier, sous dossiers inclus
|
||||
*
|
||||
* http://doc.spip.org/@calculer_taille_dossier
|
||||
*
|
||||
* @param $dir
|
||||
* @return int
|
||||
*/
|
||||
function calculer_taille_dossier ($dir) {
|
||||
$handle = @opendir($dir);
|
||||
if (!$handle) return 0;
|
||||
$taille = 0;
|
||||
while (($fichier = @readdir($handle)) !== false) {
|
||||
// Eviter ".", "..", ".htaccess", etc.
|
||||
if ($fichier[0] == '.') continue;
|
||||
if (is_file($d = "$dir/$fichier")) {
|
||||
$taille += filesize($d);
|
||||
}
|
||||
else if (is_dir($d))
|
||||
$taille += calculer_taille_dossier($d);
|
||||
}
|
||||
closedir($handle);
|
||||
return $taille;
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
|
||||
// Cette action permet de confirmer un changement d'email
|
||||
|
||||
function action_confirmer_email_dist()
|
||||
{
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
|
||||
include_spip('inc/filtres');
|
||||
if ($GLOBALS['visiteur_session']['id_auteur'] AND email_valide($arg)){
|
||||
include_spip('action/editer_auteur');
|
||||
auteur_modifier($GLOBALS['visiteur_session']['id_auteur'],array('email'=>$arg));
|
||||
}
|
||||
// verifier avant de rediriger pour invalider le message de confirmation
|
||||
// si ca n'a pas marche
|
||||
if ($redirect = _request('redirect') AND !$arg == sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($GLOBALS['visiteur_session'])))
|
||||
$GLOBALS['redirect'] = parametre_url($redirect, 'email_modif','');
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Cette action permet de confirmer une inscription
|
||||
* @return void
|
||||
*/
|
||||
function action_confirmer_inscription_dist() {
|
||||
$jeton = _request('jeton');
|
||||
$email = _request('email');
|
||||
|
||||
include_spip('action/inscrire_auteur');
|
||||
if ($auteur = auteur_verifier_jeton($jeton)
|
||||
AND $auteur['email']==$email
|
||||
AND $auteur['statut']=='nouveau'){
|
||||
|
||||
// OK c'est un nouvel inscrit qui confirme :
|
||||
// on le loge => ca va confirmer son statut et c'est plus sympa
|
||||
include_spip('inc/auth');
|
||||
auth_loger($auteur);
|
||||
|
||||
// et on efface son jeton
|
||||
auteur_effacer_jeton($auteur['id_auteur']);
|
||||
|
||||
// si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur
|
||||
// TODO: ne semble pas marcher si inscrit non visiteur, a debug
|
||||
if (!_request('redirect')){
|
||||
// on passe id_auteur explicite pour forcer une lecture en base de toutes les infos
|
||||
if (autoriser('ecrire','','',$auteur['id_auteur'])){
|
||||
// poser un cookie admin aussi
|
||||
$cookie = charger_fonction('cookie','action');
|
||||
$cookie("@".$GLOBALS['visiteur_session']['login']);
|
||||
$GLOBALS['redirect'] = _DIR_RESTREINT_ABS;
|
||||
}
|
||||
else
|
||||
$GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
// lien perime :
|
||||
if ($GLOBALS['visiteur_session']['id_auteur']){
|
||||
// on passe id_auteur explicite pour forcer une lecture en base de toutes les infos
|
||||
if (autoriser('ecrire','','',$GLOBALS['visiteur_session']['id_auteur']))
|
||||
$GLOBALS['redirect'] = _DIR_RESTREINT_ABS;
|
||||
else
|
||||
$GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
|
||||
}
|
||||
else
|
||||
// rediriger vers la page de login si pas encore loge
|
||||
$GLOBALS['redirect'] = parametre_url(generer_url_public('login','',false),'url',_request('redirect'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/cookie');
|
||||
|
||||
// changer de langue: pas de secu si espace public ou login ou installation
|
||||
// mais alors on n'accede pas a la base, on pose seulement le cookie.
|
||||
|
||||
// http://doc.spip.org/@action_converser_dist
|
||||
function action_converser_dist()
|
||||
{
|
||||
$update_session = false;
|
||||
if ( _request('arg') AND spip_connect()) {
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$securiser_action();
|
||||
$update_session = true;
|
||||
}
|
||||
|
||||
$lang = action_converser_changer_langue($update_session);
|
||||
$redirect = rawurldecode(_request('redirect'));
|
||||
|
||||
if (!$redirect) $redirect = _DIR_RESTREINT_ABS;
|
||||
$redirect = parametre_url($redirect,'lang',$lang,'&');
|
||||
redirige_par_entete($redirect, true);
|
||||
}
|
||||
|
||||
function action_converser_changer_langue($update_session){
|
||||
if ($lang = _request('var_lang'))
|
||||
action_converser_post($lang);
|
||||
elseif ($lang = _request('var_lang_ecrire')) {
|
||||
if ($update_session) {
|
||||
sql_updateq("spip_auteurs", array("lang" => $lang), "id_auteur = " . $GLOBALS['visiteur_session']['id_auteur']);
|
||||
$GLOBALS['visiteur_session']['lang'] = $lang;
|
||||
$session = charger_fonction('session', 'inc');
|
||||
if ($spip_session = $session($GLOBALS['visiteur_session'])) {
|
||||
spip_setcookie(
|
||||
'spip_session',
|
||||
$spip_session,
|
||||
time() + 3600 * 24 * 14
|
||||
);
|
||||
}
|
||||
}
|
||||
action_converser_post($lang, 'spip_lang_ecrire');
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@action_converser_post
|
||||
function action_converser_post($lang, $ecrire=false)
|
||||
{
|
||||
if ($lang) {
|
||||
include_spip('inc/lang');
|
||||
if (changer_langue($lang)) {
|
||||
spip_setcookie('spip_lang', $_COOKIE['spip_lang'] = $lang, time() + 365 * 24 * 3600);
|
||||
if ($ecrire)
|
||||
spip_setcookie('spip_lang_ecrire', $_COOKIE['spip_lang_ecrire'] = $lang, time() + 365 * 24 * 3600);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,99 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/actions');
|
||||
include_spip('inc/cookie');
|
||||
|
||||
// http://doc.spip.org/@action_cookie_dist
|
||||
function action_cookie_dist($set_cookie_admin=null, $change_session = null) {
|
||||
$redirect_echec = $redirect = null;
|
||||
$test_echec_cookie = null;
|
||||
$url = "";
|
||||
if (is_null($set_cookie_admin)){
|
||||
$set_cookie_admin = _request('cookie_admin');
|
||||
$change_session = _request('change_session');
|
||||
$test_echec_cookie = _request('test_echec_cookie');
|
||||
|
||||
// La cible de notre operation de connexion
|
||||
$url = securiser_redirect_action(_request('url'));
|
||||
$redirect = $url ? $url : generer_url_ecrire('accueil');
|
||||
$redirect_echec = _request('url_echec');
|
||||
if (!isset($redirect_echec)) {
|
||||
if (strpos($redirect,_DIR_RESTREINT_ABS)!==false)
|
||||
$redirect_echec = generer_url_public('login','',true);
|
||||
else
|
||||
$redirect_echec = $redirect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rejoue le cookie pour renouveler spip_session
|
||||
if ($change_session == 'oui') {
|
||||
$session = charger_fonction('session', 'inc');
|
||||
$session(true);
|
||||
spip_log("statut 204 pour " . $_SERVER['REQUEST_URI']);
|
||||
http_status(204); // No Content
|
||||
return;
|
||||
}
|
||||
|
||||
// tentative de connexion en auth_http
|
||||
if (_request('essai_auth_http') AND !$GLOBALS['ignore_auth_http']) {
|
||||
include_spip('inc/auth');
|
||||
if (@$_SERVER['PHP_AUTH_USER']
|
||||
AND @$_SERVER['PHP_AUTH_PW']
|
||||
AND $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])){
|
||||
auth_loger($auteur);
|
||||
redirige_par_entete(parametre_url($redirect,'t',time(),'&'));
|
||||
}
|
||||
else {
|
||||
ask_php_auth(_T('info_connexion_refusee'),
|
||||
_T('login_login_pass_incorrect'),
|
||||
_T('login_retour_site'),
|
||||
"url=".rawurlencode($redirect),
|
||||
_T('login_nouvelle_tentative'),
|
||||
(strpos($url,_DIR_RESTREINT_ABS)!==false));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
// en cas de login sur bonjour=oui, on tente de poser un cookie
|
||||
// puis de passer au login qui diagnostiquera l'echec de cookie
|
||||
// le cas echeant.
|
||||
if ($test_echec_cookie == 'oui') {
|
||||
spip_setcookie('spip_session', 'test_echec_cookie');
|
||||
if ($redirect)
|
||||
$redirect = parametre_url(parametre_url($redirect_echec,'var_echec_cookie','oui','&'),'url',rawurlencode($redirect),'&');
|
||||
}
|
||||
else {
|
||||
|
||||
$cook = isset($_COOKIE['spip_admin']) ? $_COOKIE['spip_admin'] : '';
|
||||
// Suppression cookie d'admin ?
|
||||
if ($set_cookie_admin == "non") {
|
||||
if ($cook)
|
||||
spip_setcookie('spip_admin', $cook, time() - 3600 * 24);
|
||||
}
|
||||
// Ajout de cookie d'admin
|
||||
else if ($set_cookie_admin) {
|
||||
spip_setcookie('spip_admin', $set_cookie_admin,
|
||||
time() + 14 * 24 * 3600);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Redirection finale
|
||||
if ($redirect)
|
||||
redirige_par_entete($redirect, true);
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@action_instituer_collaboration_dist
|
||||
function action_debloquer_edition_dist() {
|
||||
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
|
||||
if ($arg) {
|
||||
include_spip('inc/drapeau_edition');
|
||||
if ($arg == 'tous') {
|
||||
debloquer_tous($GLOBALS['visiteur_session']['id_auteur']);
|
||||
}
|
||||
else {
|
||||
$arg = explode("-",$arg);
|
||||
list($objet,$id_objet) = $arg;
|
||||
debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@action_desinstaller_plugin_dist
|
||||
function action_desinstaller_plugin_dist() {
|
||||
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
list($dir_plugins,$plugin) = explode("::",$arg);
|
||||
$dir_type = "_DIR_PLUGINS";
|
||||
if (defined('_DIR_PLUGINS_SUPPL') AND $dir_plugins==_DIR_PLUGINS_SUPPL)
|
||||
$dir_type = "_DIR_PLUGINS_SUPPL";
|
||||
$installer_plugins = charger_fonction('installer', 'plugins');
|
||||
$infos = $installer_plugins($plugin, 'uninstall',$dir_type);
|
||||
if ($infos AND !$infos['install_test'][0]) {
|
||||
include_spip('inc/plugin');
|
||||
ecrire_plugin_actifs(array($plugin),false,'enleve');
|
||||
$erreur = '';
|
||||
} else $erreur = 'erreur_plugin_desinstalation_echouee';
|
||||
if ($redirect = _request('redirect')){
|
||||
include_spip('inc/headers');
|
||||
if ($erreur)
|
||||
$redirect = parametre_url($redirect, 'erreur',$erreur);
|
||||
$redirect = str_replace('&','&',$redirect);
|
||||
redirige_par_entete($redirect);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,359 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@action_editer_article_dist
|
||||
function action_editer_article_dist($arg=null) {
|
||||
include_spip('inc/autoriser');
|
||||
$err="";
|
||||
if (is_null($arg)){
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
}
|
||||
|
||||
// si id_article n'est pas un nombre, c'est une creation
|
||||
// mais on verifie qu'on a toutes les donnees qu'il faut.
|
||||
if (!$id_article = intval($arg)) {
|
||||
$id_parent = _request('id_parent');
|
||||
if (!$id_parent)
|
||||
$err = _L("creation interdite d'un article sans rubrique");
|
||||
elseif(!autoriser('creerarticledans','rubrique',$id_parent))
|
||||
$err = _T("info_creerdansrubrique_non_autorise");
|
||||
else
|
||||
$id_article = article_inserer($id_parent);
|
||||
}
|
||||
|
||||
// Enregistre l'envoi dans la BD
|
||||
if ($id_article > 0) $err = article_modifier($id_article);
|
||||
|
||||
if ($err)
|
||||
spip_log("echec editeur article: $err",_LOG_ERREUR);
|
||||
|
||||
return array($id_article,$err);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appelle toutes les fonctions de modification d'un article
|
||||
* $err est de la forme chaine de langue ou vide si pas d'erreur
|
||||
* http://doc.spip.org/@articles_set
|
||||
*
|
||||
* @param $id_article
|
||||
* @param null $set
|
||||
* @return string
|
||||
*/
|
||||
function article_modifier($id_article, $set=null) {
|
||||
|
||||
// unifier $texte en cas de texte trop long
|
||||
trop_longs_articles();
|
||||
|
||||
include_spip('inc/modifier');
|
||||
include_spip('inc/filtres');
|
||||
$c = collecter_requests(
|
||||
// white list
|
||||
objet_info('article','champs_editables'),
|
||||
// black list
|
||||
array('date','statut','id_parent'),
|
||||
// donnees eventuellement fournies
|
||||
$set
|
||||
);
|
||||
|
||||
// Si l'article est publie, invalider les caches et demander sa reindexation
|
||||
$t = sql_getfetsel("statut", "spip_articles", "id_article=".intval($id_article));
|
||||
$invalideur = $indexation = false;
|
||||
if ($t == 'publie') {
|
||||
$invalideur = "id='article/$id_article'";
|
||||
$indexation = true;
|
||||
}
|
||||
|
||||
if ($err = objet_modifier_champs('article', $id_article,
|
||||
array(
|
||||
'nonvide' => array('titre' => _T('info_nouvel_article')." "._T('info_numero_abbreviation').$id_article),
|
||||
'invalideur' => $invalideur,
|
||||
'indexation' => $indexation,
|
||||
'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif
|
||||
),
|
||||
$c))
|
||||
return $err;
|
||||
|
||||
// Modification de statut, changement de rubrique ?
|
||||
$c = collecter_requests(array('date', 'statut', 'id_parent'),array(),$set);
|
||||
$err = article_instituer($id_article, $c);
|
||||
|
||||
return $err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserer un nouvel article en base
|
||||
* http://doc.spip.org/@insert_article
|
||||
*
|
||||
* @param int $id_rubrique
|
||||
* @return int
|
||||
*/
|
||||
function article_inserer($id_rubrique) {
|
||||
|
||||
|
||||
// Si id_rubrique vaut 0 ou n'est pas definie, creer l'article
|
||||
// dans la premiere rubrique racine
|
||||
if (!$id_rubrique = intval($id_rubrique)) {
|
||||
$row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1");
|
||||
$id_rubrique = $row['id_rubrique'];
|
||||
} else $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=$id_rubrique");
|
||||
|
||||
// eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue
|
||||
// cas de id_rubrique = -1 par exemple avec plugin "pages"
|
||||
$id_secteur = isset($row['id_secteur']) ? $row['id_secteur'] : 0;
|
||||
|
||||
$lang_rub = $row['lang'];
|
||||
|
||||
$lang = "";
|
||||
$choisie = 'non';
|
||||
// La langue a la creation : si les liens de traduction sont autorises
|
||||
// dans les rubriques, on essaie avec la langue de l'auteur,
|
||||
// ou a defaut celle de la rubrique
|
||||
// Sinon c'est la langue de la rubrique qui est choisie + heritee
|
||||
if (in_array('spip_articles',explode(',',$GLOBALS['meta']['multi_objets']))) {
|
||||
lang_select($GLOBALS['visiteur_session']['lang']);
|
||||
if (in_array($GLOBALS['spip_lang'],
|
||||
explode(',', $GLOBALS['meta']['langues_multilingue']))) {
|
||||
$lang = $GLOBALS['spip_lang'];
|
||||
$choisie = 'oui';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$lang) {
|
||||
$choisie = 'non';
|
||||
$lang = $lang_rub ? $lang_rub : $GLOBALS['meta']['langue_site'];
|
||||
}
|
||||
|
||||
$champs = array(
|
||||
'id_rubrique' => $id_rubrique,
|
||||
'id_secteur' => $id_secteur,
|
||||
'statut' => 'prepa',
|
||||
'date' => date('Y-m-d H:i:s'),
|
||||
'lang' => $lang,
|
||||
'langue_choisie' =>$choisie);
|
||||
|
||||
// Envoyer aux plugins
|
||||
$champs = pipeline('pre_insertion',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_articles',
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
$id_article = sql_insertq("spip_articles", $champs);
|
||||
|
||||
pipeline('post_insertion',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_articles',
|
||||
'id_objet' => $id_article
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
// controler si le serveur n'a pas renvoye une erreur
|
||||
if ($id_article > 0){
|
||||
$id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur']))?
|
||||
$GLOBALS['visiteur_session']['id_auteur']
|
||||
:_request('id_auteur'));
|
||||
if ($id_auteur){
|
||||
include_spip('action/editer_auteur');
|
||||
auteur_associer($id_auteur, array('article'=>$id_article));
|
||||
}
|
||||
}
|
||||
|
||||
return $id_article;
|
||||
}
|
||||
|
||||
|
||||
// $c est un array ('statut', 'id_parent' = changement de rubrique)
|
||||
//
|
||||
// statut et rubrique sont lies, car un admin restreint peut deplacer
|
||||
// un article publie vers une rubrique qu'il n'administre pas
|
||||
// http://doc.spip.org/@instituer_article
|
||||
function article_instituer($id_article, $c, $calcul_rub=true) {
|
||||
|
||||
include_spip('inc/autoriser');
|
||||
include_spip('inc/rubriques');
|
||||
include_spip('inc/modifier');
|
||||
|
||||
$row = sql_fetsel("statut, date, id_rubrique", "spip_articles", "id_article=$id_article");
|
||||
$id_rubrique = $row['id_rubrique'];
|
||||
$statut_ancien = $statut = $row['statut'];
|
||||
$date_ancienne = $date = $row['date'];
|
||||
$champs = array();
|
||||
|
||||
$d = isset($c['date'])?$c['date']:null;
|
||||
$s = isset($c['statut'])?$c['statut']:$statut;
|
||||
|
||||
// cf autorisations dans inc/instituer_article
|
||||
if ($s != $statut OR ($d AND $d != $date)) {
|
||||
if (autoriser('publierdans', 'rubrique', $id_rubrique))
|
||||
$statut = $champs['statut'] = $s;
|
||||
else if (autoriser('modifier', 'article', $id_article) AND $s != 'publie')
|
||||
$statut = $champs['statut'] = $s;
|
||||
else
|
||||
spip_log("editer_article $id_article refus " . join(' ', $c));
|
||||
|
||||
// En cas de publication, fixer la date a "maintenant"
|
||||
// sauf si $c commande autre chose
|
||||
// ou si l'article est deja date dans le futur
|
||||
// En cas de proposition d'un article (mais pas depublication), idem
|
||||
if ($champs['statut'] == 'publie'
|
||||
OR ($champs['statut'] == 'prop' AND ($d OR !in_array($statut_ancien, array('publie', 'prop'))))
|
||||
) {
|
||||
if ($d OR strtotime($d=$date)>time())
|
||||
$champs['date'] = $date = $d;
|
||||
else
|
||||
$champs['date'] = $date = date('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
|
||||
// Verifier que la rubrique demandee existe et est differente
|
||||
// de la rubrique actuelle
|
||||
if ($id_parent = $c['id_parent']
|
||||
AND $id_parent != $id_rubrique
|
||||
AND (sql_fetsel('1', "spip_rubriques", "id_rubrique=$id_parent"))) {
|
||||
$champs['id_rubrique'] = $id_parent;
|
||||
|
||||
// si l'article etait publie
|
||||
// et que le demandeur n'est pas admin de la rubrique de destination
|
||||
// repasser l'article en statut 'propose'.
|
||||
if ($statut == 'publie'
|
||||
AND !autoriser('publierdans', 'rubrique', $id_parent))
|
||||
$champs['statut'] = 'prop';
|
||||
}
|
||||
|
||||
// Envoyer aux plugins
|
||||
$champs = pipeline('pre_edition',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_articles',
|
||||
'id_objet' => $id_article,
|
||||
'action'=>'instituer',
|
||||
'statut_ancien' => $statut_ancien,
|
||||
'date_ancienne' => $date_ancienne,
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
if (!count($champs)) return '';
|
||||
|
||||
// Envoyer les modifs.
|
||||
|
||||
editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub);
|
||||
|
||||
// Invalider les caches
|
||||
include_spip('inc/invalideur');
|
||||
suivre_invalideur("id='article/$id_article'");
|
||||
|
||||
if ($date) {
|
||||
$t = strtotime($date);
|
||||
$p = @$GLOBALS['meta']['date_prochain_postdate'];
|
||||
if ($t > time() AND (!$p OR ($t < $p))) {
|
||||
ecrire_meta('date_prochain_postdate', $t);
|
||||
}
|
||||
}
|
||||
|
||||
// Pipeline
|
||||
pipeline('post_edition',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_articles',
|
||||
'id_objet' => $id_article,
|
||||
'action'=>'instituer',
|
||||
'statut_ancien' => $statut_ancien,
|
||||
'date_ancienne' => $date_ancienne,
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
// Notifications
|
||||
if ($notifications = charger_fonction('notifications', 'inc')) {
|
||||
$notifications('instituerarticle', $id_article,
|
||||
array('statut' => $statut, 'statut_ancien' => $statut_ancien, 'date'=>$date, 'date_ancienne' => $date_ancienne)
|
||||
);
|
||||
}
|
||||
|
||||
return ''; // pas d'erreur
|
||||
}
|
||||
|
||||
// fabrique la requete de modification de l'article, avec champs herites
|
||||
|
||||
// http://doc.spip.org/@editer_article_heritage
|
||||
function editer_article_heritage($id_article, $id_rubrique, $statut, $champs, $cond=true) {
|
||||
|
||||
// Si on deplace l'article
|
||||
// changer aussi son secteur et sa langue (si heritee)
|
||||
if (isset($champs['id_rubrique'])) {
|
||||
|
||||
$row_rub = sql_fetsel("id_secteur, lang", "spip_rubriques", "id_rubrique=".sql_quote($champs['id_rubrique']));
|
||||
|
||||
$langue = $row_rub['lang'];
|
||||
$champs['id_secteur'] = $row_rub['id_secteur'];
|
||||
if (sql_fetsel('1', 'spip_articles', "id_article=$id_article AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) {
|
||||
$champs['lang'] = $langue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$champs) return;
|
||||
|
||||
sql_updateq('spip_articles', $champs, "id_article=$id_article");
|
||||
|
||||
// Changer le statut des rubriques concernees
|
||||
|
||||
if ($cond) {
|
||||
include_spip('inc/rubriques');
|
||||
$postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false;
|
||||
calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Reunit les textes decoupes parce que trop longs
|
||||
//
|
||||
|
||||
// http://doc.spip.org/@trop_longs_articles
|
||||
function trop_longs_articles() {
|
||||
if (is_array($plus = _request('texte_plus'))) {
|
||||
foreach ($plus as $n=>$t) {
|
||||
$plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,","", $t);
|
||||
}
|
||||
set_request('texte', join('',$plus) . _request('texte'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// obsoletes
|
||||
function revisions_articles ($id_article, $c=false) {
|
||||
return article_modifier($id_article,$c);
|
||||
}
|
||||
function revision_article ($id_article, $c=false) {
|
||||
return article_modifier($id_article,$c);
|
||||
}
|
||||
function articles_set($id_article, $set=null) {
|
||||
return article_modifier($id_article,$set);
|
||||
}
|
||||
function insert_article($id_rubrique) {
|
||||
return article_inserer($id_rubrique);
|
||||
}
|
||||
function instituer_article($id_article, $c, $calcul_rub=true) {
|
||||
return article_instituer($id_article,$c,$calcul_rub);
|
||||
}
|
||||
?>
|
|
@ -1,354 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@action_editer_auteur_dist
|
||||
function action_editer_auteur_dist($arg=null) {
|
||||
|
||||
if (is_null($arg)){
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
}
|
||||
|
||||
|
||||
// si id_auteur n'est pas un nombre, c'est une creation
|
||||
if (!$id_auteur = intval($arg)) {
|
||||
|
||||
if (($id_auteur = auteur_inserer()) > 0){
|
||||
|
||||
# cf. GROS HACK
|
||||
# recuperer l'eventuel logo charge avant la creation
|
||||
# ils ont un id = 0-id_auteur de la session
|
||||
$id_hack = 0 - $GLOBALS['visiteur_session']['id_auteur'];
|
||||
$chercher_logo = charger_fonction('chercher_logo', 'inc');
|
||||
if (list($logo) = $chercher_logo($id_hack, 'id_auteur', 'on'))
|
||||
rename($logo, str_replace($id_hack, $id_auteur, $logo));
|
||||
if (list($logo) = $chercher_logo($id_hack, 'id_auteur', 'off'))
|
||||
rename($logo, str_replace($id_hack, $id_auteur, $logo));
|
||||
}
|
||||
}
|
||||
|
||||
// Enregistre l'envoi dans la BD
|
||||
$err = "";
|
||||
if ($id_auteur > 0)
|
||||
$err = auteur_modifier($id_auteur);
|
||||
|
||||
if ($err)
|
||||
spip_log("echec editeur auteur: $err",_LOG_ERREUR);
|
||||
|
||||
return array($id_auteur,$err);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserer un auteur en base
|
||||
* @param string $source
|
||||
* @return int
|
||||
*/
|
||||
function auteur_inserer($source=null) {
|
||||
|
||||
// Ce qu'on va demander comme modifications
|
||||
$champs = array();
|
||||
$champs['source'] = $source?$source:'spip';
|
||||
|
||||
$champs['login'] = '';
|
||||
$champs['statut'] = '5poubelle'; // inutilisable tant qu'il n'a pas ete renseigne et institue
|
||||
$champs['webmestre'] = 'non';
|
||||
|
||||
// Envoyer aux plugins
|
||||
$champs = pipeline('pre_insertion',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_auteurs',
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
$id_auteur = sql_insertq("spip_auteurs", $champs);
|
||||
pipeline('post_insertion',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_auteurs',
|
||||
'id_objet' => $id_auteur
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
return $id_auteur;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Appelle toutes les fonctions de modification d'un auteur
|
||||
*
|
||||
* @param int $id_auteur
|
||||
* @param array $set
|
||||
* @param bool $force_update
|
||||
* permet de forcer la maj en base des champs fournis, sans passer par instancier
|
||||
* utilise par auth/spip
|
||||
* @return string
|
||||
*/
|
||||
function auteur_modifier($id_auteur, $set = null, $force_update=false) {
|
||||
|
||||
include_spip('inc/modifier');
|
||||
include_spip('inc/filtres');
|
||||
$c = collecter_requests(
|
||||
// white list
|
||||
objet_info('auteur','champs_editables'),
|
||||
// black list
|
||||
$force_update?array():array('webmestre','pass','login'),
|
||||
// donnees eventuellement fournies
|
||||
$set
|
||||
);
|
||||
|
||||
if ($err = objet_modifier_champs('auteur', $id_auteur,
|
||||
array(
|
||||
'nonvide' => array('nom' => _T('ecrire:item_nouvel_auteur'))
|
||||
),
|
||||
$c))
|
||||
return $err;
|
||||
$session = $c;
|
||||
|
||||
$err = '';
|
||||
if (!$force_update){
|
||||
// Modification de statut, changement de rubrique ?
|
||||
$c = collecter_requests(
|
||||
// white list
|
||||
array(
|
||||
'statut', 'new_login','new_pass','login','pass','webmestre','restreintes','id_parent'
|
||||
),
|
||||
// black list
|
||||
array(),
|
||||
// donnees eventuellement fournies
|
||||
$set
|
||||
);
|
||||
if (isset($c['new_login']) AND !isset($c['login']))
|
||||
$c['login'] = $c['new_login'];
|
||||
if (isset($c['new_pass']) AND !isset($c['pass']))
|
||||
$c['pass'] = $c['new_pass'];
|
||||
$err = auteur_instituer($id_auteur, $c);
|
||||
$session = array_merge($session,$c);
|
||||
}
|
||||
|
||||
// .. mettre a jour les sessions de cet auteur
|
||||
include_spip('inc/session');
|
||||
$session['id_auteur'] = $id_auteur;
|
||||
unset($session['new_login']);
|
||||
unset($session['new_pass']);
|
||||
actualiser_sessions($session);
|
||||
|
||||
return $err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associer un auteur a des objets listes sous forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* $id_objets peut lui meme etre un scalaire ou un tableau pour une liste d'objets du meme type
|
||||
*
|
||||
* on peut passer optionnellement une qualification du (des) lien(s) qui sera
|
||||
* alors appliquee dans la foulee.
|
||||
* En cas de lot de liens, c'est la meme qualification qui est appliquee a tous
|
||||
*
|
||||
* @param int $id_auteur
|
||||
* @param array $objets
|
||||
* @param array $qualif
|
||||
* @return string
|
||||
*/
|
||||
function auteur_associer($id_auteur,$objets, $qualif = null){
|
||||
include_spip('action/editer_liens');
|
||||
return objet_associer(array('auteur'=>$id_auteur), $objets, $qualif);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ancien nommage pour compatibilite
|
||||
* @param int $id_auteur
|
||||
* @param array $c
|
||||
* @return string
|
||||
*/
|
||||
function auteur_referent($id_auteur,$c){
|
||||
return auteur_associer($id_auteur,$c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dossocier un auteur des objets listes sous forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* $id_objets peut lui meme etre un scalaire ou un tableau pour une liste d'objets du meme type
|
||||
*
|
||||
* un * pour $id_auteur,$objet,$id_objet permet de traiter par lot
|
||||
*
|
||||
* @param int $id_auteur
|
||||
* @param array $objets
|
||||
* @return string
|
||||
*/
|
||||
function auteur_dissocier($id_auteur,$objets){
|
||||
include_spip('action/editer_liens');
|
||||
return objet_dissocier(array('auteur'=>$id_auteur), $objets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Qualifier le lien d'un auteur avec les objets listes
|
||||
* array($objet=>$id_objets,...)
|
||||
* $id_objets peut lui meme etre un scalaire ou un tableau pour une liste d'objets du meme type
|
||||
* exemple :
|
||||
* $c = array('vu'=>'oui');
|
||||
* un * pour $id_auteur,$objet,$id_objet permet de traiter par lot
|
||||
*
|
||||
* @param int $id_auteur
|
||||
* @param array $objets
|
||||
* @param array $qualif
|
||||
* @return bool|int
|
||||
*/
|
||||
function auteur_qualifier($id_auteur,$objets,$qualif){
|
||||
include_spip('action/editer_liens');
|
||||
return objet_qualifier_liens(array('auteur'=>$id_auteur), $objets, $qualif);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Modifier le statut d'un auteur, ou son login/pass
|
||||
* http://doc.spip.org/@instituer_auteur
|
||||
* @param $id_auteur
|
||||
* @param $c
|
||||
* @param bool $force_webmestre
|
||||
* @return bool|string
|
||||
*/
|
||||
function auteur_instituer($id_auteur, $c, $force_webmestre = false) {
|
||||
if (!$id_auteur=intval($id_auteur))
|
||||
return false;
|
||||
$erreurs = array(); // contiendra les differentes erreurs a traduire par _T()
|
||||
$champs = array();
|
||||
|
||||
// les memoriser pour les faire passer dans le pipeline pre_edition
|
||||
if (isset($c['login']) AND strlen($c['login']))
|
||||
$champs['login'] = $c['login'];
|
||||
if (isset($c['pass']) AND strlen($c['pass']))
|
||||
$champs['pass'] = $c['pass'];
|
||||
|
||||
$statut = $statut_ancien = sql_getfetsel('statut','spip_auteurs','id_auteur='.intval($id_auteur));
|
||||
|
||||
if (isset($c['statut'])
|
||||
AND (autoriser('modifier', 'auteur', $id_auteur,null, array('statut' => $c['statut']))))
|
||||
$statut = $champs['statut'] = $c['statut'];
|
||||
|
||||
// Restreindre avant de declarer l'auteur
|
||||
// (section critique sur les droits)
|
||||
if ($c['id_parent']) {
|
||||
if (is_array($c['restreintes']))
|
||||
$c['restreintes'][] = $c['id_parent'];
|
||||
else
|
||||
$c['restreintes'] = array($c['id_parent']);
|
||||
}
|
||||
|
||||
if (isset($c['webmestre'])
|
||||
AND ($force_webmestre OR autoriser('modifier', 'auteur', $id_auteur,null, array('webmestre' => '?'))))
|
||||
$champs['webmestre'] = $c['webmestre']=='oui'?'oui':'non';
|
||||
|
||||
// Envoyer aux plugins
|
||||
$champs = pipeline('pre_edition',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_auteurs',
|
||||
'id_objet' => $id_auteur,
|
||||
'action' => 'instituer',
|
||||
'statut_ancien' => $statut_ancien,
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
if (is_array($c['restreintes'])
|
||||
AND autoriser('modifier', 'auteur', $id_auteur, NULL, array('restreint'=>$c['restreintes']))) {
|
||||
$rubriques = array_map('intval',$c['restreintes']);
|
||||
$rubriques = array_unique($rubriques);
|
||||
$rubriques = array_diff($rubriques,array(0));
|
||||
auteur_dissocier($id_auteur, array('rubrique'=>'*'));
|
||||
auteur_associer($id_auteur,array('rubrique'=>$rubriques));
|
||||
}
|
||||
|
||||
$flag_ecrire_acces = false;
|
||||
// commencer par traiter les cas particuliers des logins et pass
|
||||
// avant les autres ecritures en base
|
||||
if (isset($champs['login']) OR isset($champs['pass'])){
|
||||
$auth_methode = sql_getfetsel('source','spip_auteurs','id_auteur='.intval($id_auteur));
|
||||
include_spip('inc/auth');
|
||||
if (isset($champs['login']) AND strlen($champs['login']))
|
||||
if (!auth_modifier_login($auth_methode, $champs['login'], $id_auteur))
|
||||
$erreurs[] = 'ecrire:impossible_modifier_login_auteur';
|
||||
if (isset($champs['pass']) AND strlen($champs['pass'])){
|
||||
$champs['login'] = sql_getfetsel('login','spip_auteurs','id_auteur='.intval($id_auteur));
|
||||
if (!auth_modifier_pass($auth_methode, $champs['login'], $champs['pass'], $id_auteur))
|
||||
$erreurs[] = 'ecrire:impossible_modifier_pass_auteur';
|
||||
}
|
||||
unset($champs['login']);
|
||||
unset($champs['pass']);
|
||||
$flag_ecrire_acces = true;
|
||||
}
|
||||
|
||||
if (!count($champs)) return implode(' ', array_map('_T', $erreurs));
|
||||
sql_updateq('spip_auteurs', $champs , 'id_auteur='.$id_auteur);
|
||||
|
||||
// .. mettre a jour les fichiers .htpasswd et .htpasswd-admin
|
||||
if ($flag_ecrire_acces
|
||||
OR isset($champs['statut'])
|
||||
) {
|
||||
include_spip('inc/acces');
|
||||
ecrire_acces();
|
||||
}
|
||||
|
||||
// Invalider les caches
|
||||
include_spip('inc/invalideur');
|
||||
suivre_invalideur("id='auteur/$id_auteur'");
|
||||
|
||||
// Pipeline
|
||||
pipeline('post_edition',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_auteurs',
|
||||
'id_objet' => $id_auteur,
|
||||
'action' => 'instituer',
|
||||
'statut_ancien' => $statut_ancien,
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Notifications
|
||||
if ($notifications = charger_fonction('notifications', 'inc')) {
|
||||
$notifications('instituerauteur', $id_auteur,
|
||||
array('statut' => $statut, 'statut_ancien' => $statut_ancien)
|
||||
);
|
||||
}
|
||||
|
||||
return implode(' ', array_map('_T', $erreurs));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function insert_auteur($source=null) {
|
||||
return auteur_inserer($source);
|
||||
}
|
||||
function auteurs_set($id_auteur, $set = null) {
|
||||
return auteur_modifier($id_auteur,$set);
|
||||
}
|
||||
function instituer_auteur($id_auteur, $c, $force_webmestre = false) {
|
||||
return auteur_instituer($id_auteur,$c,$force_webmestre);
|
||||
}
|
||||
// http://doc.spip.org/@revision_auteur
|
||||
function revision_auteur($id_auteur, $c=false) {
|
||||
return auteur_modifier($id_auteur,$c);
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,660 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
/**
|
||||
* API d'édition de liens
|
||||
*
|
||||
* @package SPIP\Liens\API
|
||||
*/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Teste l'existence de la table de liaison xxx_liens d'un objet
|
||||
*
|
||||
* @api
|
||||
* @param string $objet
|
||||
* Objet à tester
|
||||
* @return array|bool
|
||||
* - false si l'objet n'est pas associable.
|
||||
* - array(clé primaire, nom de la table de lien) si associable
|
||||
*/
|
||||
function objet_associable($objet){
|
||||
$trouver_table = charger_fonction('trouver_table','base');
|
||||
$table_sql = table_objet_sql($objet);
|
||||
|
||||
$l="";
|
||||
if ($primary = id_table_objet($objet)
|
||||
AND $trouver_table($l = $table_sql."_liens")
|
||||
AND !preg_match(',[^\w],',$primary)
|
||||
AND !preg_match(',[^\w],',$l))
|
||||
return array($primary,$l);
|
||||
|
||||
spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associer un ou des objets à des objets listés
|
||||
*
|
||||
* $objets_source et $objets_lies sont de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* $id_objets peut lui meme etre un scalaire ou un tableau pour une liste d'objets du meme type
|
||||
* ou de la forme array("NOT",$id_objets) pour une selection par exclusion
|
||||
*
|
||||
* Les objets sources sont les pivots qui portent les liens
|
||||
* et pour lesquels une table spip_xxx_liens existe
|
||||
* (auteurs, documents, mots)
|
||||
*
|
||||
* on peut passer optionnellement une qualification du (des) lien(s) qui sera
|
||||
* alors appliquee dans la foulee.
|
||||
* En cas de lot de liens, c'est la meme qualification qui est appliquee a tous
|
||||
*
|
||||
* @api
|
||||
* @param array $objets_source
|
||||
* @param array|string $objets_lies
|
||||
* @param array $qualif
|
||||
* @return bool|int
|
||||
*/
|
||||
function objet_associer($objets_source, $objets_lies, $qualif = null){
|
||||
$modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies);
|
||||
|
||||
if ($qualif)
|
||||
objet_qualifier_liens($objets_source, $objets_lies, $qualif);
|
||||
|
||||
return $modifs; // pas d'erreur
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dissocier un (ou des) objet(s) des objets listés
|
||||
*
|
||||
* $objets_source et $objets sont de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* $id_objets peut lui meme etre un scalaire ou un tableau pour une liste d'objets du meme type
|
||||
*
|
||||
* Les objets sources sont les pivots qui portent les liens
|
||||
* et pour lesquels une table spip_xxx_liens existe
|
||||
* (auteurs, documents, mots)
|
||||
*
|
||||
* un * pour $objet,$id_objet permet de traiter par lot
|
||||
* seul le type de l'objet source ne peut pas accepter de joker et doit etre explicite
|
||||
*
|
||||
* @api
|
||||
* @param array $objets_source
|
||||
* @param array|string $objets_lies
|
||||
* @return bool|int
|
||||
*/
|
||||
function objet_dissocier($objets_source,$objets_lies){
|
||||
return objet_traiter_liaisons('lien_delete',$objets_source,$objets_lies);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Qualifier le lien entre un (ou des) objet(s) et des objets listés
|
||||
*
|
||||
* $objets_source et $objets sont de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* $id_objets peut lui meme etre un scalaire ou un tableau pour une liste d'objets du meme type
|
||||
*
|
||||
* Les objets sources sont les pivots qui portent les liens
|
||||
* et pour lesquels une table spip_xxx_liens existe
|
||||
* (auteurs, documents, mots)
|
||||
*
|
||||
* un * pour $objet,$id_objet permet de traiter par lot
|
||||
* seul le type de l'objet source ne peut pas accepter de joker et doit etre explicite
|
||||
*
|
||||
* @api
|
||||
* @param array $objets_source
|
||||
* @param array|string $objets_lies
|
||||
* @param array $qualif
|
||||
* @return bool|int
|
||||
*/
|
||||
function objet_qualifier_liens($objets_source,$objets_lies,$qualif){
|
||||
return objet_traiter_liaisons('lien_set',$objets_source,$objets_lies,$qualif);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trouver les liens entre objets
|
||||
*
|
||||
* $objets_source et $objets sont de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* $id_objets peut lui meme etre un scalaire ou un tableau pour une liste d'objets du meme type
|
||||
*
|
||||
* Les objets sources sont les pivots qui portent les liens
|
||||
* et pour lesquels une table spip_xxx_liens existe
|
||||
* (auteurs, documents, mots)
|
||||
*
|
||||
* un * pour $objet,$id_objet permet de traiter par lot
|
||||
* seul le type de l'objet source ne peut pas accepter de joker et doit etre explicite
|
||||
*
|
||||
* renvoie une liste de tableaux decrivant chaque lien
|
||||
* dans lequel objet_source et objet_lie sont aussi affectes avec l'id de chaque
|
||||
* par facilite
|
||||
* ex :
|
||||
* array(
|
||||
* array('id_document'=>23,'objet'=>'article','id_objet'=>12,'vu'=>'oui',
|
||||
* 'document'=>23,'article'=>12)
|
||||
* )
|
||||
*
|
||||
* @api
|
||||
* @param array $objets_source
|
||||
* @param array|string $objets_lies
|
||||
* @return array
|
||||
*/
|
||||
function objet_trouver_liens($objets_source,$objets_lies){
|
||||
return objet_traiter_liaisons('lien_find',$objets_source,$objets_lies);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Nettoyer les liens morts vers des objets qui n'existent plus
|
||||
*
|
||||
* $objets_source et $objets sont de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* $id_objets peut lui meme etre un scalaire ou un tableau pour une liste d'objets du meme type
|
||||
*
|
||||
* Les objets sources sont les pivots qui portent les liens
|
||||
* et pour lesquels une table spip_xxx_liens existe
|
||||
* (auteurs, documents, mots)
|
||||
*
|
||||
* un * pour $objet,$id_objet permet de traiter par lot
|
||||
* seul le type de l'objet source ne peut pas accepter de joker et doit etre explicite
|
||||
*
|
||||
* @api
|
||||
* @param array $objets_source
|
||||
* @param array|string $objets_lies
|
||||
* @return int
|
||||
*/
|
||||
function objet_optimiser_liens($objets_source,$objets_lies){
|
||||
return objet_traiter_liaisons('lien_optimise',$objets_source,$objets_lies);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dupliquer tous les liens entrant ou sortants d'un objet
|
||||
* vers un autre (meme type d'objet, mais id different)
|
||||
* si $types est fourni, seuls les liens depuis/vers les types listes seront copies
|
||||
* si $exclure_types est fourni, les liens depuis/vers les types listes seront ignores
|
||||
*
|
||||
* @api
|
||||
* @param string $objet
|
||||
* @param int $id_source
|
||||
* @param int $id_cible
|
||||
* @param array $types
|
||||
* @param array $exclure_types
|
||||
* @return int
|
||||
* Nombre de liens copiés
|
||||
*/
|
||||
function objet_dupliquer_liens($objet,$id_source,$id_cible,$types=null,$exclure_types=null){
|
||||
include_spip('base/objets');
|
||||
$tables = lister_tables_objets_sql();
|
||||
$n = 0;
|
||||
foreach($tables as $table_sql => $infos){
|
||||
if (
|
||||
(is_null($types) OR in_array($infos['type'],$types))
|
||||
AND (is_null($exclure_types) OR !in_array($infos['type'],$exclure_types))
|
||||
){
|
||||
if (objet_associable($infos['type'])){
|
||||
$liens = (($infos['type']==$objet)?
|
||||
objet_trouver_liens(array($objet=>$id_source),'*')
|
||||
:
|
||||
objet_trouver_liens(array($infos['type']=>'*'),array($objet=>$id_source)));
|
||||
foreach($liens as $lien){
|
||||
$n++;
|
||||
if ($infos['type']==$objet){
|
||||
objet_associer(array($objet=>$id_cible),array($lien['objet']=>$lien[$lien['objet']]),$lien);
|
||||
}
|
||||
else {
|
||||
objet_associer(array($infos['type']=>$lien[$infos['type']]),array($objet=>$id_cible),$lien);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonctions techniques
|
||||
* ne pas les appeler directement
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Fonction générique qui
|
||||
* applique une operation de liaison entre un ou des objets et des objets listés
|
||||
* $objets_source et $objets_lies sont de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* $id_objets peut lui meme etre un scalaire ou un tableau pour une liste d'objets du meme type
|
||||
*
|
||||
* Les objets sources sont les pivots qui portent les liens
|
||||
* et pour lesquels une table spip_xxx_liens existe
|
||||
* (auteurs, documents, mots)
|
||||
*
|
||||
* on peut passer optionnellement une qualification du (des) lien(s) qui sera
|
||||
* alors appliquee dans la foulee.
|
||||
* En cas de lot de liens, c'est la meme qualification qui est appliquee a tous
|
||||
*
|
||||
* @internal
|
||||
* @param string $operation
|
||||
* @param array $objets_source
|
||||
* @param array $objets_lies
|
||||
* @param array $set
|
||||
* @return bool|int|array
|
||||
*/
|
||||
function objet_traiter_liaisons($operation,$objets_source,$objets_lies, $set = null){
|
||||
// accepter une syntaxe minimale pour supprimer tous les liens
|
||||
if ($objets_lies=='*') $objets_lies = array('*'=>'*');
|
||||
$modifs = 0; // compter le nombre de modifications
|
||||
$echec = null;
|
||||
foreach($objets_source as $objet=>$ids){
|
||||
if ($a = objet_associable($objet)) {
|
||||
list($primary,$l) = $a;
|
||||
if (!is_array($ids))
|
||||
$ids = array($ids);
|
||||
elseif(reset($ids)=="NOT"){
|
||||
// si on demande un array('NOT',...) => recuperer la liste d'ids correspondants
|
||||
$where = lien_where($primary,$ids,'*','*');
|
||||
$ids = sql_allfetsel($primary,$l,$where);
|
||||
$ids = array_map('reset',$ids);
|
||||
}
|
||||
foreach($ids as $id) {
|
||||
$res = $operation($objet,$primary,$l,$id,$objets_lies,$set);
|
||||
if ($res===false) {
|
||||
spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id",_LOG_ERREUR);
|
||||
$echec = true;
|
||||
}
|
||||
else
|
||||
$modifs=($modifs?(is_array($res)?array_merge($modifs,$res):$modifs+$res):$res);
|
||||
}
|
||||
}
|
||||
else
|
||||
$echec = true;
|
||||
}
|
||||
|
||||
return ($echec?false:$modifs); // pas d'erreur
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sous fonction insertion
|
||||
* qui traite les liens pour un objet source dont la clé primaire
|
||||
* et la table de lien sont fournies
|
||||
*
|
||||
* $objets et de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
*
|
||||
* Retourne le nombre d'insertions realisees
|
||||
*
|
||||
* @internal
|
||||
* @param string $objet_source
|
||||
* @param string $primary
|
||||
* @param sgring $table_lien
|
||||
* @param int $id
|
||||
* @param array $objets
|
||||
* @return bool|int
|
||||
*/
|
||||
function lien_insert($objet_source,$primary,$table_lien,$id,$objets) {
|
||||
$ins = 0;
|
||||
$echec = null;
|
||||
foreach($objets as $objet => $id_objets){
|
||||
if (!is_array($id_objets)) $id_objets = array($id_objets);
|
||||
foreach($id_objets as $id_objet) {
|
||||
$objet = ($objet=='*')?$objet:objet_type($objet); # securite
|
||||
// Envoyer aux plugins
|
||||
$id_objet = pipeline('pre_edition_lien',
|
||||
array(
|
||||
'args' => array(
|
||||
'table_lien' => $table_lien,
|
||||
'objet_source' => $objet_source,
|
||||
'id_objet_source' => $id,
|
||||
'objet' => $objet,
|
||||
'id_objet' => $id_objet,
|
||||
'action'=>'insert',
|
||||
),
|
||||
'data' => $id_objet
|
||||
)
|
||||
);
|
||||
if ($id_objet=intval($id_objet)
|
||||
AND !sql_getfetsel(
|
||||
$primary,
|
||||
$table_lien,
|
||||
array('id_objet='.intval($id_objet), 'objet='.sql_quote($objet), $primary.'='.intval($id))))
|
||||
{
|
||||
|
||||
$e = sql_insertq($table_lien, array('id_objet' => $id_objet, 'objet'=>$objet, $primary=>$id));
|
||||
if ($e!==false) {
|
||||
$ins++;
|
||||
lien_propage_date_modif($objet,$id_objet);
|
||||
lien_propage_date_modif($objet_source,$id);
|
||||
// Envoyer aux plugins
|
||||
pipeline('post_edition_lien',
|
||||
array(
|
||||
'args' => array(
|
||||
'table_lien' => $table_lien,
|
||||
'objet_source' => $objet_source,
|
||||
'id_objet_source' => $id,
|
||||
'objet' => $objet,
|
||||
'id_objet' => $id_objet,
|
||||
'action'=>'insert',
|
||||
),
|
||||
'data' => $id_objet
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
$echec = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ($echec?false:$ins);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fabriquer la condition where en tenant compte des jokers *
|
||||
*
|
||||
* @internal
|
||||
* @param string $primary
|
||||
* @param int|string|array $id_source
|
||||
* @param string $objet
|
||||
* @param int|string|array $id_objet
|
||||
* @return array
|
||||
*/
|
||||
function lien_where($primary, $id_source, $objet, $id_objet){
|
||||
if ((!is_array($id_source) AND !strlen($id_source))
|
||||
OR !strlen($objet)
|
||||
OR (!is_array($id_objet) AND !strlen($id_objet)))
|
||||
return array("0=1"); // securite
|
||||
|
||||
$not="";
|
||||
if (is_array($id_source) AND reset($id_source)=="NOT"){
|
||||
$not = array_shift($id_source);
|
||||
$id_source = reset($id_source);
|
||||
}
|
||||
$where = array();
|
||||
if ($id_source!=='*')
|
||||
$where[] = (is_array($id_source)?sql_in(addslashes($primary),array_map('intval',$id_source),$not):addslashes($primary) . ($not?"<>":"=") . intval($id_source));
|
||||
elseif ($not)
|
||||
$where[] = "0=1"; // idiot mais quand meme
|
||||
|
||||
$not="";
|
||||
if (is_array($id_objet) AND reset($id_objet)=="NOT"){
|
||||
$not = array_shift($id_objet);
|
||||
$id_objet = reset($id_objet);
|
||||
}
|
||||
|
||||
if ($objet!=='*')
|
||||
$where[] = "objet=".sql_quote($objet);
|
||||
if ($id_objet!=='*')
|
||||
$where[] = (is_array($id_objet)?sql_in('id_objet',array_map('intval',$id_objet),$not):"id_objet" . ($not?"<>":"=") . intval($id_objet));
|
||||
elseif ($not)
|
||||
$where[] = "0=1"; // idiot mais quand meme
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sous fonction suppression
|
||||
* qui traite les liens pour un objet source dont la clé primaire
|
||||
* et la table de lien sont fournies
|
||||
*
|
||||
* $objets et de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* un * pour $id,$objet,$id_objets permet de traiter par lot
|
||||
*
|
||||
* @internal
|
||||
* @param string $objet_source
|
||||
* @param string $primary
|
||||
* @param sgring $table_lien
|
||||
* @param int $id
|
||||
* @param array $objets
|
||||
* @return bool|int
|
||||
*/
|
||||
function lien_delete($objet_source,$primary,$table_lien,$id,$objets){
|
||||
$retire = array();
|
||||
$dels = 0;
|
||||
$echec = false;
|
||||
foreach($objets as $objet => $id_objets){
|
||||
$objet = ($objet=='*')?$objet:objet_type($objet); # securite
|
||||
if (!is_array($id_objets) OR reset($id_objets)=="NOT") $id_objets = array($id_objets);
|
||||
foreach($id_objets as $id_objet) {
|
||||
// id_objet peut valoir '*'
|
||||
$where = lien_where($primary, $id, $objet, $id_objet);
|
||||
// lire les liens existants pour propager la date de modif
|
||||
$liens = sql_allfetsel("$primary,id_objet,objet",$table_lien,$where);
|
||||
// iterer sur les liens pour permettre aux plugins de gerer
|
||||
foreach($liens as $l){
|
||||
// Envoyer aux plugins
|
||||
$id_o = pipeline('pre_edition_lien',
|
||||
array(
|
||||
'args' => array(
|
||||
'table_lien' => $table_lien,
|
||||
'objet_source' => $objet_source,
|
||||
'id_objet_source' => $l[$primary],
|
||||
'objet' => $l['objet'],
|
||||
'id_objet' => $l['id_objet'],
|
||||
'action'=>'delete',
|
||||
),
|
||||
'data' => $l['id_objet']
|
||||
)
|
||||
);
|
||||
if ($id_o=intval($id_o)){
|
||||
$where = lien_where($primary, $l[$primary], $l['objet'], $id_o);
|
||||
$e = sql_delete($table_lien, $where);
|
||||
if ($e!==false){
|
||||
$dels+=$e;
|
||||
lien_propage_date_modif($l['objet'],$id_o);
|
||||
lien_propage_date_modif($objet_source,$l[$primary]);
|
||||
}
|
||||
else
|
||||
$echec = true;
|
||||
$retire[] = array('source'=>array($objet_source=>$l[$primary]),'lien'=>array($l['objet']=>$id_o),'type'=>$l['objet'],'id'=>$id_o);
|
||||
// Envoyer aux plugins
|
||||
pipeline('post_edition_lien',
|
||||
array(
|
||||
'args' => array(
|
||||
'table_lien' => $table_lien,
|
||||
'objet_source' => $objet_source,
|
||||
'id_objet_source' => $l[$primary],
|
||||
'objet' => $l['objet'],
|
||||
'id_objet' => $id_o,
|
||||
'action'=>'delete',
|
||||
),
|
||||
'data' => $id_o
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pipeline('trig_supprimer_objets_lies',$retire);
|
||||
|
||||
return ($echec?false:$dels);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sous fonction optimisation
|
||||
* qui nettoie les liens morts (vers un objet inexistant)
|
||||
* pour un objet source dont la clé primaire
|
||||
* et la table de lien sont fournies
|
||||
*
|
||||
* $objets et de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* un * pour $id,$objet,$id_objets permet de traiter par lot
|
||||
*
|
||||
* @internal
|
||||
* @param string $objet_source
|
||||
* @param string $primary
|
||||
* @param sgring $table_lien
|
||||
* @param int $id
|
||||
* @param array $objets
|
||||
* @return bool|int
|
||||
*/
|
||||
function lien_optimise($objet_source,$primary,$table_lien,$id,$objets){
|
||||
include_spip('genie/optimiser');
|
||||
$echec = false;
|
||||
$dels = 0;
|
||||
foreach($objets as $objet => $id_objets){
|
||||
$objet = ($objet=='*')?$objet:objet_type($objet); # securite
|
||||
if (!is_array($id_objets) OR reset($id_objets)=="NOT") $id_objets = array($id_objets);
|
||||
foreach($id_objets as $id_objet) {
|
||||
$where = lien_where($primary, $id, $objet, $id_objet);
|
||||
# les liens vers un objet inexistant
|
||||
$r = sql_select("DISTINCT objet",$table_lien,$where);
|
||||
while ($t = sql_fetch($r)){
|
||||
$type = $t['objet'];
|
||||
$spip_table_objet = table_objet_sql($type);
|
||||
$id_table_objet = id_table_objet($type);
|
||||
$res = sql_select("L.$primary AS id,L.id_objet",
|
||||
// la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes
|
||||
// du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN
|
||||
// il faut les eliminier en repetant la condition dans le where L.objet='xxx'
|
||||
"$table_lien AS L
|
||||
LEFT JOIN $spip_table_objet AS O
|
||||
ON (O.$id_table_objet=L.id_objet AND L.objet=".sql_quote($type).")",
|
||||
"L.objet=".sql_quote($type)." AND O.$id_table_objet IS NULL");
|
||||
// sur une cle primaire composee, pas d'autres solutions que de virer un a un
|
||||
while ($row = sql_fetch($res)){
|
||||
$e = sql_delete($table_lien, array("$primary=".$row['id'],"id_objet=".$row['id_objet'],"objet=".sql_quote($type)));
|
||||
if ($e!=false){
|
||||
$dels+=$e;
|
||||
spip_log("Entree ".$row['id']."/".$row['id_objet']."/$type supprimee dans la table $table_lien",_LOG_INFO_IMPORTANTE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# les liens depuis un objet inexistant
|
||||
$table_source = table_objet_sql($objet_source);
|
||||
// filtrer selon $id, $objet, $id_objet eventuellement fournis
|
||||
// (en general '*' pour chaque)
|
||||
$where = lien_where("L.$primary", $id, $objet, $id_objet);
|
||||
$where[] = "O.$primary IS NULL";
|
||||
$res = sql_select("L.$primary AS id",
|
||||
"$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary",
|
||||
$where);
|
||||
$dels+= optimiser_sansref($table_lien, $primary, $res);
|
||||
}
|
||||
}
|
||||
return ($echec?false:$dels);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sous fonction qualification
|
||||
* qui traite les liens pour un objet source dont la clé primaire
|
||||
* et la table de lien sont fournies
|
||||
*
|
||||
* $objets et de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* un * pour $id,$objet,$id_objets permet de traiter par lot
|
||||
*
|
||||
* exemple :
|
||||
* $qualif = array('vu'=>'oui');
|
||||
*
|
||||
* @internal
|
||||
* @param string $objet_source
|
||||
* @param string $primary
|
||||
* @param sgring $table_lien
|
||||
* @param int $id
|
||||
* @param array $objets
|
||||
* @param array $qualif
|
||||
* @return bool|int
|
||||
*/
|
||||
function lien_set($objet_source,$primary,$table_lien,$id,$objets,$qualif){
|
||||
$echec = null;
|
||||
$ok = 0;
|
||||
if (!$qualif)
|
||||
return false;
|
||||
// nettoyer qualif qui peut venir directement d'un objet_trouver_lien :
|
||||
unset($qualif[$primary]);
|
||||
unset($qualif[$objet_source]);
|
||||
if (isset($qualif['objet'])) {
|
||||
unset($qualif[$qualif['objet']]);
|
||||
}
|
||||
unset($qualif['objet']);
|
||||
unset($qualif['id_objet']);
|
||||
foreach($objets as $objet => $id_objets){
|
||||
$objet = ($objet=='*')?$objet:objet_type($objet); # securite
|
||||
if (!is_array($id_objets) OR reset($id_objets)=="NOT") $id_objets = array($id_objets);
|
||||
foreach($id_objets as $id_objet) {
|
||||
$where = lien_where($primary, $id, $objet, $id_objet);
|
||||
$e = sql_updateq($table_lien,$qualif,$where);
|
||||
if ($e===false)
|
||||
$echec = true;
|
||||
else
|
||||
$ok++;
|
||||
}
|
||||
}
|
||||
return ($echec?false:$ok);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sous fonction trouver
|
||||
* qui cherche les liens pour un objet source dont la clé primaire
|
||||
* et la table de lien sont fournies
|
||||
*
|
||||
* $objets et de la forme
|
||||
* array($objet=>$id_objets,...)
|
||||
* un * pour $id,$objet,$id_objets permet de traiter par lot
|
||||
*
|
||||
*
|
||||
* @internal
|
||||
* @param string $objet_source
|
||||
* @param string $primary
|
||||
* @param sgring $table_lien
|
||||
* @param int $id
|
||||
* @param array $objets
|
||||
* @return array
|
||||
*/
|
||||
function lien_find($objet_source,$primary,$table_lien,$id,$objets){
|
||||
$trouve = array();
|
||||
foreach($objets as $objet => $id_objets){
|
||||
$objet = ($objet=='*')?$objet:objet_type($objet); # securite
|
||||
// lien_where prend en charge les $id_objets sous forme int ou array
|
||||
$where = lien_where($primary, $id, $objet, $id_objets);
|
||||
$liens = sql_allfetsel('*',$table_lien,$where);
|
||||
// ajouter les entrees objet_source et objet cible par convenance
|
||||
foreach($liens as $l) {
|
||||
$l[$objet_source] = $l[$primary];
|
||||
$l[$objet] = $l['id_objet'];
|
||||
$trouve[] = $l;
|
||||
}
|
||||
}
|
||||
return $trouve;
|
||||
}
|
||||
|
||||
/**
|
||||
* Propager la date_modif sur les objets dont un lien a été modifié
|
||||
*
|
||||
* @internal
|
||||
* @param string $objet
|
||||
* @param array|int $ids
|
||||
*/
|
||||
function lien_propage_date_modif($objet,$ids){
|
||||
$trouver_table = charger_fonction('trouver_table','base');
|
||||
|
||||
$table = table_objet_sql($objet);
|
||||
if ($desc = $trouver_table($table)
|
||||
AND isset($desc['field']['date_modif'])){
|
||||
$primary = id_table_objet($objet);
|
||||
$where = (is_array($ids)?sql_in($primary, array_map('intval',$ids)):"$primary=".intval($ids));
|
||||
sql_updateq($table, array('date_modif'=>date('Y-m-d H:i:s')), $where);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,437 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Point d'entree d'edition d'un objet
|
||||
* on ne peut entrer que par un appel en fournissant $id et $objet
|
||||
* mais pas pas une url
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $objet
|
||||
* @param array $set
|
||||
* @return array
|
||||
*/
|
||||
function action_editer_objet_dist($id=null, $objet=null, $set=null) {
|
||||
|
||||
// appel direct depuis une url interdit
|
||||
if (is_null($id) OR is_null($objet)){
|
||||
include_spip('inc/minipres');
|
||||
echo minipres(_T('info_acces_interdit'));
|
||||
die();
|
||||
}
|
||||
|
||||
// si id n'est pas un nombre, c'est une creation
|
||||
// mais on verifie qu'on a toutes les donnees qu'il faut.
|
||||
if (!$id = intval($id)) {
|
||||
// on ne sait pas si un parent existe mais on essaye
|
||||
$id_parent = _request('id_parent');
|
||||
$id = objet_inserer($objet, $id_parent);
|
||||
}
|
||||
|
||||
if (!($id = intval($id))>0)
|
||||
return array($id,_L('echec enregistrement en base'));
|
||||
|
||||
// Enregistre l'envoi dans la BD
|
||||
$err = objet_modifier($objet, $id, $set);
|
||||
|
||||
return array($id,$err);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appelle toutes les fonctions de modification d'un objet
|
||||
* $err est un message d'erreur eventuelle
|
||||
*
|
||||
* @param string $objet
|
||||
* @param int $id
|
||||
* @param array|null $set
|
||||
* @return mixed|string
|
||||
*/
|
||||
function objet_modifier($objet, $id, $set=null) {
|
||||
if (include_spip('action/editer_'.$objet)
|
||||
AND function_exists($modifier = $objet."_modifier"))
|
||||
return $modifier($id,$set);
|
||||
|
||||
$table_sql = table_objet_sql($objet);
|
||||
$trouver_table = charger_fonction('trouver_table','base');
|
||||
$desc = $trouver_table($table_sql);
|
||||
if (!$desc OR !isset($desc['field'])) {
|
||||
spip_log("Objet $objet inconnu dans objet_modifier",_LOG_ERREUR);
|
||||
return _L("Erreur objet $objet inconnu");
|
||||
}
|
||||
include_spip('inc/modifier');
|
||||
|
||||
$champ_date = '';
|
||||
if (isset($desc['date']) AND $desc['date'])
|
||||
$champ_date = $desc['date'];
|
||||
elseif (isset($desc['field']['date']))
|
||||
$champ_date = 'date';
|
||||
|
||||
$white = array_keys($desc['field']);
|
||||
// on ne traite pas la cle primaire par defaut, notamment car
|
||||
// sur une creation, id_x vaut 'oui', et serait enregistre en id_x=0 dans la base
|
||||
$white = array_diff($white, array($desc['key']['PRIMARY KEY']));
|
||||
|
||||
if (isset($desc['champs_editables']) AND is_array($desc['champs_editables'])) {
|
||||
$white = $desc['champs_editables'];
|
||||
}
|
||||
$c = collecter_requests(
|
||||
// white list
|
||||
$white,
|
||||
// black list
|
||||
array($champ_date,'statut','id_parent','id_secteur'),
|
||||
// donnees eventuellement fournies
|
||||
$set
|
||||
);
|
||||
|
||||
// Si l'objet est publie, invalider les caches et demander sa reindexation
|
||||
if (objet_test_si_publie($objet,$id)){
|
||||
$invalideur = "id='$objet/$id'";
|
||||
$indexation = true;
|
||||
}
|
||||
else {
|
||||
$invalideur = "";
|
||||
$indexation = false;
|
||||
}
|
||||
|
||||
if ($err = objet_modifier_champs($objet, $id,
|
||||
array(
|
||||
'nonvide' => '',
|
||||
'invalideur' => $invalideur,
|
||||
'indexation' => $indexation,
|
||||
// champ a mettre a date('Y-m-d H:i:s') s'il y a modif
|
||||
'date_modif' => (isset($desc['field']['date_modif'])?'date_modif':'')
|
||||
),
|
||||
$c))
|
||||
return $err;
|
||||
|
||||
// Modification de statut, changement de rubrique ?
|
||||
// FIXME: Ici lorsqu'un $set est passé, la fonction collecter_requests() retourne tout
|
||||
// le tableau $set hors black liste, mais du coup on a possiblement des champs en trop.
|
||||
$c = collecter_requests(array($champ_date, 'statut', 'id_parent'),array(),$set);
|
||||
$err = objet_instituer($objet, $id, $c);
|
||||
|
||||
return $err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserer en base un objet generique
|
||||
* @param string $objet
|
||||
* @param int $id_parent
|
||||
* @param array|null $set
|
||||
* @return bool|int
|
||||
*/
|
||||
function objet_inserer($objet, $id_parent=null, $set=null) {
|
||||
if (include_spip('action/editer_'.$objet)
|
||||
AND function_exists($inserer = $objet."_inserer"))
|
||||
return $inserer($id_parent);
|
||||
|
||||
$table_sql = table_objet_sql($objet);
|
||||
$trouver_table = charger_fonction('trouver_table','base');
|
||||
$desc = $trouver_table($table_sql);
|
||||
if (!$desc OR !isset($desc['field']))
|
||||
return 0;
|
||||
|
||||
$lang_rub = "";
|
||||
$champs = array();
|
||||
if (isset($desc['field']['id_rubrique'])){
|
||||
// Si id_rubrique vaut 0 ou n'est pas definie, creer l'objet
|
||||
// dans la premiere rubrique racine
|
||||
if (!$id_rubrique = intval($id_parent)) {
|
||||
$row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1");
|
||||
$id_rubrique = $row['id_rubrique'];
|
||||
}
|
||||
else
|
||||
$row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=".intval($id_rubrique));
|
||||
|
||||
$champs['id_rubrique'] = $id_rubrique;
|
||||
if (isset($desc['field']['id_secteur']))
|
||||
$champs['id_secteur'] = $row['id_secteur'];
|
||||
$lang_rub = $row['lang'];
|
||||
}
|
||||
|
||||
// La langue a la creation : si les liens de traduction sont autorises
|
||||
// dans les rubriques, on essaie avec la langue de l'auteur,
|
||||
// ou a defaut celle de la rubrique
|
||||
// Sinon c'est la langue de la rubrique qui est choisie + heritee
|
||||
if (isset($desc['field']['lang']) AND $GLOBALS['meta']['multi_objets'] AND in_array($table_sql, explode(',', $GLOBALS['meta']['multi_objets']))) {
|
||||
lang_select($GLOBALS['visiteur_session']['lang']);
|
||||
if (in_array($GLOBALS['spip_lang'],
|
||||
explode(',', $GLOBALS['meta']['langues_multilingue']))) {
|
||||
$champs['lang'] = $GLOBALS['spip_lang'];
|
||||
if (isset($desc['field']['langue_choisie']))
|
||||
$champs['langue_choisie'] = 'oui';
|
||||
}
|
||||
}
|
||||
elseif (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie'])) {
|
||||
$champs['lang'] = ($lang_rub ? $lang_rub : $GLOBALS['meta']['langue_site']);
|
||||
$champs['langue_choisie'] = 'non';
|
||||
}
|
||||
|
||||
if (isset($desc['field']['statut'])){
|
||||
if (isset($desc['statut_textes_instituer'])){
|
||||
$cles_statut = array_keys($desc['statut_textes_instituer']);
|
||||
$champs['statut'] = reset($cles_statut);
|
||||
}
|
||||
else
|
||||
$champs['statut'] = 'prepa';
|
||||
}
|
||||
|
||||
|
||||
if ((isset($desc['date']) AND $d=$desc['date']) OR isset($desc['field'][$d='date']))
|
||||
$champs[$d] = date('Y-m-d H:i:s');
|
||||
|
||||
if ($set)
|
||||
$champs = array_merge($champs, $set);
|
||||
|
||||
// Envoyer aux plugins
|
||||
$champs = pipeline('pre_insertion',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => $table_sql,
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
$id = sql_insertq($table_sql, $champs);
|
||||
|
||||
if ($id){
|
||||
pipeline('post_insertion',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => $table_sql,
|
||||
'id_objet' => $id,
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
// controler si le serveur n'a pas renvoye une erreur
|
||||
// et associer l'auteur sinon
|
||||
// si la table n'a pas deja un champ id_auteur
|
||||
// et si le form n'a pas poste un id_auteur (meme vide, ce qui sert a annuler cette auto association)
|
||||
if ($id > 0
|
||||
AND !isset($desc['field']['id_auteur'])){
|
||||
$id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur']))?
|
||||
$GLOBALS['visiteur_session']['id_auteur']
|
||||
:_request('id_auteur'));
|
||||
if ($id_auteur) {
|
||||
include_spip('action/editer_auteur');
|
||||
auteur_associer($id_auteur, array($objet=>$id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* $c est un array ('statut', 'id_parent' = changement de rubrique)
|
||||
* statut et rubrique sont lies, car un admin restreint peut deplacer
|
||||
* un objet publie vers une rubrique qu'il n'administre pas
|
||||
*
|
||||
* @param string $objet
|
||||
* @param int $id
|
||||
* @param array $c
|
||||
* @param bool $calcul_rub
|
||||
* @return mixed|string
|
||||
*/
|
||||
function objet_instituer($objet, $id, $c, $calcul_rub=true) {
|
||||
if (include_spip('action/editer_'.$objet)
|
||||
AND function_exists($instituer = $objet."_instituer"))
|
||||
return $instituer($id,$c,$calcul_rub);
|
||||
|
||||
$table_sql = table_objet_sql($objet);
|
||||
$trouver_table = charger_fonction('trouver_table','base');
|
||||
$desc = $trouver_table($table_sql);
|
||||
if (!$desc OR !isset($desc['field']))
|
||||
return _L("Impossible d'instituer $objet : non connu en base");
|
||||
|
||||
include_spip('inc/autoriser');
|
||||
include_spip('inc/rubriques');
|
||||
include_spip('inc/modifier');
|
||||
|
||||
$sel = array();
|
||||
$sel[] = (isset($desc['field']['statut'])?"statut":"'' as statut");
|
||||
|
||||
$champ_date = '';
|
||||
if (isset($desc['date']) AND $desc['date'])
|
||||
$champ_date = $desc['date'];
|
||||
elseif (isset($desc['field']['date']))
|
||||
$champ_date = 'date';
|
||||
|
||||
$sel[] = ($champ_date ? "$champ_date as date" : "'' as date");
|
||||
$sel[] = (isset($desc['field']['id_rubrique'])?'id_rubrique':"0 as id_rubrique");
|
||||
|
||||
$row = sql_fetsel($sel, $table_sql, id_table_objet($objet).'='.intval($id));
|
||||
|
||||
$id_rubrique = $row['id_rubrique'];
|
||||
$statut_ancien = $statut = $row['statut'];
|
||||
$date_ancienne = $date = $row['date'];
|
||||
$champs = array();
|
||||
|
||||
$d = ($date AND isset($c[$champ_date]))?$c[$champ_date]:null;
|
||||
$s = (isset($desc['field']['statut']) AND isset($c['statut']))?$c['statut']:$statut;
|
||||
|
||||
// cf autorisations dans inc/instituer_objet
|
||||
if ($s != $statut OR ($d AND $d != $date)) {
|
||||
if ($id_rubrique ?
|
||||
autoriser('publierdans', 'rubrique', $id_rubrique)
|
||||
:
|
||||
autoriser('instituer', $objet, $id, null, array('statut'=>$s))
|
||||
)
|
||||
$statut = $champs['statut'] = $s;
|
||||
else if ($s!='publie' AND autoriser('modifier', $objet, $id))
|
||||
$statut = $champs['statut'] = $s;
|
||||
else
|
||||
spip_log("editer_objet $id refus " . join(' ', $c));
|
||||
|
||||
// En cas de publication, fixer la date a "maintenant"
|
||||
// sauf si $c commande autre chose
|
||||
// ou si l'objet est deja date dans le futur
|
||||
// En cas de proposition d'un objet (mais pas depublication), idem
|
||||
if ($champ_date) {
|
||||
if ($champs['statut'] == 'publie'
|
||||
OR ($champs['statut'] == 'prop' AND !in_array($statut_ancien, array('publie', 'prop')))
|
||||
OR $d
|
||||
) {
|
||||
if ($d OR strtotime($d=$date)>time())
|
||||
$champs[$champ_date] = $date = $d;
|
||||
else
|
||||
$champs[$champ_date] = $date = date('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Verifier que la rubrique demandee existe et est differente
|
||||
// de la rubrique actuelle
|
||||
if ($id_rubrique
|
||||
AND $id_parent = $c['id_parent']
|
||||
AND $id_parent != $id_rubrique
|
||||
AND (sql_fetsel('1', "spip_rubriques", "id_rubrique=".intval($id_parent)))) {
|
||||
$champs['id_rubrique'] = $id_parent;
|
||||
|
||||
// si l'objet etait publie
|
||||
// et que le demandeur n'est pas admin de la rubrique
|
||||
// repasser l'objet en statut 'propose'.
|
||||
if ($statut == 'publie'
|
||||
AND !autoriser('publierdans', 'rubrique', $id_rubrique))
|
||||
$champs['statut'] = 'prop';
|
||||
}
|
||||
|
||||
|
||||
// Envoyer aux plugins
|
||||
$champs = pipeline('pre_edition',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => $table_sql,
|
||||
'id_objet' => $id,
|
||||
'action'=>'instituer',
|
||||
'statut_ancien' => $statut_ancien,
|
||||
'date_ancienne' => $date_ancienne,
|
||||
'id_parent_ancien' => $id_rubrique,
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
if (!count($champs)) return '';
|
||||
|
||||
// Envoyer les modifs.
|
||||
objet_editer_heritage($objet, $id, $id_rubrique, $statut_ancien, $champs, $calcul_rub);
|
||||
|
||||
// Invalider les caches
|
||||
include_spip('inc/invalideur');
|
||||
suivre_invalideur("id='$objet/$id'");
|
||||
|
||||
/*
|
||||
if ($date) {
|
||||
$t = strtotime($date);
|
||||
$p = @$GLOBALS['meta']['date_prochain_postdate'];
|
||||
if ($t > time() AND (!$p OR ($t < $p))) {
|
||||
ecrire_meta('date_prochain_postdate', $t);
|
||||
}
|
||||
}*/
|
||||
|
||||
// Pipeline
|
||||
pipeline('post_edition',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => $table_sql,
|
||||
'id_objet' => $id,
|
||||
'action'=>'instituer',
|
||||
'statut_ancien' => $statut_ancien,
|
||||
'date_ancienne' => $date_ancienne,
|
||||
'id_parent_ancien' => $id_rubrique,
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
// Notifications
|
||||
if ($notifications = charger_fonction('notifications', 'inc')) {
|
||||
$notifications("instituer$objet", $id,
|
||||
array('statut' => $statut, 'statut_ancien' => $statut_ancien, 'date'=>$date, 'date_ancienne' => $date_ancienne)
|
||||
);
|
||||
}
|
||||
|
||||
return ''; // pas d'erreur
|
||||
}
|
||||
|
||||
/**
|
||||
* fabrique la requete d'institution de l'objet, avec champs herites
|
||||
*
|
||||
* @param string $objet
|
||||
* @param int $id
|
||||
* @param int $id_rubrique
|
||||
* @param string $statut
|
||||
* @param array $champs
|
||||
* @param bool $cond
|
||||
* @return
|
||||
*/
|
||||
function objet_editer_heritage($objet, $id, $id_rubrique, $statut, $champs, $cond=true) {
|
||||
$table_sql = table_objet_sql($objet);
|
||||
$trouver_table = charger_fonction('trouver_table','base');
|
||||
$desc = $trouver_table($table_sql);
|
||||
|
||||
// Si on deplace l'objet
|
||||
// changer aussi son secteur et sa langue (si heritee)
|
||||
if (isset($champs['id_rubrique'])) {
|
||||
|
||||
$row_rub = sql_fetsel("id_secteur, lang", "spip_rubriques", "id_rubrique=".sql_quote($champs['id_rubrique']));
|
||||
$langue = $row_rub['lang'];
|
||||
|
||||
if (isset($desc['field']['id_secteur']))
|
||||
$champs['id_secteur'] = $row_rub['id_secteur'];
|
||||
|
||||
if (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie']))
|
||||
if (sql_fetsel('1', $table_sql, id_table_objet($objet)."=".intval($id)." AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) {
|
||||
$champs['lang'] = $langue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$champs) return;
|
||||
sql_updateq($table_sql, $champs, id_table_objet($objet).'='.intval($id));
|
||||
|
||||
// Changer le statut des rubriques concernees
|
||||
if ($cond) {
|
||||
include_spip('inc/rubriques');
|
||||
//$postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false;
|
||||
$postdate = false;
|
||||
calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,335 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
/**
|
||||
* Fonctions de modifications des rubriques
|
||||
*
|
||||
* @package SPIP\Rubriques\Modifications
|
||||
*/
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/rubriques');
|
||||
|
||||
/**
|
||||
* Action d'édition d'une rubrique
|
||||
*
|
||||
* Crée la rubrique si elle n'existe pas encore
|
||||
* Redirige après l'action sur _request('redirect') si présent
|
||||
*
|
||||
* @param null|int $arg
|
||||
* - null : vérifie la sécurité de l'action.
|
||||
* Si ok, obtient l'identifiant de rubrique à éditer
|
||||
* (oui 'oui' pour une nouvelle rubrique)
|
||||
* - int : identifiant de rubrique dont on demande l'édition
|
||||
* @return array
|
||||
* Liste : identifiant de la rubrique, message d'erreur éventuel.
|
||||
*
|
||||
*/
|
||||
function action_editer_rubrique_dist($arg=null) {
|
||||
|
||||
if (is_null($arg)){
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
}
|
||||
|
||||
if (!$id_rubrique = intval($arg)) {
|
||||
if ($arg != 'oui') {
|
||||
include_spip('inc/headers');
|
||||
redirige_url_ecrire();
|
||||
}
|
||||
$id_rubrique = rubrique_inserer(_request('id_parent'));
|
||||
}
|
||||
|
||||
$err = rubrique_modifier($id_rubrique);
|
||||
|
||||
if (_request('redirect')) {
|
||||
$redirect = parametre_url(
|
||||
urldecode(_request('redirect')),
|
||||
'id_rubrique', $id_rubrique, '&');
|
||||
|
||||
include_spip('inc/headers');
|
||||
redirige_par_entete($redirect);
|
||||
}
|
||||
|
||||
return array($id_rubrique,$err);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insérer une rubrique en base
|
||||
*
|
||||
* @param int $id_parent
|
||||
* Identifiant de la rubrique parente.
|
||||
* 0 pour la racine.
|
||||
* @return int
|
||||
* Identifiant de la rubrique crée
|
||||
*/
|
||||
function rubrique_inserer($id_parent) {
|
||||
$champs = array(
|
||||
'titre' => _T('item_nouvelle_rubrique'),
|
||||
'id_parent' => intval($id_parent),
|
||||
'statut' => 'new');
|
||||
|
||||
// Envoyer aux plugins
|
||||
$champs = pipeline('pre_insertion',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_rubriques',
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
$id_rubrique = sql_insertq("spip_rubriques", $champs);
|
||||
pipeline('post_insertion',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_rubriques',
|
||||
'id_objet' => $id_rubrique
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
propager_les_secteurs();
|
||||
calculer_langues_rubriques();
|
||||
return $id_rubrique;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier une rubrique en base
|
||||
*
|
||||
* @param int $id_rubrique
|
||||
* Identifiant de la rubrique modifiée
|
||||
* @param array|null $set
|
||||
* Tableau qu'on peut proposer en lieu et place de _request()
|
||||
* @return bool|string
|
||||
* - false : Aucune modification, aucun champ n'est à modifier
|
||||
* - chaîne vide : Vide si tout s'est bien passé
|
||||
* - chaîne : Texte d'un message d'erreur
|
||||
*/
|
||||
function rubrique_modifier($id_rubrique, $set=null) {
|
||||
include_spip('inc/autoriser');
|
||||
include_spip('inc/filtres');
|
||||
|
||||
include_spip('inc/modifier');
|
||||
$c = collecter_requests(
|
||||
// white list
|
||||
objet_info('rubrique','champs_editables'),
|
||||
// black list
|
||||
array('id_parent', 'confirme_deplace'),
|
||||
// donnees eventuellement fournies
|
||||
$set
|
||||
);
|
||||
|
||||
if ($err = objet_modifier_champs('rubrique', $id_rubrique,
|
||||
array(
|
||||
'nonvide' => array('titre' => _T('titre_nouvelle_rubrique')." "._T('info_numero_abbreviation').$id_rubrique)
|
||||
),
|
||||
$c))
|
||||
return $err;
|
||||
|
||||
$c = collecter_requests(array('id_parent', 'confirme_deplace'),array(),$set);
|
||||
// Deplacer la rubrique
|
||||
if (isset($c['id_parent'])) {
|
||||
$err = rubrique_instituer($id_rubrique, $c);
|
||||
}
|
||||
|
||||
// invalider les caches marques de cette rubrique
|
||||
include_spip('inc/invalideur');
|
||||
suivre_invalideur("id='rubrique/$id_rubrique'");
|
||||
// et celui de menu_rubriques
|
||||
effacer_meta("date_calcul_rubriques");
|
||||
return $err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Déplace les brèves d'une rubrique dans le secteur d'un nouveau parent
|
||||
*
|
||||
* Si c'est une rubrique-secteur contenant des brèves, on ne deplace
|
||||
* que si $confirme_deplace == 'oui', et change alors l'id_rubrique des
|
||||
* brèves en question
|
||||
*
|
||||
* @todo À déporter dans le plugin brèves via un pipeline ?
|
||||
*
|
||||
* @param int $id_rubrique
|
||||
* Identifiant de la rubrique déplacée
|
||||
* @param int $id_parent
|
||||
* Identifiant du nouveau parent de la rubrique
|
||||
* @param array $c
|
||||
* Informations pour l'institution (id_rubrique, confirme_deplace)
|
||||
* @return bool
|
||||
* true si le déplacement est fait ou s'il n'y a rien à faire
|
||||
* false si la confirmation du déplacement n'est pas présente
|
||||
*/
|
||||
function editer_rubrique_breves($id_rubrique, $id_parent, $c=array())
|
||||
{
|
||||
if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique"))
|
||||
return true;
|
||||
|
||||
if ($c['confirme_deplace'] != 'oui')
|
||||
return false;
|
||||
|
||||
if ($id_secteur = sql_getfetsel("id_secteur",
|
||||
"spip_rubriques", "id_rubrique=$id_parent"))
|
||||
sql_updateq("spip_breves", array("id_rubrique" => $id_secteur), "id_rubrique=$id_rubrique");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instituer une rubrique (changer son parent)
|
||||
*
|
||||
* Change le parent d'une rubrique, si les autorisations sont correctes,
|
||||
* mais n'accèpte pas de déplacer une rubrique dans une de ses filles, tout de même !
|
||||
*
|
||||
* Recalcule les secteurs, les langues et déplace les brèves au passage.
|
||||
*
|
||||
* @param int $id_rubrique
|
||||
* Identifiant de la rubrique à instituer
|
||||
* @param array $c
|
||||
* Informations pour l'institution (id_rubrique, confirme_deplace)
|
||||
* @return string
|
||||
* Chaine vide : aucune erreur
|
||||
* Chaîne : Texte du message d'erreur
|
||||
*/
|
||||
function rubrique_instituer($id_rubrique, $c) {
|
||||
// traitement de la rubrique parente
|
||||
// interdiction de deplacer vers ou a partir d'une rubrique
|
||||
// qu'on n'administre pas.
|
||||
|
||||
if (NULL !== ($id_parent = $c['id_parent'])) {
|
||||
$id_parent = intval($id_parent);
|
||||
$filles = calcul_branche_in($id_rubrique);
|
||||
if (strpos(",$id_parent,", ",$filles,") !== false)
|
||||
spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent");
|
||||
else {
|
||||
$s = sql_fetsel("id_parent, statut", "spip_rubriques", "id_rubrique=$id_rubrique");
|
||||
$old_parent = $s['id_parent'];
|
||||
|
||||
if (!($id_parent != $old_parent
|
||||
AND autoriser('publierdans', 'rubrique', $id_parent)
|
||||
AND autoriser('creerrubriquedans', 'rubrique', $id_parent)
|
||||
AND autoriser('publierdans', 'rubrique', $old_parent)
|
||||
)) {
|
||||
if ($s['statut'] != 'new') {
|
||||
spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' '. $GLOBALS['visiteur_session']['statut']);
|
||||
}
|
||||
}
|
||||
elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) {
|
||||
|
||||
$champs = array('id_parent' => $id_parent);
|
||||
$statut_ancien = $s['statut'];
|
||||
|
||||
// Envoyer aux plugins
|
||||
$champs = pipeline('pre_edition',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_rubriques',
|
||||
'id_objet' => $id_rubrique,
|
||||
'action'=>'instituer',
|
||||
'statut_ancien' => $statut_ancien,
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
|
||||
if (!count($champs)) return '';
|
||||
|
||||
sql_updateq('spip_rubriques', $champs, "id_rubrique=$id_rubrique");
|
||||
|
||||
propager_les_secteurs();
|
||||
|
||||
// Deplacement d'une rubrique publiee ==> chgt general de leur statut
|
||||
if ($statut_ancien == 'publie')
|
||||
calculer_rubriques_if($old_parent, array('id_rubrique' => $id_parent), $statut_ancien);
|
||||
// Creation ou deplacement d'une rubrique non publiee
|
||||
// invalider le cache de leur menu
|
||||
elseif (!$statut_ancien || $old_parent!=$id_parent)
|
||||
effacer_meta("date_calcul_rubriques");
|
||||
|
||||
calculer_langues_rubriques();
|
||||
|
||||
// Pipeline
|
||||
pipeline('post_edition',
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => 'spip_rubriques',
|
||||
'id_objet' => $id_rubrique,
|
||||
'action'=>'instituer',
|
||||
'statut_ancien' => $statut_ancien,
|
||||
),
|
||||
'data' => $champs
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ''; // pas d'erreur
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée une rubrique
|
||||
*
|
||||
* @deprecated
|
||||
* Utiliser rubrique_inserer()
|
||||
* @see rubrique_inserer()
|
||||
*
|
||||
* @param int $id_parent
|
||||
* Identifiant de la rubrique parente.
|
||||
* 0 pour la racine.
|
||||
* @return int
|
||||
* Identifiant de la rubrique crée
|
||||
**/
|
||||
function insert_rubrique($id_parent) {
|
||||
return rubrique_inserer($id_parent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Modifie les contenus d'une rubrique
|
||||
*
|
||||
* @deprecated
|
||||
* Utiliser rubrique_modifier()
|
||||
* @see rubrique_modifier()
|
||||
*
|
||||
* @param int $id_rubrique
|
||||
* Identifiant de la rubrique à instituer
|
||||
* @param array|null $set
|
||||
* Tableau qu'on peut proposer en lieu et place de _request()
|
||||
* @return bool|string
|
||||
* - false : Aucune modification, aucun champ n'est à modifier
|
||||
* - chaîne vide : Vide si tout s'est bien passé
|
||||
* - chaîne : Texte d'un message d'erreur
|
||||
**/
|
||||
function revisions_rubriques($id_rubrique, $set=null) {
|
||||
return rubrique_modifier($id_rubrique,$set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Institue une rubrique (change son parent)
|
||||
*
|
||||
* @deprecated
|
||||
* Utiliser rubrique_instituer()
|
||||
* @see rubrique_instituer()
|
||||
*
|
||||
* @param int $id_rubrique
|
||||
* Identifiant de la rubrique à instituer
|
||||
* @param array $c
|
||||
* Informations pour l'institution (id_rubrique, confirme_deplace)
|
||||
* @return string
|
||||
* Chaine vide : aucune erreur
|
||||
* Chaîne : Texte du message d'erreur
|
||||
**/
|
||||
function instituer_rubrique($id_rubrique, $c) {
|
||||
return rubrique_instituer($id_rubrique, $c);
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/actions');
|
||||
|
||||
/**
|
||||
* Prouver qu'on a les droits de webmestre via un ftp, et
|
||||
* devenir webmestre sans refaire l'install
|
||||
* @return void
|
||||
*/
|
||||
function action_etre_webmestre_dist() {
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$time = $securiser_action();
|
||||
|
||||
if (time()-$time<15*60
|
||||
AND $GLOBALS['visiteur_session']['statut']=='0minirezo'
|
||||
AND $GLOBALS['visiteur_session']['webmestre']!=='oui') {
|
||||
$action = _T('info_admin_etre_webmestre');
|
||||
$admin = charger_fonction('admin', 'inc');
|
||||
// lance la verif par ftp et l'appel
|
||||
// a base_etre_webmestre_dist quand c'est OK
|
||||
if ($r = $admin('etre_webmestre', $action)) {
|
||||
echo $r;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function base_etre_webmestre_dist() {
|
||||
if ($GLOBALS['visiteur_session']['statut']=='0minirezo' AND $GLOBALS['visiteur_session']['webmestre']!=='oui') {
|
||||
include_spip('action/editer_auteur');
|
||||
instituer_auteur($GLOBALS['visiteur_session']['id_auteur'], array('webmestre'=>'oui'), true);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Executer un travaille immediatement
|
||||
* @return void
|
||||
*/
|
||||
function action_forcer_job_dist(){
|
||||
$securiser_action = charger_fonction('securiser_action','inc');
|
||||
$id_job = $securiser_action();
|
||||
|
||||
if ($id_job = intval($id_job)
|
||||
AND autoriser('forcer','job',$id_job)
|
||||
){
|
||||
include_spip('inc/queue');
|
||||
include_spip('inc/genie');
|
||||
queue_schedule(array($id_job));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,131 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* L'entree par l'action ne sert plus qu'a une retro compat eventuelle
|
||||
* le #FORMULAIRE_EDITER_LOGO utilise action_spip_image_ajouter_dist
|
||||
*/
|
||||
function action_iconifier_dist()
|
||||
{
|
||||
include_spip('inc/actions');
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
$iframe_redirect = _request('iframe_redirect');
|
||||
|
||||
$arg = rawurldecode($arg);
|
||||
|
||||
if (!preg_match(',^-?\d*(\D)(.*)$,',$arg, $r))
|
||||
spip_log("action iconifier: $arg pas compris");
|
||||
elseif ($r[1] == '+')
|
||||
action_spip_image_ajouter_dist($r[2], _request('sousaction2'), _request('source'));
|
||||
else action_spip_image_effacer_dist($r[2]);
|
||||
|
||||
if(_request("iframe") == 'iframe') {
|
||||
$redirect = urldecode($iframe_redirect)."&iframe=iframe";
|
||||
redirige_par_entete(urldecode($redirect));
|
||||
}
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@action_spip_image_effacer_dist
|
||||
function action_spip_image_effacer_dist($arg) {
|
||||
|
||||
if (!strstr($arg, ".."))
|
||||
spip_unlink(_DIR_LOGOS . $arg);
|
||||
}
|
||||
|
||||
//
|
||||
// Ajouter un logo
|
||||
//
|
||||
|
||||
// $source = $_FILES[0]
|
||||
// $dest = arton12.xxx
|
||||
// http://doc.spip.org/@action_spip_image_ajouter_dist
|
||||
function action_spip_image_ajouter_dist($arg,$sousaction2,$source,$return=false) {
|
||||
global $formats_logos;
|
||||
|
||||
include_spip('inc/documents');
|
||||
if (!$sousaction2) {
|
||||
if (!$_FILES) $_FILES = $GLOBALS['HTTP_POST_FILES'];
|
||||
$source = (is_array($_FILES) ? array_pop($_FILES) : "");
|
||||
}
|
||||
$erreur = "";
|
||||
if (!$source)
|
||||
spip_log("spip_image_ajouter : source inconnue");
|
||||
else {
|
||||
$f =_DIR_LOGOS . $arg . '.tmp';
|
||||
|
||||
if (!is_array($source))
|
||||
// fichier dans upload/
|
||||
$source = @copy(determine_upload() . $source, $f);
|
||||
else {
|
||||
// Intercepter une erreur a l'envoi
|
||||
if ($erreur = check_upload_error($source['error'],"",$return))
|
||||
$source ="";
|
||||
else
|
||||
// analyse le type de l'image (on ne fait pas confiance au nom de
|
||||
// fichier envoye par le browser : pour les Macs c'est plus sur)
|
||||
|
||||
$source = deplacer_fichier_upload($source['tmp_name'], $f);
|
||||
}
|
||||
if (!$source)
|
||||
spip_log("pb de copie pour $f");
|
||||
}
|
||||
if ($source AND $f) {
|
||||
$size = @getimagesize($f);
|
||||
$type = !$size ? '': ($size[2] > 3 ? '' : $formats_logos[$size[2]-1]);
|
||||
if ($type) {
|
||||
$poids = filesize($f);
|
||||
|
||||
if (_LOGO_MAX_SIZE > 0
|
||||
AND $poids > _LOGO_MAX_SIZE*1024) {
|
||||
spip_unlink ($f);
|
||||
$erreur = _T('info_logo_max_poids',
|
||||
array('maxi' => taille_en_octets(_LOGO_MAX_SIZE*1024),
|
||||
'actuel' => taille_en_octets($poids)));
|
||||
}
|
||||
|
||||
elseif (_LOGO_MAX_WIDTH * _LOGO_MAX_HEIGHT
|
||||
AND ($size[0] > _LOGO_MAX_WIDTH
|
||||
OR $size[1] > _LOGO_MAX_HEIGHT)) {
|
||||
spip_unlink ($f);
|
||||
$erreur = _T('info_logo_max_poids',
|
||||
array(
|
||||
'maxi' =>
|
||||
_T('info_largeur_vignette',
|
||||
array('largeur_vignette' => _LOGO_MAX_WIDTH,
|
||||
'hauteur_vignette' => _LOGO_MAX_HEIGHT)),
|
||||
'actuel' =>
|
||||
_T('info_largeur_vignette',
|
||||
array('largeur_vignette' => $size[0],
|
||||
'hauteur_vignette' => $size[1]))
|
||||
));
|
||||
}
|
||||
else
|
||||
@rename ($f, _DIR_LOGOS . $arg . ".$type");
|
||||
}
|
||||
else {
|
||||
spip_unlink ($f);
|
||||
$erreur = _T('info_logo_format_interdit',
|
||||
array('formats' => join(', ', $formats_logos)));
|
||||
}
|
||||
|
||||
}
|
||||
if ($erreur){
|
||||
if ($return)
|
||||
return $erreur;
|
||||
else
|
||||
check_upload_error(6,$erreur);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1 +0,0 @@
|
|||
X
|
|
@ -1,340 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
|
||||
/**
|
||||
* Inscrire un nouvel auteur sur la base de son nom et son email
|
||||
* L'email est utilise pour reperer si il existe deja ou non
|
||||
* => identifiant par defaut
|
||||
*
|
||||
* @param string $statut
|
||||
* @param string $mail_complet
|
||||
* @param string $nom
|
||||
* @param array $options
|
||||
* login : login precalcule
|
||||
* id : id_rubrique fournit en second arg de #FORMULAIRE_INSCRIPTION
|
||||
* from : email de l'envoyeur pour l'envoi du mail d'inscription
|
||||
* force_nouveau : forcer le statut nouveau sur l'auteur inscrit, meme si il existait deja en base
|
||||
* @return array|string
|
||||
*/
|
||||
function action_inscrire_auteur_dist($statut, $mail_complet, $nom, $options = array()){
|
||||
if (!is_array($options))
|
||||
$options = array('id'=>$options);
|
||||
|
||||
if (function_exists('test_inscription'))
|
||||
$f = 'test_inscription';
|
||||
else $f = 'test_inscription_dist';
|
||||
$desc = $f($statut, $mail_complet, $nom, $options);
|
||||
|
||||
// erreur ?
|
||||
if (!is_array($desc))
|
||||
return _T($desc);
|
||||
|
||||
include_spip('base/abstract_sql');
|
||||
$res = sql_select("statut, id_auteur, login, email", "spip_auteurs", "email=" . sql_quote($desc['email']));
|
||||
// erreur ?
|
||||
if (!$res)
|
||||
return _T('titre_probleme_technique');
|
||||
|
||||
$row = sql_fetch($res);
|
||||
sql_free($res);
|
||||
if ($row){
|
||||
if (isset($options['force_nouveau']) AND $options['force_nouveau']==true){
|
||||
$desc['id_auteur'] = $row['id_auteur'];
|
||||
$desc = inscription_nouveau($desc);
|
||||
}
|
||||
else
|
||||
$desc = $row;
|
||||
}
|
||||
else
|
||||
// s'il n'existe pas deja, creer les identifiants
|
||||
$desc = inscription_nouveau($desc);
|
||||
|
||||
// erreur ?
|
||||
if (!is_array($desc))
|
||||
return $desc;
|
||||
|
||||
|
||||
// generer le mot de passe (ou le refaire si compte inutilise)
|
||||
$desc['pass'] = creer_pass_pour_auteur($desc['id_auteur']);
|
||||
|
||||
// attribuer un jeton pour confirmation par clic sur un lien
|
||||
$desc['jeton'] = auteur_attribuer_jeton($desc['id_auteur']);
|
||||
|
||||
// charger de suite cette fonction, pour ses utilitaires
|
||||
$envoyer_inscription = charger_fonction("envoyer_inscription","");
|
||||
list($sujet,$msg,$from,$head) = $envoyer_inscription($desc, $nom, $statut, $options);
|
||||
|
||||
$notifications = charger_fonction('notifications', 'inc');
|
||||
notifications_envoyer_mails($mail_complet, $msg, $sujet, $from, $head);
|
||||
|
||||
// Notifications
|
||||
$notifications('inscription', $desc['id_auteur'],
|
||||
array('nom' => $desc['nom'], 'email' => $desc['email'])
|
||||
);
|
||||
|
||||
return $desc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* fonction qu'on peut redefinir pour filtrer les adresses mail et les noms,
|
||||
* et donner des infos supplementaires
|
||||
* Std: controler que le nom (qui sert a calculer le login) est plausible
|
||||
* et que l'adresse est valide. On les normalise au passage (trim etc).
|
||||
* Retour:
|
||||
* - si ok un tableau avec au minimum email, nom, mode (redac / forum)
|
||||
* - si ko une chaine de langue servant d'argument a _T expliquant le refus
|
||||
*
|
||||
* http://doc.spip.org/@test_inscription_dist
|
||||
*
|
||||
* @param string $statut
|
||||
* @param string $mail
|
||||
* @param string $nom
|
||||
* @param string $options
|
||||
* @return array|string
|
||||
*/
|
||||
function test_inscription_dist($statut, $mail, $nom, $options) {
|
||||
include_spip('inc/filtres');
|
||||
if (!$r = email_valide($mail)) return 'info_email_invalide';
|
||||
$nom = trim(corriger_caracteres($nom));
|
||||
$res = array('email' => $r, 'nom' => $nom, 'prefs' => $statut);
|
||||
if (isset($options['login'])) {
|
||||
$login = trim(corriger_caracteres($options['login']));
|
||||
if((strlen ($login) >= _LOGIN_TROP_COURT) AND (strlen($nom) <= 64))
|
||||
$res['login'] = $login;
|
||||
}
|
||||
if(!isset($res['login']) AND ((strlen ($nom) < _LOGIN_TROP_COURT) OR (strlen($nom) > 64)))
|
||||
return 'ecrire:info_login_trop_court';
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* On enregistre le demandeur comme 'nouveau', en memorisant le statut final
|
||||
* provisoirement dans le champ prefs, afin de ne pas visualiser les inactifs
|
||||
* A sa premiere connexion il obtiendra son statut final.
|
||||
*
|
||||
* http://doc.spip.org/@inscription_nouveau
|
||||
*
|
||||
* @param array $desc
|
||||
* @return mixed|string
|
||||
*/
|
||||
function inscription_nouveau($desc)
|
||||
{
|
||||
if (!isset($desc['login']) OR !strlen($desc['login']))
|
||||
$desc['login'] = test_login($desc['nom'], $desc['email']);
|
||||
|
||||
$desc['statut'] = 'nouveau';
|
||||
include_spip('action/editer_auteur');
|
||||
if (isset($desc['id_auteur']))
|
||||
$id_auteur = $desc['id_auteur'];
|
||||
else
|
||||
$id_auteur = auteur_inserer();
|
||||
|
||||
if (!$id_auteur) return _T('titre_probleme_technique');
|
||||
|
||||
include_spip('inc/autoriser');
|
||||
// lever l'autorisation pour pouvoir modifier le statut
|
||||
autoriser_exception('modifier','auteur',$id_auteur);
|
||||
auteur_modifier($id_auteur, $desc);
|
||||
autoriser_exception('modifier','auteur',$id_auteur,false);
|
||||
|
||||
$desc['id_auteur'] = $id_auteur;
|
||||
|
||||
return $desc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* http://doc.spip.org/@test_login
|
||||
*
|
||||
* @param string $nom
|
||||
* @param string $mail
|
||||
* @return string
|
||||
*/
|
||||
function test_login($nom, $mail) {
|
||||
include_spip('inc/charsets');
|
||||
$nom = strtolower(translitteration($nom));
|
||||
$login_base = preg_replace("/[^\w\d_]/", "_", $nom);
|
||||
|
||||
// il faut eviter que le login soit vraiment trop court
|
||||
if (strlen($login_base) < 3) {
|
||||
$mail = strtolower(translitteration(preg_replace('/@.*/', '', $mail)));
|
||||
$login_base = preg_replace("/[^\w\d]/", "_", $mail);
|
||||
}
|
||||
if (strlen($login_base) < 3)
|
||||
$login_base = 'user';
|
||||
|
||||
// eviter aussi qu'il soit trop long (essayer d'attraper le prenom)
|
||||
if (strlen($login_base) > 10) {
|
||||
$login_base = preg_replace("/^(.{4,}(_.{1,7})?)_.*/",
|
||||
'\1', $login_base);
|
||||
$login_base = substr($login_base, 0,13);
|
||||
}
|
||||
|
||||
$login = $login_base;
|
||||
|
||||
for ($i = 1; ; $i++) {
|
||||
if (!sql_countsel('spip_auteurs', "login='$login'"))
|
||||
return $login;
|
||||
$login = $login_base.$i;
|
||||
}
|
||||
return $login;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* construction du mail envoyant les identifiants
|
||||
* fonction redefinissable qui doit retourner un tableau
|
||||
* dont les elements seront les arguments de inc_envoyer_mail
|
||||
*
|
||||
* http://doc.spip.org/@envoyer_inscription_dist
|
||||
*
|
||||
* @param array $desc
|
||||
* @param string $nom
|
||||
* @param string $mode
|
||||
* @param array $options
|
||||
* @return array
|
||||
*/
|
||||
function envoyer_inscription_dist($desc, $nom, $mode, $options=array()) {
|
||||
|
||||
$contexte = array_merge($desc,$options);
|
||||
$contexte['nom'] = $nom;
|
||||
$contexte['mode'] = $mode;
|
||||
$contexte['url_confirm'] = generer_url_action('confirmer_inscription','',true,true);
|
||||
$contexte['url_confirm'] = parametre_url($contexte['url_confirm'],'email',$desc['email']);
|
||||
$contexte['url_confirm'] = parametre_url($contexte['url_confirm'],'jeton',$desc['jeton']);
|
||||
|
||||
$message = recuperer_fond('modeles/mail_inscription',$contexte);
|
||||
$from = (isset($options['from'])?$options['from']:null);
|
||||
$head = null;
|
||||
return array("", $message,$from,$head);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creer un mot de passe initial aleatoire
|
||||
*
|
||||
* http://doc.spip.org/@creer_pass_pour_auteur
|
||||
*
|
||||
* @param int $id_auteur
|
||||
* @return string
|
||||
*/
|
||||
function creer_pass_pour_auteur($id_auteur) {
|
||||
include_spip('inc/acces');
|
||||
$pass = creer_pass_aleatoire(8, $id_auteur);
|
||||
include_spip('action/editer_auteur');
|
||||
auteur_instituer($id_auteur, array('pass'=>$pass));
|
||||
return $pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine le statut d'inscription :
|
||||
* si $statut_tmp fourni, verifie qu'il est autorise
|
||||
* sinon determine le meilleur statut possible et le renvoie
|
||||
*
|
||||
* @param string $statut_tmp
|
||||
* @param int $id
|
||||
* @return string
|
||||
*/
|
||||
function tester_statut_inscription($statut_tmp, $id){
|
||||
include_spip('inc/autoriser');
|
||||
if ($statut_tmp)
|
||||
return autoriser('inscrireauteur', $statut_tmp, $id) ? $statut_tmp : '';
|
||||
elseif (
|
||||
autoriser('inscrireauteur', $statut_tmp = "1comite", $id)
|
||||
OR autoriser('inscrireauteur', $statut_tmp = "6forum", $id))
|
||||
return $statut_tmp;
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Un nouvel inscrit prend son statut definitif a la 1ere connexion.
|
||||
* Le statut a ete memorise dans prefs (cf test_inscription_dist).
|
||||
* On le verifie, car la config a peut-etre change depuis,
|
||||
* et pour compatibilite avec les anciennes versions qui n'utilisaient pas "prefs".
|
||||
*
|
||||
* http://doc.spip.org/@acces_statut
|
||||
*
|
||||
* @param array $auteur
|
||||
* @return array
|
||||
*/
|
||||
function confirmer_statut_inscription($auteur){
|
||||
// securite
|
||||
if ($auteur['statut'] != 'nouveau') return $auteur;
|
||||
|
||||
include_spip('inc/autoriser');
|
||||
if (!autoriser('inscrireauteur', $auteur['prefs']))
|
||||
return $auteur;
|
||||
$s = $auteur['prefs'];
|
||||
|
||||
include_spip('inc/autoriser');
|
||||
// accorder l'autorisation de modif du statut auteur
|
||||
autoriser_exception('modifier','auteur',$auteur['id_auteur']);
|
||||
include_spip('action/editer_auteur');
|
||||
// changer le statut
|
||||
auteur_modifier($auteur['id_auteur'],array('statut'=> $s));
|
||||
unset($_COOKIE['spip_session']); // forcer la maj de la session
|
||||
// lever l'autorisation de modif du statut auteur
|
||||
autoriser_exception('modifier','auteur',$auteur['id_auteur'],false);
|
||||
|
||||
// mettre a jour le statut
|
||||
$auteur['statut'] = $s;
|
||||
return $auteur;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attribuer un jeton temporaire pour un auteur
|
||||
* en assurant l'unicite du jeton
|
||||
* @param int $id_auteur
|
||||
* @return string
|
||||
*/
|
||||
function auteur_attribuer_jeton($id_auteur){
|
||||
include_spip('inc/acces');
|
||||
// s'assurer de l'unicite du jeton pour le couple (email,cookie)
|
||||
do {
|
||||
$jeton = creer_uniqid();
|
||||
sql_updateq("spip_auteurs", array("cookie_oubli" => $jeton), "id_auteur=" . intval($id_auteur));
|
||||
}
|
||||
while (sql_countsel("spip_auteurs","cookie_oubli=".sql_quote($jeton))>1);
|
||||
return $jeton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrouver l'auteur par son jeton
|
||||
* @param string $jeton
|
||||
* @return array|bool
|
||||
*/
|
||||
function auteur_verifier_jeton($jeton){
|
||||
// refuser un jeton corrompu
|
||||
if (preg_match(',[^0-9a-f.],i',$jeton))
|
||||
return false;
|
||||
|
||||
$desc = sql_fetsel('*','spip_auteurs',"cookie_oubli=".sql_quote($jeton, $serveur, 'string'));
|
||||
return $desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Effacer le jeton d'un auteur apres utilisation
|
||||
*
|
||||
* @param int $id_auteur
|
||||
* @return bool
|
||||
*/
|
||||
function auteur_effacer_jeton($id_auteur){
|
||||
return sql_updateq("spip_auteurs", array("cookie_oubli" => ''), "id_auteur=" . intval($id_auteur));
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Modifier la langue d'un objet
|
||||
* @param string $objet
|
||||
* @param int $id
|
||||
* @param int $id_rubrique
|
||||
* @param string $changer_lang
|
||||
* @return string
|
||||
*/
|
||||
function action_instituer_langue_objet_dist($objet,$id, $id_rubrique, $changer_lang) {
|
||||
if ($changer_lang) {
|
||||
$table_objet_sql = table_objet_sql($objet);
|
||||
$id_table_objet = id_table_objet($objet);
|
||||
|
||||
if ($changer_lang != "herit") {
|
||||
sql_updateq($table_objet_sql, array('lang'=>$changer_lang, 'langue_choisie'=>'oui'), "$id_table_objet=".intval($id));
|
||||
include_spip('inc/rubriques');
|
||||
$langues = calculer_langues_utilisees();
|
||||
ecrire_meta('langues_utilisees', $langues);
|
||||
}
|
||||
else {
|
||||
$langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=" . intval($id_rubrique));
|
||||
if (!$langue_parent)
|
||||
$langue_parent = $GLOBALS['meta']['langue_site'];
|
||||
sql_updateq($table_objet_sql, array('lang'=>$langue_parent, 'langue_choisie'=>'non'), "$id_table_objet=".intval($id));
|
||||
$changer_lang = $langue_parent;
|
||||
}
|
||||
}
|
||||
return $changer_lang;
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@action_instituer_langue_rubrique_dist
|
||||
function action_instituer_langue_rubrique_dist() {
|
||||
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
$changer_lang = _request('changer_lang');
|
||||
|
||||
list($id_rubrique, $id_parent) = preg_split('/\W/', $arg);
|
||||
|
||||
if ($changer_lang
|
||||
AND $id_rubrique>0
|
||||
AND $GLOBALS['meta']['multi_rubriques'] == 'oui'
|
||||
AND ($GLOBALS['meta']['multi_secteurs'] == 'non' OR $id_parent == 0)) {
|
||||
if ($changer_lang != "herit")
|
||||
sql_updateq('spip_rubriques', array('lang'=>$changer_lang, 'langue_choisie'=>'oui'), "id_rubrique=$id_rubrique");
|
||||
else {
|
||||
if ($id_parent == 0)
|
||||
$langue_parent = $GLOBALS['meta']['langue_site'];
|
||||
else {
|
||||
$langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=$id_parent");
|
||||
}
|
||||
sql_updateq('spip_rubriques', array('lang'=>$langue_parent, 'langue_choisie'=>'non'), "id_rubrique=$id_rubrique");
|
||||
}
|
||||
include_spip('inc/rubriques');
|
||||
calculer_langues_rubriques();
|
||||
|
||||
// invalider les caches marques de cette rubrique
|
||||
include_spip('inc/invalideur');
|
||||
suivre_invalideur("id='rubrique/$id_rubrique'");
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return;
|
||||
|
||||
/**
|
||||
* Instituer un objet avec les puces rapides
|
||||
* @param null|string $arg
|
||||
* @return
|
||||
*/
|
||||
function action_instituer_objet_dist($arg=null) {
|
||||
|
||||
if (is_null($arg)){
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
}
|
||||
|
||||
list($objet, $id_objet, $statut) = preg_split('/\W/', $arg);
|
||||
if (!$statut) $statut = _request('statut_nouv'); // cas POST
|
||||
if (!$statut) return; // impossible mais sait-on jamais
|
||||
|
||||
if ($id_objet = intval($id_objet)
|
||||
AND autoriser('instituer',$objet,$id_objet,'',array('statut'=>$statut))){
|
||||
|
||||
include_spip('action/editer_objet');
|
||||
objet_modifier($objet,$id_objet,array('statut' => $statut));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,130 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/cookie');
|
||||
|
||||
|
||||
/**
|
||||
* Se deloger
|
||||
* Pour eviter les CSRF on passe par une etape de confirmation si pas de jeton fourni
|
||||
* avec un autosubmit js pour ne pas compliquer l'experience utilisateur
|
||||
*
|
||||
* http://doc.spip.org/@action_logout_dist
|
||||
*
|
||||
*/
|
||||
function action_logout_dist()
|
||||
{
|
||||
$logout =_request('logout');
|
||||
$url = securiser_redirect_action(_request('url'));
|
||||
// cas particulier, logout dans l'espace public
|
||||
if ($logout == 'public' AND !$url)
|
||||
$url = url_de_base();
|
||||
|
||||
// seul le loge peut se deloger (mais id_auteur peut valoir 0 apres une restauration avortee)
|
||||
if (isset($GLOBALS['visiteur_session']['id_auteur'])
|
||||
AND is_numeric($GLOBALS['visiteur_session']['id_auteur'])
|
||||
// des sessions anonymes avec id_auteur=0 existent, mais elle n'ont pas de statut : double check
|
||||
AND isset($GLOBALS['visiteur_session']['statut'])) {
|
||||
|
||||
// il faut un jeton pour fermer la session (eviter les CSRF)
|
||||
if (!$jeton = _request('jeton')
|
||||
OR !verifier_jeton_logout($jeton,$GLOBALS['visiteur_session'])){
|
||||
$jeton = generer_jeton_logout($GLOBALS['visiteur_session']);
|
||||
$action = generer_url_action("logout","jeton=$jeton");
|
||||
$action = parametre_url($action,'logout',_request('logout'));
|
||||
$action = parametre_url($action,'url',_request('url'));
|
||||
include_spip("inc/minipres");
|
||||
include_spip("inc/filtres");
|
||||
$texte = bouton_action(_T('spip:icone_deconnecter'),$action);
|
||||
$texte = "<div class='boutons'>$texte</div>";
|
||||
$texte .= '<script type="text/javascript">document.write("<style>body{visibility:hidden;}</style>");window.document.forms[0].submit();</script>';
|
||||
$res = minipres(_T('spip:icone_deconnecter'),$texte,'',true);
|
||||
echo $res;
|
||||
return;
|
||||
}
|
||||
|
||||
include_spip('inc/auth');
|
||||
auth_trace($GLOBALS['visiteur_session'], '0000-00-00 00:00:00');
|
||||
// le logout explicite vaut destruction de toutes les sessions
|
||||
if (isset($_COOKIE['spip_session'])) {
|
||||
$session = charger_fonction('session', 'inc');
|
||||
$session($GLOBALS['visiteur_session']['id_auteur']);
|
||||
spip_setcookie('spip_session', $_COOKIE['spip_session'], time()-3600);
|
||||
}
|
||||
// si authentification http, et que la personne est loge,
|
||||
// pour se deconnecter, il faut proposer un nouveau formulaire de connexion http
|
||||
if (isset($_SERVER['PHP_AUTH_USER'])
|
||||
AND !$GLOBALS['ignore_auth_http']
|
||||
AND $GLOBALS['auth_can_disconnect']) {
|
||||
ask_php_auth(_T('login_deconnexion_ok'),
|
||||
_T('login_verifiez_navigateur'),
|
||||
_T('login_retour_public'),
|
||||
"redirect=". _DIR_RESTREINT_ABS,
|
||||
_T('login_test_navigateur'),
|
||||
true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Rediriger en contrant le cache navigateur (Safari3)
|
||||
include_spip('inc/headers');
|
||||
redirige_par_entete($url
|
||||
? parametre_url($url, 'var_hasard', uniqid(rand()), '&')
|
||||
: generer_url_public('login'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generer un jeton de logout personnel et ephemere
|
||||
* @param array $session
|
||||
* @param null|string $alea
|
||||
* @return string
|
||||
*/
|
||||
function generer_jeton_logout($session,$alea=null){
|
||||
if (is_null($alea)){
|
||||
if (!isset($GLOBALS['meta']['alea_ephemere'])){
|
||||
include_spip('base/abstract_sql');
|
||||
$GLOBALS['meta']['alea_ephemere'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere'");
|
||||
}
|
||||
$alea = $GLOBALS['meta']['alea_ephemere'];
|
||||
}
|
||||
|
||||
$jeton = md5($session['date_session']
|
||||
.$session['id_auteur']
|
||||
.$session['statut']
|
||||
.$alea
|
||||
);
|
||||
return $jeton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifier que le jeton de logout est bon
|
||||
* il faut verifier avec alea_ephemere_ancien si pas bon avec alea_ephemere
|
||||
* pour gerer le cas de la rotation d'alea
|
||||
* @param string $jeton
|
||||
* @param array $session
|
||||
* @return bool
|
||||
*/
|
||||
function verifier_jeton_logout($jeton,$session){
|
||||
if (generer_jeton_logout($session)===$jeton)
|
||||
return true;
|
||||
if (!isset($GLOBALS['meta']['alea_ephemere_ancien'])){
|
||||
include_spip('base/abstract_sql');
|
||||
$GLOBALS['meta']['alea_ephemere_ancien'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere_ancien'");
|
||||
}
|
||||
if (generer_jeton_logout($session,$GLOBALS['meta']['alea_ephemere_ancien'])===$jeton)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,159 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/autoriser');
|
||||
include_spip('inc/texte');
|
||||
include_spip('inc/filtres');
|
||||
|
||||
function action_menu_rubriques_dist() {
|
||||
|
||||
// si pas acces a ecrire, pas acces au menu
|
||||
// on renvoi un 401 qui fait echouer la requete ajax silencieusement
|
||||
if (!autoriser('ecrire')){
|
||||
$retour = "<ul class='cols_1'><li class='toutsite'><a href='".generer_url_ecrire('accueil')."'>"._T('public:lien_connecter')."</a></li></ul>";
|
||||
include_spip('inc/actions');
|
||||
ajax_retour($retour);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($date = intval(_request('date')))
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s", $date)." GMT");
|
||||
|
||||
$r = gen_liste_rubriques();
|
||||
if (!$r
|
||||
AND isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
|
||||
AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/')) {
|
||||
include_spip('inc/headers');
|
||||
header('Content-Type: text/html; charset='. $GLOBALS['meta']['charset']);
|
||||
http_status(304);
|
||||
exit;
|
||||
} else {
|
||||
include_spip('inc/actions');
|
||||
$ret = menu_rubriques();
|
||||
ajax_retour($ret);
|
||||
}
|
||||
}
|
||||
|
||||
function menu_rubriques($complet = true){
|
||||
$ret = "<li class='toutsite'><a href='".generer_url_ecrire('plan')."'>"._T('info_tout_site')."</a></li>";
|
||||
|
||||
if (!$complet) {
|
||||
return "<ul class='cols_1'>$ret\n</ul>\n";
|
||||
}
|
||||
|
||||
if (!isset($GLOBALS['db_art_cache'])){
|
||||
gen_liste_rubriques();
|
||||
}
|
||||
$arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
|
||||
|
||||
$total_lignes = $i = sizeof($arr_low);
|
||||
|
||||
if ($i > 0) {
|
||||
$nb_col = min(8,ceil($total_lignes / 30));
|
||||
if ($nb_col <= 1) $nb_col = ceil($total_lignes / 10);
|
||||
foreach( $arr_low as $id_rubrique => $titre_rubrique) {
|
||||
if (autoriser('voir','rubrique',$id_rubrique)){
|
||||
$ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$ret = "<ul class='cols_$nb_col'>"
|
||||
. $ret
|
||||
. "\n</ul>\n";
|
||||
}
|
||||
else
|
||||
$ret = "<ul class='cols_1'>$ret\n</ul>\n";
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@bandeau_rubrique
|
||||
function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal) {
|
||||
static $zmax = 6;
|
||||
|
||||
$nav = "<a href='"
|
||||
. generer_url_entite($id_rubrique,'rubrique','','',false)
|
||||
. "'>"
|
||||
. supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique))
|
||||
. "</a>\n";
|
||||
|
||||
// Limiter volontairement le nombre de sous-menus
|
||||
if (!(--$zmax)) {
|
||||
$zmax++;
|
||||
return "\n<li>$nav</li>";
|
||||
}
|
||||
|
||||
$arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
|
||||
$i = sizeof($arr_rub);
|
||||
if (!$i) {
|
||||
$zmax++;
|
||||
return "\n<li>$nav</li>";
|
||||
}
|
||||
|
||||
|
||||
$nb_col = 1;
|
||||
if ($nb_rub = count($arr_rub)) {
|
||||
$nb_col = min(10,max(1,ceil($nb_rub / 10)));
|
||||
}
|
||||
$ret = "<li class='haschild'>$nav<ul class='cols_$nb_col'>";
|
||||
foreach( $arr_rub as $id_rub => $titre_rub) {
|
||||
if (autoriser('voir','rubrique',$id_rub)){
|
||||
$titre = supprimer_numero(typo($titre_rub));
|
||||
$ret .= bandeau_rubrique($id_rub, $titre, $zdecal+$i);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$ret .= "</ul></li>\n";
|
||||
$zmax++;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
// http://doc.spip.org/@extraire_article
|
||||
function extraire_article($id_p, $t) {
|
||||
return array_key_exists($id_p, $t) ? $t[$id_p]: array();
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@gen_liste_rubriques
|
||||
function gen_liste_rubriques() {
|
||||
|
||||
include_spip('inc/config');
|
||||
// ici, un petit fichier cache ne fait pas de mal
|
||||
$last = lire_config('date_calcul_rubriques', 0);
|
||||
if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
|
||||
list($date,$GLOBALS['db_art_cache']) = @unserialize($cache);
|
||||
if ($date == $last) return false; // c'etait en cache :-)
|
||||
}
|
||||
// se restreindre aux rubriques utilisees recemment +secteurs
|
||||
|
||||
$where = sql_in_select("id_rubrique", "id_rubrique", "spip_rubriques", "", "", "id_parent=0 DESC, date DESC", _CACHE_RUBRIQUES_MAX);
|
||||
|
||||
// puis refaire la requete pour avoir l'ordre alphabetique
|
||||
|
||||
$res = sql_select("id_rubrique, titre, id_parent", "spip_rubriques", $where, '', 'id_parent, 0+titre, titre');
|
||||
|
||||
// il ne faut pas filtrer le autoriser voir ici
|
||||
// car on met le resultat en cache, commun a tout le monde
|
||||
$GLOBALS['db_art_cache'] = array();
|
||||
while ($r = sql_fetch($res)) {
|
||||
$t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
|
||||
$GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
|
||||
}
|
||||
|
||||
$t = array($last ? $last : time(), $GLOBALS['db_art_cache']);
|
||||
ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
|
||||
return true;
|
||||
}
|
||||
?>
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
|
||||
// http://doc.spip.org/@action_preferer_dist
|
||||
function action_preferer_dist() {
|
||||
//
|
||||
// Preferences de presentation de l'espace prive
|
||||
//
|
||||
if ($_GET['arg'] !== 'display:4') {
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
} else $arg = $_GET['arg'];
|
||||
|
||||
if (!preg_match(",^(.+):(.*)$,", $arg, $r))
|
||||
spip_log("action_preferer_dist: $arg pas compris");
|
||||
else {
|
||||
$prefs_mod = false;
|
||||
|
||||
list(, $op, $val) = $r;
|
||||
if ($op == 'couleur') {
|
||||
$GLOBALS['visiteur_session']['prefs']['couleur'] = $val;
|
||||
$prefs_mod = true;
|
||||
}
|
||||
elseif ($op == 'display') {
|
||||
$GLOBALS['visiteur_session']['prefs']['display'] = $val;
|
||||
$prefs_mod = true;
|
||||
}
|
||||
elseif ($op == 'display_outils') {
|
||||
$GLOBALS['visiteur_session']['prefs']['display_outils'] = $val;
|
||||
$prefs_mod = true;
|
||||
}
|
||||
|
||||
if ($prefs_mod AND intval($GLOBALS['visiteur_session']['id_auteur']))
|
||||
sql_updateq('spip_auteurs', array('prefs' => serialize($GLOBALS['visiteur_session']['prefs'])), "id_auteur=" .intval($GLOBALS['visiteur_session']['id_auteur']));
|
||||
|
||||
if ($op == 'spip_ecran') {
|
||||
// Poser un cookie,
|
||||
// car ce reglage depend plus du navigateur que de l'utilisateur
|
||||
$GLOBALS['spip_ecran'] = $val;
|
||||
include_spip('inc/cookie');
|
||||
spip_setcookie('spip_ecran', $val, time() + 365 * 24 * 3600);
|
||||
}
|
||||
|
||||
// Si modif des couleurs en ajax, redirect inutile on a change de CSS
|
||||
if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') exit;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@action_purger_dist
|
||||
function action_purger_dist($arg=null)
|
||||
{
|
||||
if (is_null($arg)) {
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$arg = $securiser_action();
|
||||
}
|
||||
|
||||
include_spip('inc/invalideur');
|
||||
|
||||
spip_log("purger $arg");
|
||||
|
||||
switch ($arg) {
|
||||
case 'inhibe_cache':
|
||||
// inhiber le cache pendant 24h
|
||||
ecrire_meta('cache_inhib',$_SERVER['REQUEST_TIME']+24*3600);
|
||||
break;
|
||||
case 'reactive_cache':
|
||||
effacer_meta('cache_inhib');
|
||||
break;
|
||||
|
||||
case 'cache':
|
||||
supprime_invalideurs();
|
||||
@spip_unlink(_CACHE_RUBRIQUES);
|
||||
@spip_unlink(_CACHE_CHEMIN);
|
||||
@spip_unlink(_DIR_TMP."plugin_xml_cache.gz");
|
||||
// on ne supprime que _CACHE_PLUGINS_OPT qui declenche la reconstruction des 3
|
||||
// _CACHE_PIPELINES _CACHE_PLUGINS_PATH et _CACHE_PLUGINS_FCT
|
||||
// pour eviter des problemes de concurence
|
||||
// cf http://core.spip.org/issues/2989
|
||||
//@spip_unlink(_CACHE_PIPELINES);
|
||||
//@spip_unlink(_CACHE_PLUGINS_PATH);
|
||||
//@spip_unlink(_CACHE_PLUGINS_FCT);
|
||||
@spip_unlink(_CACHE_PLUGINS_OPT);
|
||||
purger_repertoire(_DIR_CACHE,array('subdir'=>true));
|
||||
purger_repertoire(_DIR_AIDE);
|
||||
purger_repertoire(_DIR_VAR.'cache-css');
|
||||
purger_repertoire(_DIR_VAR.'cache-js');
|
||||
break;
|
||||
|
||||
case 'squelettes':
|
||||
purger_repertoire(_DIR_SKELS);
|
||||
break;
|
||||
|
||||
case 'vignettes':
|
||||
purger_repertoire(_DIR_VAR,array('subdir'=>true));
|
||||
supprime_invalideurs();
|
||||
purger_repertoire(_DIR_CACHE);
|
||||
break;
|
||||
}
|
||||
|
||||
// le faire savoir aux plugins
|
||||
pipeline('trig_purger',$arg);
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Purger la liste des travaux en attente
|
||||
* @return void
|
||||
*/
|
||||
function action_purger_queue_dist(){
|
||||
$securiser_action = charger_fonction('securiser_action','inc');
|
||||
$securiser_action();
|
||||
|
||||
if (autoriser('purger','queue')){
|
||||
include_spip('inc/queue');
|
||||
queue_purger();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// Un script utile pour recalculer une URL symbolique des son changement
|
||||
|
||||
function action_redirect_dist()
|
||||
{
|
||||
$type = _request('type');
|
||||
if (!preg_match('/^\w+$/', $type)) return;
|
||||
if ($m = _request('var_mode')) {
|
||||
// forcer la mise a jour de l'url de cet objet !
|
||||
if (!defined('_VAR_URLS')) define('_VAR_URLS',true);
|
||||
$m = 'var_mode='.urlencode($m);
|
||||
}
|
||||
$h = generer_url_entite_absolue(intval(_request('id')), $type, $m, '', true);
|
||||
$status = '302';
|
||||
if (_request('status') AND _request('status')=='301')
|
||||
$status = '301';
|
||||
|
||||
if ($h)
|
||||
redirige_par_entete(str_replace('&', '&', $h),'',$status);
|
||||
else
|
||||
redirige_par_entete('/','',$status);
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Definir le lien de traduction vers un objet de reference
|
||||
* si id_trad=0 : dereference le lien de traduction de id_objet
|
||||
* si id_trad=NN : reference le lien de traduction de id_objet vers NN
|
||||
* si id_objet=id_trad actuel et id_trad=new_id_trad : modifie la reference de tout le groupe de traduction
|
||||
*
|
||||
* @param string $objet
|
||||
* @param int $id_objet
|
||||
* @param int $id_trad
|
||||
* @return bool
|
||||
*/
|
||||
function action_referencer_traduction_dist($objet, $id_objet, $id_trad) {
|
||||
|
||||
// ne rien faire si id_trad est ambigu
|
||||
if (!is_numeric($id_trad)) return false;
|
||||
|
||||
$table_objet_sql = table_objet_sql($objet);
|
||||
$id_table_objet = id_table_objet($objet);
|
||||
|
||||
// on a fourni un id_trad : affectation ou modification du groupe de trad
|
||||
if ($id_trad) {
|
||||
// selectionner l'objet cible, qui doit etre different de nous-meme,
|
||||
// et quitter s'il n'existe pas
|
||||
$id_lier = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=".intval($id_trad)." AND NOT($id_table_objet=".intval($id_objet).")");
|
||||
if ($id_lier === NULL){
|
||||
spip_log("echec lien de trad vers objet $objet/$id_objet incorrect ($id_trad)");
|
||||
return false;
|
||||
}
|
||||
|
||||
// $id_lier est le numero du groupe de traduction
|
||||
// Si l'objet vise n'est pas deja traduit, son identifiant devient
|
||||
// le nouvel id_trad de ce nouveau groupe et on l'affecte aux deux
|
||||
// objets
|
||||
if ($id_lier == 0) {
|
||||
sql_updateq($table_objet_sql, array("id_trad" => $id_trad), "$id_table_objet IN ($id_trad, $id_objet)");
|
||||
}
|
||||
// si id_lier = id_objet alors on veut changer la reference de tout le groupe de trad
|
||||
elseif ($id_lier == $id_objet) {
|
||||
sql_updateq($table_objet_sql, array("id_trad" => $id_trad), "id_trad = $id_lier");
|
||||
}
|
||||
// sinon ajouter notre objet dans le groupe
|
||||
else {
|
||||
sql_updateq($table_objet_sql, array("id_trad" => $id_lier), "$id_table_objet=".intval($id_objet));
|
||||
}
|
||||
}
|
||||
// on a fourni un id_trad nul : sortir id_objet du groupe de trad
|
||||
else {
|
||||
$old_id_trad = sql_getfetsel('id_trad',$table_objet_sql,"$id_table_objet=".intval($id_objet));
|
||||
// supprimer le lien de traduction
|
||||
sql_updateq($table_objet_sql, array("id_trad" => 0), "$id_table_objet=".intval($id_objet));
|
||||
|
||||
// Verifier si l'ancien groupe ne comporte plus qu'un seul objet. Alors mettre a zero.
|
||||
$cpt = sql_countsel($table_objet_sql, "id_trad=".intval($old_id_trad));
|
||||
if ($cpt == 1)
|
||||
sql_updateq($table_objet_sql, array("id_trad" => 0), "id_trad=".intval($old_id_trad));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,91 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/autoriser');
|
||||
|
||||
// http://doc.spip.org/@gerer_deplacements
|
||||
function gerer_deplacements($deplacements){
|
||||
foreach(explode("\n",$deplacements) as $dep){
|
||||
$mouvement=explode(":",$dep);
|
||||
list($quoi,$id_quoi) = explode("-",$mouvement[0]);
|
||||
list($cible, $id_cible) =explode("-",$mouvement[1]);
|
||||
$f = 'reorganiser_' . $quoi . '_' . $cible;
|
||||
if (function_exists($f))
|
||||
$f(intval($id_quoi), intval($id_cible));
|
||||
else spip_log("reorganiser $dep: incompris");
|
||||
}
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@reorganiser_article_rubrique
|
||||
function reorganiser_article_rubrique($id_article, $id_rubrique)
|
||||
{
|
||||
if ($id_rubrique
|
||||
AND autoriser('modifier','rubrique',$id_rubrique)
|
||||
AND autoriser('modifier','article',$id_article)) {
|
||||
|
||||
include_spip('action/editer_article');
|
||||
include_spip('inc/rubriques');
|
||||
$s = sql_fetsel("statut, id_rubrique", "spip_articles", "id_article=$id_article");
|
||||
editer_article_heritage($id_article,
|
||||
$s['id_rubrique'],
|
||||
$s['statut'],
|
||||
array('id_rubrique' => $id_rubrique));
|
||||
}
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@reorganiser_rubrique_rubrique
|
||||
function reorganiser_rubrique_rubrique($id_quoi, $id_cible)
|
||||
{
|
||||
if (($id_quoi != $id_cible)
|
||||
AND autoriser('modifier','rubrique',$id_cible)
|
||||
AND autoriser('modifier','rubrique',$id_quoi)) {
|
||||
if (!$id_cible)
|
||||
$id_secteur = $id_quoi;
|
||||
else {
|
||||
$id_secteur = sql_getfetsel("id_secteur", "spip_rubriques", "id_rubrique=$id_cible");
|
||||
}
|
||||
|
||||
$s = sql_fetsel("statut, id_parent, id_secteur", "spip_rubriques", "id_rubrique=".intval($id_quoi));
|
||||
|
||||
sql_updateq('spip_rubriques', array('id_parent' => $id_cible, 'id_secteur'=>$id_secteur), "id_rubrique=".intval($id_quoi));
|
||||
|
||||
include_spip('inc/rubriques');
|
||||
// propager les secteurs si besoin
|
||||
if ($s['id_secteur']!=$id_secteur)
|
||||
propager_les_secteurs();
|
||||
// changer le statut de la rubrique source
|
||||
if ($s['statut'] == 'publie')
|
||||
calculer_rubriques_if($s['id_parent'],
|
||||
array('id_rubrique' => $id_cible),
|
||||
'publie');
|
||||
}
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@action_reorganiser_dist
|
||||
function action_reorganiser_dist(){
|
||||
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$securiser_action();
|
||||
|
||||
if (_request('deplacements')!==NULL)
|
||||
gerer_deplacements(_request('deplacements'));
|
||||
|
||||
$redirect = _request('redirect');
|
||||
if ($redirect==NULL) $redirect="";
|
||||
|
||||
redirige_par_entete(str_replace("&","&",urldecode($redirect)));
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// Pour poser une variable de session
|
||||
// poster sur cette action en indiquant var/val
|
||||
// reponse : json contenant toutes les variables publiques de la session
|
||||
// http://doc.spip.org/@action_session_dist
|
||||
function action_session_dist()
|
||||
{
|
||||
if ($var = _request('var')
|
||||
AND preg_match(',^[a-z_0-9-]+$,i', $var)
|
||||
) {
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
|
||||
include_spip('inc/session');
|
||||
session_set('session_'.$var, $val=_request('val'));
|
||||
#spip_log("autosave:$var:$val",'autosave');
|
||||
}
|
||||
}
|
||||
|
||||
# TODO: mode lecture de session ; n'afficher que ce qu'il faut
|
||||
#echo json_encode($GLOBALS['visiteur_session']);
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Url pour lancer le cron de manière asynchrone si le serveur
|
||||
* le permet
|
||||
*
|
||||
* On se base sur le même code que celui du pipeline affichage final
|
||||
*
|
||||
* Cette fonction est utile pour être appelée depuis un cron UNIX par exemple
|
||||
* car elle retourne tout de suite
|
||||
*
|
||||
* Exemple de tache cron Unix pour un appel toutes les minutes :
|
||||
* "* * * * * curl http://www.mondomaine.tld/spip.php?action=super_cron"
|
||||
*/
|
||||
function action_super_cron_dist(){
|
||||
// Si fsockopen est possible, on lance le cron via un socket
|
||||
// en asynchrone
|
||||
if(function_exists('fsockopen')){
|
||||
$url = generer_url_action('cron');
|
||||
$parts=parse_url($url);
|
||||
$fp = fsockopen($parts['host'],
|
||||
isset($parts['port'])?$parts['port']:80,
|
||||
$errno, $errstr, 30);
|
||||
if ($fp) {
|
||||
$out = "GET ".$parts['path']."?".$parts['query']." HTTP/1.1\r\n";
|
||||
$out.= "Host: ".$parts['host']."\r\n";
|
||||
$out.= "Connection: Close\r\n\r\n";
|
||||
fwrite($fp, $out);
|
||||
fclose($fp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ici lancer le cron par un CURL asynchrone si CURL est présent
|
||||
// TBD
|
||||
|
||||
return;
|
||||
}
|
||||
?>
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
function action_supprimer_lien_dist($arg=null){
|
||||
if (is_null($arg)){
|
||||
$securiser_action = charger_fonction('securiser_action','inc');
|
||||
$arg = $securiser_action();
|
||||
}
|
||||
|
||||
$arg = explode("-",$arg);
|
||||
list($objet_source,$ids,$objet_lie,$idl) = $arg;
|
||||
|
||||
include_spip('action/editer_liens');
|
||||
objet_dissocier(array($objet_source=>$ids), array($objet_lie=>$idl));
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,65 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/charsets'); # pour le nom de fichier
|
||||
|
||||
/**
|
||||
* Effacer une rubrique
|
||||
*
|
||||
* http://doc.spip.org/@action_supprimer_dist
|
||||
*
|
||||
* @param null $id_rubrique
|
||||
* @return void
|
||||
*/
|
||||
function action_supprimer_rubrique_dist($id_rubrique=null) {
|
||||
|
||||
if (is_null($id_rubrique)){
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc');
|
||||
$id_rubrique = $securiser_action();
|
||||
}
|
||||
|
||||
if (intval($id_rubrique)){
|
||||
|
||||
sql_delete("spip_rubriques", "id_rubrique=".intval($id_rubrique));
|
||||
// Les admin restreints qui n'administraient que cette rubrique
|
||||
// deviennent redacteurs
|
||||
// (il y a sans doute moyen de faire ca avec un having)
|
||||
|
||||
$q = sql_select("id_auteur", "spip_auteurs_liens", "objet='rubrique' AND id_objet=".intval($id_rubrique));
|
||||
while ($r = sql_fetch($q)) {
|
||||
$id_auteur = $r['id_auteur'];
|
||||
// degrader avant de supprimer la restriction d'admin
|
||||
// section critique sur les droits
|
||||
$n = sql_countsel("spip_auteurs_liens", "objet='rubrique' AND id_objet!=".intval($id_rubrique)." AND id_auteur=".intval($id_auteur));
|
||||
if (!$n) {
|
||||
include_spip('action/editer_auteur');
|
||||
auteurs_set($id_auteur,array("statut" => '1comite'));
|
||||
}
|
||||
sql_delete("spip_auteurs_liens", "objet='rubrique' AND id_objet=".intval($id_rubrique)." AND id_auteur=".intval($id_auteur));
|
||||
}
|
||||
// menu_rubriques devra recalculer
|
||||
effacer_meta("date_calcul_rubriques");
|
||||
|
||||
// Une rubrique supprimable n'avait pas le statut "publie"
|
||||
// donc rien de neuf pour la rubrique parente
|
||||
include_spip('inc/rubriques');
|
||||
calculer_langues_rubriques();
|
||||
|
||||
// invalider les caches marques de cette rubrique
|
||||
include_spip('inc/invalideur');
|
||||
suivre_invalideur("id='rubrique/$id_rubrique'");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,143 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// Tester nos capacites
|
||||
// http://doc.spip.org/@action_tester_dist
|
||||
function action_tester_dist() {
|
||||
$arg = _request('arg');
|
||||
|
||||
$gd_formats = $gd_formats_read_gif = "";
|
||||
// verifier les formats acceptes par GD
|
||||
if ($arg == "gd1") {
|
||||
// Si GD est installe et php >= 4.0.2
|
||||
if (function_exists('imagetypes')) {
|
||||
|
||||
if (imagetypes() & IMG_GIF) {
|
||||
$gd_formats[] = "gif";
|
||||
} else {
|
||||
# Attention GD sait lire le gif mais pas forcement l'ecrire
|
||||
if (function_exists('ImageCreateFromGIF')) {
|
||||
$srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif");
|
||||
if ($srcImage) {
|
||||
$gd_formats_read_gif = ",gif";
|
||||
ImageDestroy( $srcImage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imagetypes() & IMG_JPG)
|
||||
$gd_formats[] = "jpg";
|
||||
if (imagetypes() & IMG_PNG)
|
||||
$gd_formats[] = "png";
|
||||
}
|
||||
|
||||
else { # ancienne methode de detection des formats, qui en plus
|
||||
# est bugguee car elle teste les formats en lecture
|
||||
# alors que la valeur deduite sert a identifier
|
||||
# les formats disponibles en ecriture... (cf. inc_logos)
|
||||
|
||||
$gd_formats = Array();
|
||||
if (function_exists('ImageCreateFromJPEG')) {
|
||||
$srcImage = @ImageCreateFromJPEG(_ROOT_IMG_PACK."test.jpg");
|
||||
if ($srcImage) {
|
||||
$gd_formats[] = "jpg";
|
||||
ImageDestroy( $srcImage );
|
||||
}
|
||||
}
|
||||
if (function_exists('ImageCreateFromGIF')) {
|
||||
$srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif");
|
||||
if ($srcImage) {
|
||||
$gd_formats[] = "gif";
|
||||
ImageDestroy( $srcImage );
|
||||
}
|
||||
}
|
||||
if (function_exists('ImageCreateFromPNG')) {
|
||||
$srcImage = @ImageCreateFromPNG(_ROOT_IMG_PACK."test.png");
|
||||
if ($srcImage) {
|
||||
$gd_formats[] = "png";
|
||||
ImageDestroy( $srcImage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($gd_formats) $gd_formats = join(",", $gd_formats);
|
||||
ecrire_meta("gd_formats_read", $gd_formats.$gd_formats_read_gif);
|
||||
ecrire_meta("gd_formats", $gd_formats);
|
||||
}
|
||||
|
||||
// verifier les formats netpbm
|
||||
else if ($arg == "netpbm") {
|
||||
define('_PNMSCALE_COMMAND', 'pnmscale'); // chemin a changer dans mes_options
|
||||
if (_PNMSCALE_COMMAND == '') return;
|
||||
$netpbm_formats= Array();
|
||||
|
||||
$jpegtopnm_command = str_replace("pnmscale",
|
||||
"jpegtopnm", _PNMSCALE_COMMAND);
|
||||
$pnmtojpeg_command = str_replace("pnmscale",
|
||||
"pnmtojpeg", _PNMSCALE_COMMAND);
|
||||
|
||||
$vignette = _ROOT_IMG_PACK."test.jpg";
|
||||
$dest = _DIR_VAR . "test-jpg.jpg";
|
||||
$commande = "$jpegtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest";
|
||||
spip_log($commande);
|
||||
exec($commande);
|
||||
if ($taille = @getimagesize($dest)) {
|
||||
if ($taille[1] == 10) $netpbm_formats[] = "jpg";
|
||||
}
|
||||
$giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND);
|
||||
$pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND);
|
||||
$vignette = _ROOT_IMG_PACK."test.gif";
|
||||
$dest = _DIR_VAR . "test-gif.jpg";
|
||||
$commande = "$giftopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest";
|
||||
spip_log($commande);
|
||||
exec($commande);
|
||||
if ($taille = @getimagesize($dest)) {
|
||||
if ($taille[1] == 10) $netpbm_formats[] = "gif";
|
||||
}
|
||||
|
||||
$pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND);
|
||||
$vignette = _ROOT_IMG_PACK."test.png";
|
||||
$dest = _DIR_VAR . "test-gif.jpg";
|
||||
$commande = "$pngtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest";
|
||||
spip_log($commande);
|
||||
exec($commande);
|
||||
if ($taille = @getimagesize($dest)) {
|
||||
if ($taille[1] == 10) $netpbm_formats[] = "png";
|
||||
}
|
||||
|
||||
|
||||
if ($netpbm_formats)
|
||||
$netpbm_formats = join(",", $netpbm_formats);
|
||||
else
|
||||
$netpbm_formats = '';
|
||||
ecrire_meta("netpbm_formats", $netpbm_formats);
|
||||
}
|
||||
|
||||
// et maintenant envoyer la vignette de tests
|
||||
if (in_array($arg,array("gd1","gd2","imagick","convert","netpbm"))) {
|
||||
include_spip('inc/filtres');
|
||||
include_spip('inc/filtres_images_mini');
|
||||
$taille_preview = 150;
|
||||
$image = _image_valeurs_trans(_DIR_IMG_PACK.'test_image.jpg',"reduire-$taille_preview-$taille_preview",'jpg');
|
||||
|
||||
$image['fichier_dest']=_DIR_VAR."test_$arg";
|
||||
if ($preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true)
|
||||
AND ($preview['width'] * $preview['height'] > 0))
|
||||
redirige_par_entete($preview['fichier']);
|
||||
}
|
||||
|
||||
# image echec
|
||||
redirige_par_entete(chemin_image('puce-rouge-anim.gif'));
|
||||
}
|
||||
?>
|
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
include_spip('inc/headers');
|
||||
|
||||
function action_tester_taille_error_handler($output)
|
||||
{
|
||||
// on est ici, donc echec lors de la creation de l'image
|
||||
if ($GLOBALS['redirect']){
|
||||
return redirige_formulaire($GLOBALS['redirect']);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
// Tester nos capacites a creer des images avec GD2 (taille memoire)
|
||||
// http://doc.spip.org/@action_tester_taille_dist
|
||||
function action_tester_taille_dist() {
|
||||
|
||||
if (!autoriser('configurer'))
|
||||
return;
|
||||
|
||||
$taille = _request('arg');
|
||||
$taille = explode('-',$taille);
|
||||
|
||||
$GLOBALS['taille_max'] = end($taille);
|
||||
$GLOBALS['taille_min'] = 0;
|
||||
if (count($taille)>1)
|
||||
$GLOBALS['taille_min'] = reset($taille);
|
||||
|
||||
// si l'intervalle est assez petit, on garde la valeur min
|
||||
if ($GLOBALS['taille_max']*$GLOBALS['taille_max']-$GLOBALS['taille_min']*$GLOBALS['taille_min']<50000){
|
||||
ecrire_meta('max_taille_vignettes',$t=($GLOBALS['taille_min']*$GLOBALS['taille_min'])*0.9,'non');
|
||||
echo round($t/1000000,3).' Mpx';
|
||||
die();
|
||||
}
|
||||
|
||||
$taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max']+$GLOBALS['taille_min'])/2);
|
||||
|
||||
include_spip('inc/filtres');
|
||||
// des inclusions representatives d'un hit prive et/ou public pour la conso memoire
|
||||
include_spip('public/assembler');
|
||||
include_spip('public/balises');
|
||||
include_spip('public/boucles');
|
||||
include_spip('public/cacher');
|
||||
include_spip('public/compiler');
|
||||
include_spip('public/composer');
|
||||
include_spip('public/criteres');
|
||||
include_spip('public/interfaces');
|
||||
include_spip('public/parametrer');
|
||||
include_spip('public/phraser_html');
|
||||
include_spip('public/references');
|
||||
|
||||
include_spip('inc/presentation');
|
||||
include_spip('inc/charsets');
|
||||
include_spip('inc/documents');
|
||||
include_spip('inc/header');
|
||||
propre("<doc1>"); // charger propre avec le trairement d'un modele
|
||||
|
||||
$i = _request('i')+1;
|
||||
$image_source = chemin_image("test.png");
|
||||
$GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=".$GLOBALS['taille_min']."-".$GLOBALS['taille_test']);
|
||||
|
||||
ob_start('action_tester_taille_error_handler');
|
||||
filtrer('image_recadre',$image_source,$taille,$taille);
|
||||
$GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-".$GLOBALS['taille_max']);
|
||||
// si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee
|
||||
$taille = $GLOBALS['taille_max'];
|
||||
filtrer('image_recadre',$image_source,$taille,$taille);
|
||||
$GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-".$GLOBALS['taille_max']);
|
||||
ob_end_clean();
|
||||
|
||||
// on est ici, donc pas de plantage
|
||||
echo redirige_formulaire($GLOBALS['redirect']);
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,294 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// Authentifie via LDAP et retourne la ligne SQL decrivant l'utilisateur si ok
|
||||
|
||||
// Attributs LDAP correspondants a ceux de SPIP, notamment pour le login
|
||||
// ne pas ecraser une definition perso dans mes_options
|
||||
if (!isset($GLOBALS['ldap_attributes']) OR !is_array($GLOBALS['ldap_attributes'])){
|
||||
$GLOBALS['ldap_attributes'] = array(
|
||||
'login' => array('sAMAccountName', 'uid', 'login', 'userid', 'cn','sn'),
|
||||
'nom' => "cn",
|
||||
'email' => "mail",
|
||||
'bio' => "description");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction principale d'authentification du module auth/ldap
|
||||
*
|
||||
* - On se bind avec le compte generique defini dans config/ldap.php,
|
||||
* - On determine le DN de l'utilisateur candidat a l'authentification,
|
||||
* - On se re-bind avec ce DN et le mot de passe propose.
|
||||
*
|
||||
* Si la connexion est autorisee, on renvoie pour enregistrement en session,
|
||||
* en plus des champs SQL habituels, les informations de connexion de
|
||||
* l'utilisateur (DN et password). Cela permettra de se binder en cours de
|
||||
* session sous son identite specifique pour les operations necessitant des
|
||||
* privileges particuliers.
|
||||
* TODO: Gerer une constante de conf qui permette de choisir entre ce
|
||||
* comportement et tout faire avec le compte generique.
|
||||
*
|
||||
* @param string $login
|
||||
* @param string $pass
|
||||
* @param string $serveur
|
||||
* @param bool $phpauth
|
||||
* @return string
|
||||
*/
|
||||
// http://doc.spip.org/@inc_auth_ldap_dist
|
||||
function auth_ldap_dist ($login, $pass, $serveur='', $phpauth=false) {
|
||||
|
||||
#spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent"));
|
||||
|
||||
// Utilisateur connu ?
|
||||
// si http auth, inutile de reauthentifier: cela
|
||||
// ne marchera pas avec auth http autre que basic.
|
||||
$checkpass = isset($_SERVER["REMOTE_USER"])?false:true;
|
||||
if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) return array();
|
||||
$credentials_ldap = array('ldap_dn' => $dn, 'ldap_password' => $pass);
|
||||
|
||||
// Si l'utilisateur figure deja dans la base, y recuperer les infos
|
||||
$r = sql_fetsel("*", "spip_auteurs", "login=" . sql_quote($login) . " AND source='ldap'",'','','','',$serveur);
|
||||
|
||||
if ($r) return array_merge($r, $credentials_ldap);
|
||||
|
||||
// sinon importer les infos depuis LDAP,
|
||||
|
||||
if ($GLOBALS['meta']["ldap_statut_import"]
|
||||
AND $desc = auth_ldap_retrouver($dn, array(), $serveur)) {
|
||||
// rajouter le statut indique a l'install
|
||||
$desc['statut'] = $GLOBALS['meta']["ldap_statut_import"];
|
||||
$desc['login'] = $login;
|
||||
$desc['source'] = 'ldap';
|
||||
$desc['pass'] = '';
|
||||
|
||||
$r = sql_insertq('spip_auteurs', $desc,'',$serveur);
|
||||
}
|
||||
|
||||
if ($r)
|
||||
return array_merge(
|
||||
$credentials_ldap,
|
||||
sql_fetsel("*", "spip_auteurs", "id_auteur=".intval($r),'','','','',$serveur)
|
||||
);
|
||||
|
||||
// sinon echec
|
||||
spip_log("Creation de l'auteur '$login' impossible");
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connexion a l'annuaire LDAP
|
||||
* Il faut passer par spip_connect() pour avoir les info
|
||||
* donc potentiellement indiquer un serveur
|
||||
* meme si dans les fait cet argument est toujours vide
|
||||
*
|
||||
* @param string $serveur
|
||||
* @return string
|
||||
*/
|
||||
function auth_ldap_connect($serveur='') {
|
||||
include_spip('base/connect_sql');
|
||||
static $connexions_ldap = array();
|
||||
if (isset($connexions_ldap[$serveur])) return $connexions_ldap[$serveur];
|
||||
$connexion = spip_connect($serveur);
|
||||
if (!is_array($connexion['ldap'])) {
|
||||
if ($connexion['authentification']['ldap']) {
|
||||
$f = _DIR_CONNECT . $connexion['authentification']['ldap'];
|
||||
unset($GLOBALS['ldap_link']);
|
||||
if (is_readable($f)) { include_once($f); };
|
||||
if (isset($GLOBALS['ldap_link']))
|
||||
$connexion['ldap'] = array('link' => $GLOBALS['ldap_link'],
|
||||
'base' => $GLOBALS['ldap_base']);
|
||||
else spip_log("connection LDAP $serveur mal definie dans $f");
|
||||
if (isset($GLOBALS['ldap_champs']))
|
||||
$connexion['ldap']['attributes'] = $GLOBALS['ldap_champs'];
|
||||
} else spip_log("connection LDAP $serveur inconnue");
|
||||
}
|
||||
return $connexions_ldap[$serveur]=$connexion['ldap'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrouver un login, et verifier son pass si demande par $checkpass
|
||||
*
|
||||
* @param string $login
|
||||
* @param string $pass
|
||||
* @param bool $checkpass
|
||||
* @param string $serveur
|
||||
* @return string
|
||||
* le login trouve ou chaine vide si non trouve
|
||||
*/
|
||||
function auth_ldap_search($login, $pass, $checkpass=true, $serveur=''){
|
||||
// Securite anti-injection et contre un serveur LDAP laxiste
|
||||
$login_search = preg_replace("/[^-@._\s\d\w]/", "", $login);
|
||||
if (!strlen($login_search) OR ($checkpass AND !strlen($pass)) )
|
||||
return '';
|
||||
|
||||
// verifier la connexion
|
||||
if (!$ldap = auth_ldap_connect($serveur))
|
||||
return '';
|
||||
|
||||
$ldap_link = $ldap['link'];
|
||||
$ldap_base = $ldap['base'];
|
||||
$desc = $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes'] ;
|
||||
|
||||
$logins = is_array($desc['login']) ? $desc['login'] : array($desc['login']);
|
||||
|
||||
// Tenter une recherche pour essayer de retrouver le DN
|
||||
foreach($logins as $att) {
|
||||
$result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", array("dn"));
|
||||
$info = @ldap_get_entries($ldap_link, $result);
|
||||
// Ne pas accepter les resultats si plus d'une entree
|
||||
// (on veut un attribut unique)
|
||||
|
||||
if (is_array($info) AND $info['count'] == 1) {
|
||||
$dn = $info[0]['dn'];
|
||||
if (!$checkpass) return $dn;
|
||||
if (@ldap_bind($ldap_link, $dn, $pass)) return $dn;
|
||||
}
|
||||
}
|
||||
|
||||
if ($checkpass AND !isset($dn)) {
|
||||
// Si echec, essayer de deviner le DN
|
||||
foreach($logins as $att) {
|
||||
$dn = "$att=$login_search, $ldap_base";
|
||||
if (@ldap_bind($ldap_link, $dn, $pass))
|
||||
return "$att=$login_search, $ldap_base";
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrouver un dn
|
||||
* @param string $dn
|
||||
* @param array $desc
|
||||
* @param string $serveur
|
||||
* @return array
|
||||
*/
|
||||
function auth_ldap_retrouver($dn, $desc=array(), $serveur='')
|
||||
{
|
||||
// Lire les infos sur l'utilisateur a partir de son DN depuis LDAP
|
||||
|
||||
if (!$ldap = spip_connect_ldap($serveur)) {
|
||||
spip_log("ldap $serveur injoignable");
|
||||
return array();
|
||||
}
|
||||
|
||||
$ldap_link = $ldap['link'];
|
||||
if (!$desc) {
|
||||
$desc = $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes'] ;
|
||||
unset($desc['login']);
|
||||
}
|
||||
$result = @ldap_read($ldap_link, $dn, "objectClass=*", array_values($desc));
|
||||
|
||||
if (!$result) return array();
|
||||
|
||||
// Recuperer les donnees du premier (unique?) compte de l'auteur
|
||||
$val = @ldap_get_entries($ldap_link, $result);
|
||||
if (!is_array($val) OR !is_array($val[0])) return array();
|
||||
$val = $val[0];
|
||||
|
||||
// Convertir depuis UTF-8 (jeu de caracteres par defaut)
|
||||
include_spip('inc/charsets');
|
||||
|
||||
foreach ($desc as $k => $v)
|
||||
$desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8');
|
||||
return $desc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrouver le login de quelqu'un qui cherche a se loger
|
||||
*
|
||||
* @param string $login
|
||||
* @param string $serveur
|
||||
* @return string
|
||||
*/
|
||||
function auth_ldap_retrouver_login($login, $serveur='')
|
||||
{
|
||||
return auth_ldap_search($login, '', false, $serveur) ? $login : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification de la validite d'un mot de passe pour le mode d'auth concerne
|
||||
* c'est ici que se font eventuellement les verifications de longueur mini/maxi
|
||||
* ou de force.
|
||||
*
|
||||
* @param string $new_pass
|
||||
* @param string $login
|
||||
* le login de l'auteur : permet de verifier que pass et login sont differents
|
||||
* meme a la creation lorsque l'auteur n'existe pas encore
|
||||
* @param int $id_auteur
|
||||
* si auteur existant deja
|
||||
* @param string $serveur
|
||||
* @return string
|
||||
* message d'erreur si login non valide, chaine vide sinon
|
||||
*/
|
||||
function auth_ldap_verifier_pass($login, $new_pass, $id_auteur=0, $serveur=''){
|
||||
include_spip('auth/spip');
|
||||
return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur);
|
||||
}
|
||||
|
||||
/**
|
||||
* Informer du droit de modifier ou non le pass
|
||||
*
|
||||
* On ne peut pas détecter a l'avance si l'autorisation sera donnee, il
|
||||
* faudra informer l'utilisateur a posteriori si la modif n'a pas pu se
|
||||
* faire.
|
||||
* @param string $serveur
|
||||
* @return bool
|
||||
* pour un auteur LDAP, a priori toujours true, a conditiion que le serveur
|
||||
* l'autorise: par exemple, pour OpenLDAP il faut avoir dans slapd.conf:
|
||||
* access to attr=userPassword
|
||||
* by self write
|
||||
* ...
|
||||
*/
|
||||
function auth_ldap_autoriser_modifier_pass($serveur=''){
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction de modification du mot de passe
|
||||
*
|
||||
* On se bind au LDAP cette fois sous l'identite de l'utilisateur, car le
|
||||
* compte generique defini dans config/ldap.php n'a generalement pas (et
|
||||
* ne devrait pas avoir) les droits suffisants pour faire la modification.
|
||||
* @param $login
|
||||
* @param $new_pass
|
||||
* @param $id_auteur
|
||||
* @param string $serveur
|
||||
* @return bool
|
||||
* informe du succes ou de l'echec du changement du mot de passe
|
||||
*/
|
||||
function auth_ldap_modifier_pass($login, $new_pass, $id_auteur, $serveur=''){
|
||||
if (is_null($new_pass) OR auth_ldap_verifier_pass($login, $new_pass,$id_auteur,$serveur)!='') {
|
||||
return false;
|
||||
}
|
||||
if (!$ldap = auth_ldap_connect($serveur))
|
||||
return '';
|
||||
$link = $ldap['link'];
|
||||
include_spip("inc/session");
|
||||
$dn = session_get('ldap_dn');
|
||||
if ('' == $dn) {
|
||||
return false;
|
||||
}
|
||||
if (!ldap_bind($link, $dn, session_get('ldap_password'))) {
|
||||
return false;
|
||||
}
|
||||
$encoded_pass = "{MD5}".base64_encode(pack("H*",md5($new_pass)));
|
||||
$success = ldap_mod_replace($link, $dn, array('userPassword' => $encoded_pass));
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
|
@ -1,450 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Transparent SHA-256 Implementation for PHP 4 and PHP 5
|
||||
*
|
||||
* Author: Perry McGee (pmcgee@nanolink.ca)
|
||||
* Website: http://www.nanolink.ca/pub/sha256
|
||||
*
|
||||
* Copyright (C) 2006,2007,2008,2009 Nanolink Solutions
|
||||
*
|
||||
* Created: Feb 11, 2006
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* or see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Include:
|
||||
*
|
||||
* require_once("[path/]sha256.inc.php");
|
||||
*
|
||||
* Usage Options:
|
||||
*
|
||||
* 1) $shaStr = hash('sha256', $string_to_hash);
|
||||
*
|
||||
* 2) $shaStr = sha256($string_to_hash[, bool ignore_php5_hash = false]);
|
||||
*
|
||||
* 3) $obj = new nanoSha2([bool $upper_case_output = false]);
|
||||
* $shaStr = $obj->hash($string_to_hash[, bool $ignore_php5_hash = false]);
|
||||
*
|
||||
* Reference: http://csrc.nist.gov/groups/ST/toolkit/secure_hashing.html
|
||||
*
|
||||
* 2007-12-13: Cleaned up for initial public release
|
||||
* 2008-05-10: Moved all helper functions into a class. API access unchanged.
|
||||
* 2009-06-23: Created abstraction of hash() routine
|
||||
* 2009-07-23: Added detection of 32 vs 64bit platform, and patches.
|
||||
* Ability to define "_NANO_SHA2_UPPER" to yeild upper case hashes.
|
||||
* 2009-08-01: Added ability to attempt to use mhash() prior to running pure
|
||||
* php code.
|
||||
*
|
||||
* 2010-06-10: Added support for 16bytes char and utf8 in string
|
||||
*
|
||||
* NOTE: Some sporadic versions of PHP do not handle integer overflows the
|
||||
* same as the majority of builds. If you get hash results of:
|
||||
* 7fffffff7fffffff7fffffff7fffffff7fffffff7fffffff7fffffff7fffffff
|
||||
*
|
||||
* If you do not have permissions to change PHP versions (if you did
|
||||
* you'd probably upgrade to PHP 5 anyway) it is advised you install a
|
||||
* module that will allow you to use their hashing routines, examples are:
|
||||
* - mhash module : http://ca3.php.net/mhash
|
||||
* - Suhosin : http://www.hardened-php.net/suhosin/
|
||||
*
|
||||
* If you install the Suhosin module, this script will transparently
|
||||
* use their routine and define the PHP routine as _nano_sha256().
|
||||
*
|
||||
* If the mhash module is present, and $ignore_php5_hash = false the
|
||||
* script will attempt to use the output from mhash prior to running
|
||||
* the PHP code.
|
||||
*/
|
||||
if (!class_exists('nanoSha2'))
|
||||
{
|
||||
class nanoSha2
|
||||
{
|
||||
// php 4 - 5 compatable class properties
|
||||
var $toUpper;
|
||||
var $platform;
|
||||
var $bytesString = 16;
|
||||
|
||||
// Php 4 - 6 compatable constructor
|
||||
function nanoSha2($toUpper = false) {
|
||||
// Determine if the caller wants upper case or not.
|
||||
$this->toUpper = is_bool($toUpper)
|
||||
? $toUpper
|
||||
: ((defined('_NANO_SHA2_UPPER')) ? true : false);
|
||||
|
||||
// Deteremine if the system is 32 or 64 bit.
|
||||
$tmpInt = (int)4294967295;
|
||||
$this->platform = ($tmpInt > 0) ? 64 : 32;
|
||||
}
|
||||
|
||||
// Here are the bitwise and functions as defined in FIPS180-2 Standard
|
||||
function addmod2n($x, $y, $n = 4294967296) // Z = (X + Y) mod 2^32
|
||||
{
|
||||
$mask = 0x80000000;
|
||||
|
||||
if ($x < 0) {
|
||||
$x &= 0x7FFFFFFF;
|
||||
$x = (float)$x + $mask;
|
||||
}
|
||||
|
||||
if ($y < 0) {
|
||||
$y &= 0x7FFFFFFF;
|
||||
$y = (float)$y + $mask;
|
||||
}
|
||||
|
||||
$r = $x + $y;
|
||||
|
||||
if ($r >= $n) {
|
||||
while ($r >= $n) {
|
||||
$r -= $n;
|
||||
}
|
||||
}
|
||||
|
||||
return (int)$r;
|
||||
}
|
||||
|
||||
// Logical bitwise right shift (PHP default is arithmetic shift)
|
||||
function SHR($x, $n) // x >> n
|
||||
{
|
||||
if ($n >= 32) { // impose some limits to keep it 32-bit
|
||||
return (int)0;
|
||||
}
|
||||
|
||||
if ($n <= 0) {
|
||||
return (int)$x;
|
||||
}
|
||||
|
||||
$mask = 0x40000000;
|
||||
|
||||
if ($x < 0) {
|
||||
$x &= 0x7FFFFFFF;
|
||||
$mask = $mask >> ($n-1);
|
||||
return ($x >> $n) | $mask;
|
||||
}
|
||||
|
||||
return (int)$x >> (int)$n;
|
||||
}
|
||||
|
||||
function ROTR($x, $n) { return (int)(($this->SHR($x, $n) | ($x << (32-$n)) & 0xFFFFFFFF)); }
|
||||
function Ch($x, $y, $z) { return ($x & $y) ^ ((~$x) & $z); }
|
||||
function Maj($x, $y, $z) { return ($x & $y) ^ ($x & $z) ^ ($y & $z); }
|
||||
function Sigma0($x) { return (int) ($this->ROTR($x, 2)^$this->ROTR($x, 13)^$this->ROTR($x, 22)); }
|
||||
function Sigma1($x) { return (int) ($this->ROTR($x, 6)^$this->ROTR($x, 11)^$this->ROTR($x, 25)); }
|
||||
function sigma_0($x) { return (int) ($this->ROTR($x, 7)^$this->ROTR($x, 18)^$this->SHR($x, 3)); }
|
||||
function sigma_1($x) { return (int) ($this->ROTR($x, 17)^$this->ROTR($x, 19)^$this->SHR($x, 10)); }
|
||||
|
||||
|
||||
function string2ordUTF8($s,&$byteSize){
|
||||
$chars = array();
|
||||
// par defaut sur 8bits
|
||||
$byteSize = 8;
|
||||
$i = 0;
|
||||
while ($i<strlen($s)){
|
||||
$chars[] = $this->ordUTF8($s, $i, $bytes);
|
||||
$i+=$bytes;
|
||||
// mais si un char necessite 16bits, on passe tout sur 16
|
||||
// sinon on ne concorde pas avec le lecture de la chaine en js
|
||||
// et le sha256 js
|
||||
if ($bytes>1) $byteSize = 16;
|
||||
}
|
||||
return $chars;
|
||||
}
|
||||
|
||||
function ordUTF8($c, $index = 0, &$bytes)
|
||||
{
|
||||
$len = strlen($c);
|
||||
$bytes = 0;
|
||||
|
||||
if ($index >= $len)
|
||||
return false;
|
||||
|
||||
$h = ord($c{$index});
|
||||
|
||||
if ($h <= 0x7F) {
|
||||
$bytes = 1;
|
||||
return $h;
|
||||
}
|
||||
else if ($h < 0xC2){
|
||||
// pas utf mais renvoyer quand meme ce qu'on a
|
||||
$bytes = 1;
|
||||
return $h;
|
||||
}
|
||||
else if ($h <= 0xDF && $index < $len - 1) {
|
||||
$bytes = 2;
|
||||
return ($h & 0x1F) << 6 | (ord($c{$index + 1}) & 0x3F);
|
||||
}
|
||||
else if ($h <= 0xEF && $index < $len - 2) {
|
||||
$bytes = 3;
|
||||
return ($h & 0x0F) << 12 | (ord($c{$index + 1}) & 0x3F) << 6
|
||||
| (ord($c{$index + 2}) & 0x3F);
|
||||
}
|
||||
else if ($h <= 0xF4 && $index < $len - 3) {
|
||||
$bytes = 4;
|
||||
return ($h & 0x0F) << 18 | (ord($c{$index + 1}) & 0x3F) << 12
|
||||
| (ord($c{$index + 2}) & 0x3F) << 6
|
||||
| (ord($c{$index + 3}) & 0x3F);
|
||||
}
|
||||
else {
|
||||
// pas utf mais renvoyer quand meme ce qu'on a
|
||||
$bytes = 1;
|
||||
return $h;
|
||||
}
|
||||
}
|
||||
|
||||
function string2binint ($str,$npad=512) {
|
||||
$bin = array();
|
||||
$ords = $this->string2ordUTF8($str,$this->bytesString);
|
||||
$npad = $npad/$this->bytesString;
|
||||
$length = count($ords);
|
||||
$ords[] = 0x80; // append the "1" bit followed by 7 0's
|
||||
$pad = ceil(($length+1+32/$this->bytesString)/$npad)*$npad-32/$this->bytesString;
|
||||
$ords = array_pad($ords,$pad,0);
|
||||
$mask = (1 << $this->bytesString) - 1;
|
||||
for($i = 0; $i < count($ords) * $this->bytesString; $i += $this->bytesString) {
|
||||
if (!isset($bin[$i>>5])) { $bin[$i>>5] = 0; } // pour eviter des notices.
|
||||
$bin[$i>>5] |= ($ords[$i / $this->bytesString] & $mask) << (24 - $i%32);
|
||||
}
|
||||
$bin[] = $length*$this->bytesString;
|
||||
return $bin;
|
||||
}
|
||||
|
||||
function array_split($a, $n) {
|
||||
$split = array();
|
||||
while (count($a)>$n) {
|
||||
$s = array();
|
||||
for($i = 0;$i<$n;$i++)
|
||||
$s[] = array_shift($a);
|
||||
$split[] = $s;
|
||||
}
|
||||
if (count($a)){
|
||||
$a = array_pad($a,$n,0);
|
||||
$split[] = $a;
|
||||
}
|
||||
return $split;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process and return the hash.
|
||||
*
|
||||
* @param $str Input string to hash
|
||||
* @param $ig_func Option param to ignore checking for php > 5.1.2
|
||||
* @return string Hexadecimal representation of the message digest
|
||||
*/
|
||||
function hash($str, $ig_func = true)
|
||||
{
|
||||
unset($binStr); // binary representation of input string
|
||||
unset($hexStr); // 256-bit message digest in readable hex format
|
||||
|
||||
// check for php's internal sha256 function, ignore if ig_func==true
|
||||
if ($ig_func == false) {
|
||||
if (version_compare(PHP_VERSION,'5.1.2','>=') AND !defined('_NO_HASH_DEFINED')) {
|
||||
return hash("sha256", $str, false);
|
||||
} else if (function_exists('mhash') && defined('MHASH_SHA256')) {
|
||||
return base64_encode(bin2hex(mhash(MHASH_SHA256, $str)));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* SHA-256 Constants
|
||||
* Sequence of sixty-four constant 32-bit words representing the
|
||||
* first thirty-two bits of the fractional parts of the cube roots
|
||||
* of the first sixtyfour prime numbers.
|
||||
*/
|
||||
$K = array((int)0x428a2f98, (int)0x71374491, (int)0xb5c0fbcf,
|
||||
(int)0xe9b5dba5, (int)0x3956c25b, (int)0x59f111f1,
|
||||
(int)0x923f82a4, (int)0xab1c5ed5, (int)0xd807aa98,
|
||||
(int)0x12835b01, (int)0x243185be, (int)0x550c7dc3,
|
||||
(int)0x72be5d74, (int)0x80deb1fe, (int)0x9bdc06a7,
|
||||
(int)0xc19bf174, (int)0xe49b69c1, (int)0xefbe4786,
|
||||
(int)0x0fc19dc6, (int)0x240ca1cc, (int)0x2de92c6f,
|
||||
(int)0x4a7484aa, (int)0x5cb0a9dc, (int)0x76f988da,
|
||||
(int)0x983e5152, (int)0xa831c66d, (int)0xb00327c8,
|
||||
(int)0xbf597fc7, (int)0xc6e00bf3, (int)0xd5a79147,
|
||||
(int)0x06ca6351, (int)0x14292967, (int)0x27b70a85,
|
||||
(int)0x2e1b2138, (int)0x4d2c6dfc, (int)0x53380d13,
|
||||
(int)0x650a7354, (int)0x766a0abb, (int)0x81c2c92e,
|
||||
(int)0x92722c85, (int)0xa2bfe8a1, (int)0xa81a664b,
|
||||
(int)0xc24b8b70, (int)0xc76c51a3, (int)0xd192e819,
|
||||
(int)0xd6990624, (int)0xf40e3585, (int)0x106aa070,
|
||||
(int)0x19a4c116, (int)0x1e376c08, (int)0x2748774c,
|
||||
(int)0x34b0bcb5, (int)0x391c0cb3, (int)0x4ed8aa4a,
|
||||
(int)0x5b9cca4f, (int)0x682e6ff3, (int)0x748f82ee,
|
||||
(int)0x78a5636f, (int)0x84c87814, (int)0x8cc70208,
|
||||
(int)0x90befffa, (int)0xa4506ceb, (int)0xbef9a3f7,
|
||||
(int)0xc67178f2);
|
||||
|
||||
// Pre-processing: Padding the string
|
||||
$binStr = $this->string2binint($str,512);
|
||||
|
||||
// Parsing the Padded Message (Break into N 512-bit blocks)
|
||||
$M = $this->array_split($binStr, 16);
|
||||
|
||||
// Set the initial hash values
|
||||
$h[0] = (int)0x6a09e667;
|
||||
$h[1] = (int)0xbb67ae85;
|
||||
$h[2] = (int)0x3c6ef372;
|
||||
$h[3] = (int)0xa54ff53a;
|
||||
$h[4] = (int)0x510e527f;
|
||||
$h[5] = (int)0x9b05688c;
|
||||
$h[6] = (int)0x1f83d9ab;
|
||||
$h[7] = (int)0x5be0cd19;
|
||||
|
||||
// loop through message blocks and compute hash. ( For i=1 to N : )
|
||||
$N = count($M);
|
||||
for ($i = 0; $i < $N; $i++)
|
||||
{
|
||||
// Break input block into 16 32bit words (message schedule prep)
|
||||
$MI = $M[$i];
|
||||
|
||||
// Initialize working variables
|
||||
$_a = (int)$h[0];
|
||||
$_b = (int)$h[1];
|
||||
$_c = (int)$h[2];
|
||||
$_d = (int)$h[3];
|
||||
$_e = (int)$h[4];
|
||||
$_f = (int)$h[5];
|
||||
$_g = (int)$h[6];
|
||||
$_h = (int)$h[7];
|
||||
unset($_s0);
|
||||
unset($_s1);
|
||||
unset($_T1);
|
||||
unset($_T2);
|
||||
$W = array();
|
||||
|
||||
// Compute the hash and update
|
||||
for ($t = 0; $t < 16; $t++)
|
||||
{
|
||||
// Prepare the first 16 message schedule values as we loop
|
||||
$W[$t] = $MI[$t];
|
||||
|
||||
// Compute hash
|
||||
$_T1 = $this->addmod2n($this->addmod2n($this->addmod2n($this->addmod2n($_h, $this->Sigma1($_e)), $this->Ch($_e, $_f, $_g)), $K[$t]), $W[$t]);
|
||||
$_T2 = $this->addmod2n($this->Sigma0($_a), $this->Maj($_a, $_b, $_c));
|
||||
|
||||
// Update working variables
|
||||
$_h = $_g; $_g = $_f; $_f = $_e; $_e = $this->addmod2n($_d, $_T1);
|
||||
$_d = $_c; $_c = $_b; $_b = $_a; $_a = $this->addmod2n($_T1, $_T2);
|
||||
}
|
||||
|
||||
for (; $t < 64; $t++)
|
||||
{
|
||||
// Continue building the message schedule as we loop
|
||||
$_s0 = $W[($t+1)&0x0F];
|
||||
$_s0 = $this->sigma_0($_s0);
|
||||
$_s1 = $W[($t+14)&0x0F];
|
||||
$_s1 = $this->sigma_1($_s1);
|
||||
|
||||
$W[$t&0xF] = $this->addmod2n($this->addmod2n($this->addmod2n($W[$t&0xF], $_s0), $_s1), $W[($t+9)&0x0F]);
|
||||
|
||||
// Compute hash
|
||||
$_T1 = $this->addmod2n($this->addmod2n($this->addmod2n($this->addmod2n($_h, $this->Sigma1($_e)), $this->Ch($_e, $_f, $_g)), $K[$t]), $W[$t&0xF]);
|
||||
$_T2 = $this->addmod2n($this->Sigma0($_a), $this->Maj($_a, $_b, $_c));
|
||||
|
||||
// Update working variables
|
||||
$_h = $_g; $_g = $_f; $_f = $_e; $_e = $this->addmod2n($_d, $_T1);
|
||||
$_d = $_c; $_c = $_b; $_b = $_a; $_a = $this->addmod2n($_T1, $_T2);
|
||||
}
|
||||
|
||||
$h[0] = $this->addmod2n($h[0], $_a);
|
||||
$h[1] = $this->addmod2n($h[1], $_b);
|
||||
$h[2] = $this->addmod2n($h[2], $_c);
|
||||
$h[3] = $this->addmod2n($h[3], $_d);
|
||||
$h[4] = $this->addmod2n($h[4], $_e);
|
||||
$h[5] = $this->addmod2n($h[5], $_f);
|
||||
$h[6] = $this->addmod2n($h[6], $_g);
|
||||
$h[7] = $this->addmod2n($h[7], $_h);
|
||||
}
|
||||
|
||||
// Convert the 32-bit words into human readable hexadecimal format.
|
||||
$hexStr = sprintf("%08x%08x%08x%08x%08x%08x%08x%08x", $h[0], $h[1], $h[2], $h[3], $h[4], $h[5], $h[6], $h[7]);
|
||||
|
||||
return ($this->toUpper) ? strtoupper($hexStr) : $hexStr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('str_split'))
|
||||
{
|
||||
/**
|
||||
* Splits a string into an array of strings with specified length.
|
||||
* Compatability with older verions of PHP
|
||||
*/
|
||||
function str_split($string, $split_length = 1)
|
||||
{
|
||||
$result = array();
|
||||
$sign = ($split_length < 0) ? -1 : 1;
|
||||
$strlen = strlen($string);
|
||||
$split_length = abs($split_length);
|
||||
|
||||
if (($split_length == 0) || ($strlen == 0)) {
|
||||
$result = false;
|
||||
} elseif ($split_length >= $strlen) {
|
||||
$result[] = $string;
|
||||
} else {
|
||||
$length = $split_length;
|
||||
|
||||
for ($i = 0; $i < $strlen; $i++)
|
||||
{
|
||||
$i = (($sign < 0) ? $i + $length : $i);
|
||||
$result[] = substr($string, $sign*$i, $length);
|
||||
$i--;
|
||||
$i = (($sign < 0) ? $i : $i + $length);
|
||||
|
||||
$length = (($i + $split_length) > $strlen)
|
||||
? ($strlen - ($i + 1))
|
||||
: $split_length;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Main routine called from an application using this include.
|
||||
*
|
||||
* General usage:
|
||||
* require_once('sha256.inc.php');
|
||||
* $hashstr = sha256('abc');
|
||||
*
|
||||
* Note:
|
||||
* PHP Strings are limitd to (2^31)-1, so it is not worth it to
|
||||
* check for input strings > 2^64 as the FIPS180-2 defines.
|
||||
*/
|
||||
function _nano_sha256($str, $ig_func = true) {
|
||||
$obj = new nanoSha2((defined('_NANO_SHA2_UPPER')) ? true : false);
|
||||
return $obj->hash($str, $ig_func);
|
||||
}
|
||||
// 2009-07-23: Added check for function as the Suhosin plugin adds this routine.
|
||||
if (!function_exists('sha256')) {
|
||||
function sha256($str, $ig_func = true) { return _nano_sha256($str, $ig_func); }
|
||||
}
|
||||
|
||||
// support to give php4 the hash() routine which abstracts this code.
|
||||
if (!function_exists('hash'))
|
||||
{
|
||||
define('_NO_HASH_DEFINED',true);
|
||||
function hash($algo, $data)
|
||||
{
|
||||
if (empty($algo) || !is_string($algo) || !is_string($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (function_exists($algo)) {
|
||||
return $algo($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,376 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Authentifie et si ok retourne le tableau de la ligne SQL de l'utilisateur
|
||||
* Si risque de secu repere a l'installation retourne False
|
||||
*
|
||||
* @param string $login
|
||||
* @param string $pass
|
||||
* @param string $serveur
|
||||
* @param bool $phpauth
|
||||
* @return array|bool
|
||||
*/
|
||||
function auth_spip_dist ($login, $pass, $serveur='', $phpauth=false) {
|
||||
|
||||
// retrouver le login
|
||||
$login = auth_spip_retrouver_login($login);
|
||||
// login inconnu, n'allons pas plus loin
|
||||
if (!$login) return array();
|
||||
|
||||
$md5pass = "";
|
||||
$shapass = $shanext = "";
|
||||
|
||||
if (preg_match(",^\{([0-9a-f]{64});([0-9a-f]{64})\}$,i",$pass,$regs)){
|
||||
$shapass = $regs[1];
|
||||
$shanext = $regs[2];
|
||||
}
|
||||
// compat avec une base mixte md5/sha256 : le js a envoye les 2 hash
|
||||
elseif (preg_match(",^\{([0-9a-f]{64});([0-9a-f]{64});([0-9a-f]{32});([0-9a-f]{32})\}$,i",$pass,$regs)){
|
||||
$shapass = $regs[1];
|
||||
$shanext = $regs[2];
|
||||
$md5pass = $regs[3];
|
||||
//$md5next = $regs[4];
|
||||
}
|
||||
|
||||
// si envoi non crypte, crypter maintenant
|
||||
elseif ($pass) {
|
||||
$row = sql_fetsel("alea_actuel, alea_futur", "spip_auteurs", "login=" . sql_quote($login,$serveur,'text'),'','','','',$serveur);
|
||||
|
||||
if ($row) {
|
||||
include_spip('auth/sha256.inc');
|
||||
$shapass = _nano_sha256($row['alea_actuel'] . $pass);
|
||||
$shanext = _nano_sha256($row['alea_futur'] . $pass);
|
||||
$md5pass = md5($row['alea_actuel'] . $pass);
|
||||
}
|
||||
}
|
||||
|
||||
// login inexistant ou mot de passe vide
|
||||
if (!$shapass AND !$md5pass) return array();
|
||||
|
||||
$row = sql_fetsel("*", "spip_auteurs", "login=" . sql_quote($login,$serveur,'text') . " AND pass=" . sql_quote($shapass,$serveur,'text') . " AND statut<>'5poubelle'",'','','','',$serveur);
|
||||
|
||||
// compat avec les anciennes bases en md5
|
||||
if (!$row AND $md5pass)
|
||||
$row = sql_fetsel("*", "spip_auteurs", "login=" . sql_quote($login,$serveur,'text') . " AND pass=" . sql_quote($md5pass,$serveur,'text') . " AND statut<>'5poubelle'",'','','','',$serveur);
|
||||
|
||||
// login/mot de passe incorrect
|
||||
if (!$row) return array();
|
||||
|
||||
// fait tourner le codage du pass dans la base
|
||||
// sauf si phpauth : cela reviendrait a changer l'alea a chaque hit, et aucune action verifiable par securiser_action()
|
||||
if ($shanext AND !$phpauth) {
|
||||
|
||||
include_spip('inc/acces'); // pour creer_uniqid
|
||||
@sql_update('spip_auteurs', array('alea_actuel' => 'alea_futur', 'pass' => sql_quote($shanext,$serveur,'text'), 'alea_futur' => sql_quote(creer_uniqid(),$serveur,'text')), "id_auteur=" . $row['id_auteur'].' AND pass IN ('.sql_quote($shapass,$serveur,'text').', '.sql_quote($md5pass,$serveur,'text').')','',$serveur);
|
||||
// En profiter pour verifier la securite de tmp/
|
||||
// Si elle ne fonctionne pas a l'installation, prevenir
|
||||
if (!verifier_htaccess(_DIR_TMP) AND defined('_ECRIRE_INSTALL'))
|
||||
return false;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completer le formulaire de login avec le js ou les saisie specifiques a ce mode d'auth
|
||||
*
|
||||
* @param array $flux
|
||||
* @return array
|
||||
*/
|
||||
function auth_spip_formulaire_login($flux){
|
||||
// faut il encore envoyer md5 ?
|
||||
// on regarde si il reste des pass md5 en base pour des auteurs en statut pas poubelle
|
||||
// les hash md5 ont une longueur 32, les sha 64
|
||||
// en evitant une requete sql a chaque affichage du formulaire login sans session
|
||||
// (perf issue pour les sites qui mettent le formulaire de login sur la home)
|
||||
$compat_md5 = false;
|
||||
if (!isset($GLOBALS['meta']['sha_256_only']) OR _request('var_mode')){
|
||||
$compat_md5 = sql_countsel("spip_auteurs", "length(pass)=32 AND statut<>'poubelle'");
|
||||
if ($compat_md5 AND isset($GLOBALS['meta']['sha_256_only'])) effacer_meta('sha_256_only');
|
||||
if (!$compat_md5) ecrire_meta('sha_256_only','oui');
|
||||
}
|
||||
|
||||
// javascript qui gere la securite du login en evitant de faire circuler le pass en clair
|
||||
$flux['data'].=
|
||||
($compat_md5?'<script type="text/javascript" src="'._DIR_JAVASCRIPT.'md5.js"></script>':'')
|
||||
.'<script type="text/javascript" src="'._DIR_JAVASCRIPT.'login-sha-min.js"></script>'
|
||||
.'<script type="text/javascript">/*<![CDATA[*/'
|
||||
."var alea_actuel='".$flux['args']['contexte']['_alea_actuel']."';"
|
||||
."var alea_futur='".$flux['args']['contexte']['_alea_futur']."';"
|
||||
."var login='".$flux['args']['contexte']['var_login']."';"
|
||||
."var page_auteur = '".generer_url_public('informer_auteur')."';"
|
||||
."var informe_auteur_en_cours = false;"
|
||||
."var attente_informe = 0;"
|
||||
."var compat_md5 = ".($compat_md5?"true;":"false;")
|
||||
."jQuery(function(){
|
||||
jQuery('#password')
|
||||
.after(\"<em id='pass_securise'><img src='".chemin_image('cadenas-16.png')."' width='16' height='16' alt='" . attribut_html(_T('login_securise')) . "' title='" . attribut_html(_T('login_securise')) . "' \/><\/em>\");
|
||||
affiche_login_secure();
|
||||
jQuery('#var_login').change(actualise_auteur);
|
||||
jQuery('form#formulaire_login').submit(login_submit);
|
||||
});"
|
||||
."/*]]>*/</script>";
|
||||
|
||||
return $flux;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Informer du droit de modifier ou non son login
|
||||
* @param string $serveur
|
||||
* @return bool
|
||||
* toujours true pour un auteur cree dans SPIP
|
||||
*/
|
||||
function auth_spip_autoriser_modifier_login($serveur=''){
|
||||
if (strlen($serveur))
|
||||
return false; // les fonctions d'ecriture sur base distante sont encore incompletes
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification de la validite d'un login pour le mode d'auth concerne
|
||||
*
|
||||
* @param string $new_login
|
||||
* @param int $id_auteur
|
||||
* si auteur existant deja
|
||||
* @param string $serveur
|
||||
* @return string
|
||||
* message d'erreur si login non valide, chaine vide sinon
|
||||
*/
|
||||
function auth_spip_verifier_login($new_login, $id_auteur=0, $serveur=''){
|
||||
// login et mot de passe
|
||||
if (strlen($new_login)){
|
||||
if (strlen($new_login) < _LOGIN_TROP_COURT)
|
||||
return _T('info_login_trop_court_car_pluriel',array('nb'=>_LOGIN_TROP_COURT));
|
||||
else {
|
||||
$n = sql_countsel('spip_auteurs', "login=" . sql_quote($new_login) . " AND id_auteur!=".intval($id_auteur)." AND statut!='5poubelle'",'','',$serveur);
|
||||
if ($n)
|
||||
return _T('info_login_existant');
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier le login d'un auteur SPIP
|
||||
*
|
||||
* @param string $new_login
|
||||
* @param int $id_auteur
|
||||
* @param string $serveur
|
||||
* @return bool
|
||||
*/
|
||||
function auth_spip_modifier_login($new_login, $id_auteur, $serveur=''){
|
||||
if (is_null($new_login) OR auth_spip_verifier_login($new_login,$id_auteur,$serveur)!='')
|
||||
return false;
|
||||
if (!$id_auteur = intval($id_auteur)
|
||||
OR !$auteur = sql_fetsel('login','spip_auteurs','id_auteur='.intval($id_auteur),'','','','',$serveur))
|
||||
return false;
|
||||
if ($new_login == $auteur['login'])
|
||||
return true; // on a rien fait mais c'est bon !
|
||||
|
||||
include_spip('action/editer_auteur');
|
||||
|
||||
// vider le login des auteurs a la poubelle qui avaient ce meme login
|
||||
if (strlen($new_login)){
|
||||
$anciens = sql_allfetsel('id_auteur','spip_auteurs','login='.sql_quote($new_login,$serveur,'text')." AND statut='5poubelle'",'','','','',$serveur);
|
||||
while ($row = array_pop($anciens)){
|
||||
auteur_modifier($row['id_auteur'], array('login'=>''), true); // manque la gestion de $serveur
|
||||
}
|
||||
}
|
||||
|
||||
auteur_modifier($id_auteur, array('login'=>$new_login), true); // manque la gestion de $serveur
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrouver le login de quelqu'un qui cherche a se loger
|
||||
* Reconnaitre aussi ceux qui donnent leur nom ou email au lieu du login
|
||||
*
|
||||
* @param string $login
|
||||
* @param string $serveur
|
||||
* @return string
|
||||
*/
|
||||
function auth_spip_retrouver_login($login, $serveur=''){
|
||||
if (!strlen($login)) return null; // pas la peine de requeter
|
||||
$l = sql_quote($login,$serveur,'text');
|
||||
if ($r = sql_getfetsel('login', 'spip_auteurs',
|
||||
"statut<>'5poubelle'" .
|
||||
" AND (length(pass)>0)" .
|
||||
" AND (login=$l)",'','','','',$serveur))
|
||||
return $r;
|
||||
// Si pas d'auteur avec ce login
|
||||
// regarder s'il a saisi son nom ou son mail.
|
||||
// Ne pas fusionner avec la requete precedente
|
||||
// car un nom peut etre homonyme d'un autre login
|
||||
else return sql_getfetsel('login', 'spip_auteurs',
|
||||
"statut<>'5poubelle'" .
|
||||
" AND (length(pass)>0)" .
|
||||
" AND (login<>'' AND (nom=$l OR email=$l))",'','','','',$serveur);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* informer sur un login
|
||||
* Ce dernier transmet le tableau ci-dessous a la fonction JS informer_auteur
|
||||
* Il est invoque par la fonction JS actualise_auteur via la globale JS
|
||||
* page_auteur=#URL_PAGE{informer_auteur} dans le squelette login
|
||||
* N'y aurait-il pas plus simple ?
|
||||
*
|
||||
* @param array $infos
|
||||
* @param array $row
|
||||
* @param string $serveur
|
||||
* @return array
|
||||
*/
|
||||
function auth_spip_informer_login($infos, $row, $serveur=''){
|
||||
|
||||
// pour la methode SPIP on a besoin des alea en plus pour encoder le pass avec
|
||||
$infos['alea_actuel'] = $row['alea_actuel'];
|
||||
$infos['alea_futur'] = $row['alea_futur'];
|
||||
|
||||
return $infos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Informer du droit de modifier ou non le pass
|
||||
* @param string $serveur
|
||||
* @return bool
|
||||
* toujours true pour un auteur cree dans SPIP
|
||||
*/
|
||||
function auth_spip_autoriser_modifier_pass($serveur=''){
|
||||
if (strlen($serveur))
|
||||
return false; // les fonctions d'ecriture sur base distante sont encore incompletes
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verification de la validite d'un mot de passe pour le mode d'auth concerne
|
||||
* c'est ici que se font eventuellement les verifications de longueur mini/maxi
|
||||
* ou de force
|
||||
*
|
||||
* @param string $login
|
||||
* Le login de l'auteur : permet de verifier que pass et login sont differents
|
||||
* meme a la creation lorsque l'auteur n'existe pas encore
|
||||
* @param string $new_pass
|
||||
* Nouveau mot de passe
|
||||
* @param int $id_auteur
|
||||
* si auteur existant deja
|
||||
* @param string $serveur
|
||||
* @return string
|
||||
* message d'erreur si login non valide, chaine vide sinon
|
||||
*/
|
||||
function auth_spip_verifier_pass($login, $new_pass, $id_auteur=0, $serveur=''){
|
||||
// login et mot de passe
|
||||
if (strlen($new_pass) < _PASS_LONGUEUR_MINI)
|
||||
return _T('info_passe_trop_court_car_pluriel',array('nb'=>_PASS_LONGUEUR_MINI));
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier le mot de passe de l'auteur sur le serveur concerne
|
||||
* en s'occupant du hash et companie
|
||||
* @param string $login
|
||||
* @param string $new_pass
|
||||
* @param int $id_auteur
|
||||
* @param string $serveur
|
||||
* @return bool
|
||||
*/
|
||||
function auth_spip_modifier_pass($login, $new_pass, $id_auteur, $serveur=''){
|
||||
if (is_null($new_pass) OR auth_spip_verifier_pass($login, $new_pass,$id_auteur,$serveur)!='')
|
||||
return false;
|
||||
|
||||
if (!$id_auteur = intval($id_auteur)
|
||||
OR !sql_fetsel('login','spip_auteurs','id_auteur='.intval($id_auteur),'','','','',$serveur))
|
||||
return false;
|
||||
|
||||
$c = array();
|
||||
include_spip('inc/acces');
|
||||
include_spip('auth/sha256.inc');
|
||||
$htpass = generer_htpass($new_pass);
|
||||
$alea_actuel = creer_uniqid();
|
||||
$alea_futur = creer_uniqid();
|
||||
$pass = _nano_sha256($alea_actuel.$new_pass);
|
||||
$c['pass'] = $pass;
|
||||
$c['htpass'] = $htpass;
|
||||
$c['alea_actuel'] = $alea_actuel;
|
||||
$c['alea_futur'] = $alea_futur;
|
||||
$c['low_sec'] = '';
|
||||
|
||||
include_spip('action/editer_auteur');
|
||||
auteur_modifier($id_auteur, $c, true); // manque la gestion de $serveur
|
||||
|
||||
return true; // on a bien modifie le pass
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchroniser les fichiers htpasswd
|
||||
*
|
||||
* @param int $id_auteur
|
||||
* @param array $champs
|
||||
* @param array $options
|
||||
* all=>true permet de demander la regeneration complete des acces apres operation en base (import, upgrade)
|
||||
* @param string $serveur
|
||||
* @return void
|
||||
*/
|
||||
function auth_spip_synchroniser_distant($id_auteur, $champs, $options = array(), $serveur=''){
|
||||
// ne rien faire pour une base distante : on ne sait pas regenerer les htaccess
|
||||
if (strlen($serveur))
|
||||
return;
|
||||
// si un login, pass ou statut a ete modifie
|
||||
// regenerer les fichier htpass
|
||||
if (isset($champs['login'])
|
||||
OR isset($champs['pass'])
|
||||
OR isset($champs['statut'])
|
||||
OR (isset($options['all']) AND $options['all'])
|
||||
) {
|
||||
|
||||
$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
|
||||
$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
|
||||
|
||||
// Cette variable de configuration peut etre posee par un plugin
|
||||
// par exemple acces_restreint ;
|
||||
// si .htaccess existe, outrepasser spip_meta
|
||||
if (($GLOBALS['meta']['creer_htpasswd'] != 'oui')
|
||||
AND !@file_exists($htaccess)) {
|
||||
spip_unlink($htpasswd);
|
||||
spip_unlink($htpasswd."-admin");
|
||||
return;
|
||||
}
|
||||
|
||||
# remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
|
||||
# de devenir redacteur le cas echeant (auth http)... a nettoyer
|
||||
// attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
|
||||
|
||||
$p1 = ''; // login:htpass pour tous
|
||||
$p2 = ''; // login:htpass pour les admins
|
||||
$s = sql_select("login, htpass, statut", "spip_auteurs", sql_in("statut", array('1comite','0minirezo','nouveau')));
|
||||
while ($t = sql_fetch($s)) {
|
||||
if (strlen($t['login']) AND strlen($t['htpass'])) {
|
||||
$p1 .= $t['login'].':'.$t['htpass']."\n";
|
||||
if ($t['statut'] == '0minirezo')
|
||||
$p2 .= $t['login'].':'.$t['htpass']."\n";
|
||||
}
|
||||
}
|
||||
sql_free($s);
|
||||
if ($p1) {
|
||||
ecrire_fichier($htpasswd, $p1);
|
||||
ecrire_fichier($htpasswd.'-admin', $p2);
|
||||
spip_log("Ecriture de $htpasswd et $htpasswd-admin");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// Une balise qui prend en argument un squelette suppose contenir un FORM
|
||||
// et gere ses saises automatiquement dans une table SQL a 2 colonnes
|
||||
// nom / valeur
|
||||
|
||||
// Comme l'emplacement du squelette est calcule (par l'argument de la balise)
|
||||
// on ne peut rien dire sur l'existence du squelette lors de la compil
|
||||
// On pourrait toutefois traiter le cas de l'argument qui est une constante.
|
||||
|
||||
function balise_CONFIGURER_METAS_dist($p) {
|
||||
|
||||
return calculer_balise_dynamique($p, $p->nom_champ, array());
|
||||
}
|
||||
|
||||
// A l'execution on dispose du nom du squelette, on verifie qu'il existe.
|
||||
// Pour le calcul du contexte, c'est comme la balise #FORMULAIRE_.
|
||||
// y compris le controle au retour pour faire apparaitre le message d'erreur.
|
||||
|
||||
function balise_CONFIGURER_METAS_dyn($form) {
|
||||
|
||||
include_spip('balise/formulaire_');
|
||||
if (!existe_formulaire($form)) return '';
|
||||
$args = func_get_args();
|
||||
$contexte = balise_FORMULAIRE__contexte('configurer_metas', $args);
|
||||
if (!is_array($contexte)) return $contexte;
|
||||
return array('formulaires/' . $form, 3600, $contexte);
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,309 +0,0 @@
|
|||
<?php
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
/**
|
||||
* Fonctions génériques pour les balises formulaires
|
||||
*
|
||||
* @package SPIP\Formulaires
|
||||
**/
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/filtres');
|
||||
include_spip('inc/texte');
|
||||
|
||||
/**
|
||||
* Protéger les saisies d'un champ de formulaire
|
||||
*
|
||||
* Proteger les ' et les " dans les champs que l'on va injecter,
|
||||
* sans toucher aux valeurs sérialisées
|
||||
*
|
||||
* @see entites_html()
|
||||
* @param string|array $texte
|
||||
* Saisie à protéger
|
||||
* @return string|array
|
||||
* Saisie protégée
|
||||
**/
|
||||
function protege_champ($texte){
|
||||
if (is_array($texte))
|
||||
$texte = array_map('protege_champ',$texte);
|
||||
else {
|
||||
// ne pas corrompre une valeur serialize
|
||||
if ((preg_match(",^[abis]:\d+[:;],", $texte) AND unserialize($texte)!=false) OR is_null($texte))
|
||||
return $texte;
|
||||
if (is_string($texte)
|
||||
AND $texte
|
||||
AND strpbrk($texte, "&\"'<>")!==false
|
||||
) {
|
||||
$texte = spip_htmlspecialchars($texte,ENT_QUOTES);
|
||||
}
|
||||
elseif(is_bool($texte))
|
||||
$texte = ($texte?'1':'');
|
||||
}
|
||||
return $texte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Teste si un formulaire demandé possède un squelette pour l'afficher
|
||||
*
|
||||
* @see trouver_fond()
|
||||
* @param string
|
||||
* Nom du formulaire
|
||||
* @return string|bool
|
||||
* - string : chemin du squelette
|
||||
* - false : pas de squelette trouvé
|
||||
**/
|
||||
function existe_formulaire($form)
|
||||
{
|
||||
if (substr($form,0,11)=="FORMULAIRE_")
|
||||
$form = strtolower(substr($form,11));
|
||||
else
|
||||
$form = strtolower($form);
|
||||
|
||||
if (!$form) return ''; // on ne sait pas, le nom du formulaire n'est pas fourni ici
|
||||
|
||||
return trouver_fond($form, 'formulaires/') ? $form : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Balises Formulaires par défaut.
|
||||
*
|
||||
* Compilé en un appel à une balise dynamique.
|
||||
*
|
||||
* @param Champ $p
|
||||
* Description de la balise formulaire
|
||||
* @return Champ
|
||||
* Description complétée du code compilé appelant la balise dynamique
|
||||
**/
|
||||
function balise_FORMULAIRE__dist($p) {
|
||||
|
||||
// Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide.
|
||||
// mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer
|
||||
if (existe_formulaire($p->nom_champ)===FALSE) {
|
||||
$p->code = "''";
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
}
|
||||
|
||||
// sinon renvoyer un code php dynamique
|
||||
return calculer_balise_dynamique($p, $p->nom_champ, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Balise dynamiques par défaut des formulaires
|
||||
*
|
||||
* @param string $form
|
||||
* Nom du formulaire
|
||||
* @return string|array
|
||||
* - array : squelette à appeler, durée du cache, contexte
|
||||
* - string : texte à afficher directement
|
||||
*/
|
||||
function balise_FORMULAIRE__dyn($form)
|
||||
{
|
||||
$form = existe_formulaire($form);
|
||||
if (!$form) return '';
|
||||
|
||||
// deux moyen d'arriver ici :
|
||||
// soit #FORMULAIRE_XX reroute avec 'FORMULAIRE_XX' ajoute en premier arg
|
||||
// soit #FORMULAIRE_{xx}
|
||||
|
||||
// recuperer les arguments passes a la balise
|
||||
// on enleve le premier qui est le nom de la balise
|
||||
// deja recupere ci-dessus
|
||||
|
||||
$args = func_get_args();
|
||||
array_shift($args);
|
||||
$contexte = balise_FORMULAIRE__contexte($form, $args);
|
||||
if (!is_array($contexte)) return $contexte;
|
||||
return array("formulaires/$form", 3600, $contexte);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcule le contexte à envoyer dans le squelette d'un formulaire
|
||||
*
|
||||
* @param string $form
|
||||
* Nom du formulaire
|
||||
* @param array $args
|
||||
* Arguments envoyés à l'appel du formulaire
|
||||
* @return array
|
||||
* Contexte d'environnement à envoyer au squelette
|
||||
**/
|
||||
function balise_FORMULAIRE__contexte($form, $args)
|
||||
{
|
||||
// tester si ce formulaire vient d'etre poste (memes arguments)
|
||||
// pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page
|
||||
// si poste, on recupere les erreurs
|
||||
|
||||
$je_suis_poste = false;
|
||||
if ($post_form = _request('formulaire_action')
|
||||
AND $post_form==$form
|
||||
AND $p = _request('formulaire_action_args')
|
||||
AND is_array($p = decoder_contexte_ajax($p, $post_form))) {
|
||||
// enlever le faux attribut de langue masque
|
||||
array_shift($p);
|
||||
if (formulaire__identifier($form, $args, $p))
|
||||
$je_suis_poste = true;
|
||||
}
|
||||
|
||||
$editable = true;
|
||||
$erreurs = $post = array();
|
||||
if ($je_suis_poste) {
|
||||
$post = traiter_formulaires_dynamiques(true);
|
||||
$e = "erreurs_$form";
|
||||
$erreurs = isset($post[$e]) ? $post[$e] : array();
|
||||
$editable = "editable_$form";
|
||||
$editable = (!isset($post[$e]))
|
||||
|| count($erreurs)
|
||||
|| (isset($post[$editable]) && $post[$editable]);
|
||||
}
|
||||
|
||||
$valeurs = formulaire__charger($form, $args, $je_suis_poste);
|
||||
|
||||
// si $valeurs n'est pas un tableau, le formulaire n'est pas applicable
|
||||
// C'est plus fort qu'editable qui est gere par le squelette
|
||||
// Idealement $valeur doit etre alors un message explicatif.
|
||||
if (!is_array($valeurs)) return is_string($valeurs) ? $valeurs : '';
|
||||
|
||||
// charger peut passer une action si le formulaire ne tourne pas sur self()
|
||||
// ou une action vide si elle ne sert pas
|
||||
$action = (isset($valeurs['action'])) ? $valeurs['action'] : self('&', true);
|
||||
// bug IEx : si action finit par /
|
||||
// IE croit que le <form ... action=../ > est autoferme
|
||||
if (substr($action,-1)=='/') {
|
||||
// on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un /
|
||||
$action .= '#';
|
||||
}
|
||||
|
||||
// recuperer la saisie en cours si erreurs
|
||||
// seulement si c'est ce formulaire qui est poste
|
||||
// ou si on le demande explicitement par le parametre _forcer_request = true
|
||||
$dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request']));
|
||||
foreach(array_keys($valeurs) as $champ){
|
||||
if ($champ[0]!=='_' AND !in_array($champ, array('message_ok','message_erreur','editable'))) {
|
||||
if ($dispo AND (($v = _request($champ))!==NULL))
|
||||
$valeurs[$champ] = $v;
|
||||
// nettoyer l'url des champs qui vont etre saisis
|
||||
if ($action)
|
||||
$action = parametre_url($action,$champ,'');
|
||||
// proteger les ' et les " dans les champs que l'on va injecter
|
||||
$valeurs[$champ] = protege_champ($valeurs[$champ]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
// nettoyer l'url
|
||||
$action = parametre_url($action,'formulaire_action','');
|
||||
$action = parametre_url($action,'formulaire_action_args','');
|
||||
}
|
||||
|
||||
if (isset($valeurs['_action'])){
|
||||
$securiser_action = charger_fonction('securiser_action','inc');
|
||||
$secu = $securiser_action(reset($valeurs['_action']),end($valeurs['_action']),'',-1);
|
||||
$valeurs['_hidden'] = (isset($valeurs['_hidden'])?$valeurs['_hidden']:'') .
|
||||
"<input type='hidden' name='arg' value='".$secu['arg']."' />"
|
||||
. "<input type='hidden' name='hash' value='".$secu['hash']."' />";
|
||||
}
|
||||
|
||||
// empiler la lang en tant que premier argument implicite du CVT
|
||||
// pour permettre de la restaurer au moment du Verifier et du Traiter
|
||||
array_unshift($args, $GLOBALS['spip_lang']);
|
||||
|
||||
$valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form);
|
||||
$valeurs['erreurs'] = $erreurs;
|
||||
$valeurs['action'] = $action;
|
||||
$valeurs['form'] = $form;
|
||||
|
||||
if (!isset($valeurs['id'])) $valeurs['id'] = 'new';
|
||||
// editable peut venir de charger() ou de traiter() sinon
|
||||
if (!isset($valeurs['editable'])) $valeurs['editable'] = $editable;
|
||||
// dans tous les cas, renvoyer un espace ou vide (et pas un booleen)
|
||||
$valeurs['editable'] = ($valeurs['editable']?' ':'');
|
||||
|
||||
if ($je_suis_poste) {
|
||||
$valeurs['message_erreur'] = "";
|
||||
if (isset($erreurs['message_erreur']))
|
||||
$valeurs['message_erreur'] = $erreurs['message_erreur'];
|
||||
|
||||
$valeurs['message_ok'] = "";
|
||||
if (isset($post["message_ok_$form"]))
|
||||
$valeurs['message_ok'] = $post["message_ok_$form"];
|
||||
elseif (isset($erreurs['message_ok']))
|
||||
$valeurs['message_ok'] = $erreurs["message_ok"];
|
||||
}
|
||||
|
||||
return $valeurs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Charger les valeurs de saisie du formulaire
|
||||
*
|
||||
* @param string $form
|
||||
* @param array $args
|
||||
* @param bool $poste
|
||||
* @return array
|
||||
*/
|
||||
function formulaire__charger($form, $args, $poste)
|
||||
{
|
||||
if ($charger_valeurs = charger_fonction("charger","formulaires/$form",true))
|
||||
$valeurs = call_user_func_array($charger_valeurs,$args);
|
||||
else $valeurs = array();
|
||||
|
||||
$valeurs = pipeline(
|
||||
'formulaire_charger',
|
||||
array(
|
||||
'args'=>array('form'=>$form,'args'=>$args,'je_suis_poste'=>$poste),
|
||||
'data'=>$valeurs)
|
||||
);
|
||||
|
||||
// si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline !
|
||||
if (is_array($valeurs)){
|
||||
if (!isset($valeurs['_pipelines'])) $valeurs['_pipelines']=array();
|
||||
// l'ancien argument _pipeline devient maintenant _pipelines
|
||||
// reinjectons le vieux _pipeline au debut de _pipelines
|
||||
if (isset($valeurs['_pipeline'])) {
|
||||
$pipe = is_array($valeurs['_pipeline'])?reset($valeurs['_pipeline']):$valeurs['_pipeline'];
|
||||
$args = is_array($valeurs['_pipeline'])?end($valeurs['_pipeline']):array();
|
||||
|
||||
$pipelines = array($pipe=>$args);
|
||||
$valeurs['_pipelines'] = array_merge($pipelines,$valeurs['_pipelines']);
|
||||
}
|
||||
|
||||
// et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire
|
||||
// qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond
|
||||
// (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes)
|
||||
$valeurs['_pipelines']['formulaire_fond'] = array('form'=>$form,'args'=>$args,'je_suis_poste'=>$poste);
|
||||
}
|
||||
|
||||
return $valeurs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifier que le formulaire en cours est celui qui est poste
|
||||
*
|
||||
* On se base sur la fonction identifier (si elle existe) qui fournit
|
||||
* une signature identifiant le formulaire a partir de ses arguments
|
||||
* significatifs
|
||||
*
|
||||
* En l'absence de fonction identifier, on se base sur l'egalite des
|
||||
* arguments, ce qui fonctionne dans les cas simples
|
||||
*
|
||||
* @param string $form
|
||||
* @param array $args
|
||||
* @param array $p
|
||||
* @return bool
|
||||
*/
|
||||
function formulaire__identifier($form, $args, $p) {
|
||||
if ($identifier_args = charger_fonction("identifier","formulaires/$form",true)) {
|
||||
return call_user_func_array($identifier_args,$args)===call_user_func_array($identifier_args,$p);
|
||||
}
|
||||
return $args===$p;
|
||||
}
|
||||
?>
|
|
@ -1,202 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@balise_FORMULAIRE_ADMIN
|
||||
function balise_FORMULAIRE_ADMIN ($p) {
|
||||
return calculer_balise_dynamique($p,'FORMULAIRE_ADMIN', array());
|
||||
}
|
||||
|
||||
# on ne peut rien dire au moment de l'execution du squelette
|
||||
|
||||
// http://doc.spip.org/@balise_FORMULAIRE_ADMIN_stat
|
||||
function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) {
|
||||
return $args;
|
||||
}
|
||||
|
||||
# les boutons admin sont mis d'autorite si absents
|
||||
# donc une variable statique controle si FORMULAIRE_ADMIN a ete vu.
|
||||
# Toutefois, si c'est le debuger qui appelle,
|
||||
# il peut avoir recopie le code dans ses donnees et il faut le lui refounir.
|
||||
# Pas question de recompiler: ca fait boucler !
|
||||
# Le debuger transmet donc ses donnees, et cette balise y retrouve son petit.
|
||||
|
||||
// http://doc.spip.org/@balise_FORMULAIRE_ADMIN_dyn
|
||||
function balise_FORMULAIRE_ADMIN_dyn($float='', $debug='') {
|
||||
|
||||
global $use_cache;
|
||||
static $dejafait = false;
|
||||
|
||||
if (!@$_COOKIE['spip_admin'])
|
||||
return '';
|
||||
|
||||
if (!is_array($debug)) {
|
||||
if ($dejafait)
|
||||
return '';
|
||||
} else {
|
||||
if ($dejafait) {
|
||||
if (empty($debug['sourcefile'])) return '';
|
||||
foreach($debug['sourcefile'] as $k => $v) {
|
||||
if (strpos($v,'administration.') !== false)
|
||||
return $debug['resultat'][$k . 'tout'];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
include_spip('inc/autoriser');
|
||||
include_spip('base/abstract_sql');
|
||||
|
||||
|
||||
$dejafait = true;
|
||||
|
||||
// Preparer le #ENV des boutons
|
||||
|
||||
$env = admin_objet();
|
||||
|
||||
// Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
|
||||
if (!$env)
|
||||
$env['ecrire'] = _DIR_RESTREINT_ABS;
|
||||
|
||||
$env['divclass'] = $float;
|
||||
$env['lang'] = admin_lang();
|
||||
$env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
|
||||
$env['debug'] = ((defined('_VAR_PREVIEW') AND _VAR_PREVIEW) ? "" : admin_debug());
|
||||
$env['analyser'] = (!$env['debug'] AND !$GLOBALS['xhtml']) ? '' : admin_valider();
|
||||
$env['inclure'] = ((defined('_VAR_INCLURE') AND _VAR_INCLURE)?'inclure':'');
|
||||
|
||||
if (!$use_cache)
|
||||
$env['use_cache'] = ' *';
|
||||
|
||||
if (isset($debug['validation'])) {
|
||||
$env['xhtml_error'] = $debug['validation'];
|
||||
}
|
||||
|
||||
$env['_pipelines']['formulaire_admin']=array();
|
||||
|
||||
return array('formulaires/administration', 0, $env);
|
||||
}
|
||||
|
||||
// Afficher le bouton 'Modifier ce...'
|
||||
// s'il y a un $id_XXX defini globalement par spip_register_globals
|
||||
// Attention a l'ordre dans la boucle:
|
||||
// on ne veut pas la rubrique si un autre bouton est possible
|
||||
|
||||
// http://doc.spip.org/@admin_objet
|
||||
function admin_objet()
|
||||
{
|
||||
include_spip('inc/urls');
|
||||
$env = array();
|
||||
|
||||
$trouver_table = charger_fonction('trouver_table','base');
|
||||
$objets = urls_liste_objets(false);
|
||||
$objets = array_diff($objets, array('rubrique'));
|
||||
$objets = array_reverse($objets);
|
||||
array_unshift($objets, 'rubrique');
|
||||
foreach ($objets as $obj) {
|
||||
$type = $obj;
|
||||
if ($type==objet_type($type,false)
|
||||
AND $_id_type = id_table_objet($type)
|
||||
AND isset($GLOBALS['contexte'][$_id_type])
|
||||
AND $id = $GLOBALS['contexte'][$_id_type]
|
||||
AND !is_array($id)
|
||||
AND $id=intval($id)) {
|
||||
$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=".intval($id));
|
||||
if ($id) {
|
||||
$env[$_id_type] = $id;
|
||||
$env['objet'] = $type;
|
||||
$env['id_objet'] = $id;
|
||||
$env['voir_'.$obj] =
|
||||
str_replace('&', '&', generer_url_entite($id,$obj,'','',false));
|
||||
if ($desc = $trouver_table(table_objet_sql($type))
|
||||
AND isset($desc['field']['id_rubrique'])
|
||||
AND $type != 'rubrique') {
|
||||
unset($env['id_rubrique']);
|
||||
unset($env['voir_rubrique']);
|
||||
if (admin_preview($type, $id, $desc))
|
||||
$env['preview']=parametre_url(self(),'var_mode','preview','&');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $env;
|
||||
}
|
||||
|
||||
|
||||
// http://doc.spip.org/@admin_preview
|
||||
function admin_preview($type, $id, $desc=null)
|
||||
{
|
||||
if (defined('_VAR_PREVIEW') AND _VAR_PREVIEW) return '';
|
||||
|
||||
if (!$desc) {
|
||||
$trouver_table = charger_fonction('trouver_table','base');
|
||||
$desc = $trouver_table(table_objet_sql($type));
|
||||
}
|
||||
if (!$desc OR !isset($desc['field']['statut']))
|
||||
return '';
|
||||
|
||||
include_spip('inc/autoriser');
|
||||
if (!autoriser('previsualiser')) return '';
|
||||
|
||||
$notpub = sql_in("statut", array('prop', 'prive'));
|
||||
|
||||
if ($type == 'article' AND $GLOBALS['meta']['post_dates'] != 'oui')
|
||||
$notpub .= " OR (statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')).")";
|
||||
|
||||
return sql_fetsel('1', table_objet_sql($type), id_table_objet($type)."=".$id." AND ($notpub)");
|
||||
}
|
||||
|
||||
//
|
||||
// Regler les boutons dans la langue de l'admin (sinon tant pis)
|
||||
//
|
||||
|
||||
// http://doc.spip.org/@admin_lang
|
||||
function admin_lang()
|
||||
{
|
||||
$alang = sql_getfetsel('lang', 'spip_auteurs', "login=" . sql_quote(preg_replace(',^@,','',@$_COOKIE['spip_admin'])));
|
||||
if (!$alang) return '';
|
||||
|
||||
$l = lang_select($alang);
|
||||
$alang = $GLOBALS['spip_lang'];
|
||||
if ($l) lang_select();
|
||||
return $alang;
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@admin_valider
|
||||
function admin_valider()
|
||||
{
|
||||
global $xhtml;
|
||||
|
||||
return ((@$xhtml !== 'true') ?
|
||||
(parametre_url(self(), 'var_mode', 'debug', '&')
|
||||
.'&var_mode_affiche=validation') :
|
||||
('http://validator.w3.org/check?uri='
|
||||
. rawurlencode("http://" . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@admin_debug
|
||||
function admin_debug()
|
||||
{
|
||||
return ((
|
||||
(isset($GLOBALS['forcer_debug']) AND $GLOBALS['forcer_debug'])
|
||||
OR (isset($GLOBALS['bouton_admin_debug']) AND $GLOBALS['bouton_admin_debug'])
|
||||
OR (
|
||||
defined('_VAR_MODE') AND _VAR_MODE == 'debug'
|
||||
AND $_COOKIE['spip_debug']
|
||||
)
|
||||
) AND autoriser('debug')
|
||||
)
|
||||
? parametre_url(self(),'var_mode', 'debug', '&'): '';
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('base/abstract_sql');
|
||||
|
||||
// On prend l'email dans le contexte de maniere a ne pas avoir a le
|
||||
// verifier dans la base ni a le devoiler au visiteur
|
||||
|
||||
|
||||
// http://doc.spip.org/@balise_FORMULAIRE_ECRIRE_AUTEUR
|
||||
function balise_FORMULAIRE_ECRIRE_AUTEUR ($p) {
|
||||
return calculer_balise_dynamique($p,'FORMULAIRE_ECRIRE_AUTEUR', array('id_auteur', 'id_article', 'email'));
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@balise_FORMULAIRE_ECRIRE_AUTEUR_stat
|
||||
function balise_FORMULAIRE_ECRIRE_AUTEUR_stat($args, $context_compil) {
|
||||
include_spip('inc/filtres');
|
||||
// Pas d'id_auteur ni d'id_article ? Erreur de contexte
|
||||
$id = intval($args[1]);
|
||||
if (!$args[0] AND !$id) {
|
||||
$msg = array('zbug_champ_hors_motif',
|
||||
array ('champ' => 'FORMULAIRE_ECRIRE_AUTEUR',
|
||||
'motif' => 'AUTEURS/ARTICLES'));
|
||||
|
||||
erreur_squelette($msg, $context_compil);
|
||||
return '';
|
||||
}
|
||||
// Si on est dans un contexte article,
|
||||
// sortir tous les mails des auteurs de l'article
|
||||
if (!$args[0] AND $id) {
|
||||
$r = '';
|
||||
$s = sql_allfetsel('email',
|
||||
'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')',
|
||||
"A.email != '' AND L.id_objet=$id");
|
||||
foreach($s as $row) {
|
||||
if (email_valide($row['email']))
|
||||
$r .= ', '.$row['email'];
|
||||
}
|
||||
$args[2] = substr($r, 2);
|
||||
}
|
||||
|
||||
// On ne peut pas ecrire a un auteur dont le mail n'est pas valide
|
||||
if (!$args[2] OR !email_valide($args[2]))
|
||||
return '';
|
||||
|
||||
// OK
|
||||
return $args;
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('base/abstract_sql');
|
||||
include_spip('inc/filtres');
|
||||
|
||||
// Balise independante du contexte
|
||||
|
||||
/**
|
||||
* http://doc.spip.org/@balise_FORMULAIRE_INSCRIPTION
|
||||
*
|
||||
* @param object $p
|
||||
* @return mixed
|
||||
*/
|
||||
function balise_FORMULAIRE_INSCRIPTION ($p) {
|
||||
|
||||
return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', array());
|
||||
}
|
||||
|
||||
/**
|
||||
* http://doc.spip.org/@balise_FORMULAIRE_INSCRIPTION_stat
|
||||
*
|
||||
* [(#FORMULAIRE_INSCRIPTION{nom_inscription, #ID_RUBRIQUE})]
|
||||
*
|
||||
* @param array $args
|
||||
* args[0] un statut d'auteur (redacteur par defaut)
|
||||
* args[1] indique la rubrique eventuelle de proposition
|
||||
* @param array $context_compil
|
||||
* @return array|string
|
||||
*/
|
||||
function balise_FORMULAIRE_INSCRIPTION_stat($args, $context_compil) {
|
||||
list($mode, $id) = $args;
|
||||
include_spip('action/inscrire_auteur');
|
||||
$mode = tester_statut_inscription($mode, $id);
|
||||
return $mode ? array($mode, $id) : '';
|
||||
}
|
||||
|
||||
?>
|
|
@ -1 +0,0 @@
|
|||
X
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Generer n'importe quel info pour un objet : #INFO_TITRE{article, #ENV{id_article}}
|
||||
* Utilise la fonction generer_info_entite() de inc/filtres
|
||||
* se reporter a sa documentation
|
||||
*
|
||||
*/
|
||||
function balise_INFO__dist($p){
|
||||
$info = $p->nom_champ;
|
||||
$type_objet = interprete_argument_balise(1,$p);
|
||||
$id_objet = interprete_argument_balise(2,$p);
|
||||
if ($info === 'INFO_' or !$type_objet or !$id_objet) {
|
||||
$msg = _T('zbug_balise_sans_argument', array('balise' => ' INFO_'));
|
||||
erreur_squelette($msg, $p);
|
||||
$p->interdire_scripts = true;
|
||||
return $p;
|
||||
}
|
||||
else {
|
||||
$info_sql = strtolower(substr($info,5));
|
||||
$code = "generer_info_entite($id_objet, $type_objet, '$info_sql'".($p->etoile?","._q($p->etoile):"").")";
|
||||
$p->code = champ_sql($info, $p, $code);
|
||||
$p->interdire_scripts = true;
|
||||
return $p;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2010 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return; #securite
|
||||
|
||||
|
||||
// http://doc.spip.org/@balise_LOGIN_PRIVE
|
||||
function balise_LOGIN_PRIVE ($p) {
|
||||
return calculer_balise_dynamique($p, 'LOGIN_PRIVE', array('url'));
|
||||
}
|
||||
|
||||
# retourner:
|
||||
# 1. l'url collectee ci-dessus (args0) ou donnee en premier parametre (args1)
|
||||
# #LOGIN_PRIVE{#URL_ECRIRE}
|
||||
# 2. un eventuel parametre (args2) indiquant le login et permettant une ecriture
|
||||
# <boucle(AUTEURS)>[(#LOGIN_PRIVE{#URL_ECRIRE, #LOGIN})]
|
||||
|
||||
// http://doc.spip.org/@balise_LOGIN_PRIVE_stat
|
||||
function balise_LOGIN_PRIVE_stat ($args, $context_compil) {
|
||||
return array(isset($args[1]) ? $args[1] : $args[0], (isset($args[2]) ? $args[2] : ''));
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@balise_LOGIN_PRIVE_dyn
|
||||
function balise_LOGIN_PRIVE_dyn($url, $login) {
|
||||
include_spip('balise/formulaire_');
|
||||
if (!$url # pas d'url passee en filtre ou dans le contexte
|
||||
AND !$url = _request('url') # ni d'url passee par l'utilisateur
|
||||
)
|
||||
$url = generer_url_ecrire('accueil','',true);
|
||||
return balise_FORMULAIRE__dyn('login',$url,$login,true);
|
||||
}
|
||||
?>
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2010 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return; #securite
|
||||
|
||||
|
||||
// http://doc.spip.org/@balise_LOGIN_PUBLIC
|
||||
function balise_LOGIN_PUBLIC ($p, $nom='LOGIN_PUBLIC') {
|
||||
return calculer_balise_dynamique($p, $nom, array('url'));
|
||||
}
|
||||
|
||||
# retourner:
|
||||
# 1. l'url collectee ci-dessus (args0) ou donnee en premier parametre (args1)
|
||||
# #LOGIN_PUBLIC{#SELF}
|
||||
# 2. un eventuel parametre (args2) indiquant le login et permettant une ecriture
|
||||
# <boucle(AUTEURS)>[(#LOGIN_PUBLIC{#SELF, #LOGIN})]
|
||||
|
||||
// http://doc.spip.org/@balise_LOGIN_PUBLIC_stat
|
||||
function balise_LOGIN_PUBLIC_stat ($args, $context_compil) {
|
||||
return array(isset($args[1]) ? $args[1] : $args[0], (isset($args[2]) ? $args[2] : ''));
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@balise_LOGIN_PUBLIC_dyn
|
||||
function balise_LOGIN_PUBLIC_dyn($url, $login) {
|
||||
include_spip('balise/formulaire_');
|
||||
if (!$url # pas d'url passee en filtre ou dans le contexte
|
||||
AND !$url = _request('url') # ni d'url passee par l'utilisateur
|
||||
)
|
||||
$url = parametre_url(self(), '', '', '&');
|
||||
return balise_FORMULAIRE__dyn('login',$url,$login,false);
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,124 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
//
|
||||
// Fonction des balises #LOGO_XXXX
|
||||
// (les balises portant ce type de nom sont traitees en bloc ici)
|
||||
//
|
||||
|
||||
// http://doc.spip.org/@balise_LOGO__dist
|
||||
function balise_LOGO__dist ($p) {
|
||||
|
||||
preg_match(",^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i", $p->nom_champ, $regs);
|
||||
$type = strtolower($regs[1]);
|
||||
$suite_logo = $regs[2];
|
||||
|
||||
// cas de #LOGO_SITE_SPIP
|
||||
if ($type == 'site_spip') {
|
||||
$type = 'site';
|
||||
$_id_objet = "\"'0'\"";
|
||||
}
|
||||
|
||||
$id_objet = id_table_objet($type);
|
||||
if (!isset($_id_objet) OR !$_id_objet)
|
||||
$_id_objet = champ_sql($id_objet, $p);
|
||||
|
||||
$fichier = ($p->etoile === '**') ? -1 : 0;
|
||||
$coord = array();
|
||||
$align = $lien = '';
|
||||
$mode_logo = '';
|
||||
|
||||
if ($p->param AND !$p->param[0][0]) {
|
||||
$params = $p->param[0];
|
||||
array_shift($params);
|
||||
foreach($params as $a) {
|
||||
if ($a[0]->type === 'texte') {
|
||||
$n = $a[0]->texte;
|
||||
if (is_numeric($n))
|
||||
$coord[]= $n;
|
||||
elseif (in_array($n,array('top','left','right','center','bottom')))
|
||||
$align = $n;
|
||||
elseif (in_array($n,array('auto','icone','apercu','vignette')))
|
||||
$mode_logo = $n;
|
||||
}
|
||||
else $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$coord_x = !$coord ? 0 : intval(array_shift($coord));
|
||||
$coord_y = !$coord ? 0 : intval(array_shift($coord));
|
||||
|
||||
if ($p->etoile === '*') {
|
||||
include_spip('balise/url_');
|
||||
$lien = generer_generer_url_arg($type, $p, $_id_objet);
|
||||
}
|
||||
|
||||
$connect = $p->id_boucle ?$p->boucles[$p->id_boucle]->sql_serveur :'';
|
||||
if ($type == 'document') {
|
||||
$qconnect = _q($connect);
|
||||
$doc = "quete_document($_id_objet, $qconnect)";
|
||||
if ($fichier)
|
||||
$code = "quete_logo_file($doc, $qconnect)";
|
||||
else $code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
|
||||
// (x=non-faux ? y : '') pour affecter x en retournant y
|
||||
if ($p->descr['documents'])
|
||||
$code = '(($doublons["documents"] .= ",". '
|
||||
. $_id_objet
|
||||
. ") ? $code : '')";
|
||||
}
|
||||
elseif ($connect) {
|
||||
$code = "''";
|
||||
spip_log("Les logos distants ne sont pas prevus");
|
||||
} else {
|
||||
$code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo);
|
||||
}
|
||||
|
||||
// demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0}
|
||||
if ($coord_x OR $coord_y) {
|
||||
$code = "filtrer('image_graver',filtrer('image_reduire',".$code.", '$coord_x', '$coord_y'))";
|
||||
}
|
||||
|
||||
$p->code = $code;
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
}
|
||||
|
||||
function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite)
|
||||
{
|
||||
$code = "quete_logo('$id_objet', '" .
|
||||
(($suite == '_SURVOL') ? 'off' :
|
||||
(($suite == '_NORMAL') ? 'on' : 'ON')) .
|
||||
"', $_id_objet," .
|
||||
(($suite == '_RUBRIQUE') ?
|
||||
champ_sql("id_rubrique", $p) :
|
||||
(($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
|
||||
", " . intval($fichier) . ")";
|
||||
|
||||
if ($fichier) return $code;
|
||||
|
||||
$code = "\n((!is_array(\$l = $code)) ? '':\n (" .
|
||||
'"<img class=\"spip_logos\" alt=\"\"' .
|
||||
($align ? " align=\\\"$align\\\"" : '')
|
||||
. ' src=\"$l[0]\"" . $l[2] . ($l[1] ? " onmouseover=\"this.src=\'$l[1]\'\" onmouseout=\"this.src=\'$l[0]\'\"" : "") . \' />\'))';
|
||||
|
||||
if (!$lien) return $code;
|
||||
|
||||
return ('(strlen($logo='.$code.')?\'<a href="\' .' . $lien . ' . \'">\' . $logo . \'</a>\':\'\')');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// #MENU_LANG affiche le menu des langues de l'espace public
|
||||
// et preselectionne celle la globale $lang
|
||||
// ou de l'argument fourni: #MENU_LANG{#ENV{malangue}}
|
||||
|
||||
|
||||
// http://doc.spip.org/@balise_MENU_LANG
|
||||
function balise_MENU_LANG ($p) {
|
||||
return calculer_balise_dynamique($p,'MENU_LANG', array('lang'));
|
||||
}
|
||||
|
||||
// s'il n'y a qu'une langue eviter definitivement la balise ?php
|
||||
// http://doc.spip.org/@balise_MENU_LANG_stat
|
||||
function balise_MENU_LANG_stat ($args, $context_compil) {
|
||||
if (strpos($GLOBALS['meta']['langues_multilingue'],',') === false) return '';
|
||||
return $args;
|
||||
}
|
||||
|
||||
// normalement $opt sera toujours non vide suite au test ci-dessus
|
||||
// http://doc.spip.org/@balise_MENU_LANG_dyn
|
||||
function balise_MENU_LANG_dyn($opt) {
|
||||
include_spip('balise/menu_lang_ecrire');
|
||||
return menu_lang_pour_tous('var_lang', $opt);
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// #MENU_LANG_ECRIRE affiche le menu des langues de l'espace privé
|
||||
// et preselectionne celle la globale $lang
|
||||
// ou de l'arguemnt fourni: #MENU_LANG_ECRIRE{#ENV{malangue}}
|
||||
|
||||
// http://doc.spip.org/@balise_MENU_LANG_ECRIRE
|
||||
function balise_MENU_LANG_ECRIRE ($p) {
|
||||
return calculer_balise_dynamique($p,'MENU_LANG_ECRIRE', array('lang'));
|
||||
}
|
||||
|
||||
// s'il n'y a qu'une langue proposee eviter definitivement la balise ?php
|
||||
// http://doc.spip.org/@balise_MENU_LANG_ECRIRE_stat
|
||||
function balise_MENU_LANG_ECRIRE_stat ($args, $context_compil) {
|
||||
include_spip('inc/lang');
|
||||
if (strpos($GLOBALS['meta']['langues_proposees'],',') === false) return '';
|
||||
return $args;
|
||||
}
|
||||
|
||||
// normalement $opt sera toujours non vide suite au test ci-dessus
|
||||
// http://doc.spip.org/@balise_MENU_LANG_ECRIRE_dyn
|
||||
function balise_MENU_LANG_ECRIRE_dyn($opt) {
|
||||
return menu_lang_pour_tous('var_lang_ecrire', $opt);
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@menu_lang_pour_tous
|
||||
function menu_lang_pour_tous($nom, $default) {
|
||||
include_spip('inc/lang');
|
||||
|
||||
if ($GLOBALS['spip_lang'] <> $default) {
|
||||
$opt = lang_select($default); # et remplace
|
||||
if ($GLOBALS['spip_lang'] <> $default) {
|
||||
$default = ''; # annule tout choix par defaut
|
||||
if ($opt) lang_select();
|
||||
}
|
||||
}
|
||||
|
||||
# lien a partir de /
|
||||
$cible = parametre_url(self(), 'lang' , '', '&');
|
||||
$post = generer_url_action('converser', 'redirect='. rawurlencode($cible), '&');
|
||||
|
||||
return array('formulaires/menu_lang',
|
||||
3600,
|
||||
array('nom' => $nom,
|
||||
'url' => $post,
|
||||
'name' => $nom,
|
||||
'default' => $default,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,220 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// Les balises URL_$type sont generiques, sauf qq cas particuliers.
|
||||
// Si ces balises sont utilisees pour la base locale,
|
||||
// production des appels a generer_url_entite(id-courant, entite)
|
||||
// Si la base est externe et non geree par SPIP
|
||||
// on retourne NULL pour provoquer leur interpretation comme champ SQL normal.
|
||||
// Si la base est externe et sous SPIP,
|
||||
// on produit l'URL de l'objet si c'est une piece jointe
|
||||
// ou sinon l'URL du site local applique sur l'objet externe
|
||||
// ce qui permet de le voir a travers les squelettes du site local
|
||||
// On communique le type-url distant a generer_url_entite mais il ne sert pas
|
||||
// car rien ne garantit que le .htaccess soit identique. A approfondir
|
||||
|
||||
// http://doc.spip.org/@generer_generer_url
|
||||
function generer_generer_url($type, $p){
|
||||
$_id = interprete_argument_balise(1,$p);
|
||||
|
||||
if (!$_id) {
|
||||
$primary = id_table_objet($type);
|
||||
$_id = champ_sql($primary, $p);
|
||||
}
|
||||
|
||||
return generer_generer_url_arg($type, $p, $_id);
|
||||
}
|
||||
|
||||
function generer_generer_url_arg($type, $p, $_id)
|
||||
{
|
||||
if ($s = trouver_nom_serveur_distant($p)) {
|
||||
|
||||
// si une fonction de generation des url a ete definie pour ce connect l'utiliser
|
||||
if (function_exists($f = 'generer_generer_url_'.$s)){
|
||||
return $f($type, $_id, $s);
|
||||
}
|
||||
if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
|
||||
return NULL;
|
||||
}
|
||||
$s = _q($s);
|
||||
# exception des urls de documents sur un serveur distant...
|
||||
if ($type == 'document') {
|
||||
return
|
||||
"quete_meta('adresse_site', $s) . '/' .\n\t" .
|
||||
"quete_meta('dir_img', $s) . \n\t" .
|
||||
"quete_fichier($_id,$s)";
|
||||
}
|
||||
$s = ", '', '', $s, quete_meta('type_urls', $s)";
|
||||
}
|
||||
else
|
||||
$s = ", '', '', true";
|
||||
return "urlencode_1738(generer_url_entite($_id, '$type'$s))";
|
||||
}
|
||||
|
||||
|
||||
// http://doc.spip.org/@balise_URL__dist
|
||||
function balise_URL__dist($p) {
|
||||
|
||||
$nom = $p->nom_champ;
|
||||
if ($nom === 'URL_') {
|
||||
$msg = array('zbug_balise_sans_argument', array('balise' => ' URL_'));
|
||||
erreur_squelette($msg, $p);
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
} elseif ($f = charger_fonction($nom, 'balise', true)) {
|
||||
return $f($p);
|
||||
}else {
|
||||
$nom = strtolower($nom);
|
||||
$code = generer_generer_url(substr($nom,4), $p);
|
||||
$code = champ_sql($nom, $p, $code);
|
||||
$p->code = $code;
|
||||
if (!$p->etoile)
|
||||
$p->code = "vider_url($code)";
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
}
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@balise_URL_ARTICLE_dist
|
||||
function balise_URL_ARTICLE_dist($p) {
|
||||
|
||||
// Cas particulier des boucles (SYNDIC_ARTICLES)
|
||||
if ($p->type_requete == 'syndic_articles') {
|
||||
$code = champ_sql('url', $p);
|
||||
} else $code = generer_generer_url('article', $p);
|
||||
|
||||
$p->code = $code;
|
||||
if (!$p->etoile)
|
||||
$p->code = "vider_url($code)";
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@balise_URL_SITE_dist
|
||||
function balise_URL_SITE_dist($p)
|
||||
{
|
||||
$code = champ_sql('url_site', $p);
|
||||
if (strpos($code, '@$Pile[0]') !== false) {
|
||||
$code = generer_generer_url('site', $p);
|
||||
if ($code === NULL) return NULL;
|
||||
} else {
|
||||
if (!$p->etoile)
|
||||
$code = "calculer_url($code,'','url', \$connect)";
|
||||
}
|
||||
$p->code = $code;
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
}
|
||||
|
||||
// Autres balises URL_*, qui ne concernent pas une table
|
||||
// (historique)
|
||||
|
||||
// http://doc.spip.org/@balise_URL_SITE_SPIP_dist
|
||||
function balise_URL_SITE_SPIP_dist($p) {
|
||||
$p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
|
||||
$p->code = "spip_htmlspecialchars(".$p->code.")";
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
}
|
||||
|
||||
//
|
||||
// #URL_PAGE{backend} -> backend.php3 ou ?page=backend selon les cas
|
||||
// Pour les pages qui commencent par "spip_", il faut eventuellement
|
||||
// aller chercher spip_action.php?action=xxxx
|
||||
// Sans argument, #URL_PAGE retourne l'URL courante.
|
||||
// #URL_PAGE* retourne l'URL sans convertir les & en &
|
||||
// http://doc.spip.org/@balise_URL_PAGE_dist
|
||||
function balise_URL_PAGE_dist($p) {
|
||||
|
||||
$code = interprete_argument_balise(1,$p);
|
||||
$args = interprete_argument_balise(2,$p);
|
||||
if ($args == NULL)
|
||||
$args = "''";
|
||||
|
||||
if ($s = trouver_nom_serveur_distant($p)) {
|
||||
// si une fonction de generation des url a ete definie pour ce connect l'utiliser
|
||||
// elle devra aussi traiter le cas derogatoire type=page
|
||||
if (function_exists($f = 'generer_generer_url_'.$s)){
|
||||
if ($args AND $args!=="''") $code .= ", $args";
|
||||
$code = $f('page', $code, $s);
|
||||
return $p;
|
||||
}
|
||||
$s = 'connect=' . addslashes($s);
|
||||
$args = (($args AND $args!=="''") ? "$args . '&$s'" : "'$s'");
|
||||
}
|
||||
|
||||
if (!$code) {
|
||||
$noentities = $p->etoile ? "'&'" : '';
|
||||
$code = "url_de_base() . preg_replace(',^./,', '', self($noentities))";
|
||||
} else{
|
||||
if (!$args) $args = "''";
|
||||
$noentities = $p->etoile ? ", true" : '';
|
||||
$code = "generer_url_public($code, $args$noentities)";
|
||||
}
|
||||
$p->code = $code;
|
||||
spip_log("connect vaut $s ca donne " . $p->code . " args $args");
|
||||
|
||||
#$p->interdire_scripts = true;
|
||||
return $p;
|
||||
}
|
||||
|
||||
//
|
||||
// #URL_ECRIRE{rubriques} -> ecrire/?exec=rubriques
|
||||
// #URL_ECRIRE* meme chose, mais sans convertir les & en &
|
||||
// http://doc.spip.org/@balise_URL_ECRIRE_dist
|
||||
function balise_URL_ECRIRE_dist($p) {
|
||||
|
||||
$code = interprete_argument_balise(1,$p);
|
||||
if (!$code) {
|
||||
$fonc = "''";
|
||||
}
|
||||
else {
|
||||
$fonc = $code;
|
||||
$args = interprete_argument_balise(2,$p);
|
||||
if ($args === NULL) {
|
||||
$args = "''";
|
||||
}
|
||||
$noentities = $p->etoile ? ", true" : '';
|
||||
if (($args != "''") OR $noentities) {
|
||||
$fonc .= ",$args$noentities";
|
||||
}
|
||||
}
|
||||
$p->code = 'generer_url_ecrire(' . $fonc .')';
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
}
|
||||
|
||||
//
|
||||
// #URL_ACTION_AUTEUR{converser,arg,redirect} -> ecrire/?action=converser&arg=arg&hash=xxx&redirect=redirect
|
||||
//
|
||||
// http://doc.spip.org/@balise_URL_ACTION_AUTEUR_dist
|
||||
function balise_URL_ACTION_AUTEUR_dist($p) {
|
||||
$p->descr['session'] = true;
|
||||
|
||||
$p->code = interprete_argument_balise(1,$p);
|
||||
$args = interprete_argument_balise(2,$p);
|
||||
if ($args != "''" && $args!==NULL)
|
||||
$p->code .= ",".$args;
|
||||
$redirect = interprete_argument_balise(3,$p);
|
||||
if ($redirect != "''" && $redirect!==NULL) {
|
||||
if ($args == "''" || $args===NULL)
|
||||
$p->code .= ",''";
|
||||
$p->code .= ",".$redirect;
|
||||
}
|
||||
|
||||
$p->code = "generer_action_auteur(" . $p->code . ")";
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
}
|
||||
?>
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@balise_URL_LOGOUT
|
||||
function balise_URL_LOGOUT ($p) {return calculer_balise_dynamique($p,'URL_LOGOUT', array());
|
||||
}
|
||||
|
||||
// $args[0] = url destination apres logout [(#URL_LOGOUT{url})]
|
||||
// http://doc.spip.org/@balise_URL_LOGOUT_stat
|
||||
function balise_URL_LOGOUT_stat ($args, $context_compil) {
|
||||
$url = isset($args[0]) ? $args[0] : '';
|
||||
return array($url);
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@balise_URL_LOGOUT_dyn
|
||||
function balise_URL_LOGOUT_dyn($cible) {
|
||||
|
||||
if (!$GLOBALS['visiteur_session']['login'] AND !$GLOBALS['visiteur_session']['statut']) return '';
|
||||
|
||||
return generer_url_action('logout',"logout=public&url=" . rawurlencode($cible ? $cible : self('&')));
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load diff
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
/**
|
||||
* Déclare la liste des tables auxiliaires
|
||||
*
|
||||
* @todo
|
||||
* Nettoyages à faire dans le core : on ne devrait plus appeler
|
||||
* Ce fichier mais directement base/objets si nécessaire
|
||||
*
|
||||
* @package SPIP\SQL\Tables
|
||||
**/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('base/objets');
|
||||
lister_tables_objets_sql();
|
||||
|
||||
?>
|
|
@ -1,358 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
require_once _ROOT_RESTREINT . 'base/objets.php';
|
||||
|
||||
//
|
||||
// Utilitaires indispensables autour des serveurs SQL
|
||||
//
|
||||
|
||||
// API d'appel aux bases de donnees:
|
||||
// on charge le fichier config/$serveur ($serveur='connect' pour le principal)
|
||||
// qui est cense initaliser la connexion en appelant spip_connect_db
|
||||
// laquelle met dans la globale db_ok la description de la connexion
|
||||
// On la memorise dans un tableau pour permettre plusieurs serveurs.
|
||||
// A l'installation, il faut simuler l'existence de ce fichier
|
||||
|
||||
// http://doc.spip.org/@spip_connect
|
||||
function spip_connect($serveur='', $version='') {
|
||||
global $connexions, $spip_sql_version;
|
||||
|
||||
$serveur = !is_string($serveur) ? '' : strtolower($serveur);
|
||||
$index = $serveur ? $serveur : 0;
|
||||
if (!$version) $version = $spip_sql_version;
|
||||
if (isset($connexions[$index][$version])) return $connexions[$index];
|
||||
|
||||
include_spip('base/abstract_sql');
|
||||
$install = (_request('exec') == 'install');
|
||||
|
||||
// Premiere connexion ?
|
||||
if (!($old = isset($connexions[$index]))) {
|
||||
$f = (!preg_match('/^[\w\.]*$/', $serveur))
|
||||
? '' // nom de serveur mal ecrit
|
||||
: ($serveur ?
|
||||
( _DIR_CONNECT. $serveur . '.php') // serveur externe
|
||||
: (_FILE_CONNECT ? _FILE_CONNECT // serveur principal ok
|
||||
: ($install ? _FILE_CONNECT_TMP // init du serveur principal
|
||||
: ''))); // installation pas faite
|
||||
|
||||
unset($GLOBALS['db_ok']);
|
||||
unset($GLOBALS['spip_connect_version']);
|
||||
if ($f) {
|
||||
if (is_readable($f)) {
|
||||
include($f);
|
||||
} elseif ($serveur AND !$install) {
|
||||
// chercher une declaration de serveur dans le path
|
||||
// qui pourra un jour servir a declarer des bases sqlite
|
||||
// par des plugins. Et sert aussi aux boucles POUR.
|
||||
find_in_path("$serveur.php",'connect/',true);
|
||||
}
|
||||
}
|
||||
if (!isset($GLOBALS['db_ok'])) {
|
||||
// fera mieux la prochaine fois
|
||||
if ($install) return false;
|
||||
if ($f AND is_readable($f))
|
||||
spip_log("spip_connect: fichier de connexion '$f' OK.", _LOG_INFO_IMPORTANTE);
|
||||
else
|
||||
spip_log("spip_connect: fichier de connexion '$f' non trouve", _LOG_INFO_IMPORTANTE);
|
||||
spip_log("spip_connect: echec connexion ou serveur $index mal defini dans '$f'.", _LOG_HS);
|
||||
// ne plus reessayer si ce n'est pas l'install
|
||||
return $connexions[$index]=false;
|
||||
}
|
||||
$connexions[$index] = $GLOBALS['db_ok'];
|
||||
}
|
||||
// si la connexion a deja ete tentee mais a echoue, le dire!
|
||||
if (!$connexions[$index]) return false;
|
||||
|
||||
// la connexion a reussi ou etait deja faite.
|
||||
// chargement de la version du jeu de fonctions
|
||||
// si pas dans le fichier par defaut
|
||||
$type = $GLOBALS['db_ok']['type'];
|
||||
$jeu = 'spip_' . $type .'_functions_' . $version;
|
||||
if (!isset($GLOBALS[$jeu])) {
|
||||
if (!find_in_path($type . '_' . $version . '.php', 'req/', true)){
|
||||
spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS);
|
||||
// ne plus reessayer
|
||||
return $connexions[$index][$version] = array();
|
||||
}
|
||||
}
|
||||
$connexions[$index][$version] = $GLOBALS[$jeu];
|
||||
if ($old) return $connexions[$index];
|
||||
|
||||
$connexions[$index]['spip_connect_version'] = isset($GLOBALS['spip_connect_version']) ? $GLOBALS['spip_connect_version'] : 0;
|
||||
|
||||
// initialisation de l'alphabet utilise dans les connexions SQL
|
||||
// si l'installation l'a determine.
|
||||
// Celui du serveur principal l'impose aux serveurs secondaires
|
||||
// s'ils le connaissent
|
||||
|
||||
if (!$serveur) {
|
||||
$charset = spip_connect_main($GLOBALS[$jeu]);
|
||||
if (!$charset) {
|
||||
unset($connexions[$index]);
|
||||
spip_log("spip_connect: absence de charset", _LOG_AVERTISSEMENT);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// spip_meta n'existe pas toujours dans la base
|
||||
// C'est le cas d'un dump sqlite par exemple
|
||||
if ($connexions[$index]['spip_connect_version']
|
||||
AND sql_showtable('spip_meta', true, $serveur)
|
||||
AND $r = sql_getfetsel('valeur', 'spip_meta', "nom='charset_sql_connexion'",'','','','',$serveur))
|
||||
$charset = $r;
|
||||
else $charset = -1;
|
||||
}
|
||||
if ($charset != -1) {
|
||||
$f = $GLOBALS[$jeu]['set_charset'];
|
||||
if (function_exists($f))
|
||||
$f($charset, $serveur);
|
||||
}
|
||||
return $connexions[$index];
|
||||
}
|
||||
|
||||
function spip_sql_erreur($serveur='')
|
||||
{
|
||||
$connexion = spip_connect($serveur);
|
||||
$e = sql_errno($serveur);
|
||||
$t = (isset($connexion['type']) ? $connexion['type'] : 'sql');
|
||||
$m = "Erreur $e de $t: " . sql_error($serveur) . "\n" . $connexion['last'];
|
||||
$f = $t . $serveur;
|
||||
spip_log($m, $f.'.'._LOG_ERREUR);
|
||||
}
|
||||
|
||||
// Cette fonction ne doit etre appelee qu'a travers la fonction sql_serveur
|
||||
// definie dans base/abstract_sql
|
||||
// Elle existe en tant que gestionnaire de versions,
|
||||
// connue seulement des convertisseurs automatiques
|
||||
|
||||
// http://doc.spip.org/@spip_connect_sql
|
||||
function spip_connect_sql($version, $ins='', $serveur='', $cont=false) {
|
||||
$desc = spip_connect($serveur, $version);
|
||||
if (function_exists($f = @$desc[$version][$ins])) return $f;
|
||||
if ($cont) return $desc;
|
||||
if ($ins)
|
||||
spip_log("Le serveur '$serveur' version $version n'a pas '$ins'", _LOG_ERREUR);
|
||||
include_spip('inc/minipres');
|
||||
echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'));
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction appelee par le fichier cree dans config/ a l'instal'.
|
||||
* Il contient un appel direct a cette fonction avec comme arguments
|
||||
* les identifants de connexion.
|
||||
* Si la connexion reussit, la globale db_ok memorise sa description.
|
||||
* C'est un tableau egalement retourne en valeur, pour les appels a l'install'
|
||||
*
|
||||
* http://doc.spip.org/@spip_connect_db
|
||||
*
|
||||
* @param string $host
|
||||
* @param string $port
|
||||
* @param string $login
|
||||
* @param string $pass
|
||||
* @param string $db
|
||||
* @param string $type
|
||||
* @param string $prefixe
|
||||
* @param string $auth
|
||||
* @return array
|
||||
*/
|
||||
function spip_connect_db($host, $port, $login, $pass, $db='', $type='mysql', $prefixe='', $auth='') {
|
||||
global $db_ok;
|
||||
|
||||
// temps avant nouvelle tentative de connexion
|
||||
// suite a une connection echouee
|
||||
if (!defined('_CONNECT_RETRY_DELAY'))
|
||||
define('_CONNECT_RETRY_DELAY',30);
|
||||
|
||||
$f = "";
|
||||
// un fichier de identifiant par combinaison (type,host,port,db)
|
||||
// pour ne pas declarer tout indisponible d'un coup
|
||||
// si en cours d'installation ou si db=@test@ on ne pose rien
|
||||
// car c'est un test de connexion
|
||||
if (!defined('_ECRIRE_INSTALL') AND !$db=="@test@")
|
||||
$f = _DIR_TMP . $type . '.' . substr(md5($host.$port.$db),0,8) . '.out';
|
||||
elseif ($db=='@test@')
|
||||
$db = '';
|
||||
|
||||
if ($f
|
||||
AND @file_exists($f)
|
||||
AND (time() - @filemtime($f) < _CONNECT_RETRY_DELAY)) {
|
||||
spip_log( "Echec : $f recent. Pas de tentative de connexion", _LOG_HS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$prefixe)
|
||||
$prefixe = isset($GLOBALS['table_prefix'])
|
||||
? $GLOBALS['table_prefix'] : $db;
|
||||
$h = charger_fonction($type, 'req', true);
|
||||
if (!$h) {
|
||||
spip_log( "les requetes $type ne sont pas fournies", _LOG_HS);
|
||||
return;
|
||||
}
|
||||
if ($g = $h($host, $port, $login, $pass, $db, $prefixe)) {
|
||||
|
||||
if (!is_array($auth)) {
|
||||
// compatibilite version 0.7 initiale
|
||||
$g['ldap'] = $auth;
|
||||
$auth = array('ldap' => $auth);
|
||||
}
|
||||
$g['authentification'] = $auth;
|
||||
$g['type'] = $type;
|
||||
return $db_ok = $g;
|
||||
}
|
||||
// En cas d'indisponibilite du serveur, eviter de le bombarder
|
||||
if ($f) {
|
||||
@touch($f);
|
||||
spip_log( "Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type.'.'._LOG_HS);
|
||||
}
|
||||
}
|
||||
|
||||
// Premiere connexion au serveur principal:
|
||||
// retourner le charset donnee par la table principale
|
||||
// mais verifier que le fichier de connexion n'est pas trop vieux
|
||||
// Version courante = 0.7
|
||||
// La version 0.7 indique un serveur d'authentification comme 8e arg
|
||||
// La version 0.6 indique le prefixe comme 7e arg
|
||||
// La version 0.5 indique le serveur comme 6e arg
|
||||
//
|
||||
// La version 0.0 (non numerotee) doit etre refaite par un admin
|
||||
// les autres fonctionnent toujours, meme si :
|
||||
// - la version 0.1 est moins performante que la 0.2
|
||||
// - la 0.2 fait un include_ecrire('inc_db_mysql.php3').
|
||||
|
||||
// http://doc.spip.org/@spip_connect_main
|
||||
function spip_connect_main($connexion)
|
||||
{
|
||||
if ($GLOBALS['spip_connect_version']< 0.1 AND _DIR_RESTREINT){
|
||||
include_spip('inc/headers');
|
||||
redirige_url_ecrire('upgrade', 'reinstall=oui');
|
||||
}
|
||||
|
||||
if (!($f = $connexion['select'])) return false;
|
||||
// en cas d'erreur select retourne la requette (is_string=true donc)
|
||||
if (!$r = $f('valeur','spip_meta', "nom='charset_sql_connexion'")
|
||||
OR is_string($r))
|
||||
return false;
|
||||
if (!($f = $connexion['fetch'])) return false;
|
||||
$r = $f($r);
|
||||
return ($r['valeur'] ? $r['valeur'] : -1);
|
||||
}
|
||||
|
||||
// compatibilite
|
||||
function spip_connect_ldap($serveur='') {
|
||||
include_spip('auth/ldap');
|
||||
return auth_ldap_connect($serveur);
|
||||
}
|
||||
|
||||
// Echappement d'une valeur (num, string, array) sous forme de chaine PHP
|
||||
// pour un array(1,'a',"a'") renvoie la chaine "'1','a','a\''"
|
||||
// Usage sql un peu deprecie, a remplacer par sql_quote()
|
||||
// http://doc.spip.org/@_q
|
||||
function _q ($a) {
|
||||
return (is_numeric($a)) ? strval($a) :
|
||||
(!is_array($a) ? ("'" . addslashes($a) . "'")
|
||||
: join(",", array_map('_q', $a)));
|
||||
}
|
||||
|
||||
|
||||
// Recuperer le nom de la table de jointure xxxx sur l'objet yyyy
|
||||
// http://doc.spip.org/@table_jointure
|
||||
function table_jointure($x, $y) {
|
||||
$trouver_table = charger_fonction('trouver_table', 'base');
|
||||
$xdesc = $trouver_table(table_objet($x));
|
||||
$ydesc = $trouver_table(table_objet($y));
|
||||
$ix = @$xdesc['key']["PRIMARY KEY"];
|
||||
$iy = @$ydesc['key']["PRIMARY KEY"];
|
||||
if ($table = $ydesc['tables_jointures'][$ix]) return $table;
|
||||
if ($table = $xdesc['tables_jointures'][$iy]) return $table;
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Echapper les textes entre ' ' ou " " d'une requete SQL
|
||||
* avant son pre-traitement
|
||||
* On renvoi la query sans textes et les textes separes, dans
|
||||
* leur ordre d'apparition dans la query
|
||||
*
|
||||
* @param string $query
|
||||
* @return array
|
||||
*/
|
||||
function query_echappe_textes($query){
|
||||
static $codeEchappements = array("''"=>"\x1@##@\x1", "\'"=>"\x2@##@\x2", "\\\""=>"\x3@##@\x3");
|
||||
$query = str_replace(array_keys($codeEchappements), array_values($codeEchappements), $query);
|
||||
if (preg_match_all("/((['])[^']*(\\2))|(([\"])[^\"]*(\\5))/S",$query,$textes)){
|
||||
$textes = reset($textes); // indice 0 du match
|
||||
switch(count($textes)){
|
||||
case 0:$replace=array();break;
|
||||
case 1:$replace=array('%1$s');break;
|
||||
case 2:$replace=array('%1$s','%2$s');break;
|
||||
case 3:$replace=array('%1$s','%2$s','%3$s');break;
|
||||
case 4:$replace=array('%1$s','%2$s','%3$s','%4$s');break;
|
||||
case 5:$replace=array('%1$s','%2$s','%3$s','%4$s','%5$s');break;
|
||||
default:
|
||||
$replace = range(1,count($textes));
|
||||
$replace = '%'.implode('$s,%',$replace).'$s';
|
||||
$replace = explode(',',$replace);
|
||||
break;
|
||||
}
|
||||
$query = str_replace($textes,$replace,$query);
|
||||
}
|
||||
else
|
||||
$textes = array();
|
||||
|
||||
return array($query, $textes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinjecter les textes d'une requete SQL a leur place initiale,
|
||||
* apres traitement de la requete
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $textes
|
||||
* @return string
|
||||
*/
|
||||
function query_reinjecte_textes($query, $textes){
|
||||
static $codeEchappements = array("''"=>"\x1@##@\x1", "\'"=>"\x2@##@\x2", "\\\""=>"\x3@##@\x3");
|
||||
# debug de la substitution
|
||||
#if (($c1=substr_count($query,"%"))!=($c2=count($textes))){
|
||||
# spip_log("$c1 ::". $query,"tradquery"._LOG_ERREUR);
|
||||
# spip_log("$c2 ::". var_export($textes,1),"tradquery"._LOG_ERREUR);
|
||||
# spip_log("ini ::". $qi,"tradquery"._LOG_ERREUR);
|
||||
#}
|
||||
switch (count($textes)){
|
||||
case 0:break;
|
||||
case 1:$query=sprintf($query,$textes[0]);break;
|
||||
case 2:$query=sprintf($query,$textes[0],$textes[1]);break;
|
||||
case 3:$query=sprintf($query,$textes[0],$textes[1],$textes[2]);break;
|
||||
case 4:$query=sprintf($query,$textes[0],$textes[1],$textes[2],$textes[3]);break;
|
||||
case 5:$query=sprintf($query,$textes[0],$textes[1],$textes[2],$textes[3],$textes[4]);break;
|
||||
default:
|
||||
array_unshift($textes,$query);
|
||||
$query = call_user_func_array('sprintf',$textes);
|
||||
break;
|
||||
}
|
||||
|
||||
$query = str_replace(array_values($codeEchappements), array_keys($codeEchappements), $query);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
// Pour compatibilite. Ne plus utiliser.
|
||||
// http://doc.spip.org/@spip_query
|
||||
function spip_query($query, $serveur='') {
|
||||
global $spip_sql_version;
|
||||
$f = spip_connect_sql($spip_sql_version, 'query', $serveur, true);
|
||||
return function_exists($f) ? $f($query, $serveur) : false;
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,176 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/acces');
|
||||
include_spip('base/objets');
|
||||
include_spip('base/typedoc');
|
||||
include_spip('base/abstract_sql');
|
||||
|
||||
/**
|
||||
* Determiner le flag autoinc pour une table
|
||||
* en fonction de si c'est une table principale
|
||||
*
|
||||
* @param string $table
|
||||
* @param array $desc
|
||||
* @return bool
|
||||
*/
|
||||
function base_determine_autoinc($table,$desc=array()){
|
||||
if ($t=lister_tables_principales() AND isset($t[$table]))
|
||||
$autoinc = true;
|
||||
elseif ($t=lister_tables_auxiliaires() AND isset($t[$table]))
|
||||
$autoinc = false;
|
||||
else {
|
||||
// essayer de faire au mieux !
|
||||
$autoinc = (isset($desc['key']['PRIMARY KEY'])
|
||||
AND strpos($desc['key']['PRIMARY KEY'],',')===false
|
||||
AND strpos($desc['field'][$desc['key']['PRIMARY KEY']],'default')===false);
|
||||
}
|
||||
return $autoinc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creer une table,
|
||||
* ou ajouter les champs manquants si elle existe deja
|
||||
*
|
||||
* http://doc.spip.org/@creer_ou_upgrader_table
|
||||
*
|
||||
* @param string $table
|
||||
* @param array $desc
|
||||
* @param bool|string $autoinc
|
||||
* 'auto' pour detecter automatiquement si le champ doit etre autoinc ou non
|
||||
* en fonction de la table
|
||||
* @param bool $upgrade
|
||||
* @param string $serveur
|
||||
* @return void
|
||||
*/
|
||||
function creer_ou_upgrader_table($table,$desc,$autoinc,$upgrade=false,$serveur='') {
|
||||
#spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE);
|
||||
$sql_desc = $upgrade ? sql_showtable($table,true,$serveur) : false;
|
||||
#if (!$sql_desc) $sql_desc = false;
|
||||
#spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE);
|
||||
if (!$sql_desc) {
|
||||
if ($autoinc==='auto')
|
||||
$autoinc = base_determine_autoinc($table,$desc);
|
||||
#spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE);
|
||||
sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur);
|
||||
// verifier la bonne installation de la table (php-fpm es-tu la ?)
|
||||
$sql_desc = sql_showtable($table,true,$serveur);
|
||||
#if (!$sql_desc) $sql_desc = false;
|
||||
#spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE);
|
||||
if (!$sql_desc){
|
||||
// on retente avec un sleep ?
|
||||
sleep(1);
|
||||
sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur);
|
||||
$sql_desc = sql_showtable($table,true,$serveur);
|
||||
#if (!$sql_desc) $sql_desc = false;
|
||||
#spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE);
|
||||
if (!$sql_desc){
|
||||
spip_log("Echec creation table $table","maj"._LOG_CRITIQUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
#spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE);
|
||||
// ajouter les champs manquants
|
||||
// on ne supprime jamais les champs, car c'est dangereux
|
||||
// c'est toujours a faire manuellement
|
||||
$last = '';
|
||||
foreach($desc['field'] as $field=>$type){
|
||||
if (!isset($sql_desc['field'][$field]))
|
||||
sql_alter("TABLE $table ADD $field $type".($last?" AFTER $last":""),$serveur);
|
||||
$last = $field;
|
||||
}
|
||||
foreach($desc['key'] as $key=>$type){
|
||||
// Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees
|
||||
// par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY"
|
||||
if (!isset($sql_desc['key'][$key]) AND !isset($sql_desc['key']["$key $type"]))
|
||||
sql_alter("TABLE $table ADD $key ($type)",$serveur);
|
||||
$last = $field;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creer ou mettre a jour un ensemble de tables
|
||||
* en fonction du flag $up
|
||||
*
|
||||
* @param array $tables_inc
|
||||
* tables avec autoincrement sur la cle primaire
|
||||
* @param $tables_noinc
|
||||
* tables sans autoincrement sur la cle primaire
|
||||
* @param bool|array $up
|
||||
* upgrader (true) ou creer (false)
|
||||
* si un tableau de table est fournie, seules l'intersection de ces tables
|
||||
* et des $tables_inc / $tables_noinc seront traitees
|
||||
* @param string $serveur
|
||||
* serveur sql
|
||||
* @return void
|
||||
*/
|
||||
function alterer_base($tables_inc, $tables_noinc, $up=false, $serveur='')
|
||||
{
|
||||
if ($up === false) {
|
||||
$old = false;
|
||||
$up = array();
|
||||
} else {
|
||||
$old = true;
|
||||
if (!is_array($up)) $up = array($up);
|
||||
}
|
||||
foreach($tables_inc as $k => $v)
|
||||
if (!$old OR in_array($k, $up))
|
||||
creer_ou_upgrader_table($k,$v,true,$old,$serveur);
|
||||
|
||||
foreach($tables_noinc as $k => $v)
|
||||
if (!$old OR in_array($k, $up))
|
||||
creer_ou_upgrader_table($k,$v,false,$old,$serveur);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creer une base de donnee
|
||||
* a partir des tables principales et auxiliaires
|
||||
*
|
||||
* http://doc.spip.org/@creer_base
|
||||
*
|
||||
* @param string $serveur
|
||||
* @return void
|
||||
*/
|
||||
function creer_base($serveur='') {
|
||||
|
||||
// Note: les mises a jour reexecutent ce code pour s'assurer
|
||||
// de la conformite de la base
|
||||
// pas de panique sur "already exists" et "duplicate entry" donc.
|
||||
|
||||
alterer_base(lister_tables_principales(),
|
||||
lister_tables_auxiliaires(),
|
||||
false,
|
||||
$serveur);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mettre a jour une liste de tables,
|
||||
* fonction facilitatrice utilisee pour les maj de base
|
||||
* dans les plugins
|
||||
*
|
||||
* @param array $upgrade_tables
|
||||
* @param string $serveur
|
||||
* @return void
|
||||
*/
|
||||
function maj_tables($upgrade_tables=array(),$serveur=''){
|
||||
alterer_base(lister_tables_principales(),
|
||||
lister_tables_auxiliaires(),
|
||||
$upgrade_tables,
|
||||
$serveur);
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@base_delete_all_dist
|
||||
function base_delete_all_dist($titre)
|
||||
{
|
||||
$delete = _request('delete');
|
||||
$res = array();
|
||||
if (is_array($delete)) {
|
||||
foreach ($delete as $table) {
|
||||
if (sql_drop_table($table))
|
||||
$res[] = $table;
|
||||
else spip_log( "SPIP n'a pas pu detruire $table.", _LOG_ERREUR);
|
||||
}
|
||||
|
||||
// un pipeline pour detruire les tables installees par les plugins
|
||||
pipeline('delete_tables', '');
|
||||
|
||||
spip_unlink(_FILE_CONNECT);
|
||||
spip_unlink(_FILE_CHMOD);
|
||||
spip_unlink(_FILE_META);
|
||||
spip_unlink(_ACCESS_FILE_NAME);
|
||||
spip_unlink(_CACHE_RUBRIQUES);
|
||||
}
|
||||
$d = count($delete);
|
||||
$r = count($res);
|
||||
spip_log("Tables detruites: $r sur $d: " . join(', ',$res), _LOG_INFO_IMPORTANTE);
|
||||
}
|
||||
?>
|
|
@ -1,663 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
/**
|
||||
*
|
||||
* Fonctions de base pour la sauvegarde
|
||||
* Boite a outil commune, sans prejuger de la methode de sauvegarde
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
define('_VERSION_ARCHIVE', '1.3');
|
||||
|
||||
include_spip('base/serial');
|
||||
include_spip('base/auxiliaires');
|
||||
include_spip('public/interfaces'); // pour table_jointures
|
||||
|
||||
// NB: Ce fichier peut ajouter des tables (old-style)
|
||||
// donc il faut l'inclure "en globals"
|
||||
if ($f = find_in_path('mes_fonctions.php')) {
|
||||
global $dossier_squelettes;
|
||||
@include_once (_ROOT_CWD . $f);
|
||||
}
|
||||
|
||||
if (@is_readable(_CACHE_PLUGINS_FCT)){
|
||||
// chargement optimise precompile
|
||||
include_once(_CACHE_PLUGINS_FCT);
|
||||
}
|
||||
|
||||
function base_dump_meta_name($rub){
|
||||
return $meta = "status_dump_{$rub}_" . abs($GLOBALS['visiteur_session']['id_auteur']);
|
||||
}
|
||||
function base_dump_dir($meta){
|
||||
include_spip('inc/documents');
|
||||
// determine upload va aussi initialiser l'index "restreint"
|
||||
$maindir = determine_upload();
|
||||
if (!$GLOBALS['visiteur_session']['restreint'])
|
||||
$maindir = _DIR_DUMP;
|
||||
$dir = sous_repertoire($maindir, $meta);
|
||||
return $dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lister toutes les tables d'un serveur
|
||||
* en excluant eventuellement une liste fournie
|
||||
*
|
||||
* @param string $serveur
|
||||
* @param array $tables
|
||||
* @param array $exclude
|
||||
* @param bool $affiche_vrai_prefixe
|
||||
* @return array
|
||||
*/
|
||||
function base_lister_toutes_tables($serveur='', $tables=array(), $exclude = array(),$affiche_vrai_prefixe=false) {
|
||||
spip_connect($serveur);
|
||||
$connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
|
||||
$prefixe = $connexion['prefixe'];
|
||||
|
||||
$p = '/^' . $prefixe . '/';
|
||||
$res = $tables;
|
||||
foreach(sql_alltable(null,$serveur) as $t) {
|
||||
if (preg_match($p, $t)) {
|
||||
$t1 = preg_replace($p, 'spip', $t);
|
||||
if (!in_array($t1, $tables) AND !in_array($t1, $exclude))
|
||||
$res[]= ($affiche_vrai_prefixe?$t:$t1);
|
||||
}
|
||||
}
|
||||
sort($res);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrouver le prefixe des tables
|
||||
* @param string $serveur
|
||||
* @return string
|
||||
*/
|
||||
function base_prefixe_tables($serveur=''){
|
||||
spip_connect($serveur);
|
||||
$connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
|
||||
$prefixe = $connexion['prefixe'];
|
||||
return $prefixe;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fabrique la liste a cocher des tables a traiter (copie, delete, sauvegarde)
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $tables
|
||||
* @param array $exclude
|
||||
* @param array|null $post
|
||||
* @param string $serveur
|
||||
* @return array
|
||||
*/
|
||||
function base_saisie_tables($name, $tables, $exclude = array(), $post=null, $serveur='') {
|
||||
include_spip('inc/filtres');
|
||||
$res = array();
|
||||
foreach ($tables as $k => $t) {
|
||||
// par defaut tout est coche sauf les tables dans $exclude
|
||||
if (is_null($post))
|
||||
$check = (in_array($t,$exclude)?false:true);
|
||||
// mais si on a poste une selection, la reprendre
|
||||
else
|
||||
$check = in_array($t,$post);
|
||||
|
||||
$res[$k] = "<input type='checkbox' value='$t' name='$name"
|
||||
. "[]' id='$name$k'"
|
||||
. ($check ? " checked='checked'" : '')
|
||||
. "/>\n"
|
||||
. "<label for='$name$k'>".$t."</label>"
|
||||
. " ("
|
||||
. sinon(singulier_ou_pluriel(sql_countsel($t,'','','',$serveur), 'dump:une_donnee', 'dump:nb_donnees'),_T('dump:aucune_donnee'))
|
||||
. ")";
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lister les tables non exportables par defaut
|
||||
* (liste completable par le pipeline lister_tables_noexport
|
||||
*
|
||||
* @staticvar array $EXPORT_tables_noexport
|
||||
* @return array
|
||||
*/
|
||||
function lister_tables_noexport(){
|
||||
// par defaut tout est exporte sauf les tables ci-dessous
|
||||
static $EXPORT_tables_noexport = null;
|
||||
if (!is_null($EXPORT_tables_noexport))
|
||||
return $EXPORT_tables_noexport;
|
||||
|
||||
$EXPORT_tables_noexport= array(
|
||||
'spip_caches', // plugin invalideur
|
||||
'spip_resultats', // resultats de recherche ... c'est un cache !
|
||||
'spip_test', // c'est un test !
|
||||
#'spip_referers',
|
||||
#'spip_referers_articles',
|
||||
#'spip_visites',
|
||||
#'spip_visites_articles',
|
||||
#'spip_versions',
|
||||
#'spip_versions_fragments'
|
||||
);
|
||||
|
||||
$EXPORT_tables_noexport = pipeline('lister_tables_noexport',$EXPORT_tables_noexport);
|
||||
return $EXPORT_tables_noexport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lister les tables non importables par defaut
|
||||
* (liste completable par le pipeline lister_tables_noimport
|
||||
*
|
||||
* @staticvar array $IMPORT_tables_noimport
|
||||
* @return array
|
||||
*/
|
||||
function lister_tables_noimport(){
|
||||
static $IMPORT_tables_noimport=null;
|
||||
if (!is_null($IMPORT_tables_noimport))
|
||||
return $IMPORT_tables_noimport;
|
||||
|
||||
$IMPORT_tables_noimport = array();
|
||||
// par defaut tout est importe sauf les tables ci-dessous
|
||||
// possibiliter de definir cela tables via la meta
|
||||
// compatibilite
|
||||
if (isset($GLOBALS['meta']['IMPORT_tables_noimport'])){
|
||||
$IMPORT_tables_noimport = unserialize($GLOBALS['meta']['IMPORT_tables_noimport']);
|
||||
if (!is_array($IMPORT_tables_noimport)){
|
||||
include_spip('inc/meta');
|
||||
effacer_meta('IMPORT_tables_noimport');
|
||||
}
|
||||
}
|
||||
$IMPORT_tables_noimport = pipeline('lister_tables_noimport',$IMPORT_tables_noimport);
|
||||
return $IMPORT_tables_noimport;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lister les tables a ne pas effacer
|
||||
* (liste completable par le pipeline lister_tables_noerase
|
||||
*
|
||||
* @staticvar array $IMPORT_tables_noerase
|
||||
* @return array
|
||||
*/
|
||||
function lister_tables_noerase(){
|
||||
static $IMPORT_tables_noerase=null;
|
||||
if (!is_null($IMPORT_tables_noerase))
|
||||
return $IMPORT_tables_noerase;
|
||||
|
||||
$IMPORT_tables_noerase = array(
|
||||
'spip_meta',
|
||||
// par defaut on ne vide pas les stats, car elles ne figurent pas dans les dump
|
||||
// et le cas echeant, un bouton dans l'admin permet de les vider a la main...
|
||||
'spip_referers',
|
||||
'spip_referers_articles',
|
||||
'spip_visites',
|
||||
'spip_visites_articles'
|
||||
);
|
||||
$IMPORT_tables_noerase = pipeline('lister_tables_noerase',$IMPORT_tables_noerase);
|
||||
return $IMPORT_tables_noerase;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* construction de la liste des tables pour le dump :
|
||||
* toutes les tables principales
|
||||
* + toutes les tables auxiliaires hors relations
|
||||
* + les tables relations dont les deux tables liees sont dans la liste
|
||||
*
|
||||
* @param array $exclude_tables
|
||||
* @return array
|
||||
*/
|
||||
function base_liste_table_for_dump($exclude_tables = array()){
|
||||
$tables_for_dump = array();
|
||||
$tables_pointees = array();
|
||||
$tables = array();
|
||||
$tables_principales = $GLOBALS['tables_principales'];
|
||||
$tables_auxiliaires = $GLOBALS['tables_auxiliaires'];
|
||||
$tables_jointures = $GLOBALS['tables_jointures'];
|
||||
|
||||
if (include_spip('base/objets')
|
||||
AND function_exists('lister_tables_objets_sql')){
|
||||
$tables = lister_tables_objets_sql();
|
||||
foreach($tables as $t=>$infos){
|
||||
if ($infos['principale'] AND !isset($tables_principales[$t]))
|
||||
$tables_principales[$t] = true;
|
||||
if (!$infos['principale'] AND !isset($tables_auxiliaires[$t]))
|
||||
$tables_auxiliaires[$t] = true;
|
||||
if (count($infos['tables_jointures']))
|
||||
$tables_jointures[$t] = array_merge(isset($tables_jointures[$t])?$tables_jointures[$t]:array(),$infos['tables_jointures']);
|
||||
}
|
||||
}
|
||||
|
||||
// on construit un index des tables de liens
|
||||
// pour les ajouter SI les deux tables qu'ils connectent sont sauvegardees
|
||||
$tables_for_link = array();
|
||||
foreach($tables_jointures as $table => $liste_relations)
|
||||
if (is_array($liste_relations))
|
||||
{
|
||||
$nom = $table;
|
||||
if (!isset($tables_auxiliaires[$nom])&&!isset($tables_principales[$nom]))
|
||||
$nom = "spip_$table";
|
||||
if (isset($tables_auxiliaires[$nom])||isset($tables_principales[$nom])){
|
||||
foreach($liste_relations as $link_table){
|
||||
if (isset($tables_auxiliaires[$link_table])/*||isset($tables_principales[$link_table])*/){
|
||||
$tables_for_link[$link_table][] = $nom;
|
||||
}
|
||||
else if (isset($tables_auxiliaires["spip_$link_table"])/*||isset($tables_principales["spip_$link_table"])*/){
|
||||
$tables_for_link["spip_$link_table"][] = $nom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$liste_tables = array_merge(array_keys($tables_principales),array_keys($tables_auxiliaires),array_keys($tables));
|
||||
foreach($liste_tables as $table){
|
||||
// $name = preg_replace("{^spip_}","",$table);
|
||||
if ( !isset($tables_pointees[$table])
|
||||
&& !in_array($table,$exclude_tables)
|
||||
&& !isset($tables_for_link[$table])){
|
||||
$tables_for_dump[] = $table;
|
||||
$tables_pointees[$table] = 1;
|
||||
}
|
||||
}
|
||||
foreach ($tables_for_link as $link_table =>$liste){
|
||||
$connecte = true;
|
||||
foreach($liste as $connect_table)
|
||||
if (!in_array($connect_table,$tables_for_dump))
|
||||
$connecte = false;
|
||||
if ($connecte)
|
||||
# on ajoute les liaisons en premier
|
||||
# si une restauration est interrompue,
|
||||
# cela se verra mieux si il manque des objets
|
||||
# que des liens
|
||||
array_unshift($tables_for_dump,$link_table);
|
||||
}
|
||||
return array($tables_for_dump, $tables_for_link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vider les tables de la base de destination
|
||||
* pour la copie dans une base
|
||||
*
|
||||
* peut etre utilise pour l'import depuis xml,
|
||||
* ou la copie de base a base (mysql<->sqlite par exemple)
|
||||
*
|
||||
* @param array $tables
|
||||
* @param array $exclure_tables
|
||||
* @param string $serveur
|
||||
*/
|
||||
function base_vider_tables_destination_copie($tables, $exclure_tables = array(), $serveur=''){
|
||||
$trouver_table = charger_fonction('trouver_table', 'base');
|
||||
|
||||
spip_log('Vider '.count($tables) . " tables sur serveur '$serveur' : " . join(', ', $tables),'base.'._LOG_INFO_IMPORTANTE);
|
||||
foreach($tables as $table){
|
||||
if (!in_array($table,$exclure_tables)){
|
||||
// sur le serveur principal, il ne faut pas supprimer l'auteur loge !
|
||||
if (($table!='spip_auteurs') OR $serveur!=''){
|
||||
// regarder si il y a au moins un champ impt='non'
|
||||
$desc = $trouver_table($table,$serveur);
|
||||
if (isset($desc['field']['impt'])){
|
||||
sql_delete($table, "impt='oui'", $serveur);
|
||||
}
|
||||
else{
|
||||
sql_delete($table, "", $serveur);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sur le serveur principal, il ne faut pas supprimer l'auteur loge !
|
||||
// Bidouille pour garder l'acces admin actuel pendant toute la restauration
|
||||
if ($serveur==''
|
||||
AND in_array('spip_auteurs',$tables)
|
||||
AND !in_array('spip_auteurs',$exclure_tables)) {
|
||||
base_conserver_copieur(true, $serveur);
|
||||
sql_delete("spip_auteurs", "id_auteur>0",$serveur);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Conserver le copieur si besoin
|
||||
* @param bool $move
|
||||
* @param string $serveur
|
||||
* @return void
|
||||
*/
|
||||
function base_conserver_copieur($move = true,$serveur=''){
|
||||
// s'asurer qu'on a pas deja fait la manip !
|
||||
if ($GLOBALS['visiteur_session']['id_auteur']>0 AND sql_countsel("spip_auteurs", "id_auteur>0")) {
|
||||
spip_log('Conserver copieur '.$GLOBALS['visiteur_statut']['id_auteur'] . " dans id_auteur=".$GLOBALS['visiteur_statut']['id_auteur']." pour le serveur '$serveur'",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
sql_delete("spip_auteurs", "id_auteur<0",$serveur);
|
||||
if ($move){
|
||||
sql_updateq('spip_auteurs', array('id_auteur'=>-$GLOBALS['visiteur_session']['id_auteur']), "id_auteur=".intval($GLOBALS['visiteur_session']['id_auteur']),array(),$serveur);
|
||||
}
|
||||
else {
|
||||
$row = sql_fetsel('*','spip_auteurs','id_auteur='.$GLOBALS['visiteur_session']['id_auteur'],'','','','',$serveur);
|
||||
$row['id_auteur'] = -$GLOBALS['visiteur_session']['id_auteur'];
|
||||
sql_insertq('spip_auteurs',$row,array(),$serveur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Effacement de la bidouille ci-dessus
|
||||
* Toutefois si la table des auteurs ne contient plus qu'elle
|
||||
* c'est que la copie etait incomplete et on restaure le compte
|
||||
* pour garder la connection au site
|
||||
*
|
||||
* (mais il doit pas etre bien beau
|
||||
* et ca ne marche que si l'id_auteur est sur moins de 3 chiffres)
|
||||
*
|
||||
* @param string $serveur
|
||||
*/
|
||||
function base_detruire_copieur_si_besoin($serveur='')
|
||||
{
|
||||
// rien a faire si ce n'est pas le serveur principal !
|
||||
if ($serveur=='') {
|
||||
if (sql_countsel("spip_auteurs", "id_auteur>0")) {
|
||||
spip_log("Detruire copieur id_auteur<0 pour le serveur '$serveur'",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
sql_delete("spip_auteurs", "id_auteur<0", $serveur);
|
||||
}
|
||||
else {
|
||||
spip_log( "Restaurer copieur id_auteur<0 pour le serveur '$serveur' (aucun autre auteur en base)",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
sql_update('spip_auteurs', array('id_auteur'=>'-id_auteur'), "id_auteur<0");
|
||||
}
|
||||
}
|
||||
else
|
||||
spip_log("Pas de destruction copieur sur serveur '$serveur'",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preparer la table dans la base de destination :
|
||||
* la droper si elle existe (sauf si auteurs ou meta sur le serveur principal)
|
||||
* la creer si necessaire, ou ajouter simplement les champs manquants
|
||||
*
|
||||
* @param string $table
|
||||
* @param array $desc
|
||||
* @param string $serveur_dest
|
||||
* @param bool $init
|
||||
* @return array
|
||||
*/
|
||||
function base_preparer_table_dest($table, $desc, $serveur_dest, $init=false) {
|
||||
$upgrade = false;
|
||||
// si la table existe et qu'on est a l'init, la dropper
|
||||
if ($desc_dest=sql_showtable($table,true,$serveur_dest) AND $init) {
|
||||
if ($serveur_dest=='' AND in_array($table,array('spip_meta','spip_auteurs'))) {
|
||||
// ne pas dropper auteurs et meta sur le serveur principal
|
||||
// faire un simple upgrade a la place
|
||||
// pour ajouter les champs manquants
|
||||
$upgrade = true;
|
||||
// coherence avec le drop sur les autres tables
|
||||
base_vider_tables_destination_copie(array($table),array(),$serveur_dest);
|
||||
if ($table=='spip_meta'){
|
||||
// virer les version base qui vont venir avec l'import
|
||||
sql_delete($table, "nom like '%_base_version'",$serveur_dest);
|
||||
// hum casse la base si pas version_installee a l'import ...
|
||||
sql_delete($table, "nom='version_installee'",$serveur_dest);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sql_drop_table($table, '', $serveur_dest);
|
||||
spip_log( "drop table '$table' sur serveur '$serveur_dest'",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
}
|
||||
$desc_dest = false;
|
||||
}
|
||||
// si la table n'existe pas dans la destination, la creer a l'identique !
|
||||
if (!$desc_dest) {
|
||||
spip_log( "creation '$table' sur serveur '$serveur_dest'",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
include_spip('base/create');
|
||||
creer_ou_upgrader_table($table, $desc, 'auto', $upgrade,$serveur_dest);
|
||||
$desc_dest = sql_showtable($table,true,$serveur_dest);
|
||||
}
|
||||
if (!$desc_dest){
|
||||
spip_log( "Erreur creation '$table' sur serveur '$serveur_dest'".var_export($desc,1),'dump.'._LOG_ERREUR);
|
||||
}
|
||||
|
||||
return $desc_dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copier de base a base
|
||||
*
|
||||
* @param string $status_file
|
||||
* nom avec chemin complet du fichier ou est stocke le status courant
|
||||
* @param array $tables
|
||||
* liste des tables a copier
|
||||
* @param string $serveur_source
|
||||
* @param string $serveur_dest
|
||||
* @param array $options
|
||||
* parametres optionnels sous forme de tableau :
|
||||
* param string $callback_progression
|
||||
* fonction a appeler pour afficher la progression, avec les arguments (compteur,total,table)
|
||||
* param int $max_time
|
||||
* limite de temps au dela de laquelle sortir de la fonction proprement (de la forme time()+15)
|
||||
* param bool $drop_source
|
||||
* vider les tables sources apres copie
|
||||
* param array $no_erase_dest
|
||||
* liste des tables a ne pas vider systematiquement (ne seront videes que si existent dans la base source)
|
||||
* param array $where
|
||||
* liste optionnelle de condition where de selection des donnees pour chaque table
|
||||
* param string $racine_fonctions_dest
|
||||
* racine utilisee pour charger_fonction() des operations elementaires sur la base de destination.
|
||||
* Permet de deleguer vers une autre voie de communication.
|
||||
* Par defaut on utilise 'base', ce qui route vers les fonctions de ce fichier. Concerne :
|
||||
* - vider_tables_destination_copie
|
||||
* - preparer_table_dest
|
||||
* - detruire_copieur_si_besoin
|
||||
* - inserer_copie
|
||||
* param array $fonction_base_inserer
|
||||
* fonction d'insertion en base. Par defaut "inserer_copie" qui fait un insertq a l'identique.
|
||||
* Attention, la fonction appelee est prefixee par $racine_fonctions_dest via un charger_fonction()
|
||||
* Peut etre personalisee pour filtrer, renumeroter....
|
||||
* param array $desc_tables_dest
|
||||
* description des tables de destination a utiliser de preference a la description de la table source
|
||||
* param int data_pool
|
||||
* nombre de ko de donnees a envoyer d'un coup en insertion dans la table cible (par defaut 1)
|
||||
* permet des envois groupes pour plus de rapidite, notamment si l'insertion est distante
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function base_copier_tables($status_file, $tables, $serveur_source, $serveur_dest, $options=array()){
|
||||
|
||||
$callback_progression = isset($options['callback_progression'])?$options['callback_progression']:'';
|
||||
$max_time = isset($options['max_time'])?$options['max_time']:0;
|
||||
$drop_source = isset($options['drop_source'])?$options['drop_source']:false;
|
||||
$no_erase_dest = isset($options['no_erase_dest'])?$options['no_erase_dest']:array();
|
||||
$where = isset($options['where'])?$options['where']:array();
|
||||
$fonction_base_inserer = isset($options['fonction_base_inserer'])?$options['fonction_base_inserer']:'inserer_copie';
|
||||
$desc_tables_dest = isset($options['desc_tables_dest'])?$options['desc_tables_dest']:array();
|
||||
$racine_fonctions = (isset($options['racine_fonctions_dest'])?$options['racine_fonctions_dest']:'base');
|
||||
$data_pool = (isset($options['data_pool'])?$options['data_pool']:50*1024);
|
||||
|
||||
spip_log( "Copier ".count($tables)." tables de '$serveur_source' vers '$serveur_dest'",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
|
||||
if (!$inserer_copie = charger_fonction($fonction_base_inserer,$racine_fonctions, true)) {
|
||||
spip_log( "Fonction '{$racine_fonctions}_$fonction_base_inserer' inconnue. Abandon",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
return true; // echec mais on a fini, donc true
|
||||
}
|
||||
if (!$preparer_table_dest = charger_fonction('preparer_table_dest',$racine_fonctions, true)) {
|
||||
spip_log( "Fonction '{$racine_fonctions}_$preparer_table_dest' inconnue. Abandon",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
return true; // echec mais on a fini, donc true
|
||||
}
|
||||
|
||||
if (!lire_fichier($status_file, $status)
|
||||
OR !$status = unserialize($status))
|
||||
$status = array();
|
||||
$status['etape'] = 'basecopie';
|
||||
|
||||
// puis relister les tables a importer
|
||||
// et les vider si besoin, au moment du premier passage ici
|
||||
$initialisation_copie = (!isset($status["dump_status_copie"])) ? 0 : $status["dump_status_copie"];
|
||||
|
||||
// si init pas encore faite, vider les tables du serveur destination
|
||||
if (!$initialisation_copie) {
|
||||
if (!$vider_tables_destination_copie = charger_fonction('vider_tables_destination_copie',$racine_fonctions, true)) {
|
||||
spip_log( "Fonction '{$racine_fonctions}_vider_tables_destination_copie' inconnue. Abandon",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
return true; // echec mais on a fini, donc true
|
||||
}
|
||||
$vider_tables_destination_copie($tables, $no_erase_dest, $serveur_dest);
|
||||
$status["dump_status_copie"]='ok';
|
||||
ecrire_fichier($status_file,serialize($status));
|
||||
}
|
||||
|
||||
// les tables auteurs et meta doivent etre copiees en dernier !
|
||||
if (in_array('spip_auteurs',$tables)){
|
||||
$tables = array_diff($tables,array('spip_auteurs'));
|
||||
$tables[] = 'spip_auteurs';
|
||||
}
|
||||
if (in_array('spip_meta',$tables)){
|
||||
$tables = array_diff($tables,array('spip_meta'));
|
||||
$tables[] = 'spip_meta';
|
||||
}
|
||||
spip_log( "Tables a copier :".implode(", ",$tables),'dump.'._LOG_INFO);
|
||||
|
||||
$trouver_table = charger_fonction('trouver_table','base');
|
||||
|
||||
foreach ($tables as $table){
|
||||
// si table commence par spip_ c'est une table SPIP, renommer le prefixe si besoin
|
||||
// sinon chercher la vraie table
|
||||
$desc_source = false;
|
||||
if (strncmp($table,"spip_",5)==0){
|
||||
$desc_source = $trouver_table(preg_replace(",^spip_,","",$table), $serveur_source, true);
|
||||
}
|
||||
if (!$desc_source OR !isset($desc_source['exist']) OR !$desc_source['exist'])
|
||||
$desc_source = $trouver_table($table, $serveur_source, false);
|
||||
|
||||
// verifier que la table est presente dans la base source
|
||||
if ($desc_source){
|
||||
// $status['tables_copiees'][$table] contient l'avancement
|
||||
// de la copie pour la $table : 0 a N et -N quand elle est finie (-1 si vide et finie...)
|
||||
if (!isset($status['tables_copiees'][$table]))
|
||||
$status['tables_copiees'][$table] = 0;
|
||||
|
||||
if (is_numeric($status['tables_copiees'][$table])
|
||||
AND $status['tables_copiees'][$table]>=0
|
||||
AND $desc_dest = $preparer_table_dest(
|
||||
$table,
|
||||
isset($desc_tables_dest[$table])?$desc_tables_dest[$table]:$desc_source,
|
||||
$serveur_dest,
|
||||
$status['tables_copiees'][$table] == 0)){
|
||||
if ($callback_progression)
|
||||
$callback_progression($status['tables_copiees'][$table],0,$table);
|
||||
while (true) {
|
||||
$n = intval($status['tables_copiees'][$table]);
|
||||
// on copie par lot de 400
|
||||
$res = sql_select('*',$table,isset($where[$table])?$where[$table]:'','','',"$n,400",'',$serveur_source);
|
||||
while ($row = sql_fetch($res,$serveur_source)){
|
||||
$rows = array($row);
|
||||
// lire un groupe de donnees si demande en option
|
||||
// (permet un envoi par lot vers la destination)
|
||||
if ($data_pool>0){
|
||||
$s = strlen(serialize($row));
|
||||
while ($s<$data_pool AND $row = sql_fetch($res,$serveur_source)){
|
||||
$s += strlen(serialize($row));
|
||||
$rows[]= $row;
|
||||
}
|
||||
}
|
||||
// si l'enregistrement est deja en base, ca fera un echec ou un doublon
|
||||
// mais si ca renvoie false c'est une erreur fatale => abandon
|
||||
if ($inserer_copie($table,$rows,$desc_dest,$serveur_dest)===false) {
|
||||
// forcer la sortie, charge a l'appelant de gerer l'echec
|
||||
spip_log("Erreur fatale dans $inserer_copie table $table","dump"._LOG_ERREUR);
|
||||
$status['errors'][] = "Erreur fatale lors de la copie de la table $table";
|
||||
ecrire_fichier($status_file,serialize($status));
|
||||
// copie finie
|
||||
return true;
|
||||
}
|
||||
$status['tables_copiees'][$table]+=count($rows);
|
||||
if ($max_time AND time()>$max_time)
|
||||
break;
|
||||
}
|
||||
if ($n == $status['tables_copiees'][$table])
|
||||
break;
|
||||
spip_log( "recopie $table ".$status['tables_copiees'][$table],'dump.'._LOG_INFO_IMPORTANTE);
|
||||
if ($callback_progression)
|
||||
$callback_progression($status['tables_copiees'][$table],0,$table);
|
||||
ecrire_fichier($status_file,serialize($status));
|
||||
if ($max_time AND time()>$max_time)
|
||||
return false; // on a pas fini, mais le temps imparti est ecoule
|
||||
}
|
||||
if ($drop_source) {
|
||||
sql_drop_table($table,'',$serveur_source);
|
||||
spip_log( "drop $table sur serveur source '$serveur_source'",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
}
|
||||
$status['tables_copiees'][$table]=($status['tables_copiees'][$table]?-$status['tables_copiees'][$table]:"zero");
|
||||
ecrire_fichier($status_file,serialize($status));
|
||||
spip_log( "tables_recopiees ".implode(',',$status['tables_copiees']),'dump.'._LOG_INFO);
|
||||
if ($callback_progression)
|
||||
$callback_progression($status['tables_copiees'][$table],$status['tables_copiees'][$table],$table);
|
||||
}
|
||||
else {
|
||||
if ($status['tables_copiees'][$table]<0)
|
||||
spip_log("Table $table deja copiee : ".$status['tables_copiees'][$table],"dump."._LOG_INFO);
|
||||
if ($callback_progression)
|
||||
$callback_progression(0,$status['tables_copiees'][$table],"$table".((is_numeric($status['tables_copiees'][$table]) AND $status['tables_copiees'][$table]>=0)?"[Echec]":""));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status['errors'][] = "Impossible de lire la description de la table $table";
|
||||
ecrire_fichier($status_file,serialize($status));
|
||||
spip_log("Impossible de lire la description de la table $table","dump."._LOG_ERREUR);
|
||||
}
|
||||
}
|
||||
|
||||
// si le nombre de tables envoyees n'est pas egal au nombre de tables demandees
|
||||
// abandonner
|
||||
if (count($status['tables_copiees'])<count($tables)){
|
||||
spip_log("Nombre de tables copiees incorrect : ".count($status['tables_copiees'])."/".count($tables),"dump."._LOG_ERREUR);
|
||||
$status['errors'][] = "Nombre de tables copiees incorrect : ".count($status['tables_copiees'])."/".count($tables);
|
||||
ecrire_fichier($status_file,serialize($status));
|
||||
}
|
||||
|
||||
if ($detruire_copieur_si_besoin = charger_fonction('detruire_copieur_si_besoin',$racine_fonctions, true)) {
|
||||
$detruire_copieur_si_besoin($serveur_dest);
|
||||
}
|
||||
else {
|
||||
spip_log( "Fonction '{$racine_fonctions}_detruire_copieur_si_besoin' inconnue.",'dump.'._LOG_INFO_IMPORTANTE);
|
||||
}
|
||||
|
||||
// OK, copie complete
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* fonction d'insertion en base lors de la copie de base a base
|
||||
*
|
||||
* @param string $table
|
||||
* @param array $rows
|
||||
* @param array $desc_dest
|
||||
* @param string $serveur_dest
|
||||
* @return int/bool
|
||||
*/
|
||||
function base_inserer_copie($table,$rows,$desc_dest,$serveur_dest){
|
||||
|
||||
// verifier le nombre d'insertion
|
||||
$nb1 = sql_countsel($table,'','','',$serveur_dest);
|
||||
// si l'enregistrement est deja en base, ca fera un echec ou un doublon
|
||||
$r = sql_insertq_multi($table,$rows,$desc_dest,$serveur_dest);
|
||||
$nb = sql_countsel($table,'','','',$serveur_dest);
|
||||
if ($nb-$nb1<count($rows)){
|
||||
spip_log("base_inserer_copie : ".($nb-$nb1)." insertions au lieu de ".count($rows).". On retente 1 par 1","dump"._LOG_INFO_IMPORTANTE);
|
||||
foreach($rows as $row){
|
||||
// si l'enregistrement est deja en base, ca fera un echec ou un doublon
|
||||
$r = sql_insertq($table,$row,$desc_dest,$serveur_dest);
|
||||
}
|
||||
// on reverifie le total
|
||||
$r = 0;
|
||||
$nb = sql_countsel($table,'','','',$serveur_dest);
|
||||
if ($nb-$nb1<count($rows)){
|
||||
spip_log("base_inserer_copie : ".($nb-$nb1)." insertions au lieu de ".count($rows)." apres insertion 1 par 1","dump"._LOG_ERREUR);
|
||||
$r = false;
|
||||
}
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
?>
|
|
@ -1 +0,0 @@
|
|||
X
|
File diff suppressed because it is too large
Load diff
|
@ -1,123 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@base_admin_repair_dist
|
||||
function base_repair_dist($titre='', $reprise='') {
|
||||
|
||||
$res = admin_repair_tables();
|
||||
if (!$res) {
|
||||
$res = "<div class='error'>"._T('avis_erreur_mysql').' '.sql_errno().': '.sql_error() ."</div>\n";
|
||||
} else {
|
||||
include_spip('inc/rubriques');
|
||||
calculer_rubriques();
|
||||
propager_les_secteurs();
|
||||
}
|
||||
include_spip('inc/minipres');
|
||||
$res .= pipeline('base_admin_repair',$res);
|
||||
echo minipres(_T('texte_tentative_recuperation'),
|
||||
$res . generer_form_ecrire('accueil', '','',_T('public:accueil_site')));
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@admin_repair_plat
|
||||
function admin_repair_plat(){
|
||||
spip_log( "verification des documents joints", _LOG_INFO_IMPORTANTE);
|
||||
$out = "";
|
||||
$repertoire = array();
|
||||
include_spip('inc/getdocument');
|
||||
$res = sql_select('*','spip_documents',"fichier REGEXP CONCAT('^',extension,'[^/\]') AND distant='non'");
|
||||
|
||||
while ($row=sql_fetch($res)){
|
||||
$ext = $row['extension'];
|
||||
if (!$ext) {
|
||||
spip_log("document sans extension: " . $row['id_document'], _LOG_INFO_IMPORTANTE);
|
||||
continue;
|
||||
}
|
||||
if (!isset($repertoire[$ext])){
|
||||
if (@file_exists($plat = _DIR_IMG. $ext .".plat"))
|
||||
spip_unlink($plat);
|
||||
$repertoire[$ext] = creer_repertoire_documents($ext);
|
||||
if (preg_match(',_$,',$repertoire[$ext]))
|
||||
$repertoire[$ext] = false;
|
||||
}
|
||||
if ($d=$repertoire[$ext]){
|
||||
$d = substr($d,strlen(_DIR_IMG));
|
||||
$src = $row['fichier'];
|
||||
$dest = $d . substr($src,strlen($d));
|
||||
if (@copy(_DIR_IMG . $src, _DIR_IMG . $dest)
|
||||
AND file_exists(_DIR_IMG . $dest)) {
|
||||
sql_updateq('spip_documents',array('fichier'=>$dest),'id_document='.intval($row['id_document']));
|
||||
spip_unlink(_DIR_IMG . $src);
|
||||
$out .= "$src => $dest<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@admin_repair_tables
|
||||
function admin_repair_tables() {
|
||||
|
||||
$repair = sql_repair('repair', NULL, 'continue');
|
||||
|
||||
// recreer les tables manquantes eventuelles
|
||||
include_spip('base/create');
|
||||
creer_base();
|
||||
|
||||
$connexion = $GLOBALS['connexions'][0];
|
||||
$prefixe = $connexion['prefixe'];
|
||||
$res1 = sql_showbase();
|
||||
$res = "";
|
||||
if ($res1) {
|
||||
while ($r = sql_fetch($res1)) {
|
||||
$tab = array_shift($r);
|
||||
|
||||
$class = "";
|
||||
$m = "<strong>$tab</strong> ";
|
||||
spip_log("Repare $tab", _LOG_INFO_IMPORTANTE);
|
||||
// supprimer la meta avant de lancer la reparation
|
||||
// car le repair peut etre long ; on ne veut pas boucler
|
||||
effacer_meta('admin_repair');
|
||||
if ($repair){
|
||||
$result_repair = sql_repair($tab);
|
||||
if (!$result_repair) return false;
|
||||
}
|
||||
|
||||
// essayer de maj la table (creation de champs manquants)
|
||||
maj_tables($tab);
|
||||
|
||||
$count = sql_countsel($tab);
|
||||
|
||||
if ($count>1)
|
||||
$m .= "("._T('texte_compte_elements', array('count' => $count)).")\n";
|
||||
else if ($count==1)
|
||||
$m .= "("._T('texte_compte_element', array('count' => $count)).")\n";
|
||||
else
|
||||
$m .= "("._T('texte_vide').")\n";
|
||||
|
||||
if ($result_repair
|
||||
AND $msg = join(" ", sql_fetch($result_repair)) . ' '
|
||||
AND strpos($msg, ' OK ')==FALSE){
|
||||
$class = " class='notice'";
|
||||
$m .= "<br /><tt>".spip_htmlentities($msg)."</tt>\n";
|
||||
}
|
||||
else
|
||||
$m .= " "._T('texte_table_ok');
|
||||
|
||||
$res .="<div$class>$m</div>";
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
?>
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
/**
|
||||
* Déclare la liste des tables principales
|
||||
*
|
||||
* @todo
|
||||
* Nettoyages à faire dans le core : on ne devrait plus appeler
|
||||
* Ce fichier mais directement base/objets si nécessaire
|
||||
*
|
||||
* @package SPIP\SQL\Tables
|
||||
**/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('base/objets');
|
||||
lister_tables_objets_sql();
|
||||
|
||||
?>
|
|
@ -1,181 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
/**
|
||||
* Gestion de l'obtention des descriptions de tables SQL
|
||||
*
|
||||
* @package SPIP\SQL\Tables
|
||||
**/
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
include_spip('base/objets');
|
||||
|
||||
/**
|
||||
* Retourne la description d'une table SQL
|
||||
*
|
||||
* Cela sert notamment au moment de la compilation des boucles, critères et balise.
|
||||
*
|
||||
* Les champs et clés de la tables sont retrouvés prioritairement via le
|
||||
* gestionnaire de base de données. Les descriptions sont complétées,
|
||||
* pour les tables éditoriales, des informations déclarées ou construites
|
||||
* par la déclaration des objets éditoriaux.
|
||||
*
|
||||
* @example
|
||||
* $trouver_table = charger_fonction('trouver_table', 'base');
|
||||
* $desc = $trouver_table('spip_groupes_mots');
|
||||
*
|
||||
* Cette fonction intervient à la compilation, mais aussi pour la balise
|
||||
* contextuelle EXPOSE ou certains critères.
|
||||
*
|
||||
* L'ensemble des descriptions de table d'un serveur est stocké dans un
|
||||
* fichier cache/sql_desc.txt par soucis de performance. Un appel
|
||||
* avec $nom vide est une demande explicite de vidange de ce cache
|
||||
*
|
||||
* @see lister_tables_objets_sql()
|
||||
*
|
||||
* @api
|
||||
* @param string $nom
|
||||
* Nom de la table
|
||||
* Vide '' demande de vider le cache des discriptions
|
||||
* @param string $serveur
|
||||
* Nom du connecteur
|
||||
* @param bool $table_spip
|
||||
* Indique s'il faut transformer le préfixe de table
|
||||
* @return array|bool
|
||||
* false si table introuvable
|
||||
* tableau de description de la table sinon, en particulier :
|
||||
* - field : tableau des colonnes SQL et leur description (comme dans serial.php ou objets.php)
|
||||
* - key : tableau des KEY (comme dans serial.php ou objets.php)
|
||||
* - table et table_sql : nom de la table (avec spip_ en préfixe)
|
||||
* - id_table : nom SPIP de la table (type de boucle)
|
||||
* le compilateur produit FROM $r['table'] AS $r['id_table']
|
||||
* - Toutes les autres informations des objets éditoriaux si la table est l'un d'eux.
|
||||
*
|
||||
*
|
||||
**/
|
||||
function base_trouver_table_dist($nom, $serveur='', $table_spip = true){
|
||||
static $nom_cache_desc_sql=array();
|
||||
global $tables_principales, $tables_auxiliaires, $table_des_tables;
|
||||
|
||||
if (!spip_connect($serveur)
|
||||
OR !preg_match('/^[a-zA-Z0-9._-]*/',$nom))
|
||||
return null;
|
||||
|
||||
$connexion = &$GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0];
|
||||
$objets_sql = lister_tables_objets_sql("::md5");
|
||||
|
||||
// le nom du cache depend du serveur mais aussi du nom de la db et du prefixe
|
||||
// ce qui permet une auto invalidation en cas de modif manuelle du fichier
|
||||
// de connexion, et tout risque d'ambiguite
|
||||
if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])){
|
||||
$nom_cache_desc_sql[$serveur][$objets_sql] =
|
||||
_DIR_CACHE . 'sql_desc_'
|
||||
. ($serveur ? "{$serveur}_":"")
|
||||
. substr(md5($connexion['db'].":".$connexion['prefixe'].":$objets_sql"),0,8)
|
||||
.'.txt';
|
||||
// nouveau nom de cache = nouvelle version en memoire
|
||||
unset($connexion['tables']);
|
||||
}
|
||||
|
||||
// un appel avec $nom vide est une demande explicite de vidange du cache des descriptions
|
||||
if (!$nom){
|
||||
spip_unlink($nom_cache_desc_sql[$serveur][$objets_sql]);
|
||||
$connexion['tables'] = array();
|
||||
return null;
|
||||
}
|
||||
|
||||
$nom_sql = $nom;
|
||||
if (preg_match('/\.(.*)$/', $nom, $s))
|
||||
$nom_sql = $s[1];
|
||||
else
|
||||
$nom_sql = $nom;
|
||||
|
||||
$fdesc = $desc = '';
|
||||
$connexion = &$GLOBALS['connexions'][$serveur ? $serveur : 0];
|
||||
|
||||
// base sous SPIP: gerer les abreviations explicites des noms de table
|
||||
if ($connexion['spip_connect_version']) {
|
||||
if ($table_spip AND isset($table_des_tables[$nom])) {
|
||||
$nom = $table_des_tables[$nom];
|
||||
$nom_sql = 'spip_' . $nom;
|
||||
}
|
||||
}
|
||||
|
||||
// si c'est la premiere table qu'on cherche
|
||||
// et si on est pas explicitement en recalcul
|
||||
// on essaye de recharger le cache des decriptions de ce serveur
|
||||
// dans le fichier cache
|
||||
if (!isset($connexion['tables'][$nom_sql])
|
||||
AND defined('_VAR_MODE') AND _VAR_MODE!=='recalcul'
|
||||
AND (!isset($connexion['tables']) OR !$connexion['tables'])) {
|
||||
if (lire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],$desc_cache)
|
||||
AND $desc_cache=unserialize($desc_cache))
|
||||
$connexion['tables'] = $desc_cache;
|
||||
}
|
||||
if ($table_spip AND !isset($connexion['tables'][$nom_sql])) {
|
||||
|
||||
if (isset($tables_principales[$nom_sql]))
|
||||
$fdesc = $tables_principales[$nom_sql];
|
||||
// meme si pas d'abreviation declaree, trouver la table spip_$nom
|
||||
// si c'est une table principale,
|
||||
// puisqu'on le fait aussi pour les tables auxiliaires
|
||||
elseif ($nom_sql==$nom AND isset($tables_principales['spip_' .$nom])){
|
||||
$nom_sql = 'spip_' . $nom;
|
||||
$fdesc = &$tables_principales[$nom_sql];
|
||||
}
|
||||
elseif (isset($tables_auxiliaires[$n=$nom])
|
||||
OR isset($tables_auxiliaires[$n='spip_'.$nom])) {
|
||||
$nom_sql = $n;
|
||||
$fdesc = &$tables_auxiliaires[$n];
|
||||
} # table locale a cote de SPIP, comme non SPIP:
|
||||
}
|
||||
if (!isset($connexion['tables'][$nom_sql])) {
|
||||
|
||||
// La *vraie* base a la priorite
|
||||
$desc = sql_showtable($nom_sql, $table_spip, $serveur);
|
||||
if (!$desc OR !$desc['field']) {
|
||||
if (!$fdesc) {
|
||||
spip_log("trouver_table: table inconnue '$serveur' '$nom'",_LOG_INFO_IMPORTANTE);
|
||||
return null;
|
||||
}
|
||||
// on ne sait pas lire la structure de la table :
|
||||
// on retombe sur la description donnee dans les fichiers spip
|
||||
$desc = $fdesc;
|
||||
}
|
||||
else {
|
||||
$desc['exist'] = true;
|
||||
}
|
||||
|
||||
$desc['table'] = $desc['table_sql'] = $nom_sql;
|
||||
$desc['connexion']= $serveur;
|
||||
|
||||
// charger les infos declarees pour cette table
|
||||
// en lui passant les infos connues
|
||||
// $desc est prioritaire pour la description de la table
|
||||
$desc = array_merge(lister_tables_objets_sql($nom_sql,$desc),$desc);
|
||||
|
||||
// si tables_objets_sql est bien fini d'init, on peut cacher
|
||||
$connexion['tables'][$nom_sql] = $desc;
|
||||
$res = &$connexion['tables'][$nom_sql];
|
||||
// une nouvelle table a ete decrite
|
||||
// mettons donc a jour le cache des descriptions de ce serveur
|
||||
if (is_writeable(_DIR_CACHE))
|
||||
ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql],serialize($connexion['tables']),true);
|
||||
}
|
||||
else
|
||||
$res = &$connexion['tables'][$nom_sql];
|
||||
|
||||
// toujours retourner $nom dans id_table
|
||||
$res['id_table']=$nom;
|
||||
|
||||
return $res;
|
||||
}
|
||||
?>
|
|
@ -1,455 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Programme de mise a jour des tables SQL lors d'un chgt de version.
|
||||
* L'entree dans cette fonction est reservee au maj de SPIP coeur
|
||||
*
|
||||
* Marche aussi pour les plugins en appelant directement la fonction maj_plugin
|
||||
* Pour que ceux-ci profitent aussi de la reprise sur interruption,
|
||||
* ils doivent simplement indiquer leur numero de version installee dans une meta
|
||||
* et fournir le tableau maj a la fonction maj_plugin.
|
||||
* La reprise sur timeout se fait alors par la page admin_plugin et jamais par ici
|
||||
*
|
||||
* http://doc.spip.org/@base_upgrade_dist
|
||||
*
|
||||
* @param string $titre
|
||||
* @param string $reprise
|
||||
* @return
|
||||
*/
|
||||
function base_upgrade_dist($titre='', $reprise='')
|
||||
{
|
||||
if (!$titre) return; // anti-testeur automatique
|
||||
if ($GLOBALS['spip_version_base']!=$GLOBALS['meta']['version_installee']) {
|
||||
if (!is_numeric(_request('reinstall'))) {
|
||||
include_spip('base/create');
|
||||
spip_log("recree les tables eventuellement disparues","maj."._LOG_INFO_IMPORTANTE);
|
||||
creer_base();
|
||||
}
|
||||
|
||||
// quand on rentre par ici, c'est toujours une mise a jour de SPIP
|
||||
// lancement de l'upgrade SPIP
|
||||
$res = maj_base();
|
||||
|
||||
if ($res) {
|
||||
// on arrete tout ici !
|
||||
exit;
|
||||
}
|
||||
}
|
||||
spip_log("Fin de mise a jour SQL. Debut m-a-j acces et config","maj."._LOG_INFO_IMPORTANTE);
|
||||
|
||||
// supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
|
||||
@spip_unlink(_CACHE_RUBRIQUES);
|
||||
@spip_unlink(_CACHE_PIPELINES);
|
||||
@spip_unlink(_CACHE_PLUGINS_PATH);
|
||||
@spip_unlink(_CACHE_PLUGINS_OPT);
|
||||
@spip_unlink(_CACHE_PLUGINS_FCT);
|
||||
@spip_unlink(_CACHE_CHEMIN);
|
||||
@spip_unlink(_DIR_TMP."plugin_xml_cache.gz");
|
||||
|
||||
include_spip('inc/auth');
|
||||
auth_synchroniser_distant();
|
||||
$config = charger_fonction('config', 'inc');
|
||||
$config();
|
||||
}
|
||||
|
||||
/**
|
||||
* MAJ de base de SPIP
|
||||
*
|
||||
* http://doc.spip.org/@maj_base
|
||||
*
|
||||
* @param int $version_cible
|
||||
* @param string $redirect
|
||||
* @return array|bool
|
||||
*/
|
||||
function maj_base($version_cible = 0, $redirect = '') {
|
||||
global $spip_version_base;
|
||||
|
||||
$version_installee = @$GLOBALS['meta']['version_installee'];
|
||||
//
|
||||
// Si version nulle ou inexistante, c'est une nouvelle installation
|
||||
// => ne pas passer par le processus de mise a jour.
|
||||
// De meme en cas de version superieure: ca devait etre un test,
|
||||
// il y a eu le message d'avertissement il doit savoir ce qu'il fait
|
||||
//
|
||||
// version_installee = 1.702; quand on a besoin de forcer une MAJ
|
||||
|
||||
spip_log("Version anterieure: $version_installee. Courante: $spip_version_base","maj."._LOG_INFO_IMPORTANTE);
|
||||
if (!$version_installee OR ($spip_version_base < $version_installee)) {
|
||||
sql_replace('spip_meta',
|
||||
array('nom' => 'version_installee',
|
||||
'valeur' => $spip_version_base,
|
||||
'impt' => 'non'));
|
||||
return false;
|
||||
}
|
||||
if (!upgrade_test()) return true;
|
||||
|
||||
$cible = ($version_cible ? $version_cible : $spip_version_base);
|
||||
|
||||
if ($version_installee <= 1.926) {
|
||||
$n = floor($version_installee * 10);
|
||||
while ($n < 19) {
|
||||
$nom = sprintf("v%03d",$n);
|
||||
$f = charger_fonction($nom, 'maj', true);
|
||||
if ($f) {
|
||||
spip_log( "$f repercute les modifications de la version " . ($n/10),"maj."._LOG_INFO_IMPORTANTE);
|
||||
$f($version_installee, $spip_version_base);
|
||||
} else spip_log( "pas de fonction pour la maj $n $nom","maj."._LOG_INFO_IMPORTANTE);
|
||||
$n++;
|
||||
}
|
||||
include_spip('maj/v019_pre193');
|
||||
v019_pre193($version_installee, $version_cible);
|
||||
}
|
||||
if ($version_installee < 2000) {
|
||||
if ($version_installee < 2)
|
||||
$version_installee = $version_installee*1000;
|
||||
include_spip('maj/v019');
|
||||
}
|
||||
if ($cible < 2)
|
||||
$cible = $cible*1000;
|
||||
|
||||
include_spip('maj/svn10000');
|
||||
ksort($GLOBALS['maj']);
|
||||
$res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee','meta', $redirect, true);
|
||||
if ($res) {
|
||||
if (!is_array($res))
|
||||
spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR);
|
||||
else {
|
||||
echo _T('avis_operation_echec') . ' ' . join(' ', $res);
|
||||
echo install_fin_html();
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mise à jour d'un plugin de SPIP
|
||||
*
|
||||
* Fonction appelée par la fonction de maj d'un plugin.
|
||||
* On lui fournit un tableau de fonctions élementaires
|
||||
* dont l'indice est la version
|
||||
*
|
||||
* @param string $nom_meta_base_version
|
||||
* Nom de la meta informant de la version du schéma de données du plugin installé dans SPIP
|
||||
* @param string $version_cible
|
||||
* Version du schéma de données dans le plugin (déclaré dans paquet.xml)
|
||||
* @param array $maj
|
||||
* Tableau d'actions à faire à l'installation (clé 'create') et pour chaque
|
||||
* version intermédiaire entre la version actuelle du schéma du plugin dans SPIP
|
||||
* et la version du schéma déclaré dans le plugin (ex. clé '1.1.0').
|
||||
*
|
||||
* Chaque valeur est un tableau contenant une liste de fonctions à exécuter,
|
||||
* cette liste étant elle-même un tableau avec premier paramètre le nom de la fonction
|
||||
* et les suivant les paramètres à lui passer
|
||||
* @example
|
||||
* array(
|
||||
* 'create' => array(
|
||||
* array('maj_tables', array('spip_rubriques', 'spip_articles')),
|
||||
* array('creer_base)),
|
||||
* '1.1.0' => array(
|
||||
* array('sql_alter', 'TABLE spip_articles ADD INDEX truc (truc)'))
|
||||
* )
|
||||
* @param string $table_meta
|
||||
* Nom de la table meta (sans le prefixe spip_) dans laquelle trouver la meta $nom_meta_base_version
|
||||
* @return void
|
||||
*/
|
||||
function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta='meta'){
|
||||
|
||||
if ($table_meta!=='meta')
|
||||
lire_metas($table_meta);
|
||||
if ( (!isset($GLOBALS[$table_meta][$nom_meta_base_version]) )
|
||||
|| (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version],$version_cible,'='))){
|
||||
|
||||
// $maj['create'] contient les directives propres a la premiere creation de base
|
||||
// c'est une operation derogatoire qui fait aboutir directement dans la version_cible
|
||||
if (isset($maj['create'])){
|
||||
if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])){
|
||||
// installation : on ne fait que l'operation create
|
||||
$maj = array("init"=>$maj['create']);
|
||||
// et on lui ajoute un appel a inc/config
|
||||
// pour creer les metas par defaut
|
||||
$config = charger_fonction('config','inc');
|
||||
$maj[$version_cible] = array(array($config));
|
||||
}
|
||||
// dans tous les cas enlever cet index du tableau
|
||||
unset($maj['create']);
|
||||
}
|
||||
// si init, deja dans le bon ordre
|
||||
if (!isset($maj['init'])){
|
||||
include_spip('inc/plugin'); // pour spip_version_compare
|
||||
uksort($maj,'spip_version_compare');
|
||||
}
|
||||
|
||||
// la redirection se fait par defaut sur la page d'administration des plugins
|
||||
// sauf lorsque nous sommes sur l'installation de SPIP
|
||||
// ou define _REDIRECT_MAJ_PLUGIN
|
||||
$redirect = (defined('_REDIRECT_MAJ_PLUGIN')?_REDIRECT_MAJ_PLUGIN:generer_url_ecrire('admin_plugin'));
|
||||
if (defined('_ECRIRE_INSTALL')) {
|
||||
$redirect = parametre_url(generer_url_ecrire('install'),'etape', _request('etape'));
|
||||
}
|
||||
|
||||
$res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
|
||||
if ($res) {
|
||||
if (!is_array($res))
|
||||
spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR);
|
||||
else {
|
||||
echo "<p>"._T('avis_operation_echec') . ' ' . join(' ', $res)."</p>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Relancer le hit de maj avant timeout
|
||||
* si pas de redirect fourni, on redirige vers exec=upgrade pour finir
|
||||
* ce qui doit etre une maj SPIP
|
||||
*
|
||||
* @param string $meta
|
||||
* @param string $table
|
||||
* @param string $redirect
|
||||
* @return void
|
||||
*/
|
||||
function relance_maj($meta,$table,$redirect=''){
|
||||
include_spip('inc/headers');
|
||||
if (!$redirect){
|
||||
// recuperer la valeur installee en cours
|
||||
// on la tronque numeriquement, elle ne sert pas reellement
|
||||
// sauf pour verifier que ce n'est pas oui ou non
|
||||
// sinon is_numeric va echouer sur un numero de version 1.2.3
|
||||
$installee = intval($GLOBALS[$table][$meta]);
|
||||
$redirect = generer_url_ecrire('upgrade',"reinstall=$installee&meta=$meta&table=$table",true);
|
||||
}
|
||||
echo redirige_formulaire($redirect);
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialiser la page pour l'affichage des progres de l'upgrade
|
||||
* uniquement si la page n'a pas deja ete initilalisee
|
||||
*
|
||||
* @param string $installee
|
||||
* @param string $meta
|
||||
* @param string $table
|
||||
* @return
|
||||
*/
|
||||
function maj_debut_page($installee,$meta,$table){
|
||||
static $done = false;
|
||||
if ($done) return;
|
||||
include_spip('inc/minipres');
|
||||
@ini_set("zlib.output_compression","0"); // pour permettre l'affichage au fur et a mesure
|
||||
$timeout = _UPGRADE_TIME_OUT*2;
|
||||
$titre = _T('titre_page_upgrade');
|
||||
$balise_img = charger_filtre('balise_img');
|
||||
$titre .= $balise_img(chemin_image('searching.gif'));
|
||||
echo ( install_debut_html($titre));
|
||||
// script de rechargement auto sur timeout
|
||||
$redirect = generer_url_ecrire('upgrade',"reinstall=$installee&meta=$meta&table=$table",true);
|
||||
echo http_script("window.setTimeout('location.href=\"".$redirect."\";',".($timeout*1000).")");
|
||||
echo "<div style='text-align: left'>\n";
|
||||
ob_flush();flush();
|
||||
$done = true;
|
||||
}
|
||||
|
||||
define('_UPGRADE_TIME_OUT', 20);
|
||||
|
||||
/**
|
||||
* A partir des > 1.926 (i.e SPIP > 1.9.2), cette fonction gere les MAJ.
|
||||
* Se relancer soi-meme pour eviter l'interruption pendant une operation SQL
|
||||
* (qu'on espere pas trop longue chacune)
|
||||
* evidemment en ecrivant dans la meta a quel numero on en est.
|
||||
*
|
||||
* Cette fonction peut servir aux plugins qui doivent donner comme arguments:
|
||||
* 1. le numero de version courant (numero de version 1.2.3 ou entier)
|
||||
* 2. le numero de version a atteindre (numero de version 1.2.3 ou entier)
|
||||
* 3. le tableau des instructions de mise a jour a executer
|
||||
* Pour profiter du mecanisme de reprise sur interruption il faut de plus
|
||||
* 4. le nom de la meta permettant de retrouver tout ca
|
||||
* 5. la table des meta ou elle se trouve ($table_prefix . '_meta' par defaut)
|
||||
* (cf debut de fichier)
|
||||
* en cas d'echec, cette fonction retourne un tableau (etape,sous-etape)
|
||||
* sinon elle retourne un tableau vide
|
||||
*
|
||||
* les fonctions sql_xx appelees lors des maj sont supposees atomiques et ne sont pas relancees
|
||||
* en cas de timeout
|
||||
* mais les fonctions specifiques sont relancees jusqu'a ce qu'elles finissent
|
||||
* elles doivent donc s'assurer de progresser a chaque reprise
|
||||
*
|
||||
* http://doc.spip.org/@maj_while
|
||||
*
|
||||
* @param $installee
|
||||
* @param $cible
|
||||
* @param $maj
|
||||
* @param string $meta
|
||||
* @param string $table
|
||||
* @param string $redirect
|
||||
* @param bool $debut_page
|
||||
* @return array
|
||||
*/
|
||||
function maj_while($installee, $cible, $maj, $meta='', $table='meta', $redirect='', $debut_page = false)
|
||||
{
|
||||
# inclusions pour que les procedures d'upgrade disposent des fonctions de base
|
||||
include_spip('base/create');
|
||||
include_spip('base/abstract_sql');
|
||||
$trouver_table = charger_fonction('trouver_table','base');
|
||||
include_spip('inc/plugin'); // pour spip_version_compare
|
||||
$n = 0;
|
||||
$time = time();
|
||||
// definir le timeout qui peut etre utilise dans les fonctions
|
||||
// de maj qui durent trop longtemps
|
||||
define('_TIME_OUT',$time+_UPGRADE_TIME_OUT);
|
||||
|
||||
reset($maj);
|
||||
while (list($v,)=each($maj)) {
|
||||
// si une maj pour cette version
|
||||
if ($v=='init' OR
|
||||
(spip_version_compare($v,$installee,'>')
|
||||
AND spip_version_compare($v,$cible,'<='))) {
|
||||
if ($debut_page)
|
||||
maj_debut_page($v,$meta,$table);
|
||||
echo "MAJ $v";
|
||||
$etape = serie_alter($v, $maj[$v], $meta, $table, $redirect);
|
||||
$trouver_table(''); // vider le cache des descriptions de table
|
||||
# echec sur une etape en cours ?
|
||||
# on sort
|
||||
if ($etape) return array($v, $etape);
|
||||
$n = time() - $time;
|
||||
spip_log( "$table $meta: $v en $n secondes",'maj.'._LOG_INFO_IMPORTANTE);
|
||||
if ($meta) ecrire_meta($meta, $installee=$v,'oui', $table);
|
||||
echo "<br />";
|
||||
}
|
||||
if (time() >= _TIME_OUT) {
|
||||
relance_maj($meta,$table,$redirect);
|
||||
}
|
||||
}
|
||||
$trouver_table(''); // vider le cache des descriptions de table
|
||||
// indispensable pour les chgt de versions qui n'ecrivent pas en base
|
||||
// tant pis pour la redondance eventuelle avec ci-dessus
|
||||
if ($meta) ecrire_meta($meta, $cible,'oui',$table);
|
||||
spip_log( "MAJ terminee. $meta: $installee",'maj.'._LOG_INFO_IMPORTANTE);
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Appliquer une serie de chgt qui risquent de partir en timeout
|
||||
* (Alter cree une copie temporaire d'une table, c'est lourd)
|
||||
*
|
||||
* http://doc.spip.org/@serie_alter
|
||||
*
|
||||
* @param string $serie
|
||||
* numero de version upgrade
|
||||
* @param array $q
|
||||
* tableau des operations pour cette version
|
||||
* @param string $meta
|
||||
* nom de la meta qui contient le numero de version
|
||||
* @param string $table
|
||||
* nom de la table meta
|
||||
* @param string $redirect
|
||||
* url de redirection en cas d'interruption
|
||||
* @return int
|
||||
*/
|
||||
function serie_alter($serie, $q = array(), $meta='', $table='meta', $redirect='') {
|
||||
$meta2 = $meta . '_maj_' . $serie;
|
||||
$etape = intval(@$GLOBALS[$table][$meta2]);
|
||||
foreach ($q as $i => $r) {
|
||||
if ($i >= $etape) {
|
||||
$msg = "maj $table $meta2 etape $i";
|
||||
if (is_array($r)
|
||||
AND function_exists($f = array_shift($r))) {
|
||||
spip_log( "$msg: $f " . join(',',$r),'maj.'._LOG_INFO_IMPORTANTE);
|
||||
// pour les fonctions atomiques sql_xx
|
||||
// on enregistre le meta avant de lancer la fonction,
|
||||
// de maniere a eviter de boucler sur timeout
|
||||
// mais pour les fonctions complexes,
|
||||
// il faut les rejouer jusqu'a achevement.
|
||||
// C'est a elle d'assurer qu'elles progressent a chaque rappel
|
||||
if (strncmp($f,"sql_",4)==0)
|
||||
ecrire_meta($meta2, $i+1, 'non', $table);
|
||||
echo " <span title='$i'>.</span>";
|
||||
call_user_func_array($f, $r);
|
||||
// si temps imparti depasse, on relance sans ecrire en meta
|
||||
// car on est peut etre sorti sur timeout si c'est une fonction longue
|
||||
if (time() >= _TIME_OUT) {
|
||||
relance_maj($meta,$table,$redirect);
|
||||
}
|
||||
ecrire_meta($meta2, $i+1, 'non', $table);
|
||||
spip_log( "$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE);
|
||||
}
|
||||
else {
|
||||
if (!is_array($r))
|
||||
spip_log("maj $i format incorrect","maj."._LOG_ERREUR);
|
||||
else
|
||||
spip_log("maj $i fonction $f non definie","maj."._LOG_ERREUR);
|
||||
// en cas d'erreur serieuse, on s'arrete
|
||||
// mais on permet de passer par dessus en rechargeant la page.
|
||||
return $i+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
effacer_meta($meta2, $table);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// La fonction a appeler dans le tableau global $maj
|
||||
// quand on rajoute des types MIME. cf par exemple la 1.953
|
||||
|
||||
// http://doc.spip.org/@upgrade_types_documents
|
||||
function upgrade_types_documents() {
|
||||
if (include_spip('base/medias')
|
||||
AND function_exists('creer_base_types_doc'))
|
||||
creer_base_types_doc();
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@upgrade_test
|
||||
function upgrade_test() {
|
||||
sql_drop_table("spip_test", true);
|
||||
sql_create("spip_test", array('a' => 'int'));
|
||||
sql_alter("TABLE spip_test ADD b INT");
|
||||
sql_insertq('spip_test', array('b' => 1), array('field'=>array('b' => 'int')));
|
||||
$result = sql_select('b', "spip_test");
|
||||
// ne pas garder le resultat de la requete sinon sqlite3
|
||||
// ne peut pas supprimer la table spip_test lors du sql_alter qui suit
|
||||
// car cette table serait alors 'verouillee'
|
||||
$result = $result?true:false;
|
||||
sql_alter("TABLE spip_test DROP b");
|
||||
return $result;
|
||||
}
|
||||
|
||||
// pour versions <= 1.926
|
||||
// http://doc.spip.org/@maj_version
|
||||
function maj_version ($version, $test = true) {
|
||||
if ($test) {
|
||||
if ($version>=1.922)
|
||||
ecrire_meta('version_installee', $version, 'oui');
|
||||
else {
|
||||
// on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
|
||||
$GLOBALS['meta']['version_installee'] = $version;
|
||||
sql_updateq('spip_meta', array('valeur' => $version), "nom=" . sql_quote('version_installee') );
|
||||
}
|
||||
spip_log( "mise a jour de la base en $version","maj."._LOG_INFO_IMPORTANTE);
|
||||
} else {
|
||||
echo _T('alerte_maj_impossible', array('version' => $version));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// pour versions <= 1.926
|
||||
// http://doc.spip.org/@upgrade_vers
|
||||
function upgrade_vers($version, $version_installee, $version_cible = 0){
|
||||
return ($version_installee<$version
|
||||
AND (($version_cible>=$version) OR ($version_cible==0))
|
||||
);
|
||||
}
|
||||
?>
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
// cp1250 - Mathieu Lutfy - ref.
|
||||
// http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT
|
||||
|
||||
$GLOBALS['CHARSET']['cp1250'] = array (
|
||||
0x80 => 0x20AC, 0x82 => 0x201A,
|
||||
0x84 => 0x201E, 0x85 => 0x2026, 0x86 => 0x2020,
|
||||
0x87 => 0x2021, 0x89 => 0x2030, 0x8A => 0x0160,
|
||||
0x8B => 0x2039, 0x8C => 0x015A, 0x8D => 0x0164,
|
||||
0x8E => 0x017D, 0x8F => 0x0179, 0x91 => 0x2018,
|
||||
0x92 => 0x2019, 0x93 => 0x201C, 0x94 => 0x201D,
|
||||
0x95 => 0x2022, 0x96 => 0x2013, 0x97 => 0x2014,
|
||||
0x99 => 0x2122, 0x9A => 0x0161, 0x9B => 0x203A,
|
||||
0x9C => 0x015B, 0x9D => 0x0165, 0x9E => 0x017E,
|
||||
0x9F => 0x017A, 0xA0 => 0x00A0, 0xA1 => 0x02C7,
|
||||
0xA2 => 0x02D8, 0xA3 => 0x0141, 0xA4 => 0x00A4,
|
||||
0xA5 => 0x0104, 0xA6 => 0x00A6, 0xA7 => 0x00A7,
|
||||
0xA8 => 0x00A8, 0xA9 => 0x00A9, 0xAA => 0x015E,
|
||||
0xAB => 0x00AB, 0xAC => 0x00AC, 0xAD => 0x00AD,
|
||||
0xAE => 0x00AE, 0xAF => 0x017B, 0xB0 => 0x00B0,
|
||||
0xB1 => 0x00B1, 0xB2 => 0x02DB, 0xB3 => 0x0142,
|
||||
0xB4 => 0x00B4, 0xB5 => 0x00B5, 0xB6 => 0x00B6,
|
||||
0xB7 => 0x00B7, 0xB8 => 0x00B8, 0xB9 => 0x0105,
|
||||
0xBA => 0x015F, 0xBB => 0x00BB, 0xBC => 0x013D,
|
||||
0xBD => 0x02DD, 0xBE => 0x013E, 0xBF => 0x017C,
|
||||
0xC0 => 0x0154, 0xC1 => 0x00C1, 0xC2 => 0x00C2,
|
||||
0xC3 => 0x0102, 0xC4 => 0x00C4, 0xC5 => 0x0139,
|
||||
0xC6 => 0x0106, 0xC7 => 0x00C7, 0xC8 => 0x010C,
|
||||
0xC9 => 0x00C9, 0xCA => 0x0118, 0xCB => 0x00CB,
|
||||
0xCC => 0x011A, 0xCD => 0x00CD, 0xCE => 0x00CE,
|
||||
0xCF => 0x010E, 0xD0 => 0x0110, 0xD1 => 0x0143,
|
||||
0xD2 => 0x0147, 0xD3 => 0x00D3, 0xD4 => 0x00D4,
|
||||
0xD5 => 0x0150, 0xD6 => 0x00D6, 0xD7 => 0x00D7,
|
||||
0xD8 => 0x0158, 0xD9 => 0x016E, 0xDA => 0x00DA,
|
||||
0xDB => 0x0170, 0xDC => 0x00DC, 0xDD => 0x00DD,
|
||||
0xDE => 0x0162, 0xDF => 0x00DF, 0xE0 => 0x0155,
|
||||
0xE1 => 0x00E1, 0xE2 => 0x00E2, 0xE3 => 0x0103,
|
||||
0xE4 => 0x00E4, 0xE5 => 0x013A, 0xE6 => 0x0107,
|
||||
0xE7 => 0x00E7, 0xE8 => 0x010D, 0xE9 => 0x00E9,
|
||||
0xEA => 0x0119, 0xEB => 0x00EB, 0xEC => 0x011B,
|
||||
0xED => 0x00ED, 0xEE => 0x00EE, 0xEF => 0x010F,
|
||||
0xF0 => 0x0111, 0xF1 => 0x0144, 0xF2 => 0x0148,
|
||||
0xF3 => 0x00F3, 0xF4 => 0x00F4, 0xF5 => 0x0151,
|
||||
0xF6 => 0x00F6, 0xF7 => 0x00F7, 0xF8 => 0x0159,
|
||||
0xF9 => 0x016F, 0xFA => 0x00FA, 0xFB => 0x0171,
|
||||
0xFC => 0x00FC, 0xFD => 0x00FD, 0xFE => 0x0163,
|
||||
0xFF => 0x02D9 );
|
||||
|
||||
?>
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
// cyrillic - ref. http://czyborra.com/charsets/cyrillic.html
|
||||
|
||||
$GLOBALS['CHARSET']['cp1251'] = array (
|
||||
0x80=>0x0402, 0x81=>0x0403, 0x82=>0x201A, 0x83=>0x0453, 0x84=>0x201E,
|
||||
0x85=>0x2026, 0x86=>0x2020, 0x87=>0x2021, 0x88=>0x20AC, 0x89=>0x2030,
|
||||
0x8A=>0x0409, 0x8B=>0x2039, 0x8C=>0x040A, 0x8D=>0x040C, 0x8E=>0x040B,
|
||||
0x8F=>0x040F, 0x90=>0x0452, 0x91=>0x2018, 0x92=>0x2019, 0x93=>0x201C,
|
||||
0x94=>0x201D, 0x95=>0x2022, 0x96=>0x2013, 0x97=>0x2014, 0x99=>0x2122,
|
||||
0x9A=>0x0459, 0x9B=>0x203A, 0x9C=>0x045A, 0x9D=>0x045C, 0x9E=>0x045B,
|
||||
0x9F=>0x045F, 0xA0=>0x00A0, 0xA1=>0x040E, 0xA2=>0x045E, 0xA3=>0x0408,
|
||||
0xA4=>0x00A4, 0xA5=>0x0490, 0xA6=>0x00A6, 0xA7=>0x00A7, 0xA8=>0x0401,
|
||||
0xA9=>0x00A9, 0xAA=>0x0404, 0xAB=>0x00AB, 0xAC=>0x00AC, 0xAD=>0x00AD,
|
||||
0xAE=>0x00AE, 0xAF=>0x0407, 0xB0=>0x00B0, 0xB1=>0x00B1, 0xB2=>0x0406,
|
||||
0xB3=>0x0456, 0xB4=>0x0491, 0xB5=>0x00B5, 0xB6=>0x00B6, 0xB7=>0x00B7,
|
||||
0xB8=>0x0451, 0xB9=>0x2116, 0xBA=>0x0454, 0xBB=>0x00BB, 0xBC=>0x0458,
|
||||
0xBD=>0x0405, 0xBE=>0x0455, 0xBF=>0x0457, 0xC0=>0x0410, 0xC1=>0x0411,
|
||||
0xC2=>0x0412, 0xC3=>0x0413, 0xC4=>0x0414, 0xC5=>0x0415, 0xC6=>0x0416,
|
||||
0xC7=>0x0417, 0xC8=>0x0418, 0xC9=>0x0419, 0xCA=>0x041A, 0xCB=>0x041B,
|
||||
0xCC=>0x041C, 0xCD=>0x041D, 0xCE=>0x041E, 0xCF=>0x041F, 0xD0=>0x0420,
|
||||
0xD1=>0x0421, 0xD2=>0x0422, 0xD3=>0x0423, 0xD4=>0x0424, 0xD5=>0x0425,
|
||||
0xD6=>0x0426, 0xD7=>0x0427, 0xD8=>0x0428, 0xD9=>0x0429, 0xDA=>0x042A,
|
||||
0xDB=>0x042B, 0xDC=>0x042C, 0xDD=>0x042D, 0xDE=>0x042E, 0xDF=>0x042F,
|
||||
0xE0=>0x0430, 0xE1=>0x0431, 0xE2=>0x0432, 0xE3=>0x0433, 0xE4=>0x0434,
|
||||
0xE5=>0x0435, 0xE6=>0x0436, 0xE7=>0x0437, 0xE8=>0x0438, 0xE9=>0x0439,
|
||||
0xEA=>0x043A, 0xEB=>0x043B, 0xEC=>0x043C, 0xED=>0x043D, 0xEE=>0x043E,
|
||||
0xEF=>0x043F, 0xF0=>0x0440, 0xF1=>0x0441, 0xF2=>0x0442, 0xF3=>0x0443,
|
||||
0xF4=>0x0444, 0xF5=>0x0445, 0xF6=>0x0446, 0xF7=>0x0447, 0xF8=>0x0448,
|
||||
0xF9=>0x0449, 0xFA=>0x044A, 0xFB=>0x044B, 0xFC=>0x044C, 0xFD=>0x044D,
|
||||
0xFE=>0x044E, 0xFF=>0x044F);
|
||||
|
||||
?>
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
// arabic - george kandalaft
|
||||
// http://www.microsoft.com/typography/unicode/1256.htm
|
||||
|
||||
$GLOBALS['CHARSET']['cp1256'] = array (
|
||||
0x80=>0x20AC, 0x81=>0x067E, 0x82=>0x201A, 0x83=>0x0192, 0x84=>0x201E,
|
||||
0x85=>0x2026, 0x86=>0x2020, 0x87=>0x2021, 0x88=>0x02C6, 0x89=>0x2030,
|
||||
0x8A=>0x0679, 0x8B=>0x2039, 0x8C=>0x0152, 0x8D=>0x0686, 0x8E=>0x0698,
|
||||
0x8F=>0x0688, 0x90=>0x06AF, 0x91=>0x2018, 0x92=>0x2019, 0x93=>0x201C,
|
||||
0x94=>0x201D, 0x95=>0x2022, 0x96=>0x2013, 0x97=>0x2014, 0x98=>0x06A9,
|
||||
0x99=>0x2122, 0x9A=>0x0691, 0x9B=>0x203A, 0x9C=>0x0153, 0x9D=>0x200C,
|
||||
0x9E=>0x200D, 0x9F=>0x06BA, 0xA0=>0x00A0, 0xA1=>0x060C, 0xA2=>0x00A2,
|
||||
0xA3=>0x00A3, 0xA4=>0x00A4, 0xA5=>0x00A5, 0xA6=>0x00A6, 0xA7=>0x00A7,
|
||||
0xA8=>0x00A8, 0xA9=>0x00A9, 0xAA=>0x06BE, 0xAB=>0x00AB, 0xAC=>0x00AC,
|
||||
0xAD=>0x00AD, 0xAE=>0x00AE, 0xAF=>0x00AF, 0xB0=>0x00B0, 0xB1=>0x00B1,
|
||||
0xB2=>0x00B2, 0xB3=>0x00B3, 0xB4=>0x00B4, 0xB5=>0x00B5, 0xB6=>0x00B6,
|
||||
0xB7=>0x00B7, 0xB8=>0x00B8, 0xB9=>0x00B9, 0xBA=>0x061B, 0xBB=>0x00BB,
|
||||
0xBC=>0x00BC, 0xBD=>0x00BD, 0xBE=>0x00BE, 0xBF=>0x061F, 0xC0=>0x06C1,
|
||||
0xC1=>0x0621, 0xC2=>0x0622, 0xC3=>0x0623, 0xC4=>0x0624, 0xC5=>0x0625,
|
||||
0xC6=>0x0626, 0xC7=>0x0627, 0xC8=>0x0628, 0xC9=>0x0629, 0xCA=>0x062A,
|
||||
0xCB=>0x062B, 0xCC=>0x062C, 0xCD=>0x062D, 0xCE=>0x062E, 0xCF=>0x062F,
|
||||
0xD0=>0x0630, 0xD1=>0x0631, 0xD2=>0x0632, 0xD3=>0x0633, 0xD4=>0x0634,
|
||||
0xD5=>0x0635, 0xD6=>0x0636, 0xD7=>0x00D7, 0xD8=>0x0637, 0xD9=>0x0638,
|
||||
0xDA=>0x0639, 0xDB=>0x063A, 0xDC=>0x0640, 0xDD=>0x0641, 0xDE=>0x0642,
|
||||
0xDF=>0x0643, 0xE0=>0x00E0, 0xE1=>0x0644, 0xE2=>0x00E2, 0xE3=>0x0645,
|
||||
0xE4=>0x0646, 0xE5=>0x0647, 0xE6=>0x0648, 0xE7=>0x00E7, 0xE8=>0x00E8,
|
||||
0xE9=>0x00E9, 0xEA=>0x00EA, 0xEB=>0x00EB, 0xEC=>0x0649, 0xED=>0x064A,
|
||||
0xEE=>0x00EE, 0xEF=>0x00EF, 0xF0=>0x064B, 0xF1=>0x064C, 0xF2=>0x064D,
|
||||
0xF3=>0x064E, 0xF4=>0x00F4, 0xF5=>0x064F, 0xF6=>0x0650, 0xF7=>0x00F7,
|
||||
0xF8=>0x0651, 0xF9=>0x00F9, 0xFA=>0x0652, 0xFB=>0x00FB, 0xFC=>0x00FC,
|
||||
0xFD=>0x200E, 0xFE=>0x200F, 0xFF=>0x06D2);
|
||||
|
||||
?>
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
// entites html (a completer eventuellement)
|
||||
|
||||
$GLOBALS['CHARSET']['html'] = array (
|
||||
'ldquo'=>'“', 'rdquo'=>'”', 'bdquo'=>'„', 'cent'=>'¢', 'pound'=>'£',
|
||||
'curren'=>'¤', 'yen'=>'¥', 'brvbar'=>'¦', 'sect'=>'§',
|
||||
'uml'=>'¨', 'ordf'=>'ª', 'laquo'=>'«', 'lsquo'=>'‘', 'rsquo'=>'’', 'not'=>'¬',
|
||||
'shy'=>'­', 'macr'=>'¯', 'deg'=>'°', 'plusmn'=>'±',
|
||||
'sup2'=>'²', 'sup3'=>'³', 'acute'=>'´', 'micro'=>'µ',
|
||||
'para'=>'¶', 'middot'=>'·', 'cedil'=>'¸', 'sup1'=>'¹',
|
||||
'ordm'=>'º', 'raquo'=>'»', 'iquest'=>'¿', 'Agrave'=>'À',
|
||||
'Aacute'=>'Á', 'Acirc'=>'Â', 'Atilde'=>'Ã', 'Auml'=>'Ä',
|
||||
'Aring'=>'Å', 'AElig'=>'Æ', 'Ccedil'=>'Ç', 'Egrave'=>'È',
|
||||
'Eacute'=>'É', 'Ecirc'=>'Ê', 'Euml'=>'Ë', 'Igrave'=>'Ì',
|
||||
'Iacute'=>'Í', 'Icirc'=>'Î', 'Iuml'=>'Ï', 'ETH'=>'Ð',
|
||||
'Ntilde'=>'Ñ', 'Ograve'=>'Ò', 'Oacute'=>'Ó', 'Ocirc'=>'Ô',
|
||||
'Otilde'=>'Õ', 'Ouml'=>'Ö', 'times'=>'×', 'Oslash'=>'Ø',
|
||||
'Ugrave'=>'Ù', 'Uacute'=>'Ú', 'Ucirc'=>'Û', 'Uuml'=>'Ü',
|
||||
'Yacute'=>'Ý', 'THORN'=>'Þ', 'szlig'=>'ß', 'agrave'=>'à',
|
||||
'Scaron'=>'Š', 'scaron'=>'š', 'zcaron'=>'ž', 'Zcaron'=>'Ž',
|
||||
'aacute'=>'á', 'acirc'=>'â', 'atilde'=>'ã', 'auml'=>'ä',
|
||||
'aring'=>'å', 'aelig'=>'æ', 'ccedil'=>'ç', 'egrave'=>'è',
|
||||
'eacute'=>'é', 'ecirc'=>'ê', 'euml'=>'ë', 'igrave'=>'ì',
|
||||
'iacute'=>'í', 'icirc'=>'î', 'iuml'=>'ï', 'eth'=>'ð',
|
||||
'ntilde'=>'ñ', 'ograve'=>'ò', 'oacute'=>'ó', 'ocirc'=>'ô',
|
||||
'otilde'=>'õ', 'ouml'=>'ö', 'divide'=>'÷', 'oslash'=>'ø',
|
||||
'ugrave'=>'ù', 'uacute'=>'ú', 'ucirc'=>'û', 'uuml'=>'ü',
|
||||
'yacute'=>'ý', 'thorn'=>'þ', 'nbsp' => " ", 'thinsp' =>' ', 'ensp' =>' ', 'emsp' =>' ', 'copy' => "(c)",
|
||||
'reg' => "(r)", 'frac14' => "1/4", 'frac12' => "1/2", 'frac34' => "3/4",
|
||||
'apos' => "'", 'mdash' => '—', 'ndash' => '–', 'hellip' =>'…',
|
||||
'euro' => '€', 'OElig' => 'Œ', 'oelig' => 'œ','iexcl' => '¡'
|
||||
|
||||
);
|
||||
|
||||
## caracteres tres speciaux a ne pas convertir
|
||||
#'amp' => '&', 'quot' => '"', 'lt' => '<', 'gt' => '>',
|
||||
|
||||
?>
|
|
@ -1 +0,0 @@
|
|||
X
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
# charset iso-8859-1
|
||||
|
||||
$GLOBALS['CHARSET']['iso-8859-1'] = array (
|
||||
|
||||
// plage invalide en iso-8859-1 mais souvent utilisee quand meme (windows)
|
||||
// cf. http://openweb.eu.org/articles/caracteres_illegaux/
|
||||
// voir aussi copie de ces valeurs dans inc/charsets.php
|
||||
128=>8364, 129=>129 /* ?? */, 130=>8218, 131=>402, 132=>8222, 133=>8230,
|
||||
134=>8224, 135=>8225, 136=>710, 137=>8240, 138=>352, 139=>8249, 140=>338,
|
||||
141=>141 /* ?? */, 142=>381, 143=>143 /* ?? */, 144=>144 /* ?? */, 145=>8216,
|
||||
146=>8217, 147=>8220, 148=>8221, 149=>8226, 150=>8211, 151=>8212, 152=>732,
|
||||
153=>8482, 154=>353, 155=>8250, 156=>339, 157=>157 /* ?? */, 158=>382, 159=>376,
|
||||
|
||||
160=>160, 161=>161, 162=>162, 163=>163, 164=>164, 165=>165, 166=>166, 167=>167,
|
||||
168=>168, 169=>169, 170=>170, 171=>171, 172=>172, 173=>173, 174=>174, 175=>175,
|
||||
176=>176, 177=>177, 178=>178, 179=>179, 180=>180, 181=>181, 182=>182, 183=>183,
|
||||
184=>184, 185=>185, 186=>186, 187=>187, 188=>188, 189=>189, 190=>190, 191=>191,
|
||||
192=>192, 193=>193, 194=>194, 195=>195, 196=>196, 197=>197, 198=>198, 199=>199,
|
||||
200=>200, 201=>201, 202=>202, 203=>203, 204=>204, 205=>205, 206=>206, 207=>207,
|
||||
208=>208, 209=>209, 210=>210, 211=>211, 212=>212, 213=>213, 214=>214, 215=>215,
|
||||
216=>216, 217=>217, 218=>218, 219=>219, 220=>220, 221=>221, 222=>222, 223=>223,
|
||||
224=>224, 225=>225, 226=>226, 227=>227, 228=>228, 229=>229, 230=>230, 231=>231,
|
||||
232=>232, 233=>233, 234=>234, 235=>235, 236=>236, 237=>237, 238=>238, 239=>239,
|
||||
240=>240, 241=>241, 242=>242, 243=>243, 244=>244, 245=>245, 246=>246, 247=>247,
|
||||
248=>248, 249=>249, 250=>250, 251=>251, 252=>252, 253=>253, 254=>254, 255=>255
|
||||
|
||||
);
|
||||
|
||||
?>
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// iso latin 15 - Gaetan Ryckeboer <gryckeboer@virtual-net.fr>
|
||||
|
||||
load_charset('iso-8859-1');
|
||||
|
||||
$trans = $GLOBALS['CHARSET']['iso-8859-1'];
|
||||
$trans[164]=8364;
|
||||
$trans[166]=352;
|
||||
$trans[168]=353;
|
||||
$trans[180]=381;
|
||||
$trans[184]=382;
|
||||
$trans[188]=338;
|
||||
$trans[189]=339;
|
||||
$trans[190]=376;
|
||||
|
||||
$GLOBALS['CHARSET']['iso-8859-15'] = $trans;
|
||||
|
||||
?>
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
|
||||
// arabic iso-8859-6 - http://czyborra.com/charsets/iso8859.html#ISO-8859-6
|
||||
|
||||
load_charset('iso-8859-1');
|
||||
|
||||
$trans = $GLOBALS['CHARSET']['iso-8859-1'];
|
||||
|
||||
$mod = Array(
|
||||
0xA0=>0x00A0, 0xA4=>0x00A4, 0xAC=>0x060C, 0xAD=>0x00AD, 0xBB=>0x061B,
|
||||
0xBF=>0x061F, 0xC1=>0x0621, 0xC2=>0x0622, 0xC3=>0x0623, 0xC4=>0x0624,
|
||||
0xC5=>0x0625, 0xC6=>0x0626, 0xC7=>0x0627, 0xC8=>0x0628, 0xC9=>0x0629,
|
||||
0xCA=>0x062A, 0xCB=>0x062B, 0xCC=>0x062C, 0xCD=>0x062D, 0xCE=>0x062E,
|
||||
0xCF=>0x062F, 0xD0=>0x0630, 0xD1=>0x0631, 0xD2=>0x0632, 0xD3=>0x0633,
|
||||
0xD4=>0x0634, 0xD5=>0x0635, 0xD6=>0x0636, 0xD7=>0x0637, 0xD8=>0x0638,
|
||||
0xD9=>0x0639, 0xDA=>0x063A, 0xE0=>0x0640, 0xE1=>0x0641, 0xE2=>0x0642,
|
||||
0xE3=>0x0643, 0xE4=>0x0644, 0xE5=>0x0645, 0xE6=>0x0646, 0xE7=>0x0647,
|
||||
0xE8=>0x0648, 0xE9=>0x0649, 0xEA=>0x064A, 0xEB=>0x064B, 0xEC=>0x064C,
|
||||
0xED=>0x064D, 0xEE=>0x064E, 0xEF=>0x064F, 0xF0=>0x0650, 0xF1=>0x0651,
|
||||
0xF2=>0x0652
|
||||
);
|
||||
|
||||
foreach ($mod as $num=>$val)
|
||||
$trans[$num]=$val;
|
||||
|
||||
$GLOBALS['CHARSET']['iso-8859-6'] = $trans;
|
||||
|
||||
?>
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// iso latin 9 - Turc <alexis@nds.k12.tr>
|
||||
|
||||
load_charset('iso-8859-1');
|
||||
|
||||
$trans = $GLOBALS['CHARSET']['iso-8859-1'];
|
||||
$trans[240]=287; //gbreve
|
||||
$trans[208]=286; //Gbreve
|
||||
$trans[221]=304; //Idot
|
||||
$trans[253]=305; //inodot
|
||||
$trans[254]=351; //scedil
|
||||
$trans[222]=350; //Scedil
|
||||
|
||||
$GLOBALS['CHARSET']['iso-8859-9'] = $trans;
|
||||
|
||||
?>
|
File diff suppressed because it is too large
Load diff
|
@ -1,100 +0,0 @@
|
|||
<?php
|
||||
|
||||
// translitteration simple
|
||||
|
||||
$GLOBALS['CHARSET']['translit'] = array (
|
||||
// latin [fausse plage]
|
||||
128=>'EUR', 131=>'f', 140=>'OE', 147=>'\'\'', 148=>'\'\'',
|
||||
153=>'(TM)', 156=>'oe', 159=>'Y',
|
||||
|
||||
// latin [legal]
|
||||
160=>' ', 161=>'!', 162=>'c', 163=>'L', 164=>'O', 165=>'yen',166=>'|',
|
||||
167=>'p',169=>'(c)', 171=>'<<',172=>'-',173=>'-',174=>'(R)',
|
||||
176=>'o',177=>'+-',181=>'mu',182=>'p',183=>'.',186=>'o ',187=>'>>',
|
||||
191=>'?', 192=>'A',
|
||||
193=>'A', 194=>'A', 195=>'A', 196=>'A', 197=>'A', 198=>'AE', 199=>'C',
|
||||
200=>'E', 201=>'E', 202=>'E', 203=>'E', 204=>'I', 205=>'I', 206=>'I',
|
||||
207=>'I', 209=>'N', 210=>'O', 211=>'O', 212=>'O', 213=>'O', 214=>'O',
|
||||
216=>'O', 217=>'U', 218=>'U', 219=>'U', 220=>'U', 223=>'ss', 224=>'a',
|
||||
225=>'a', 226=>'a', 227=>'a', 228=>'a', 229=>'a', 230=>'ae', 231=>'c',
|
||||
232=>'e', 233=>'e', 234=>'e', 235=>'e', 236=>'i', 237=>'i', 238=>'i',
|
||||
239=>'i', 241=>'n', 242=>'o', 243=>'o', 244=>'o', 245=>'o', 246=>'o',
|
||||
248=>'o', 249=>'u', 250=>'u', 251=>'u', 252=>'u', 255=>'y',
|
||||
|
||||
// turc
|
||||
286=>'G', 287=>'g', 304=>'I', 305=>'i', 350=>'S', 351=>'s',
|
||||
|
||||
// esperanto
|
||||
264 => 'Cx',265 => 'cx',
|
||||
284 => 'Gx',285 => 'gx',
|
||||
292 => 'Hx',293 => 'hx',
|
||||
308 => 'Jx',309 => 'jx',
|
||||
348 => 'Sx',349 => 'sx',
|
||||
364 => 'Ux',365 => 'ux',
|
||||
|
||||
|
||||
// latin2 [Czech]
|
||||
283=>'e', 353=>'s', 269=>'c', 345=>'r', 382=>'z',
|
||||
367=>'u', 328=>'n', 357=>'t', 271=>'d', 449=>'o',
|
||||
282=>'E', 352=>'S', 268=>'C', 344=>'R', 381=>'Z',
|
||||
366=>'U', 327=>'N', 356=>'T', 270=>'D', 467=>'O',
|
||||
|
||||
// francais
|
||||
338=>'OE', 339=>'oe', 376=>'Y', 402=>'f',
|
||||
|
||||
//polskie
|
||||
260=>'A', 261=>'a', 262=>'C', 263=>'c',
|
||||
280=>'E', 281=>'e', 321=>'L', 322=>'l',
|
||||
323=>'N', 324=>'n', 346=>'S', 347=>'s',
|
||||
377=>'Z', 378=>'z', 379=>'Z', 380=>'z',
|
||||
|
||||
//roumain
|
||||
258=>'A', 259=>'a', 350=>'S', 351=>'s', 354=>'T', 355=>'t',
|
||||
|
||||
// cyrillique
|
||||
1026=>'D%', 1027=>'G%', 8218=>'\'', 1107=>'g%', 8222=>'"', 8230=>'...',
|
||||
8224=>'/-', 8225=>'/=', 8364=>'EUR', 8240=>'0/00', 1033=>'LJ',
|
||||
8249=>'<', 1034=>'NJ', 1036=>'KJ', 1035=>'Ts', 1039=>'DZ', 1106=>'d%',
|
||||
8216=>'`', 8217=>'\'', 8220=>'"', 8221=>'"', 8226=>' o ', 8211=>'-',
|
||||
8212=>'--', 8212=>'~', 8482=>'(TM)', 1113=>'lj', 8250=>'>', 1114=>'nj',
|
||||
1116=>'kj', 1115=>'ts', 1119=>'dz', 1038=>'V%', 1118=>'v%', 1032=>'J%',
|
||||
1168=>'G3', 1025=>'IO', 1028=>'IE', 1031=>'YI', 1030=>'II',
|
||||
1110=>'ii', 1169=>'g3', 1105=>'io', 8470=>'No.', 1108=>'ie',
|
||||
1112=>'j%', 1029=>'DS', 1109=>'ds', 1111=>'yi', 1040=>'A', 1041=>'B',
|
||||
1042=>'V', 1043=>'G', 1044=>'D', 1045=>'E', 1046=>'ZH', 1047=>'Z',
|
||||
1048=>'I', 1049=>'J', 1050=>'K', 1051=>'L', 1052=>'M', 1053=>'N',
|
||||
1054=>'O', 1055=>'P', 1056=>'R', 1057=>'S', 1058=>'T', 1059=>'U',
|
||||
1060=>'F', 1061=>'H', 1062=>'C', 1063=>'CH', 1064=>'SH', 1065=>'SCH',
|
||||
1066=>'"', 1067=>'Y', 1068=>'\'', 1069=>'`E', 1070=>'YU', 1071=>'YA',
|
||||
1072=>'a', 1073=>'b', 1074=>'v', 1075=>'g', 1076=>'d', 1077=>'e',
|
||||
1078=>'zh', 1079=>'z', 1080=>'i', 1081=>'j', 1082=>'k', 1083=>'l',
|
||||
1084=>'m', 1085=>'n', 1086=>'o', 1087=>'p', 1088=>'r', 1089=>'s',
|
||||
1090=>'t', 1091=>'u', 1092=>'f', 1093=>'h', 1094=>'c', 1095=>'ch',
|
||||
1096=>'sh', 1097=>'sch', 1098=>'"', 1099=>'y', 1100=>'\'', 1101=>'`e',
|
||||
1102=>'yu', 1103=>'ya',
|
||||
|
||||
// vietnamien en translitteration de base
|
||||
7843=>"a",7841=>"a",7845=>"a",7847=>"a",7849=>"a",7851=>"a",7853=>"a",
|
||||
7855=>"a",7857=>"a",7859=>"a",7861=>"a",7863=>"a",
|
||||
7842=>"A",7840=>"A",7844=>"A",7846=>"A",7848=>"A",
|
||||
7850=>"A",7852=>"A",7854=>"A",7856=>"A",7858=>"A",7860=>"A",
|
||||
7862=>"A",7867=>"e",7869=>"e",7865=>"e",
|
||||
7871=>"e",7873=>"e",7875=>"e",7877=>"e",7879=>"e",
|
||||
7866=>"E",7868=>"E",7864=>"E",7870=>"E",7872=>"E",7874=>"E",
|
||||
7876=>"E",7878=>"E",7881=>"i",7883=>"i",
|
||||
7880=>"I",7882=>"I",
|
||||
7887=>"o",7885=>"o",7889=>"o",7891=>"o",7893=>"o",
|
||||
7895=>"o",7897=>"o",417=>"o",7899=>"o",7901=>"o",7903=>"o",7905=>"o",
|
||||
7907=>"o",7886=>"O",7884=>"O",
|
||||
7888=>"O",7890=>"O",7892=>"O",7894=>"O",7896=>"O",416=>"O",7898=>"O",
|
||||
7900=>"O",7902=>"O",7904=>"O",7906=>"O",7911=>"u",
|
||||
361=>"u",7909=>"u",432=>"u",7913=>"u",7915=>"u",7917=>"u",7919=>"u",
|
||||
7921=>"u",7910=>"U",360=>"U",7908=>"U",431=>"U",
|
||||
7912=>"U",7914=>"U",7916=>"U",7918=>"U",7920=>"U",253=>"y",7923=>"y",
|
||||
7927=>"y",7929=>"y",7925=>"y",221=>"Y",7922=>"Y",7926=>"Y",7928=>"Y",
|
||||
7924=>"Y",273=>"d"
|
||||
|
||||
);
|
||||
|
||||
|
||||
?>
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// translitteration complexe
|
||||
|
||||
load_charset('translit');
|
||||
$trans = $GLOBALS['CHARSET']['translit'];
|
||||
|
||||
$translit_c = array (
|
||||
// vietnamien
|
||||
225=>"a'", 224=>"a`",7843=>"a?",227=>"a~",7841=>"a.",
|
||||
226=>"a^",7845=>"a^'",7847=>"a^`",7849=>"a^?",7851=>"a^~",7853=>"a^.",259=>"a(",
|
||||
7855=>"a('",7857=>"a(`",7859=>"a(?",7861=>"a(~",7863=>"a(.",193=>"A'",192=>"A`",
|
||||
7842=>"A?",195=>"A~",7840=>"A.",194=>"A^",7844=>"A^'",7846=>"A^`",7848=>"A^?",
|
||||
7850=>"A^~",7852=>"A^.",258=>"A(",7854=>"A('",7856=>"A(`",7858=>"A(?",7860=>"A(~",
|
||||
7862=>"A(.",233=>"e'",232=>"e`",7867=>"e?",7869=>"e~",7865=>"e.",234=>"e^",
|
||||
7871=>"e^'",7873=>"e^`",7875=>"e^?",7877=>"e^~",7879=>"e^.",201=>"E'",200=>"E`",
|
||||
7866=>"E?",7868=>"E~",7864=>"E.",202=>"E^",7870=>"E^'",7872=>"E^`",7874=>"E^?",
|
||||
7876=>"E^~",7878=>"E^.",237=>"i'",236=>"i`",7881=>"i?",297=>"i~",7883=>"i.",
|
||||
205=>"I'",204=>"I`",7880=>"I?",296=>"I~",7882=>"I.",243=>"o'",242=>"o`",
|
||||
7887=>"o?",245=>"o~",7885=>"o.",244=>"o^",7889=>"o^'",7891=>"o^`",7893=>"o^?",
|
||||
7895=>"o^~",7897=>"o^.",417=>"o+",7899=>"o+'",7901=>"o+`",7903=>"o+?",7905=>"o+~",
|
||||
7907=>"o+.",211=>"O'",210=>"O`",7886=>"O?",213=>"O~",7884=>"O.",212=>"O^",
|
||||
7888=>"O^'",7890=>"O^`",7892=>"O^?",7894=>"O^~",7896=>"O^.",416=>"O+",7898=>"O+'",
|
||||
7900=>"O+`",7902=>"O+?",7904=>"O+~",7906=>"O+.",250=>"u'",249=>"u`",7911=>"u?",
|
||||
361=>"u~",7909=>"u.",432=>"u+",7913=>"u+'",7915=>"u+`",7917=>"u+?",7919=>"u+~",
|
||||
7921=>"u+.",218=>"U'",217=>"U`",7910=>"U?",360=>"U~",7908=>"U.",431=>"U+",
|
||||
7912=>"U+'",7914=>"U+`",7916=>"U+?",7918=>"U+~",7920=>"U+.",253=>"y'",7923=>"y`",
|
||||
7927=>"y?",7929=>"y~",7925=>"y.",221=>"Y'",7922=>"Y`",7926=>"Y?",7928=>"Y~",
|
||||
7924=>"Y.",273=>"d-",208=>"D-",
|
||||
|
||||
// allemand
|
||||
228=>'ae',246=>'oe',252=>'ue',196=>'Ae',214=>'Oe',220=>'Ue'
|
||||
);
|
||||
|
||||
foreach($translit_c as $u=>$t)
|
||||
$trans[$u] = $t;
|
||||
$GLOBALS['CHARSET']['translitcomplexe'] = $trans;
|
||||
|
||||
?>
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Un exec d'acces interdit
|
||||
*/
|
||||
function exec_403_dist(){
|
||||
|
||||
$exec = _request('exec');
|
||||
|
||||
$titre = "exec_$exec";
|
||||
$navigation = "";
|
||||
$extra = "";
|
||||
|
||||
$contenu = "<h1>"._T('info_acces_interdit')."</h1>"
|
||||
. _L("Vous n'avez pas le droit d'accéder à la page <b>@exec@</b>.",array('exec'=>_request('exec')));
|
||||
|
||||
if (_request('var_zajax')) {
|
||||
include_spip('inc/actions');
|
||||
ajax_retour($contenu);
|
||||
}
|
||||
else {
|
||||
include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini
|
||||
|
||||
$commencer_page = charger_fonction('commencer_page','inc');
|
||||
echo $commencer_page($titre);
|
||||
|
||||
echo debut_gauche("403_$exec",true);
|
||||
echo recuperer_fond('prive/squelettes/navigation/dist',array());
|
||||
echo pipeline('affiche_gauche',array('args'=>array('exec'=>'403','exec_erreur'=>$exec),'data'=>''));
|
||||
|
||||
echo creer_colonne_droite("403",true);
|
||||
echo pipeline('affiche_droite',array('args'=>array('exec'=>'403','exec_erreur'=>$exec),'data'=>''));
|
||||
|
||||
echo debut_droite("403",true);
|
||||
echo pipeline('affiche_milieu',array('args'=>array('exec'=>'403','exec_erreur'=>$exec),'data'=>$contenu));
|
||||
|
||||
echo fin_gauche(),fin_page();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Un exec d'erreur
|
||||
*/
|
||||
function exec_404_dist(){
|
||||
|
||||
$exec = _request('exec');
|
||||
|
||||
$titre = "exec_$exec";
|
||||
$navigation = "";
|
||||
$extra = "";
|
||||
|
||||
include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini
|
||||
$commencer_page = charger_fonction('commencer_page','inc');
|
||||
echo $commencer_page($titre);
|
||||
|
||||
echo debut_gauche("404_$exec",true);
|
||||
echo pipeline('affiche_gauche',array('args'=>array('exec'=>'404','exec_erreur'=>$exec),'data'=>''));
|
||||
|
||||
echo creer_colonne_droite("404",true);
|
||||
echo pipeline('affiche_droite',array('args'=>array('exec'=>'404','exec_erreur'=>$exec),'data'=>''));
|
||||
|
||||
echo debut_droite("404",true);
|
||||
echo "<h1 class='grostitre'>"._T('fichier_introuvable',array('fichier'=>$exec))."</h1>";
|
||||
echo pipeline('affiche_milieu',array('args'=>array('exec'=>'404','exec_erreur'=>$exec),'data'=>''));
|
||||
|
||||
echo fin_gauche(),fin_page();
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,248 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/config');
|
||||
include_spip('inc/plugin');
|
||||
include_spip('inc/presentation');
|
||||
include_spip('inc/layer');
|
||||
include_spip('inc/actions');
|
||||
include_spip('inc/securiser_action');
|
||||
|
||||
// http://doc.spip.org/@exec_admin_plugin_dist
|
||||
function exec_admin_plugin_dist($retour='') {
|
||||
|
||||
if (!autoriser('configurer', '_plugins')) {
|
||||
include_spip('inc/minipres');
|
||||
echo minipres();
|
||||
} else {
|
||||
// on fait la verif du path avant tout,
|
||||
// et l'installation des qu'on est dans la colonne principale
|
||||
// si jamais la liste des plugins actifs change, il faut faire un refresh du hit
|
||||
// pour etre sur que les bons fichiers seront charges lors de l'install
|
||||
$new = actualise_plugins_actifs();
|
||||
if ($new AND _request('actualise')<2) {
|
||||
include_spip('inc/headers');
|
||||
redirige_par_entete(parametre_url(self(),'actualise',_request('actualise')+1,'&'));
|
||||
}
|
||||
else {
|
||||
admin_plug_args(_request('voir'), _request('erreur'), _request('format'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function admin_plug_args($quoi, $erreur, $format)
|
||||
{
|
||||
if (!$quoi) $quoi = 'actifs';
|
||||
// empecher l'affichage des erreurs dans le bandeau, on le donne ensuite
|
||||
// format brut par plugin
|
||||
$GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false);
|
||||
// format resume mis en forme
|
||||
$erreur_activation = plugin_donne_erreurs();
|
||||
$commencer_page = charger_fonction('commencer_page', 'inc');
|
||||
echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin");
|
||||
|
||||
echo debut_gauche('plugin',true);
|
||||
echo recuperer_fond('prive/squelettes/navigation/configurer',array('exec'=>'admin_plugin'));
|
||||
|
||||
echo pipeline('affiche_gauche',
|
||||
array(
|
||||
'args'=>array('exec'=>'admin_plugin'),
|
||||
'data'=>afficher_librairies()
|
||||
)
|
||||
);
|
||||
|
||||
echo debut_droite('plugin', true);
|
||||
echo gros_titre(_T('icone_admin_plugin'),'',false);
|
||||
|
||||
// Barre d'onglets de premier niveau
|
||||
echo barre_onglets("plugins", "plugins_actifs");
|
||||
// Barre d'onglets de second niveau
|
||||
$onglet2 = $quoi=='actifs' ? 'plugins_actifs' : 'admin_plugin';
|
||||
echo debut_onglet('onglets_simple second');
|
||||
echo onglet(_T('plugins_tous_liste'), generer_url_ecrire("admin_plugin", "voir=tous"), 'admin_plugin', $onglet2);
|
||||
echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire("admin_plugin"), 'plugins_actifs', $onglet2);
|
||||
echo fin_onglet();
|
||||
|
||||
// message d'erreur au retour d'une operation
|
||||
if ($erreur)
|
||||
echo "<div class='error'>$erreur</div>";
|
||||
if ($erreur_activation){
|
||||
echo "<div class='error'>$erreur_activation</div>";
|
||||
}
|
||||
|
||||
// la mise a jour de cette meta a ete faite par ecrire_plugin_actifs
|
||||
$actifs = unserialize($GLOBALS['meta']['plugin']);
|
||||
$lcpa = $actifs + unserialize($GLOBALS['meta']['plugin_attente']);
|
||||
|
||||
// Les affichages se basent sur le repertoire, pas sur le nom
|
||||
$actifs = liste_chemin_plugin($actifs, '');
|
||||
if (defined('_DIR_PLUGINS_SUPPL'))
|
||||
$lcpas = liste_chemin_plugin($lcpa,_DIR_PLUGINS_SUPPL);
|
||||
$lcpa = liste_chemin_plugin($lcpa);
|
||||
|
||||
// on installe les plugins maintenant,
|
||||
// cela permet aux scripts d'install de faire des affichages (moches...)
|
||||
plugin_installes_meta();
|
||||
|
||||
echo "<div class='liste-plugins formulaire_spip'>";
|
||||
echo debut_cadre_trait_couleur('plugin-24.png',true,'',_T('plugins_liste'), 'plugins');
|
||||
|
||||
if ($quoi!=='actifs'){
|
||||
$lpf = liste_plugin_files();
|
||||
if ($lpf)
|
||||
echo "<p>"._T('texte_presente_plugin')."</p>";
|
||||
else {
|
||||
if (!@is_dir(_DIR_PLUGINS))
|
||||
echo "<p>"._T('plugin_info_automatique_ftp',array('rep'=>joli_repertoire(_DIR_PLUGINS)))
|
||||
. " — "._T('plugin_info_automatique_creer')."</p>";
|
||||
}
|
||||
$lcpaffiche = $lpf;
|
||||
if (defined('_DIR_PLUGINS_SUPPL'))
|
||||
$lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL);
|
||||
}
|
||||
else {
|
||||
// la liste
|
||||
// $quoi=='actifs'
|
||||
$lcpaffiche = $lcpa;
|
||||
if (defined('_DIR_PLUGINS_SUPPL'))
|
||||
$lcpaffichesup = $lcpas;
|
||||
}
|
||||
|
||||
if ($quoi=='actifs' OR $lpf){
|
||||
$nb = count($lcpa);
|
||||
if (defined('_DIR_PLUGINS_SUPPL'))
|
||||
$nb += count($lcpas);
|
||||
echo "<h3>".sinon(singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), _T('plugins_actif_aucun'))."</h3>";
|
||||
}
|
||||
|
||||
if (empty($format))
|
||||
$format = 'liste';
|
||||
elseif (!in_array($format,array('liste','repertoires')))
|
||||
$format = 'repertoires';
|
||||
|
||||
$afficher = charger_fonction("afficher_$format",'plugins');
|
||||
$corps = $afficher(self(),$lcpaffiche, $lcpa, $actifs);
|
||||
if (defined('_DIR_PLUGINS_SUPPL'))
|
||||
$corps .= $afficher(self(),$lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL);
|
||||
|
||||
if ($corps)
|
||||
$corps .= "\n<div class='boutons' style='display:none;'>"
|
||||
. "<input type='submit' class='submit save' value='"._T('bouton_enregistrer')
|
||||
."' />"
|
||||
. "</div>";
|
||||
|
||||
echo redirige_action_post('activer_plugins','activer','admin_plugin','', $corps);
|
||||
|
||||
echo fin_cadre_trait_couleur(true);
|
||||
|
||||
if ($quoi=='actifs')
|
||||
echo affiche_les_plugins_verrouilles($actifs);
|
||||
echo "</div>";
|
||||
|
||||
echo http_script("
|
||||
jQuery(function(){
|
||||
jQuery('.plugins li.item a[rel=info]').click(function(){
|
||||
var li = jQuery(this).parents('li').eq(0);
|
||||
var prefix = li.find('input.checkbox').attr('name');
|
||||
if (!jQuery('div.details',li).html()) {
|
||||
jQuery('div.details',li).prepend(ajax_image_searching).load(
|
||||
jQuery(this).attr('href').replace(/admin_plugin|plugins/, 'info_plugin'), function(){
|
||||
li.addClass('on');
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
if (jQuery('div.details',li).toggle().is(':visible'))
|
||||
li.addClass('on');
|
||||
else
|
||||
li.removeClass('on');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
jQuery('.plugins li.item input.checkbox').change(function(){
|
||||
jQuery(this).parents('form').eq(0).find('.boutons').slideDown();
|
||||
});
|
||||
});
|
||||
");
|
||||
|
||||
echo pipeline('affiche_milieu',
|
||||
array(
|
||||
'args'=>array('exec'=>'admin_plugin'),
|
||||
'data'=>''
|
||||
)
|
||||
);
|
||||
|
||||
echo fin_gauche(), fin_page();
|
||||
}
|
||||
|
||||
function affiche_les_plugins_verrouilles($actifs)
|
||||
{
|
||||
if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) return '';
|
||||
|
||||
$afficher = charger_fonction("afficher_liste",'plugins');
|
||||
$liste = $afficher(self(), $liste, array(), $actifs, _DIR_PLUGINS_DIST);
|
||||
|
||||
return
|
||||
"<div id='plugins_dist'>"
|
||||
. debut_cadre_trait_couleur('',true,'',_T('plugins_liste_dist'), 'liste_plugins_dist')
|
||||
. "<p>"
|
||||
. _T('plugin_info_plugins_dist_1', array('plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)))
|
||||
. '<br />'. _T('plugin_info_plugins_dist_2')
|
||||
. "</p>"
|
||||
. $liste
|
||||
. fin_cadre_trait_couleur(true)
|
||||
. "</div>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Afficher la liste des librairies presentes
|
||||
*
|
||||
* @return <type>
|
||||
*/
|
||||
function afficher_librairies(){
|
||||
|
||||
if (!$libs = liste_librairies()) return '';
|
||||
ksort($libs);
|
||||
$res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees'));
|
||||
$res .= '<dl>';
|
||||
foreach ($libs as $lib => $rep)
|
||||
$res .= "<dt>$lib</dt><dd>".joli_repertoire($rep)."</dd>\n";
|
||||
$res .= '</dl>';
|
||||
$res .= fin_cadre_enfonce(true);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Faire la liste des librairies disponibles
|
||||
* retourne un array ( nom de la lib => repertoire , ... )
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
// http://doc.spip.org/@liste_librairies
|
||||
function liste_librairies() {
|
||||
$libs = array();
|
||||
foreach (array_reverse(creer_chemin()) as $d) {
|
||||
if (is_dir($dir = $d.'lib/')
|
||||
AND $t = @opendir($dir)) {
|
||||
while (($f = readdir($t)) !== false) {
|
||||
if ($f[0] != '.'
|
||||
AND is_dir("$dir/$f"))
|
||||
$libs[$f] = $dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $libs;
|
||||
}
|
||||
?>
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// http://doc.spip.org/@exec_delete_all_dist
|
||||
function exec_base_delete_all_dist()
|
||||
{
|
||||
include_spip('inc/autoriser');
|
||||
if (!autoriser('detruire')) {
|
||||
include_spip('inc/minipres');
|
||||
echo minipres();
|
||||
} else {
|
||||
include_spip('base/dump');
|
||||
$res = base_lister_toutes_tables('',array(),array(),true);
|
||||
if (!$res) {
|
||||
include_spip('inc/minipres');
|
||||
spip_log("Erreur base de donnees");
|
||||
echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'). "<p><tt>".sql_errno()." ".sql_error()."</tt></p>");
|
||||
} else {
|
||||
$res = base_saisie_tables('delete', $res);
|
||||
include_spip('inc/headers');
|
||||
$res = "\n<ol style='text-align:left'><li>\n" .
|
||||
join("</li>\n<li>", $res) .
|
||||
'</li></ol>';
|
||||
$admin = charger_fonction('admin', 'inc');
|
||||
$res = $admin('delete_all', _T('titre_page_delete_all'), $res);
|
||||
if (!$res)
|
||||
redirige_url_ecrire('install','');
|
||||
else echo $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/*
|
||||
* REMARQUE IMPORTANTE : SECURITE
|
||||
* Ce systeme de reparation doit pouvoir fonctionner meme si
|
||||
* la table spip_auteurs est en panne : index.php n'appelle donc pas
|
||||
* inc_auth ; seule l'authentification ftp est exigee
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reparer la base de donnees
|
||||
*/
|
||||
function exec_base_repair_dist()
|
||||
{
|
||||
$ok = false;
|
||||
if (!spip_connect())
|
||||
$message = _T('titre_probleme_technique');
|
||||
else {
|
||||
$version_sql = sql_version();
|
||||
if (!$version_sql)
|
||||
$message = _T('avis_erreur_connexion_mysql');
|
||||
else {
|
||||
$message = _T('texte_requetes_echouent');
|
||||
$ok = true;
|
||||
}
|
||||
$action = _T('texte_tenter_reparation');
|
||||
}
|
||||
if ($ok) {
|
||||
$admin = charger_fonction('admin', 'inc');
|
||||
echo $admin('repair', $action, $message, true);
|
||||
} else {
|
||||
include_spip('inc/minipres');
|
||||
echo minipres(_T('titre_reparation'), "<p>$message</p>");
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
|
||||
// http://doc.spip.org/@exec_demande_mise_a_jour_dist
|
||||
function exec_demande_mise_a_jour_dist() {
|
||||
// on fait la verif du path avant tout,
|
||||
// et l'installation des qu'on est dans la colonne principale
|
||||
// si jamais la liste des plugins actifs change, il faut faire un refresh du hit
|
||||
// pour etre sur que les bons fichiers seront charges lors de l'install
|
||||
include_spip('inc/plugin');
|
||||
if (actualise_plugins_actifs()){
|
||||
include_spip('inc/headers');
|
||||
redirige_par_entete(self());
|
||||
}
|
||||
|
||||
include_spip('inc/presentation');
|
||||
include_spip('inc/filtres_boites');
|
||||
$commencer_page = charger_fonction('commencer_page', 'inc');
|
||||
echo $commencer_page('','','','',true,false,false);
|
||||
|
||||
echo debut_grand_cadre(true);
|
||||
echo boite_ouvrir(_T('info_message_technique'),'notice');
|
||||
echo "<p>"._T('info_procedure_maj_version')."</p>",
|
||||
"<p>"._T('info_administrateur_site_01')."</p>";
|
||||
echo bouton_action(_T('bouton_mettre_a_jour_base'),generer_url_ecrire("upgrade","reinstall=non"));
|
||||
echo boite_fermer();
|
||||
// masquer les erreurs sql sur cette page car proviennent de la base pas a jour !
|
||||
echo '<style type="text/css">#debug-nav {display: none;}</style>';
|
||||
echo fin_grand_cadre(true);
|
||||
echo fin_page();
|
||||
}
|
||||
?>
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
|
||||
$fond = _request('exec');
|
||||
$GLOBALS['delais'] = 0;// pas de cache !
|
||||
// Securite
|
||||
if (strstr($fond, '/')) {
|
||||
if (!include_spip('inc/autoriser')
|
||||
OR !autoriser('webmestre')) {
|
||||
include_spip('inc/minipres');
|
||||
echo minipres();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
$fond = "prive/squelettes/$fond";
|
||||
|
||||
// quelques inclusions et ini prealables
|
||||
include_spip('inc/commencer_page');
|
||||
|
||||
function shutdown_error(){
|
||||
|
||||
// si on arrive ici avec un tampon non ferme : erreur fatale
|
||||
/* if (ob_get_level()){
|
||||
// envoyer tous les tampons
|
||||
while (ob_get_level())
|
||||
ob_end_flush();
|
||||
|
||||
var_dump(error_get_last());
|
||||
#echo "<hr />"."Erreur fatale (memoire ?)<hr />";
|
||||
@flush();
|
||||
}*/
|
||||
}
|
||||
register_shutdown_function('shutdown_error');
|
||||
|
||||
|
||||
// on retient l'envoi de html pour pouvoir tout jeter et generer une 403
|
||||
// si on tombe sur un filtre sinon_interdire_acces
|
||||
// il faudrait etre capable de flusher cela des que le contenu principal est genere
|
||||
// car c'est lui qui peut faire des appels a ce filtre
|
||||
ob_start();
|
||||
# comme on est dans un exec, l'auth a deja ete testee
|
||||
# on peut appeler directement public.php
|
||||
include "public.php";
|
||||
// flushons si cela ne l'a pas encore ete
|
||||
ob_end_flush();
|
||||
/**
|
||||
* Un exec generique qui branche sur un squelette Z pour ecrire
|
||||
* La fonction ne fait rien, c'est l'inclusion du fichier qui declenche le traitement
|
||||
*
|
||||
*/
|
||||
function exec_fond_dist(){
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,105 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
/**
|
||||
* Un exec generique qui utilise le fond homonyme de l'exec demande
|
||||
* dans l'url
|
||||
* Ancien systeme transitoire base sur un squelette unique avec un
|
||||
* pseudo balisage par commentaires html
|
||||
* deprecie, ne plus utiliser
|
||||
*
|
||||
*/
|
||||
function exec_fond_monobloc_dist(){
|
||||
|
||||
// pas d'autorisation
|
||||
// c'est au fond de les gerer avec #AUTORISER, et de renvoyer un fond vide le cas echeant
|
||||
// qui declenchera un minipres acces interdit
|
||||
$exec = _request('exec');
|
||||
$fond = trim(recuperer_fond("prive/exec/$exec",$_REQUEST));
|
||||
if (!$fond) {
|
||||
include_spip('inc/minipres');
|
||||
echo minipres();
|
||||
} else {
|
||||
|
||||
$titre = "exec_$exec";
|
||||
$hierarchie = "";
|
||||
$navigation = "";
|
||||
$extra = "";
|
||||
|
||||
// recuperer le titre dans le premier hn de la page
|
||||
if (preg_match(",<h[1-6][^>]*>(.+)</h[1-6]>,Uims",$fond,$match)){
|
||||
$titre = $match[1];
|
||||
}
|
||||
|
||||
// recuperer la hierarchie (au-dessus du contenu)
|
||||
if (preg_match(",<!--#hierarchie-->.+<!--/#hierarchie-->,Uims",$fond,$match)){
|
||||
$hierarchie = $match[0];
|
||||
$fond = str_replace($hierarchie,"",$fond);
|
||||
}
|
||||
|
||||
// recuperer la navigation (colonne de gauche)
|
||||
if (preg_match(",<!--#navigation-->.+<!--/#navigation-->,Uims",$fond,$match)){
|
||||
$navigation = $match[0];
|
||||
$fond = str_replace($navigation,"",$fond);
|
||||
}
|
||||
|
||||
// recuperer les extras (colonne de droite)
|
||||
if (preg_match(",<!--#extra-->.+<!--/#extra-->,Uims",$fond,$match)){
|
||||
$extra = $match[0];
|
||||
$fond = str_replace($extra,"",$fond);
|
||||
}
|
||||
|
||||
include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini
|
||||
$commencer_page = charger_fonction('commencer_page','inc');
|
||||
echo $commencer_page($titre);
|
||||
|
||||
if ($hierarchie){
|
||||
echo debut_grand_cadre(true);
|
||||
echo pipeline(
|
||||
'affiche_hierarchie',
|
||||
array(
|
||||
'args' => array(
|
||||
'exec' => $exec
|
||||
),
|
||||
'data' => $hierarchie
|
||||
)
|
||||
);
|
||||
echo fin_grand_cadre(true);
|
||||
}
|
||||
|
||||
echo debut_gauche("exec_$exec",true);
|
||||
|
||||
$contexte = array('exec'=>$exec);
|
||||
if ($objet_exec = trouver_objet_exec($exec)){
|
||||
$id = $objet_exec['id_table_objet'];
|
||||
if (_request($id))
|
||||
$contexte[$id] = _request($id);
|
||||
}
|
||||
|
||||
echo $navigation;
|
||||
echo pipeline('affiche_gauche',array('args'=>$contexte,'data'=>''));
|
||||
|
||||
echo creer_colonne_droite("exec_$exec",true);
|
||||
echo $extra;
|
||||
echo pipeline('affiche_droite',array('args'=>$contexte,'data'=>''));
|
||||
|
||||
echo debut_droite("exec_$exec",true);
|
||||
echo $fond;
|
||||
echo pipeline('affiche_milieu',array('args'=>$contexte,'data'=>''));
|
||||
|
||||
echo fin_gauche(),fin_page();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1 +0,0 @@
|
|||
X
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/actions');
|
||||
// http://doc.spip.org/@exec_info_plugin_dist
|
||||
function exec_info_plugin_dist() {
|
||||
if (!autoriser('configurer', '_plugins')) {
|
||||
include_spip('inc/minipres');
|
||||
echo minipres();
|
||||
} else {
|
||||
$plug = _DIR_RACINE . _request('plugin');
|
||||
$get_infos = charger_fonction('get_infos','plugins');
|
||||
$dir = "";
|
||||
if (strncmp($plug,_DIR_PLUGINS,strlen(_DIR_PLUGINS))==0)
|
||||
$dir = _DIR_PLUGINS;
|
||||
elseif (strncmp($plug,_DIR_PLUGINS_DIST,strlen(_DIR_PLUGINS_DIST))==0)
|
||||
$dir = _DIR_PLUGINS_DIST;
|
||||
if ($dir)
|
||||
$plug = substr($plug,strlen($dir));
|
||||
$info = $get_infos($plug,false,$dir);
|
||||
$afficher_plugin = charger_fonction("afficher_plugin","plugins");
|
||||
ajax_retour(affiche_bloc_plugin($plug, $info, $dir));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/actions');
|
||||
|
||||
# Les informations d'une rubrique selectionnee dans le mini navigateur
|
||||
|
||||
// http://doc.spip.org/@exec_informer_dist
|
||||
function exec_informer_dist()
|
||||
{
|
||||
$id = intval(_request('id'));
|
||||
$col = intval(_request('col'));
|
||||
$exclus = intval(_request('exclus'));
|
||||
$do = _request('do');
|
||||
|
||||
if (preg_match('/^\w*$/', $do)) {
|
||||
if (!$do) $do = 'aff';
|
||||
|
||||
$informer = charger_fonction('informer', 'inc');
|
||||
$res = $informer($id, $col, $exclus, _request('rac'), _request('type'), $do);
|
||||
} else $res = '';
|
||||
ajax_retour($res);
|
||||
}
|
||||
?>
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/minipres');
|
||||
include_spip('inc/install');
|
||||
include_spip('inc/autoriser');
|
||||
|
||||
define('_ECRIRE_INSTALL', "1");
|
||||
define('_FILE_TMP', '_install');
|
||||
|
||||
// http://doc.spip.org/@exec_install_dist
|
||||
function exec_install_dist()
|
||||
{
|
||||
$etape = _request('etape');
|
||||
$deja = (_FILE_CONNECT AND analyse_fichier_connection(_FILE_CONNECT));
|
||||
|
||||
// Si deja installe, on n'a plus le droit qu'a l'etape chmod
|
||||
// pour chgt post-install ou aux etapes supplementaires
|
||||
// de declaration de base externes.
|
||||
// Mais alors il faut authentifier car ecrire/index.php l'a omis
|
||||
|
||||
if ($deja AND in_array($etape, array('chmod', 'sup1', 'sup2'))) {
|
||||
|
||||
$auth = charger_fonction('auth', 'inc');
|
||||
if (!$auth()) {
|
||||
verifier_visiteur();
|
||||
$deja = (!autoriser('configurer'));
|
||||
}
|
||||
}
|
||||
if ($deja) {
|
||||
// Rien a faire ici
|
||||
echo minipres();
|
||||
} else {
|
||||
include_spip('base/create');
|
||||
$fonc = charger_fonction("etape_$etape", 'install');
|
||||
$fonc();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2014 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
# afficher les sous-rubriques d'une rubrique (composant du mini-navigateur)
|
||||
|
||||
// http://doc.spip.org/@exec_plonger_dist
|
||||
function exec_plonger_dist()
|
||||
{
|
||||
include_spip('inc/actions');
|
||||
|
||||
$rac = _request('rac');
|
||||
$id = intval(_request('id'));
|
||||
$exclus = intval(_request('exclus'));
|
||||
$col = intval(_request('col'));
|
||||
$do = _request('do');
|
||||
if (preg_match('/^\w*$/', $do)) {
|
||||
if (!$do) $do = 'aff';
|
||||
|
||||
$plonger = charger_fonction('plonger', 'inc');
|
||||
$r = $plonger($id, spip_htmlentities($rac), array(), $col, $exclus, $do);
|
||||
} else $r = '';
|
||||
|
||||
ajax_retour($r);
|
||||
}
|
||||
?>
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue