mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-06 11:10:43 +08:00
= 4.0.7.1 - 4-30-20 =
* Fixed: JSON decoding issues on specific setups * Fixed: an issue with incorrect images URL * Fixed: conflict with the Download Manager plugin * Fixed: multiple PHP warnings * Fixed: MySQL query compatibility problems * Fixed: an issue with saving Wordfence settings * Fixed: an issue with showing correct post and page creating time * Fixed: an issue with displaying correct author in reports * Added: support for WPVivid backups in the reporting system * Preventative: security improvements
This commit is contained in:
parent
4cf9fa51b1
commit
2b360be79e
53 changed files with 7066 additions and 12059 deletions
11
.gitattributes
vendored
11
.gitattributes
vendored
|
@ -1,11 +0,0 @@
|
|||
# Ignore all test and documentation with “export-ignore”
|
||||
.github export-ignore
|
||||
bin export-ignore
|
||||
composer.* export-ignore
|
||||
tests export-ignore
|
||||
.gitattributes export-ignore
|
||||
phpcs.xml export-ignore
|
||||
.travis.yml export-ignore
|
||||
LICENSE.md export-ignore
|
||||
LICENSE.txt export-ignore
|
||||
README.md export-ignore
|
76
.github/CODE_OF_CONDUCT.md
vendored
76
.github/CODE_OF_CONDUCT.md
vendored
|
@ -1,76 +0,0 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at support@mainwp.com. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
78
.github/CONTRIBUTING.md
vendored
78
.github/CONTRIBUTING.md
vendored
|
@ -1,78 +0,0 @@
|
|||
# How to contribute to MainWP Child plugin
|
||||
|
||||
Community made patches, localizations, bug reports and contributions are always welcome. Your help making it even more awesome will be greatly appreciated :)
|
||||
|
||||
When contributing please ensure you follow the guidelines below to help us keep on top of things.
|
||||
|
||||
__Please Note:__
|
||||
|
||||
GitHub is for _bug reports and contributions only_ - if you have a support question or a request for a customization this is not the right place to post it. Use [MainWP Support](https://mainwp.com/support/) for customer support and for customizations we recommend one of our MainWP trusted Experts:
|
||||
|
||||
[MainWP Experts](https://mainwp.com/mainwp-experts/)
|
||||
|
||||
|
||||
## Contributing To The Core
|
||||
|
||||
### Reporting Issues
|
||||
|
||||
Reporting issues is a great way to become a contributor as it doesn't require technical skills. In fact you don't even need to know a programming language or to be able to check the code itself, you just need to make sure that everything works as expected and [submit an issue report](https://github.com/mainwp/mainwp/issues/new) if you spot a bug. Sound like something you're up for? Go for it!
|
||||
|
||||
#### How To Submit An Issue Report
|
||||
|
||||
If something isn't working, congratulations you've found a bug! Help us fix it by submitting an issue report:
|
||||
|
||||
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
||||
* Search the [Existing Issues](https://github.com/mainwp/mainwp/issues) to be sure that the one you've noticed isn't already there
|
||||
* Submit a report for your issue
|
||||
* Clearly describe the issue (including steps to reproduce it if it's a bug)
|
||||
* Make sure you fill in the earliest version that you know has the issue.
|
||||
|
||||
### Making Changes
|
||||
|
||||
Helping aking changes to the MainWP Dashboard is a key way to help us improve MainWP overall. You will need some technical skills to make a change, like knowing a bit of PHP, CSS, SASS or JavaScript.
|
||||
|
||||
If you think something could be improved and you're able to do so, make your changes and submit a Pull Request. We'll be pleased to get it :)
|
||||
|
||||
#### How To Submit A PR
|
||||
|
||||
* Fork the repository on GitHub
|
||||
* Make the changes to your forked repository
|
||||
* **Ensure you stick to the [WordPress Coding Standards](http://make.wordpress.org/core/handbook/coding-standards/php/).**
|
||||
* Ensure you use LF line endings - no crazy Windows line endings please :)
|
||||
* When committing, reference your issue number (#1234) and include a note about the fix
|
||||
* Push the changes to your fork and submit a pull request on the master branch of the MainWP Dashboard repository. Existing maintenance branches will be maintained by MainWP developers
|
||||
* Please **don't** modify the changelog - this will be maintained by the MainWP developers.
|
||||
* Please **don't** add your localizations or update the .pot files - these will also be maintained by the MainWP developers. To contribute to the localization of MainWP, please join the [translate.wordpress.org project](https://translate.wordpress.org/projects/wp-plugins/mainwp). This is much needed, if you speak a language that needs translating consider yourself officially invited.
|
||||
|
||||
After you follow the step above, the next stage will be waiting on us to merge your Pull Request. We review them all, and make suggestions and changes as and if necessary.
|
||||
|
||||
## Contribute To Localizing MainWP
|
||||
|
||||
Localization is a very important part of MainWP. We believe in net neutrality and want our platform to be available to everyone, everywhere with equal ease. When you localize MainWP, you are helping hundreds of people in the world, and all the people who speak your language. That's pretty neat.
|
||||
|
||||
### Glossary & Style Guide
|
||||
|
||||
Please refer to this page on the [Translator Handbook](https://make.wordpress.org/polyglots/handbook/translating/glossary-style-guide/) for information about the glossary and the style guide.
|
||||
|
||||
Each translation editor will take care of updating the glossary on GlotPress by editing/adding items when needed.
|
||||
|
||||
_**Note**: Only editors can create/import and edit glossaries and glossary items on GlotPress. Anyone can suggest new items to add to the glossary or translate them._
|
||||
|
||||
### Translating The Core
|
||||
|
||||
We have a [project on translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/mainwp). You can join the localization team of your language and help by translating MainWP. [Find more about using joining a language team and using GlotPress](https://make.wordpress.org/polyglots/handbook/tools/glotpress-translate-wordpress-org/).
|
||||
|
||||
If MainWP is already 100% translated for your language, join the team anyway! We regularly update our language files and there will definitely be need of your help soon.
|
||||
|
||||
|
||||
# Additional Resources
|
||||
|
||||
* [General GitHub documentation](http://help.github.com/)
|
||||
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
|
||||
* [Translator Handbook](https://make.wordpress.org/polyglots/handbook/)
|
||||
* [MainWP Docs](http://docs.mainwp.com/)
|
||||
* [MainWP API / Codex](http://codex.mainwp.com/)
|
||||
|
||||
# CONTRIBUTING File Credit
|
||||
|
||||
This CONTRIBUTING.md file relies heavily WooCommerce's [CONTRIBUTING.md](https://github.com/woothemes/woocommerce/blob/master/CONTRIBUTING.md) for wording and contribution requirements.
|
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
@ -1,38 +0,0 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
33
.github/PULL_REQUEST_TEMPLATE.md
vendored
33
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -1,33 +0,0 @@
|
|||
### All Submissions:
|
||||
|
||||
* [ ] Have you followed the [MainWP Contributing guideline](https://github.com/mainwp/mainwp-child/blob/master/.github/CONTRIBUTING.md)?
|
||||
* [ ] Does your code follow the [WordPress' coding standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/)?
|
||||
* [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/mainwp/mainwp-child/pulls) for the same update/change?
|
||||
|
||||
<!-- Mark completed items with an [x] -->
|
||||
|
||||
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
|
||||
|
||||
### Changes proposed in this Pull Request:
|
||||
|
||||
<!-- Describe the changes made to this Pull Request and the reason for such changes. -->
|
||||
|
||||
Closes # .
|
||||
|
||||
### How to test the changes in this Pull Request:
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
### Other information:
|
||||
|
||||
* [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
|
||||
* [ ] Have you written new tests for your changes, as applicable?
|
||||
* [ ] Have you successfully run tests with your changes locally?
|
||||
|
||||
<!-- Mark completed items with an [x] -->
|
||||
|
||||
### Changelog entry
|
||||
|
||||
> Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.
|
4
.github/SECURITY.md
vendored
4
.github/SECURITY.md
vendored
|
@ -1,4 +0,0 @@
|
|||
# Security Policy
|
||||
|
||||
## Reporting Security Issues
|
||||
To disclose a security issue to our team, [please submit a report via HackerOne here](https://hackerone.com/mainwp).
|
60
.travis.yml
60
.travis.yml
|
@ -1,60 +0,0 @@
|
|||
sudo: false
|
||||
dist: xenial
|
||||
|
||||
language: php
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
on_failure: change
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 7.4
|
||||
env: WP_TRAVISCI=phpcs WP_VERSION=latest
|
||||
- php: 7.3
|
||||
env: WP_VERSION=latest
|
||||
- php: 7.2
|
||||
env: WP_VERSION=latest
|
||||
- php: 7.1
|
||||
env: WP_VERSION=latest
|
||||
- php: 7.0
|
||||
env: WP_VERSION=latest
|
||||
|
||||
before_script:
|
||||
- export PATH="$HOME/.composer/vendor/bin:$PATH"
|
||||
- |
|
||||
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
|
||||
phpenv config-rm xdebug.ini
|
||||
else
|
||||
echo "xdebug.ini does not exist"
|
||||
fi
|
||||
- |
|
||||
if [[ ! -z "$WP_VERSION" ]] ; then
|
||||
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
|
||||
composer global require "phpunit/phpunit=4.8.*|5.7.*"
|
||||
fi
|
||||
- |
|
||||
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
|
||||
composer global require wp-coding-standards/wpcs
|
||||
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
|
||||
fi
|
||||
|
||||
script:
|
||||
- |
|
||||
if [[ ! -z "$WP_VERSION" ]] ; then
|
||||
phpunit
|
||||
WP_MULTISITE=1 phpunit
|
||||
fi
|
||||
- |
|
||||
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
|
||||
phpcs
|
||||
fi
|
674
LICENSE.md
674
LICENSE.md
|
@ -1,674 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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
|
||||
<https://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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
674
LICENSE.txt
674
LICENSE.txt
|
@ -1,674 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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
|
||||
<https://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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
45
README.md
45
README.md
|
@ -1,45 +0,0 @@
|
|||
|
||||
<p align="center"><a href="https://mainwp.com"><img src="https://mainwp.com/images/mainwp-logo.png" alt="MainWP"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://packagist.org/packages/mainwp/mainwp-child"><img src="https://poser.pugx.org/mainwp/mainwp-child/license" alt="license"></a>
|
||||
<a href="https://packagist.org/packages/mainwp/mainwp-child"><img src="https://poser.pugx.org/mainwp/mainwp-child/v/stable" alt="Latest Stable Version"></a>
|
||||
<img alt="WordPress Plugin Active Installs" src="https://img.shields.io/wordpress/plugin/installs/mainwp-child?label=MainWP%20Child%20Active%20Installs">
|
||||
<img alt="WordPress Plugin Rating" src="https://img.shields.io/wordpress/plugin/stars/mainwp-child?label=WP.org%20Rating">
|
||||
</p>
|
||||
|
||||
Welcome to the [MainWP](https://mainwp.com) Child plugin repository on GitHub. Here you can browse the source, look at open issues and keep track of development.
|
||||
|
||||
# Not a Developer
|
||||
|
||||
If you are not a developer, please use the [MainWP Community](https://meta.mainwp.com) for questions or issues.
|
||||
|
||||
# Developer
|
||||
|
||||
The MainWP WordPress management system consists of 2 core plugins, the MainWP Dashboard plugin which is [containted in this repository](https://github.com/mainwp/mainwp/). The second plugin is the MainWP Child plugin, which is in this repository.
|
||||
|
||||
The [MainWP Child](https://wordpress.org/plugins/mainwp-child/) plugin is installed on the WordPress sites that you want to control from the MainWP Dashboard.
|
||||
|
||||
The [MainWP Dashboard](https://wordpress.org/plugins/mainwp/) is a stand-alone plugin that is installed on its own WordPress site; no other plugins should be installed with it, and it should not be installed on an active WordPress site with visitors. The MainWP Dashboard currently has an <img alt="WordPress Plugin Active Installs" src="https://img.shields.io/wordpress/plugin/installs/mainwp?label=active%20install%20count%20of%20">
|
||||
|
||||
|
||||
## Documentation
|
||||
* [MainWP Help Documentation](https://mainwp.com/help/)
|
||||
* [MainWP Codex](https://mainwp.com/codex/)
|
||||
* [MainWP Dev Community](https://meta.mainwp.com/c/dev/15)
|
||||
|
||||
## Reporting Security Issues
|
||||
To disclose a security issue to our team, [please submit a report via HackerOne here](https://hackerone.com/mainwp).
|
||||
|
||||
## Support
|
||||
This repository is not suitable for support. Please don't use our issue tracker for support requests, but for core MainWP issues only. Support can take place through the appropriate channels:
|
||||
|
||||
* If you have a problem, you may want to start with the [Help Docs](https://mainwp.com/help/).
|
||||
* [The MainWP Community](https://meta.mainwp.com/) which is available for all MainWP users.
|
||||
* You can also [open a support ticket](https://mainwp.com/support/).
|
||||
* For customizations take a look at our list of [MainWP Exteperts](https://mainwp.com/mainwp-experts/) or [Codeable](https://codeable.io/).
|
||||
|
||||
Support requests in issues on this repository will be closed on sight.
|
||||
|
||||
## Contributing to MainWP
|
||||
If you have a patch or have stumbled upon an issue with the MainWP Plugin you can contribute this back to the code. Please read our [contributor guidelines](https://github.com/mainwp/mainwp/blob/master/.github/CONTRIBUTING.md) for more informationon how you can do this.
|
|
@ -1,155 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DB_NAME=$1
|
||||
DB_USER=$2
|
||||
DB_PASS=$3
|
||||
DB_HOST=${4-localhost}
|
||||
WP_VERSION=${5-latest}
|
||||
SKIP_DB_CREATE=${6-false}
|
||||
|
||||
TMPDIR=${TMPDIR-/tmp}
|
||||
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
|
||||
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
|
||||
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}
|
||||
|
||||
download() {
|
||||
if [ `which curl` ]; then
|
||||
curl -s "$1" > "$2";
|
||||
elif [ `which wget` ]; then
|
||||
wget -nv -O "$2" "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then
|
||||
WP_BRANCH=${WP_VERSION%\-*}
|
||||
WP_TESTS_TAG="branches/$WP_BRANCH"
|
||||
|
||||
elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
|
||||
WP_TESTS_TAG="branches/$WP_VERSION"
|
||||
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
||||
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
|
||||
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
|
||||
WP_TESTS_TAG="tags/${WP_VERSION%??}"
|
||||
else
|
||||
WP_TESTS_TAG="tags/$WP_VERSION"
|
||||
fi
|
||||
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
||||
WP_TESTS_TAG="trunk"
|
||||
else
|
||||
# http serves a single offer, whereas https serves multiple. we only want one
|
||||
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
|
||||
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
|
||||
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
|
||||
if [[ -z "$LATEST_VERSION" ]]; then
|
||||
echo "Latest WordPress version could not be found"
|
||||
exit 1
|
||||
fi
|
||||
WP_TESTS_TAG="tags/$LATEST_VERSION"
|
||||
fi
|
||||
set -ex
|
||||
|
||||
install_wp() {
|
||||
|
||||
if [ -d $WP_CORE_DIR ]; then
|
||||
return;
|
||||
fi
|
||||
|
||||
mkdir -p $WP_CORE_DIR
|
||||
|
||||
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
||||
mkdir -p $TMPDIR/wordpress-nightly
|
||||
download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip
|
||||
unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/
|
||||
mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR
|
||||
else
|
||||
if [ $WP_VERSION == 'latest' ]; then
|
||||
local ARCHIVE_NAME='latest'
|
||||
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then
|
||||
# https serves multiple offers, whereas http serves single.
|
||||
download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json
|
||||
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
|
||||
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
|
||||
LATEST_VERSION=${WP_VERSION%??}
|
||||
else
|
||||
# otherwise, scan the releases and get the most up to date minor version of the major release
|
||||
local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'`
|
||||
LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1)
|
||||
fi
|
||||
if [[ -z "$LATEST_VERSION" ]]; then
|
||||
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
||||
else
|
||||
local ARCHIVE_NAME="wordpress-$LATEST_VERSION"
|
||||
fi
|
||||
else
|
||||
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
||||
fi
|
||||
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz
|
||||
tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR
|
||||
fi
|
||||
|
||||
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
|
||||
}
|
||||
|
||||
install_test_suite() {
|
||||
# portable in-place argument for both GNU sed and Mac OSX sed
|
||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||
local ioption='-i.bak'
|
||||
else
|
||||
local ioption='-i'
|
||||
fi
|
||||
|
||||
# set up testing suite if it doesn't yet exist
|
||||
if [ ! -d $WP_TESTS_DIR ]; then
|
||||
# set up testing suite
|
||||
mkdir -p $WP_TESTS_DIR
|
||||
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
|
||||
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
|
||||
fi
|
||||
|
||||
if [ ! -f wp-tests-config.php ]; then
|
||||
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
|
||||
# remove all forward slashes in the end
|
||||
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
|
||||
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
install_db() {
|
||||
|
||||
if [ ${SKIP_DB_CREATE} = "true" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# parse DB_HOST for port or socket references
|
||||
local PARTS=(${DB_HOST//\:/ })
|
||||
local DB_HOSTNAME=${PARTS[0]};
|
||||
local DB_SOCK_OR_PORT=${PARTS[1]};
|
||||
local EXTRA=""
|
||||
|
||||
if ! [ -z $DB_HOSTNAME ] ; then
|
||||
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
|
||||
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
|
||||
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
|
||||
EXTRA=" --socket=$DB_SOCK_OR_PORT"
|
||||
elif ! [ -z $DB_HOSTNAME ] ; then
|
||||
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
|
||||
fi
|
||||
fi
|
||||
|
||||
# create database
|
||||
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
|
||||
}
|
||||
|
||||
install_wp
|
||||
install_test_suite
|
||||
install_db
|
|
@ -43,7 +43,7 @@ class MainWP_Backup {
|
|||
$pid = trailingslashit( $backupdir ) . 'backup-' . $pid . '.pid';
|
||||
}
|
||||
|
||||
// Verify if another backup is running, if so, return an error
|
||||
//Verify if another backup is running, if so, return an error
|
||||
$files = glob( $backupdir . '*.pid' );
|
||||
foreach ( $files as $file ) {
|
||||
if ( basename( $file ) == basename( $pid ) ) {
|
||||
|
@ -68,23 +68,38 @@ class MainWP_Backup {
|
|||
$ext = $this->archiver->getExtension();
|
||||
}
|
||||
|
||||
// throw new Exception('Test 1 2 : ' . print_r($append,1));
|
||||
if ( ( false !== $fileSuffix ) && ! empty( $fileSuffix ) ) {
|
||||
// Append already contains extension!
|
||||
$file = $fileSuffix . ( true === $append ? '' : $ext );
|
||||
$file = $fileSuffix . ( true === $append ? '' : $ext ); //Append already contains extension!
|
||||
} else {
|
||||
$file = 'backup-' . $filePrefix . $timestamp . $ext;
|
||||
}
|
||||
$filepath = $backupdir . $file;
|
||||
$fileurl = $file;
|
||||
|
||||
// if (!$append)
|
||||
// {
|
||||
// if ($dh = opendir($backupdir))
|
||||
// {
|
||||
// while (($file = readdir($dh)) !== false)
|
||||
// {
|
||||
// if ($file != '.' && $file != '..' && preg_match('/(.*).(zip|tar|tar.gz|tar.bz2|pid|done)$/', $file))
|
||||
// {
|
||||
// @unlink($backupdir . $file);
|
||||
// }
|
||||
// }
|
||||
// closedir($dh);
|
||||
// }
|
||||
// }
|
||||
|
||||
if ( ! $addConfig ) {
|
||||
if ( ! in_array( str_replace( ABSPATH, '', WP_CONTENT_DIR ), $excludes, true ) && ! in_array( 'wp-admin', $excludes, true ) && ! in_array( WPINC, $excludes, true ) ) {
|
||||
if ( ! in_array( str_replace( ABSPATH, '', WP_CONTENT_DIR ), $excludes ) && ! in_array( 'wp-admin', $excludes ) && ! in_array( WPINC, $excludes ) ) {
|
||||
$addConfig = true;
|
||||
$includeCoreFiles = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->timeout = 20 * 60 * 60;
|
||||
$this->timeout = 20 * 60 * 60; /*20 minutes*/
|
||||
$mem = '512M';
|
||||
// @codingStandardsIgnoreStart
|
||||
@ini_set( 'memory_limit', $mem );
|
||||
|
@ -94,9 +109,9 @@ class MainWP_Backup {
|
|||
|
||||
if ( null !== $this->archiver ) {
|
||||
$success = $this->archiver->createFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp, $append );
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
$success = $this->createZipFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp );
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
} else if ( $this->checkZipConsole() ) {
|
||||
$success = $this->createZipConsoleFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp );
|
||||
} else {
|
||||
$success = $this->createZipPclFullBackup2( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp );
|
||||
|
@ -110,7 +125,7 @@ class MainWP_Backup {
|
|||
}
|
||||
|
||||
public function zipFile( $files, $archive ) {
|
||||
$this->timeout = 20 * 60 * 60;
|
||||
$this->timeout = 20 * 60 * 60; /*20 minutes*/
|
||||
$mem = '512M';
|
||||
// @codingStandardsIgnoreStart
|
||||
@ini_set( 'memory_limit', $mem );
|
||||
|
@ -118,15 +133,15 @@ class MainWP_Backup {
|
|||
@ini_set( 'max_execution_time', $this->timeout );
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
if ( ! is_array( $files ) ) {
|
||||
$files = array( $files );
|
||||
if ( !is_array( $files ) ) {
|
||||
$files = array ($files );
|
||||
}
|
||||
|
||||
if ( null !== $this->archiver ) {
|
||||
$success = $this->archiver->zipFile( $files, $archive );
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
$success = $this->_zipFile( $files, $archive );
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
} else if ( $this->checkZipConsole() ) {
|
||||
$success = $this->_zipFileConsole( $files, $archive );
|
||||
} else {
|
||||
$success = $this->_zipFilePcl( $files, $archive );
|
||||
|
@ -157,8 +172,8 @@ class MainWP_Backup {
|
|||
}
|
||||
|
||||
public function _zipFilePcl( $files, $archive ) {
|
||||
// Zip this backup folder..
|
||||
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
||||
//Zip this backup folder..
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
||||
$this->zip = new PclZip( $archive );
|
||||
|
||||
$error = false;
|
||||
|
@ -168,7 +183,7 @@ class MainWP_Backup {
|
|||
}
|
||||
}
|
||||
|
||||
return ! $error;
|
||||
return !$error;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,6 +202,7 @@ class MainWP_Backup {
|
|||
*/
|
||||
public function checkZipConsole() {
|
||||
return false;
|
||||
// return function_exists('system');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,7 +248,7 @@ class MainWP_Backup {
|
|||
foreach ( $nodes as $key => $node ) {
|
||||
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
} else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else {
|
||||
foreach ( $coreFiles as $coreFile ) {
|
||||
|
@ -264,7 +280,7 @@ class MainWP_Backup {
|
|||
if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) {
|
||||
if ( is_dir( $node ) ) {
|
||||
$this->zipAddDir( $node, $excludes );
|
||||
} elseif ( is_file( $node ) ) {
|
||||
} else if ( is_file( $node ) ) {
|
||||
$this->addFileToZip( $node, str_replace( ABSPATH, '', $node ) );
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +352,7 @@ class MainWP_Backup {
|
|||
* @return bool
|
||||
*/
|
||||
public function createZipPclFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
||||
$this->zip = new PclZip( $filepath );
|
||||
$nodes = glob( ABSPATH . '*' );
|
||||
if ( ! $includeCoreFiles ) {
|
||||
|
@ -366,7 +382,7 @@ class MainWP_Backup {
|
|||
foreach ( $nodes as $key => $node ) {
|
||||
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
} else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else {
|
||||
foreach ( $coreFiles as $coreFile ) {
|
||||
|
@ -392,13 +408,13 @@ class MainWP_Backup {
|
|||
}
|
||||
if ( ! $error ) {
|
||||
foreach ( $nodes as $node ) {
|
||||
if ( null === $excludes || ! in_array( str_replace( ABSPATH, '', $node ), $excludes, true ) ) {
|
||||
if ( null === $excludes || ! in_array( str_replace( ABSPATH, '', $node ), $excludes ) ) {
|
||||
if ( is_dir( $node ) ) {
|
||||
if ( ! $this->pclZipAddDir( $node, $excludes ) ) {
|
||||
$error = true;
|
||||
break;
|
||||
}
|
||||
} elseif ( is_file( $node ) ) {
|
||||
} else if ( is_file( $node ) ) {
|
||||
if ( 0 === ( $rslt = $this->zip->add( $node, PCLZIP_OPT_REMOVE_PATH, ABSPATH ) ) ) {
|
||||
$error = true;
|
||||
break;
|
||||
|
@ -455,7 +471,7 @@ class MainWP_Backup {
|
|||
$newnodes = glob( $node . DIRECTORY_SEPARATOR . '*' );
|
||||
$this->copy_dir( $newnodes, $excludes, $backupfolder, $excludenonwp, false );
|
||||
unset( $newnodes );
|
||||
} elseif ( is_file( $node ) ) {
|
||||
} else if ( is_file( $node ) ) {
|
||||
if ( $this->excludeZip && MainWP_Helper::endsWith( $node, '.zip' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -469,16 +485,16 @@ class MainWP_Backup {
|
|||
}
|
||||
|
||||
public function createZipPclFullBackup2( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ) {
|
||||
// Create backup folder
|
||||
//Create backup folder
|
||||
$backupFolder = dirname( $filepath ) . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR;
|
||||
// @codingStandardsIgnoreStart
|
||||
@mkdir( $backupFolder );
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
// Create DB backup
|
||||
//Create DB backup
|
||||
$db_files = $this->createBackupDB( $backupFolder . 'dbBackup' );
|
||||
|
||||
// Copy installation to backup folder
|
||||
//Copy installation to backup folder
|
||||
$nodes = glob( ABSPATH . '*' );
|
||||
if ( ! $includeCoreFiles ) {
|
||||
$coreFiles = array(
|
||||
|
@ -507,7 +523,7 @@ class MainWP_Backup {
|
|||
foreach ( $nodes as $key => $node ) {
|
||||
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
} else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else {
|
||||
foreach ( $coreFiles as $coreFile ) {
|
||||
|
@ -530,8 +546,8 @@ class MainWP_Backup {
|
|||
// @codingStandardsIgnoreEnd
|
||||
unset( $nodes );
|
||||
|
||||
// Zip this backup folder..
|
||||
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
||||
//Zip this backup folder..
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
||||
$this->zip = new PclZip( $filepath );
|
||||
$this->zip->create( $backupFolder, PCLZIP_OPT_REMOVE_PATH, $backupFolder );
|
||||
if ( $addConfig ) {
|
||||
|
@ -546,7 +562,7 @@ class MainWP_Backup {
|
|||
|
||||
$this->addFileFromStringToPCLZip( 'clone/config.txt', $string, $filepath );
|
||||
}
|
||||
// Remove backup folder
|
||||
//Remove backup folder
|
||||
MainWP_Helper::delete_dir( $backupFolder );
|
||||
|
||||
return true;
|
||||
|
@ -583,6 +599,24 @@ class MainWP_Backup {
|
|||
|
||||
$iterator = null;
|
||||
unset( $iterator );
|
||||
|
||||
// $nodes = glob(rtrim($path, '/') . '/*');
|
||||
// if (empty($nodes)) return true;
|
||||
//
|
||||
// foreach ($nodes as $node)
|
||||
// {
|
||||
// if (!MainWP_Helper::inExcludes($excludes, str_replace(ABSPATH, '', $node)))
|
||||
// {
|
||||
// if (is_dir($node))
|
||||
// {
|
||||
// $this->zipAddDir($node, $excludes);
|
||||
// }
|
||||
// else if (is_file($node))
|
||||
// {
|
||||
// $this->addFileToZip($node, str_replace(ABSPATH, '', $node));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public function pclZipAddDir( $path, $excludes ) {
|
||||
|
@ -593,13 +627,13 @@ class MainWP_Backup {
|
|||
}
|
||||
|
||||
foreach ( $nodes as $node ) {
|
||||
if ( null === $excludes || ! in_array( str_replace( ABSPATH, '', $node ), $excludes, true ) ) {
|
||||
if ( null === $excludes || ! in_array( str_replace( ABSPATH, '', $node ), $excludes ) ) {
|
||||
if ( is_dir( $node ) ) {
|
||||
if ( ! $this->pclZipAddDir( $node, $excludes ) ) {
|
||||
$error = true;
|
||||
break;
|
||||
}
|
||||
} elseif ( is_file( $node ) ) {
|
||||
} else if ( is_file( $node ) ) {
|
||||
if ( 0 === ( $rslt = $this->zip->add( $node, PCLZIP_OPT_REMOVE_PATH, ABSPATH ) ) ) {
|
||||
$error = true;
|
||||
break;
|
||||
|
@ -623,8 +657,7 @@ class MainWP_Backup {
|
|||
$this->zip->delete( PCLZIP_OPT_BY_NAME, $file );
|
||||
$add = $this->zip->add( $tmpfilename,
|
||||
PCLZIP_OPT_REMOVE_PATH, dirname( $filepath ),
|
||||
PCLZIP_OPT_ADD_PATH, $localpath
|
||||
);
|
||||
PCLZIP_OPT_ADD_PATH, $localpath );
|
||||
unlink( $tmpfilename );
|
||||
if ( ! empty( $add ) ) {
|
||||
return true;
|
||||
|
@ -660,7 +693,7 @@ class MainWP_Backup {
|
|||
$this->zipArchiveSizeCount += filesize( $path );
|
||||
$this->gcCnt ++;
|
||||
|
||||
// 5 mb limit!
|
||||
//5 mb limit!
|
||||
if ( ! $this->loadFilesBeforeZip || ( filesize( $path ) > 5 * 1024 * 1024 ) ) {
|
||||
$this->zipArchiveFileCount ++;
|
||||
$added = $this->zip->addFile( $path, $zipEntryName );
|
||||
|
@ -686,7 +719,7 @@ class MainWP_Backup {
|
|||
$this->gcCnt = 0;
|
||||
}
|
||||
|
||||
// Over limits?
|
||||
//Over limits?
|
||||
if ( ( ( $this->file_descriptors > 0 ) && ( $this->zipArchiveFileCount > $this->file_descriptors ) ) ) { // || $this->zipArchiveSizeCount >= (31457280 * 2))
|
||||
$this->zip->close();
|
||||
$this->zip = null;
|
||||
|
@ -709,11 +742,13 @@ class MainWP_Backup {
|
|||
}
|
||||
|
||||
public function createZipConsoleFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ) {
|
||||
// @TODO to work with 'zip' from system if PHP Zip library not available
|
||||
//system('zip');
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createBackupDB( $filepath_prefix, $archiveExt = false, &$archiver = null ) {
|
||||
$timeout = 20 * 60 * 60;
|
||||
$timeout = 20 * 60 * 60; //20minutes
|
||||
// @codingStandardsIgnoreStart
|
||||
@set_time_limit( $timeout );
|
||||
@ini_set( 'max_execution_time', $timeout );
|
||||
|
@ -725,7 +760,7 @@ class MainWP_Backup {
|
|||
global $wpdb;
|
||||
|
||||
$db_files = array();
|
||||
// Get all the tables
|
||||
//Get all the tables
|
||||
$tables_db = $wpdb->get_results( 'SHOW TABLES FROM `' . DB_NAME . '`', ARRAY_N );
|
||||
foreach ( $tables_db as $curr_table ) {
|
||||
if ( null !== $archiver ) {
|
||||
|
@ -739,11 +774,11 @@ class MainWP_Backup {
|
|||
if ( file_exists( $currentfile ) ) {
|
||||
continue;
|
||||
}
|
||||
$fh = fopen( $currentfile . '.tmp', 'w' ); // or error;
|
||||
$fh = fopen( $currentfile . '.tmp', 'w' ); //or error;
|
||||
|
||||
fwrite( $fh, "\n\n" . 'DROP TABLE IF EXISTS ' . $table . ';' );
|
||||
// todo fix this
|
||||
// $table_create = $wpdb->get_row( $wpdb->prepare( 'SHOW CREATE TABLE %s', $table ), ARRAY_N );
|
||||
//todo fix this
|
||||
//$table_create = $wpdb->get_row( $wpdb->prepare( 'SHOW CREATE TABLE %s', $table ), ARRAY_N );
|
||||
$table_create = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N );
|
||||
fwrite( $fh, "\n" . $table_create[1] . ";\n\n" );
|
||||
|
||||
|
@ -804,10 +839,11 @@ class MainWP_Backup {
|
|||
@unlink( $db_file );
|
||||
}
|
||||
} else {
|
||||
// todo: throw exception!
|
||||
//todo: throw exception!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ( false !== $archiveExt ? array( 'filepath' => $archivefilePath ) : $db_files );
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -21,21 +21,22 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
public static $instance = null;
|
||||
public $is_plugin_installed = false;
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Back_Up_Wordpress();
|
||||
if ( null === MainWP_Child_Back_Up_Wordpress::$instance ) {
|
||||
MainWP_Child_Back_Up_Wordpress::$instance = new MainWP_Child_Back_Up_Wordpress();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_Back_Up_Wordpress::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
|
||||
$this->is_plugin_installed = true;
|
||||
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
|
||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function init() {
|
||||
|
@ -43,9 +44,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
return;
|
||||
}
|
||||
if (!$this->is_plugin_installed) return;
|
||||
|
||||
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
||||
|
||||
|
@ -67,7 +66,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if ( ! MainWP_Helper::is_screen_with_update() ) {
|
||||
if (! MainWP_Helper::is_screen_with_update()) {
|
||||
return $value;
|
||||
}
|
||||
if ( isset( $value->response['backupwordpress/backupwordpress.php'] ) ) {
|
||||
|
@ -155,7 +154,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
|
||||
try {
|
||||
$information['syncBackUpWordPress'] = $this->get_sync_data();
|
||||
} catch ( Exception $e ) {
|
||||
} catch(Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +170,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
||||
$backups_time = array();
|
||||
|
||||
if ( is_array($schedules) && count($schedules) ) {
|
||||
if (is_array($schedules) && count($schedules)) {
|
||||
$check = current($schedules);
|
||||
MainWP_Helper::check_methods($check, array( 'get_backups' ) );
|
||||
|
||||
|
@ -194,7 +193,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
}
|
||||
|
||||
function do_site_stats() {
|
||||
if ( has_action('mainwp_child_reports_log') ) {
|
||||
if (has_action('mainwp_child_reports_log')) {
|
||||
do_action( 'mainwp_child_reports_log', 'backupwordpress');
|
||||
} else {
|
||||
$this->do_reports_log('backupwordpress');
|
||||
|
@ -202,13 +201,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
}
|
||||
|
||||
// ok
|
||||
public function do_reports_log( $ext = '' ) {
|
||||
if ( $ext !== 'backupwordpress' ) {
|
||||
return;
|
||||
}
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
return;
|
||||
}
|
||||
public function do_reports_log($ext = '') {
|
||||
if ( $ext !== 'backupwordpress' ) return;
|
||||
if (!$this->is_plugin_installed) return;
|
||||
|
||||
try {
|
||||
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
||||
|
@ -217,26 +212,26 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
// Refresh the schedules from the database to make sure we have the latest changes
|
||||
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
||||
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
||||
if ( is_array($schedules) && count($schedules) > 0 ) {
|
||||
if (is_array($schedules) && count($schedules) > 0) {
|
||||
$check = current($schedules);
|
||||
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
|
||||
|
||||
foreach ( $schedules as $schedule ) {
|
||||
foreach($schedules as $schedule) {
|
||||
foreach ( $schedule->get_backups() as $file ) {
|
||||
$backup_type = $schedule->get_type();
|
||||
$message = 'BackupWordpres backup ' . $backup_type . ' finished';
|
||||
$destination = 'N/A';
|
||||
$message = "BackupWordpres backup " . $backup_type . ' finished';
|
||||
$destination = "N/A";
|
||||
if ( file_exists( $file ) ) {
|
||||
$date = @filemtime( $file );
|
||||
if ( ! empty( $date ) ) {
|
||||
do_action( 'mainwp_reports_backupwordpress_backup', $destination, $message, 'finished', $backup_type, $date );
|
||||
if ( !empty( $date ) ) {
|
||||
do_action( "mainwp_reports_backupwordpress_backup", $destination, $message, 'finished', $backup_type, $date );
|
||||
MainWP_Helper::update_lasttime_backup('backupwordpress', $date); // to support backup before update feature
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
} catch(Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -267,8 +262,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$schedule_id = $this->check_schedule();
|
||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) );
|
||||
|
||||
|
||||
// Delete the running backup
|
||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
||||
if (method_exists($schedule, 'get_running_backup_filename' )) {
|
||||
if ( $schedule->get_running_backup_filename() && file_exists( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ) ) {
|
||||
unlink( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() );
|
||||
}
|
||||
|
@ -284,11 +280,12 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
if ( file_exists( $status->get_status_filepath() ) ) {
|
||||
unlink( $status->get_status_filepath() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HM\BackUpWordPress\Path::get_instance()->cleanup();
|
||||
|
||||
if ( $status === null ) {
|
||||
if ($status === null) {
|
||||
$information['scheduleStatus'] = $schedule->get_status();
|
||||
} else {
|
||||
$information['scheduleStatus'] = $status->get_status();
|
||||
|
@ -303,7 +300,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$schedule_id = $this->check_schedule();
|
||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) );
|
||||
|
||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
||||
if (method_exists($schedule, 'get_running_backup_filename' )) {
|
||||
$information['scheduleStatus'] = $schedule->get_status();
|
||||
} else {
|
||||
$status = $schedule->get_status();
|
||||
|
@ -317,17 +314,16 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
function run_schedule() {
|
||||
$schedule_id = $this->check_schedule();
|
||||
if ( function_exists('hmbkp_run_schedule_async') ) {
|
||||
if (function_exists('hmbkp_run_schedule_async')) {
|
||||
hmbkp_run_schedule_async($schedule_id);
|
||||
} elseif ( function_exists('\HM\BackUpWordPress\run_schedule_async') ) {
|
||||
} else if (function_exists('\HM\BackUpWordPress\run_schedule_async')) {
|
||||
HM\BackUpWordPress\Path::get_instance()->cleanup();
|
||||
// Fixes an issue on servers which only allow a single session per client
|
||||
session_write_close();
|
||||
$task = new \HM\Backdrop\Task( '\HM\BackUpWordPress\run_schedule_async', $schedule_id );
|
||||
$task->schedule();
|
||||
} else {
|
||||
} else
|
||||
return array( 'error' => __('Error while trying to trigger the schedule', 'mainwp-child') );
|
||||
}
|
||||
return array( 'result' => 'SUCCESS' );
|
||||
}
|
||||
|
||||
|
@ -360,7 +356,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
'started_ago' => human_time_diff( $started_ago ),
|
||||
);
|
||||
|
||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
||||
if (method_exists($schedule, 'get_running_backup_filename' )) {
|
||||
$out['scheduleStatus'] = $schedule->get_status();
|
||||
} else {
|
||||
$status = $schedule->get_status();
|
||||
|
@ -388,7 +384,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
'scheduleStatus' => $schedule->get_status(),
|
||||
'started_ago' => human_time_diff( $started_ago ),
|
||||
);
|
||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
||||
if (method_exists($schedule, 'get_running_backup_filename' )) {
|
||||
$send_back_schedules['scheduleStatus'] = $schedule->get_status();
|
||||
} else {
|
||||
$status = $schedule->get_status();
|
||||
|
@ -398,11 +394,10 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
}
|
||||
}
|
||||
|
||||
if ( function_exists('HM\BackUpWordPress\Backup::get_home_path') ) {
|
||||
if (function_exists('HM\BackUpWordPress\Backup::get_home_path'))
|
||||
$backups_path = str_replace( HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path() );
|
||||
} else {
|
||||
else
|
||||
$backups_path = str_replace( HM\BackUpWordPress\Path::get_home_path(), '', HM\BackUpWordPress\Path::get_path() );
|
||||
}
|
||||
|
||||
$information['backups_path'] = $backups_path;
|
||||
$information['send_back_schedules'] = $send_back_schedules;
|
||||
|
@ -432,7 +427,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
'count' => count( $schedule->get_backups() ),
|
||||
'file_size_text' => $this->hmbkp_get_site_size_text( $schedule ),
|
||||
);
|
||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
||||
if (method_exists($schedule, 'get_running_backup_filename' )) {
|
||||
$ret['scheduleStatus'] = $schedule->get_status();
|
||||
} else {
|
||||
$status = $schedule->get_status();
|
||||
|
@ -450,7 +445,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<tr>
|
||||
|
||||
<th scope="col"><?php function_exists('hmbkp_backups_number') ? hmbkp_backups_number( $schedule ) : ( function_exists('backups_number') ? backups_number( $schedule ) : '' ); ?></th>
|
||||
<th scope="col"><?php function_exists('hmbkp_backups_number') ? hmbkp_backups_number( $schedule ) : ( function_exists('backups_number') ? backups_number( $schedule ) : "" ) ; ?></th>
|
||||
<th scope="col"><?php esc_html_e( 'Size', 'mainwp-backupwordpress-extension' ); ?></th>
|
||||
<th scope="col"><?php esc_html_e( 'Type', 'mainwp-backupwordpress-extension' ); ?></th>
|
||||
<th scope="col"><?php esc_html_e( 'Actions', 'mainwp-backupwordpress-extension' ); ?></th>
|
||||
|
@ -461,8 +456,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
if ( $schedule->get_backups() ) {
|
||||
<?php if ( $schedule->get_backups() ) {
|
||||
|
||||
$schedule->delete_old_backups();
|
||||
|
||||
|
@ -475,8 +469,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$this->hmbkp_get_backup_row( $file, $schedule );
|
||||
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
} else { ?>
|
||||
|
||||
<tr>
|
||||
<td class="hmbkp-no-backups"
|
||||
|
@ -496,7 +489,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
|
||||
function hmbkp_get_site_size_text( HM\BackUpWordPress\Scheduled_Backup $schedule ) {
|
||||
if ( method_exists($schedule, 'is_site_size_cached') ) {
|
||||
if (method_exists($schedule, 'is_site_size_cached')) {
|
||||
if ( ( 'database' === $schedule->get_type() ) || $schedule->is_site_size_cached() ) {
|
||||
return sprintf( '(<code title="' . __( 'Backups will be compressed and should be smaller than this.', 'mainwp-backupwordpress-extension' ) . '">%s</code>)', esc_attr( $schedule->get_formatted_site_size() ) );
|
||||
}
|
||||
|
@ -508,6 +501,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
}
|
||||
|
||||
return sprintf( '(<code class="calculating" title="' . __( 'this shouldn\'t take long…', 'mainwp-backupwordpress-extension' ) . '">' . __( 'calculating the size of your backup…', 'mainwp-backupwordpress-extension' ) . '</code>)' );
|
||||
|
||||
}
|
||||
|
||||
function hmbkp_get_backup_row( $file, HM\BackUpWordPress\Scheduled_Backup $schedule ) {
|
||||
|
@ -531,23 +525,20 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<td>
|
||||
|
||||
<?php
|
||||
if ( function_exists('hmbkp_is_path_accessible') ) {
|
||||
<?php if (function_exists('hmbkp_is_path_accessible')) {
|
||||
if ( hmbkp_is_path_accessible( hmbkp_path() ) ) {
|
||||
?>
|
||||
<a href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
||||
class="download-action"><?php esc_html_e( 'Download', 'backupwordpress' ); ?></a> |
|
||||
<?php
|
||||
};
|
||||
} elseif ( function_exists('HM\BackUpWordPress\is_path_accessible') ) {
|
||||
if ( HM\BackUpWordPress\is_path_accessible(HM\BackUpWordPress\Path::get_path()) ) {
|
||||
<?php };
|
||||
} else if (function_exists('HM\BackUpWordPress\is_path_accessible') ) {
|
||||
if (HM\BackUpWordPress\is_path_accessible(HM\BackUpWordPress\Path::get_path())) {
|
||||
?>
|
||||
<a href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
||||
class="download-action"><?php esc_html_e( 'Download', 'backupwordpress' ); ?></a> |
|
||||
<?php
|
||||
};
|
||||
<?php };
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -559,8 +550,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
<?php }
|
||||
|
||||
function get_excluded( $browse_dir = null ) {
|
||||
|
||||
|
@ -568,7 +558,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) );
|
||||
|
||||
$new_version = true;
|
||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
||||
if (method_exists($schedule, 'get_running_backup_filename' )) {
|
||||
$new_version = false;
|
||||
$user_excludes = array_diff( $schedule->get_excludes(), $schedule->backup->default_excludes() );
|
||||
$root_dir = $schedule->backup->get_root();
|
||||
|
@ -585,7 +575,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
?>
|
||||
<div class="hmbkp-exclude-settings">
|
||||
|
||||
<?php // if ( $schedule->get_excludes() ) : ?>
|
||||
<?php //if ( $schedule->get_excludes() ) : ?>
|
||||
|
||||
<h3>
|
||||
<?php esc_html_e( 'Currently Excluded', 'backupwordpress' ); ?>
|
||||
|
@ -625,14 +615,12 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<td>
|
||||
<?php
|
||||
if ( $new_version ) {
|
||||
if ($new_version)
|
||||
$is_default_rule = ( in_array( $exclude, $excludes->get_default_excludes() ) ) || ( HM\BackUpWordPress\Path::get_path() === trailingslashit( HM\BackUpWordPress\Path::get_root() ) . untrailingslashit( $exclude ) );
|
||||
} else {
|
||||
$is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) );
|
||||
}
|
||||
else
|
||||
$is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) ) ;
|
||||
|
||||
if ( $is_default_rule ) :
|
||||
?>
|
||||
if ( $is_default_rule ) : ?>
|
||||
<?php esc_html_e( 'Default rule', 'backupwordpress' ); ?>
|
||||
|
||||
<?php elseif ( defined( 'HMBKP_EXCLUDE' ) && false !== strpos( HMBKP_EXCLUDE, $exclude ) ) : ?>
|
||||
|
@ -657,7 +645,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
</table>
|
||||
|
||||
<?php // endif; ?>
|
||||
<?php //endif; ?>
|
||||
|
||||
<h3 id="directory-listing"><?php esc_html_e( 'Your Site', 'backupwordpress' ); ?></h3>
|
||||
|
||||
|
@ -678,22 +666,21 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
}
|
||||
|
||||
// Kick off a recursive filesize scan
|
||||
if ( $new_version ) {
|
||||
if ($new_version) {
|
||||
|
||||
$site_size = new HM\BackUpWordPress\Site_Size();
|
||||
$site_size = new HM\BackUpWordPress\Site_Size;
|
||||
|
||||
$exclude_string = implode( '|', $excludes->get_excludes_for_regex() );
|
||||
|
||||
if ( function_exists('HM\BackUpWordPress\list_directory_by_total_filesize') ) {
|
||||
if (function_exists('HM\BackUpWordPress\list_directory_by_total_filesize'))
|
||||
$files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory, $excludes );
|
||||
}
|
||||
|
||||
} else {
|
||||
$files = $schedule->list_directory_by_total_filesize( $directory );
|
||||
$exclude_string = $schedule->backup->exclude_string( 'regex' );
|
||||
}
|
||||
|
||||
if ( $files ) {
|
||||
?>
|
||||
if ( $files ) { ?>
|
||||
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
|
@ -715,19 +702,16 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<th scope="col">
|
||||
|
||||
<?php
|
||||
if ( $root_dir !== $directory ) {
|
||||
<?php if ( $root_dir !== $directory ) {
|
||||
// echo esc_url( remove_query_arg( 'hmbkp_directory_browse' ) );
|
||||
?>
|
||||
<a href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('', this)"><?php echo esc_html( $root_dir ); ?></a>
|
||||
<code>/</code>
|
||||
|
||||
<?php
|
||||
$parents = array_filter( explode( '/', str_replace( trailingslashit( $root_dir ), '', trailingslashit( dirname( $directory ) ) ) ) );
|
||||
<?php $parents = array_filter( explode( '/', str_replace( trailingslashit( $root_dir ), '', trailingslashit( dirname( $directory ) ) ) ) );
|
||||
|
||||
foreach ( $parents as $directory_basename ) {
|
||||
?>
|
||||
foreach ( $parents as $directory_basename ) { ?>
|
||||
|
||||
<a href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo urlencode( substr( $directory, 0, strpos( $directory, $directory_basename ) ) . $directory_basename ); ?>', this)"><?php echo esc_html( $directory_basename ); ?></a>
|
||||
|
@ -756,7 +740,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
$root = new SplFileInfo( $root_dir );
|
||||
|
||||
if ( $new_version ) {
|
||||
if ($new_version) {
|
||||
$size = $site_size->filesize( $root );
|
||||
} else {
|
||||
$size = $schedule->filesize( $root, true );
|
||||
|
@ -809,13 +793,12 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
foreach ( $files as $size => $file ) {
|
||||
<?php foreach ( $files as $size => $file ) {
|
||||
|
||||
$is_excluded = $is_unreadable = false;
|
||||
|
||||
// Check if the file is excluded
|
||||
if ( $new_version ) {
|
||||
if ($new_version) {
|
||||
if ( $exclude_string && preg_match( '(' . $exclude_string . ')', str_ireplace( trailingslashit( $root_dir ), '', wp_normalize_path( $file->getPathname() ) ) ) ) {
|
||||
$is_excluded = true;
|
||||
}
|
||||
|
@ -828,8 +811,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
// Skip unreadable files
|
||||
if ( ! @realpath( $file->getPathname() ) || ! $file->isReadable() ) {
|
||||
$is_unreadable = true;
|
||||
}
|
||||
?>
|
||||
} ?>
|
||||
|
||||
<tr>
|
||||
|
||||
|
@ -853,9 +835,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<td>
|
||||
<?php
|
||||
if ( $new_version ) {
|
||||
if ( $is_unreadable ) {
|
||||
?>
|
||||
if ($new_version) {
|
||||
if ( $is_unreadable ) { ?>
|
||||
|
||||
<code class="strikethrough"
|
||||
title="<?php echo esc_attr( wp_normalize_path( $file->getRealPath() ) ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
||||
|
@ -871,11 +852,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo urlencode( wp_normalize_path( $file->getPathname()) ); ?>', this)"><?php echo esc_html( $file->getBasename() ); ?></a></code>
|
||||
|
||||
|
||||
<?php
|
||||
}
|
||||
<?php }
|
||||
} else {
|
||||
if ( $is_unreadable ) {
|
||||
?>
|
||||
if ( $is_unreadable ) { ?>
|
||||
|
||||
<code class="strikethrough"
|
||||
title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
||||
|
@ -885,16 +864,14 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
<code
|
||||
title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
||||
|
||||
<?php
|
||||
} elseif ( $file->isDir() ) {
|
||||
// echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) );
|
||||
<?php } elseif ( $file->isDir() ) {
|
||||
//echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) );
|
||||
?>
|
||||
<code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a
|
||||
href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo urlencode( $file->getPathname() ); ?>', this)"><?php echo esc_html( $file->getBasename() ); ?></a></code>
|
||||
|
||||
<?php
|
||||
}
|
||||
<?php }
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -908,7 +885,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<?php
|
||||
else :
|
||||
if ( $new_version ) {
|
||||
if ($new_version) {
|
||||
$size = $site_size->filesize( $file );
|
||||
} else {
|
||||
$size = $schedule->filesize( $file );
|
||||
|
@ -920,8 +897,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
if ( ! $size ) {
|
||||
$size = '0 B';
|
||||
}
|
||||
?>
|
||||
} ?>
|
||||
|
||||
<code>
|
||||
|
||||
|
@ -942,8 +918,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<code>--</code>
|
||||
|
||||
<?php
|
||||
}
|
||||
<?php }
|
||||
endif;
|
||||
?>
|
||||
|
||||
|
@ -960,8 +935,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
<span
|
||||
title="<?php echo esc_attr( wp_normalize_path( $file->GetRealPath() ) ); ?>"><?php esc_html_e( 'Symlink', 'backupwordpress' ); ?></span>
|
||||
|
||||
<?php
|
||||
elseif ( $file->isDir() ) :
|
||||
<?php elseif ( $file->isDir() ) :
|
||||
|
||||
esc_html_e( 'Folder', 'backupwordpress' );
|
||||
|
||||
|
@ -1025,6 +999,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$information['e'] = $output;
|
||||
|
||||
return $information;
|
||||
|
||||
}
|
||||
|
||||
function directory_browse() {
|
||||
|
@ -1063,6 +1038,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$out['current_browse_dir'] = $_POST['browse_dir'];
|
||||
|
||||
return $out;
|
||||
|
||||
}
|
||||
|
||||
function hmbkp_remove_exclude_rule() {
|
||||
|
@ -1077,11 +1053,10 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$excludes = $schedule->get_excludes();
|
||||
$exclude_rule_to_remove = stripslashes( sanitize_text_field( $_POST['remove_rule'] ) );
|
||||
|
||||
if ( method_exists($excludes, 'get_user_excludes') ) {
|
||||
if (method_exists($excludes, 'get_user_excludes')) {
|
||||
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
|
||||
} else {
|
||||
} else
|
||||
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
|
||||
}
|
||||
|
||||
$schedule->save();
|
||||
|
||||
|
@ -1107,39 +1082,39 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
$exclude_paths = urldecode( $_POST['exclude_paths'] );
|
||||
$exclude_paths = explode("\n", $exclude_paths);
|
||||
if ( is_array($exclude_paths) && count($exclude_paths) > 0 ) {
|
||||
if (is_array($exclude_paths) && count($exclude_paths) > 0) {
|
||||
foreach ( $exclude_paths as $excl_rule ) {
|
||||
$excl_rule = trim($excl_rule);
|
||||
$excl_rule = trim($excl_rule, '/');
|
||||
|
||||
if ( empty($excl_rule) ) {
|
||||
if (empty($excl_rule))
|
||||
continue;
|
||||
}
|
||||
|
||||
$exclude_rule = ABSPATH . $excl_rule;
|
||||
$path = realpath($exclude_rule);
|
||||
// If it exist
|
||||
if ( $path !== false ) {
|
||||
if($path !== false)
|
||||
{
|
||||
$schedule->set_excludes( $exclude_rule, true );
|
||||
$schedule->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$un_exclude_paths = urldecode( $_POST['un_exclude_paths'] );
|
||||
$un_exclude_paths = explode("\n", $un_exclude_paths);
|
||||
|
||||
if ( is_array($un_exclude_paths) && count(get_user_excludes) > 0 ) {
|
||||
if (is_array($un_exclude_paths) && count(get_user_excludes) > 0) {
|
||||
foreach ( $un_exclude_paths as $exclude_rule_to_remove ) {
|
||||
$exclude_rule_to_remove = trim($exclude_rule_to_remove);
|
||||
$exclude_rule_to_remove = trim($exclude_rule_to_remove, '/');
|
||||
|
||||
if ( empty($exclude_rule_to_remove) ) {
|
||||
if (empty($exclude_rule_to_remove))
|
||||
continue;
|
||||
}
|
||||
|
||||
$excludes = $schedule->get_excludes();
|
||||
if ( method_exists($excludes, 'get_user_excludes') ) {
|
||||
if (method_exists($excludes, 'get_user_excludes')) {
|
||||
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
|
||||
} else {
|
||||
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
|
||||
|
@ -1148,7 +1123,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
}
|
||||
}
|
||||
|
||||
return array( 'result' => 'SUCCESS' );
|
||||
return array('result' => 'SUCCESS');
|
||||
}
|
||||
|
||||
|
||||
|
@ -1161,11 +1136,11 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
return array( 'error' => 'Error: Schedule data' );
|
||||
}
|
||||
|
||||
// $current_value = get_option( 'hmbkp_schedule_' . $sch_id );
|
||||
// if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) {
|
||||
// do not update 'excludes' value
|
||||
// $options['excludes'] = $current_value['excludes'];
|
||||
// }
|
||||
// $current_value = get_option( 'hmbkp_schedule_' . $sch_id );
|
||||
// if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) {
|
||||
// // do not update 'excludes' value
|
||||
// $options['excludes'] = $current_value['excludes'];
|
||||
// }
|
||||
|
||||
$filter_opts = array(
|
||||
'type',
|
||||
|
@ -1219,10 +1194,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
}
|
||||
|
||||
$out = array();
|
||||
foreach ( $schedules as $sch_id => $sch ) {
|
||||
if ( empty($sch_id) || ! isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) {
|
||||
foreach($schedules as $sch_id => $sch) {
|
||||
if ( empty($sch_id) || !isset( $sch['options'] ) || ! is_array( $sch['options'] ) )
|
||||
continue;
|
||||
}
|
||||
$options = $sch['options'];
|
||||
$filter_opts = array(
|
||||
'type',
|
||||
|
|
|
@ -58,15 +58,15 @@ class MainWP_Child_Back_WP_Up {
|
|||
);
|
||||
|
||||
static function Instance() {
|
||||
if ( self::$instance == null ) {
|
||||
self::$instance = new MainWP_Child_Back_WP_Up();
|
||||
if ( MainWP_Child_Back_WP_Up::$instance == null ) {
|
||||
MainWP_Child_Back_WP_Up::$instance = new MainWP_Child_Back_WP_Up();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_Back_WP_Up::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
|
||||
try {
|
||||
|
||||
|
@ -80,27 +80,27 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
|
||||
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
|
||||
require_once $file_path1;
|
||||
require_once $file_path2;
|
||||
require_once( $file_path1 );
|
||||
require_once( $file_path2 );
|
||||
$this->is_backwpup_installed = true;
|
||||
$this->is_backwpup_pro = true;
|
||||
} elseif ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
|
||||
} else if ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
|
||||
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
|
||||
MainWP_Helper::check_files_exists(array( $file_path ));
|
||||
require_once $file_path;
|
||||
require_once( $file_path );
|
||||
$this->is_backwpup_installed = true;
|
||||
}
|
||||
|
||||
if ( $this->is_backwpup_installed ) {
|
||||
if ($this->is_backwpup_installed) {
|
||||
MainWP_Helper::check_classes_exists('BackWPup');
|
||||
MainWP_Helper::check_methods('get_instance');
|
||||
BackWPup::get_instance();
|
||||
|
||||
// add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
|
||||
//add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
|
||||
add_action( 'admin_init', array( $this, 'init_download_backup' ) );
|
||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
} catch ( Exception $e) {
|
||||
// do not exit()
|
||||
$this->is_backwpup_installed = false;
|
||||
}
|
||||
|
@ -116,11 +116,11 @@ class MainWP_Child_Back_WP_Up {
|
|||
error_reporting( 0 );
|
||||
function mainwp_backwpup_handle_fatal_error() {
|
||||
$error = error_get_last();
|
||||
$info = self::$information;
|
||||
$info = MainWP_Child_Back_WP_Up::$information;
|
||||
if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) {
|
||||
MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
|
||||
} elseif ( ! empty( $info ) ) {
|
||||
MainWP_Helper::write( self::$information );
|
||||
} else if ( ! empty( $info ) ) {
|
||||
MainWP_Helper::write( MainWP_Child_Back_WP_Up::$information );
|
||||
} else {
|
||||
MainWP_Helper::write( array( 'error' => 'Missing information array inside fatal_error' ) );
|
||||
}
|
||||
|
@ -212,15 +212,14 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
self::$information = $information;
|
||||
MainWP_Child_Back_WP_Up::$information = $information;
|
||||
exit();
|
||||
}
|
||||
|
||||
public function init() {
|
||||
|
||||
if ( ! $this->is_backwpup_installed ) {
|
||||
if (!$this->is_backwpup_installed)
|
||||
return;
|
||||
}
|
||||
|
||||
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
||||
|
||||
|
@ -231,24 +230,21 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
|
||||
function do_site_stats() {
|
||||
if ( has_action('mainwp_child_reports_log') ) {
|
||||
if (has_action('mainwp_child_reports_log')) {
|
||||
do_action( 'mainwp_child_reports_log', 'backwpup');
|
||||
} else {
|
||||
$this->do_reports_log('backwpup');
|
||||
}
|
||||
}
|
||||
// ok
|
||||
public function do_reports_log( $ext = '' ) {
|
||||
if ( $ext !== 'backwpup' ) {
|
||||
public function do_reports_log($ext = '') {
|
||||
if ( $ext !== 'backwpup' ) return;
|
||||
if (!$this->is_backwpup_installed)
|
||||
return;
|
||||
}
|
||||
if ( ! $this->is_backwpup_installed ) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
MainWP_Helper::check_classes_exists(array( 'BackWPup_File', 'BackWPup_Job' ));
|
||||
MainWP_Helper::check_classes_exists(array('BackWPup_File', 'BackWPup_Job'));
|
||||
MainWP_Helper::check_methods('BackWPup_File', array( 'get_absolute_path' ));
|
||||
MainWP_Helper::check_methods('BackWPup_Job', array( 'read_logheader' ));
|
||||
|
||||
|
@ -258,12 +254,12 @@ class MainWP_Child_Back_WP_Up {
|
|||
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
|
||||
$log_folder = untrailingslashit( $log_folder );
|
||||
|
||||
// load logs
|
||||
//load logs
|
||||
$logfiles = array();
|
||||
if ( is_readable( $log_folder ) && $dir = opendir( $log_folder ) ) {
|
||||
while ( ( $file = readdir( $dir ) ) !== false ) {
|
||||
while ( ( $file = readdir( $dir ) ) !== FALSE ) {
|
||||
$log_file = $log_folder . '/' . $file;
|
||||
if ( is_file( $log_file ) && is_readable( $log_file ) && false !== strpos( $file, 'backwpup_log_' ) && false !== strpos( $file, '.html' ) ) {
|
||||
if ( is_file( $log_file ) && is_readable( $log_file ) && FALSE !== strpos( $file, 'backwpup_log_' ) && FALSE !== strpos( $file, '.html' ) ) {
|
||||
$logfiles[] = $file;
|
||||
}
|
||||
}
|
||||
|
@ -273,44 +269,43 @@ class MainWP_Child_Back_WP_Up {
|
|||
$log_items = array();
|
||||
foreach ( $logfiles as $mtime => $logfile ) {
|
||||
$meta = BackWPup_Job::read_logheader( $log_folder . '/' . $logfile );
|
||||
if ( ! isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged ) {
|
||||
if (!isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged)
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset($meta['errors']) && ! empty($meta['errors']) ) {
|
||||
if (isset($meta['errors']) && !empty($meta['errors'])) {
|
||||
continue; // do not logging backups have errors
|
||||
}
|
||||
|
||||
$log_items[ $mtime ] = $meta;
|
||||
$log_items[ $mtime ]['file'] = $logfile;
|
||||
$log_items[$mtime] = $meta;
|
||||
$log_items[$mtime]['file'] = $logfile;
|
||||
}
|
||||
|
||||
if ( ! empty( $log_items ) ) {
|
||||
if ( !empty( $log_items ) ) {
|
||||
$job_types = array(
|
||||
'DBDUMP' => __('Database backup', 'mainwp-child'),
|
||||
'FILE' => __('File backup', 'mainwp-child'),
|
||||
'WPEXP' => __('WordPress XML export', 'mainwp-child'),
|
||||
'WPPLUGIN' => __('Installed plugins list', 'mainwp-child'),
|
||||
'DBCHECK' => __('Check database tables', 'mainwp-child'),
|
||||
'DBCHECK' => __('Check database tables', 'mainwp-child')
|
||||
);
|
||||
|
||||
$new_lasttime_logged = $lasttime_logged;
|
||||
|
||||
foreach ( $log_items as $log ) {
|
||||
$backup_time = $log['logtime'];
|
||||
if ( $backup_time < $lasttime_logged ) {
|
||||
foreach ($log_items as $log) {
|
||||
$backup_time = $log[ "logtime" ];
|
||||
if ($backup_time < $lasttime_logged) {
|
||||
// small than last backup time then skip
|
||||
continue;
|
||||
}
|
||||
$job_job_types = explode('+', $log['type']);
|
||||
$backup_type = '';
|
||||
foreach ( $job_job_types as $typeid ) {
|
||||
if ( isset( $job_types[ $typeid ] ) ) {
|
||||
$backup_type .= ' + ' . $job_types[ $typeid ];
|
||||
foreach($job_job_types as $typeid) {
|
||||
if (isset( $job_types[$typeid] )) {
|
||||
$backup_type .= ' + ' . $job_types[$typeid];
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty($backup_type) ) {
|
||||
if (empty($backup_type)) {
|
||||
continue;
|
||||
} else {
|
||||
$backup_type = ltrim($backup_type, ' + ');
|
||||
|
@ -318,16 +313,15 @@ class MainWP_Child_Back_WP_Up {
|
|||
$message = 'BackWPup backup finished (' . $backup_type . ')';
|
||||
do_action( 'mainwp_reports_backwpup_backup', $message, $backup_type, $backup_time );
|
||||
|
||||
if ( $new_lasttime_logged < $backup_time ) {
|
||||
if ($new_lasttime_logged < $backup_time)
|
||||
$new_lasttime_logged = $backup_time;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $new_lasttime_logged > $lasttime_logged ) {
|
||||
if ($new_lasttime_logged > $lasttime_logged ) {
|
||||
MainWP_Helper::update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature
|
||||
}
|
||||
}
|
||||
} catch ( Exception $ex ) {
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -335,12 +329,12 @@ class MainWP_Child_Back_WP_Up {
|
|||
// ok
|
||||
function syncOthersData( $information, $data = array() ) {
|
||||
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
|
||||
try {
|
||||
try{
|
||||
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
|
||||
$information['syncBackwpupData'] = array(
|
||||
'lastbackup' => $lastbackup,
|
||||
'lastbackup' => $lastbackup
|
||||
);
|
||||
} catch ( Exception $e ) {
|
||||
} catch(Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +342,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
|
||||
function get_destinations_list() {
|
||||
MainWP_Helper::check_classes_exists(array( 'BackWPup', 'BackWPup_Option' ));
|
||||
MainWP_Helper::check_classes_exists(array('BackWPup', 'BackWPup_Option'));
|
||||
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
|
||||
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
|
||||
|
||||
|
@ -361,15 +355,15 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
$dests = BackWPup_Option::get( $jobid, 'destinations' );
|
||||
foreach ( $dests as $dest ) {
|
||||
if ( ! $destinations[ $dest ]['class'] ) {
|
||||
if ( ! $destinations[ $dest ][ 'class' ] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dest_class = BackWPup::get_destination( $dest );
|
||||
if ( $dest_class && method_exists($dest_class, 'file_get_list') ) {
|
||||
if ($dest_class && method_exists($dest_class, 'file_get_list')) {
|
||||
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
|
||||
if ( ! empty( $can_do_dest ) ) {
|
||||
$jobdest[] = $jobid . '_' . $dest;
|
||||
$jobdest[ ] = $jobid . '_' . $dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -518,7 +512,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
echo '<tr title="WP_MEMORY_LIMIT"><td>' . __( 'WP memory limit', 'backwpup' ) . '</td><td>' . esc_html( WP_MEMORY_LIMIT ) . '</td></tr>';
|
||||
echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __( 'WP maximum memory limit', 'backwpup' ) . '</td><td>' . esc_html( WP_MAX_MEMORY_LIMIT ) . '</td></tr>';
|
||||
echo '<tr title=""><td>' . __( 'Memory in use', 'backwpup' ) . '</td><td>' . esc_html( size_format( @memory_get_usage( true ), 2 ) ) . '</td></tr>';
|
||||
// disabled PHP functions
|
||||
//disabled PHP functions
|
||||
$disabled = ini_get( 'disable_functions' );
|
||||
if ( ! empty( $disabled ) ) {
|
||||
$disabledarry = explode( ',', $disabled );
|
||||
|
@ -526,7 +520,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
echo esc_html( implode( ', ', $disabledarry ) );
|
||||
echo '</td></tr>';
|
||||
}
|
||||
// Loaded PHP Extensions
|
||||
//Loaded PHP Extensions
|
||||
echo '<tr title=""><td>' . __( 'Loaded PHP Extensions:', 'backwpup' ) . '</td><td>';
|
||||
$extensions = get_loaded_extensions();
|
||||
sort( $extensions );
|
||||
|
@ -538,10 +532,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
ob_end_clean();
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $output,
|
||||
);
|
||||
return array( 'success' => 1, 'response' => $output );
|
||||
}
|
||||
|
||||
protected function delete_log() {
|
||||
|
@ -610,17 +601,11 @@ class MainWP_Child_Back_WP_Up {
|
|||
if ( is_array( $file ) && $file['file'] == $backupfile ) {
|
||||
$dest_class->file_delete( $dest, $backupfile );
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => 'DELETED',
|
||||
);
|
||||
return array( 'success' => 1, 'response' => 'DELETED' );
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => 'Not found',
|
||||
);
|
||||
return array( 'success' => 1, 'response' => 'Not found' );
|
||||
}
|
||||
|
||||
protected function view_log() {
|
||||
|
@ -650,10 +635,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $output,
|
||||
);
|
||||
return array( 'success' => 1, 'response' => $output );
|
||||
}
|
||||
|
||||
protected function tables() {
|
||||
|
@ -679,10 +661,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
$log_folder = untrailingslashit( $log_folder );
|
||||
|
||||
if ( ! is_dir( $log_folder ) ) {
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $array,
|
||||
);
|
||||
return array( 'success' => 1, 'response' => $array );
|
||||
}
|
||||
update_user_option( get_current_user_id(), 'backwpuplogs_per_page', 99999999 );
|
||||
$output = new BackWPup_Page_Logs();
|
||||
|
@ -713,7 +692,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
foreach ( $items as $item ) {
|
||||
$temp_single_item = $item;
|
||||
$temp_single_item['dest'] = $jobid . '_' . $dest;
|
||||
$temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item['time'], true ), date_i18n( get_option( 'time_format' ), $temp_single_item['time'], true ) );
|
||||
$temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item[ 'time' ], TRUE ), date_i18n( get_option( 'time_format' ), $temp_single_item[ 'time' ], TRUE ) );
|
||||
$output->items[] = $temp_single_item;
|
||||
}
|
||||
}
|
||||
|
@ -765,7 +744,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
$temp_array['website_id'] = $website_id;
|
||||
$array[] = $temp_array;
|
||||
}
|
||||
} elseif ( $type == 'backups' ) {
|
||||
} else if ( $type == 'backups' ) {
|
||||
$without_dupes = array();
|
||||
foreach ( $output->items as $key ) {
|
||||
$temp_array = $key;
|
||||
|
@ -778,8 +757,8 @@ class MainWP_Child_Back_WP_Up {
|
|||
), $temp_array['downloadurl'] . '&_wpnonce=' . $this->create_nonce_without_session( 'mainwp_download_backup' ) );
|
||||
|
||||
$temp_array['downloadurl_id'] = '/wp-admin/admin.php?page=backwpupbackups';
|
||||
if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches ) ) {
|
||||
if ( ! empty( $matches[1] ) && is_numeric( $matches[1] ) ) {
|
||||
if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches )) {
|
||||
if ( !empty( $matches[1] ) && is_numeric( $matches[1] ) ) {
|
||||
$temp_array['downloadurl_id'] .= '&download_click_id=' . $matches[1];
|
||||
}
|
||||
error_log('did match' . print_r($matches, true));
|
||||
|
@ -801,14 +780,11 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $array,
|
||||
);
|
||||
return array( 'success' => 1, 'response' => $array );
|
||||
}
|
||||
|
||||
public function init_download_backup() {
|
||||
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'backwpupbackups' || ! isset( $_GET['download_click_id'] ) || empty( $_GET['download_click_id'] ) ) {
|
||||
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'backwpupbackups' || !isset( $_GET['download_click_id'] ) || empty( $_GET['download_click_id'] )) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
@ -921,10 +897,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
ob_end_clean();
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $output,
|
||||
);
|
||||
return array( 'success' => 1, 'response' => $output );
|
||||
}
|
||||
|
||||
protected function backup_now() {
|
||||
|
@ -960,10 +933,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
'logfile' => basename( $job_object->logfile ),
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $output['message'],
|
||||
);
|
||||
return array( 'success' => 1, 'response' => $output['message'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -985,10 +955,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
if ( isset( $output['error'] ) ) {
|
||||
return array( 'error' => 'Cannot abort: ' . $output['error'] );
|
||||
} else {
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $output['message'],
|
||||
);
|
||||
return array( 'success' => 1, 'response' => $output['message'] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1002,11 +969,12 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
if ( ! function_exists( 'add_screen_option' ) ) {
|
||||
function add_screen_option( $option, $args = array() ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WP_List_Table' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1021,10 +989,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
ob_end_clean();
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $output,
|
||||
);
|
||||
return array( 'success' => 1, 'response' => $output );
|
||||
} else {
|
||||
return array( 'error' => 'Missing BackWPup_Pro_Wizard_SystemTest' );
|
||||
}
|
||||
|
@ -1049,7 +1014,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
// From BackWPup_Destination_Email::edit_ajax
|
||||
if ( $emailmethod ) {
|
||||
// do so if i'm the wp_mail to get the settings
|
||||
//do so if i'm the wp_mail to get the settings
|
||||
global $phpmailer;
|
||||
// (Re)create it, if it's gone missing
|
||||
if ( ! is_object( $phpmailer ) || ! $phpmailer instanceof PHPMailer ) {
|
||||
|
@ -1057,10 +1022,10 @@ class MainWP_Child_Back_WP_Up {
|
|||
require_once ABSPATH . WPINC . '/class-smtp.php';
|
||||
$phpmailer = new PHPMailer( true );
|
||||
}
|
||||
// only if PHPMailer really used
|
||||
//only if PHPMailer really used
|
||||
if ( is_object( $phpmailer ) ) {
|
||||
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
|
||||
// get settings from PHPMailer
|
||||
//get settings from PHPMailer
|
||||
$emailmethod = $phpmailer->Mailer;
|
||||
$emailsendmail = $phpmailer->Sendmail;
|
||||
$emailhost = $phpmailer->Host;
|
||||
|
@ -1071,7 +1036,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
// Generate mail with Swift Mailer
|
||||
//Generate mail with Swift Mailer
|
||||
if ( ! class_exists( 'Swift', false ) ) {
|
||||
require BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php';
|
||||
}
|
||||
|
@ -1123,10 +1088,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'message' => $message,
|
||||
);
|
||||
return array( 'success' => 1, 'message' => $message );
|
||||
}
|
||||
|
||||
protected function get_job_files() {
|
||||
|
@ -1192,18 +1154,11 @@ class MainWP_Child_Back_WP_Up {
|
|||
@closedir( $dir );
|
||||
}
|
||||
|
||||
$return[ $key ] = array(
|
||||
'size' => $main_folder_size,
|
||||
'name' => $folder,
|
||||
'folders' => $return_temp,
|
||||
);
|
||||
$return[ $key ] = array( 'size' => $main_folder_size, 'name' => $folder, 'folders' => $return_temp );
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'folders' => $return,
|
||||
);
|
||||
return array( 'success' => 1, 'folders' => $return );
|
||||
}
|
||||
|
||||
protected function get_child_tables() {
|
||||
|
@ -1255,13 +1210,10 @@ class MainWP_Child_Back_WP_Up {
|
|||
$return['tables'] = $tables_temp;
|
||||
}
|
||||
|
||||
if ( isset($settings['job_id']) ) {
|
||||
if (isset($settings['job_id'])) {
|
||||
$return['dbdumpexclude'] = BackWPup_Option::get( $settings['job_id'], 'dbdumpexclude' );
|
||||
}
|
||||
return array(
|
||||
'success' => 1,
|
||||
'return' => $return,
|
||||
);
|
||||
return array( 'success' => 1, 'return' => $return );
|
||||
}
|
||||
|
||||
protected function insert_or_update_jobs_global() {
|
||||
|
@ -1342,7 +1294,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
$to_exclude_parsed = array();
|
||||
foreach ( $to_exclude as $key => $value ) {
|
||||
$normalized = wp_normalize_path( trim( $value ) );
|
||||
$normalized and $to_exclude_parsed[ $key ] = $normalized;
|
||||
$normalized and $to_exclude_parsed[$key] = $normalized;
|
||||
}
|
||||
sort( $to_exclude_parsed );
|
||||
BackWPup_Option::update( $id, 'fileexclude', implode( ',', $to_exclude_parsed ) );
|
||||
|
@ -1357,7 +1309,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
$normalized = trailingslashit( wp_normalize_path( trim( $value ) ) );
|
||||
$normalized and $normalized = filter_var( $normalized, FILTER_SANITIZE_URL );
|
||||
$realpath = $normalized && $normalized !== '/' ? realpath( $normalized ) : false;
|
||||
$realpath and $to_include_parsed[ $key ] = $realpath;
|
||||
$realpath and $to_include_parsed[$key] = $realpath;
|
||||
}
|
||||
sort( $to_include_parsed );
|
||||
BackWPup_Option::update( $id, 'dirinclude', implode( ',', $to_include_parsed ) );
|
||||
|
@ -1375,34 +1327,19 @@ class MainWP_Child_Back_WP_Up {
|
|||
'backupuploads' => FILTER_VALIDATE_BOOLEAN,
|
||||
);
|
||||
|
||||
foreach ( $boolean_fields_def as $key => $value ) {
|
||||
BackWPup_Option::update( $id, $key, ! empty( $post_data[ $key ] ) );
|
||||
foreach( $boolean_fields_def as $key => $value ) {
|
||||
BackWPup_Option::update( $id, $key, ! empty( $post_data[$key] ) );
|
||||
}
|
||||
// Parse and save directories to exclude
|
||||
$exclude_dirs_def = array(
|
||||
'backuprootexcludedirs' => array(
|
||||
'filter' => FILTER_SANITIZE_URL,
|
||||
'flags' => FILTER_FORCE_ARRAY,
|
||||
),
|
||||
'backuppluginsexcludedirs' => array(
|
||||
'filter' => FILTER_SANITIZE_URL,
|
||||
'flags' => FILTER_FORCE_ARRAY,
|
||||
),
|
||||
'backupcontentexcludedirs' => array(
|
||||
'filter' => FILTER_SANITIZE_URL,
|
||||
'flags' => FILTER_FORCE_ARRAY,
|
||||
),
|
||||
'backupthemesexcludedirs' => array(
|
||||
'filter' => FILTER_SANITIZE_URL,
|
||||
'flags' => FILTER_FORCE_ARRAY,
|
||||
),
|
||||
'backupuploadsexcludedirs' => array(
|
||||
'filter' => FILTER_SANITIZE_URL,
|
||||
'flags' => FILTER_FORCE_ARRAY,
|
||||
),
|
||||
'backuprootexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
|
||||
'backuppluginsexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
|
||||
'backupcontentexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
|
||||
'backupthemesexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
|
||||
'backupuploadsexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
|
||||
);
|
||||
foreach ( $exclude_dirs_def as $key => $filter ) {
|
||||
$value = ! empty( $post_data[ $key ] ) && is_array( $post_data[ $key ] ) ? $post_data[ $key ] : array();
|
||||
foreach( $exclude_dirs_def as $key => $filter ) {
|
||||
$value = ! empty( $post_data[$key] ) && is_array( $post_data[$key] ) ? $post_data[$key] : array();
|
||||
BackWPup_Option::update( $id, $key, $value );
|
||||
}
|
||||
}
|
||||
|
@ -1430,7 +1367,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
if ( $settings['job_id'] > 0 ) {
|
||||
$job_id = intval( $settings['job_id'] );
|
||||
} else {
|
||||
// generate jobid if not exists
|
||||
//generate jobid if not exists
|
||||
$newjobid = BackWPup_Option::get_job_ids();
|
||||
sort( $newjobid );
|
||||
$job_id = end( $newjobid ) + 1;
|
||||
|
@ -1438,9 +1375,9 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
update_site_option( 'backwpup_messages', array() );
|
||||
|
||||
if ( isset($settings['value']['backupdir']) && empty($settings['value']['backupdir']) ) {
|
||||
$backupdir = BackWPup_Option::get( (int) $job_id, 'backupdir' );
|
||||
if ( ! empty($backupdir) ) {
|
||||
if (isset($settings['value']['backupdir']) && empty($settings['value']['backupdir'])) {
|
||||
$backupdir = BackWPup_Option::get( (int)$job_id, 'backupdir' );
|
||||
if (!empty($backupdir)) {
|
||||
$settings['value']['backupdir'] = $backupdir;
|
||||
}
|
||||
}
|
||||
|
@ -1449,16 +1386,16 @@ class MainWP_Child_Back_WP_Up {
|
|||
$_POST[ $key ] = $val;
|
||||
}
|
||||
|
||||
if ( $settings['tab'] == 'jobtype-FILE' ) {
|
||||
if ($settings['tab'] == 'jobtype-FILE') {
|
||||
// to fix
|
||||
$this->edit_form_post_save($settings['value'], $job_id);
|
||||
// saved message
|
||||
//saved message
|
||||
$messages = BackWPup_Admin::get_messages();
|
||||
if ( empty( $messages['error'] ) ) {
|
||||
$url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id );
|
||||
BackWPup_Admin::message( sprintf( __( 'Changes for job <i>%s</i> saved.', 'backwpup' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' <a href="' . network_admin_url( 'admin.php' ) . '?page=backwpupjobs">' . __( 'Jobs overview', 'backwpup' ) . '</a> | <a href="' . $url['url'] . '">' . __( 'Run now', 'backwpup' ) . '</a>' );
|
||||
}
|
||||
} elseif ( $settings['tab'] == 'dest-DROPBOX' ) {
|
||||
} else if ($settings['tab'] == 'dest-DROPBOX') {
|
||||
unset($settings['value']); // do not save dropbox settings
|
||||
BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id );
|
||||
} else {
|
||||
|
@ -1500,7 +1437,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
if ( ! in_array( $key, $this->exclusions[ $settings['tab'] ] ) && strcmp( $temp_value, $val ) != 0 ) {
|
||||
$changes_array[ $key ] = $temp_value;
|
||||
}
|
||||
} elseif ( strcmp( $temp_value, $val ) != 0 ) {
|
||||
} else if ( strcmp( $temp_value, $val ) != 0 ) {
|
||||
$changes_array[ $key ] = $temp_value;
|
||||
}
|
||||
}
|
||||
|
@ -1573,11 +1510,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'changes' => $changes_array,
|
||||
'message' => $return['message'],
|
||||
);
|
||||
return array( 'success' => 1, 'changes' => $changes_array, 'message' => $return['message'] );
|
||||
}
|
||||
|
||||
protected function check_backwpup_messages() {
|
||||
|
@ -1586,11 +1519,12 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
if ( isset( $message['error'] ) ) {
|
||||
return array( 'error' => implode( ', ', $message['error'] ) );
|
||||
} elseif ( isset( $message['updated'] ) ) {
|
||||
} else if ( isset( $message['updated'] ) ) {
|
||||
return array( 'message' => $message['updated'] );
|
||||
} else {
|
||||
return array( 'error' => 'Generic error' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ class MainWP_Child_Branding {
|
|||
public $child_branding_options = null;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Branding();
|
||||
if ( null === MainWP_Child_Branding::$instance ) {
|
||||
MainWP_Child_Branding::$instance = new MainWP_Child_Branding();
|
||||
}
|
||||
return self::$instance;
|
||||
return MainWP_Child_Branding::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
@ -20,11 +20,11 @@ class MainWP_Child_Branding {
|
|||
$this->child_branding_options = $this->init_options();
|
||||
}
|
||||
|
||||
function init_options() {
|
||||
function init_options(){
|
||||
|
||||
$opts = get_option( 'mainwp_child_branding_settings' );
|
||||
|
||||
if ( ! is_array( $opts ) ) {
|
||||
if ( !is_array( $opts ) ) {
|
||||
// compatible with old code
|
||||
$opts = array();
|
||||
|
||||
|
@ -38,7 +38,7 @@ class MainWP_Child_Branding {
|
|||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $opts );
|
||||
}
|
||||
|
||||
if ( ! isset($opts['contact_label']) || empty($opts['contact_label']) ) {
|
||||
if ( !isset($opts['contact_label']) || empty($opts['contact_label']) ) {
|
||||
$opts['contact_label'] = 'Contact Support';
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class MainWP_Child_Branding {
|
|||
$opts['branding_preserve_title'] = '';
|
||||
|
||||
if ( ! $cancelled_branding ) {
|
||||
if ( isset($opts['branding_header']) ) {
|
||||
if (isset($opts['branding_header'])) {
|
||||
$branding_header = $opts['branding_header'];
|
||||
if ( is_array( $branding_header ) && isset( $branding_header['name'] ) && ! empty( $branding_header['name'] ) ) {
|
||||
$opts['branding_preserve_title'] = stripslashes( $branding_header['name'] );
|
||||
|
@ -64,12 +64,11 @@ class MainWP_Child_Branding {
|
|||
|
||||
function get_extra_options() {
|
||||
$extra = array();
|
||||
if ( is_array($this->child_branding_options) && isset($this->child_branding_options['extra_settings']) ) {
|
||||
if (is_array($this->child_branding_options) && isset($this->child_branding_options['extra_settings'])) {
|
||||
$extra = $this->child_branding_options['extra_settings'];
|
||||
if ( ! is_array($extra) ) {
|
||||
if (!is_array($extra))
|
||||
$extra = array();
|
||||
}
|
||||
}
|
||||
|
||||
return $extra;
|
||||
}
|
||||
|
@ -110,7 +109,7 @@ class MainWP_Child_Branding {
|
|||
'mainwp_branding_remove_wp_tools',
|
||||
'mainwp_branding_remove_wp_setting',
|
||||
'mainwp_branding_remove_permalink',
|
||||
// 'mainwp_branding_plugin_header', // don't remove header
|
||||
//'mainwp_branding_plugin_header', // don't remove header
|
||||
'mainwp_branding_button_contact_label',
|
||||
'mainwp_branding_send_email_message',
|
||||
'mainwp_branding_message_return_sender',
|
||||
|
@ -136,7 +135,7 @@ class MainWP_Child_Branding {
|
|||
'remove_wp_tools',
|
||||
'remove_wp_setting',
|
||||
'remove_permalink',
|
||||
// 'branding_header', // don't remove header
|
||||
//'branding_header', // don't remove header
|
||||
'contact_label',
|
||||
'email_message',
|
||||
'message_return_sender',
|
||||
|
@ -145,12 +144,13 @@ class MainWP_Child_Branding {
|
|||
'branding_ext_enabled',
|
||||
);
|
||||
|
||||
foreach ( $brandingOptions_empty as $opt ) {
|
||||
if ( isset($this->child_branding_options[ $opt ]) ) {
|
||||
$this->child_branding_options[ $opt ] = '';
|
||||
foreach($brandingOptions_empty as $opt) {
|
||||
if (isset($this->child_branding_options[$opt])) {
|
||||
$this->child_branding_options[$opt] = '';
|
||||
}
|
||||
}
|
||||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,7 +174,7 @@ class MainWP_Child_Branding {
|
|||
$current_settings = $this->child_branding_options;
|
||||
$current_extra_setting = $this->child_branding_options['extra_settings'];
|
||||
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
|
||||
//MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
|
||||
$current_settings['branding_ext_enabled'] = 'Y';
|
||||
|
||||
$header = array(
|
||||
|
@ -187,22 +187,22 @@ class MainWP_Child_Branding {
|
|||
|
||||
MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' ); // to compatible with old version of child report plugin
|
||||
MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' ); // to compatible
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] );
|
||||
// if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
|
||||
// }
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] );
|
||||
// if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
|
||||
// }
|
||||
|
||||
$current_settings['preserve_branding'] = $settings['child_preserve_branding'];
|
||||
$current_settings['branding_header'] = $header;
|
||||
|
@ -211,7 +211,7 @@ class MainWP_Child_Branding {
|
|||
$current_settings['remove_restore'] = $settings['child_remove_restore'];
|
||||
$current_settings['remove_setting'] = $settings['child_remove_setting'];
|
||||
$current_settings['remove_server_info'] = $settings['child_remove_server_info'];
|
||||
$current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0;
|
||||
$current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0 ;
|
||||
$current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools'];
|
||||
$current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting'];
|
||||
$current_settings['remove_permalink'] = $settings['child_remove_permalink'];
|
||||
|
@ -266,12 +266,9 @@ class MainWP_Child_Branding {
|
|||
$extra_setting['login_image'] = array();
|
||||
} else {
|
||||
try {
|
||||
$upload = $this->uploadImage( $settings['child_login_image_url'] ); // Upload image to WP
|
||||
$upload = $this->uploadImage( $settings['child_login_image_url'] ); //Upload image to WP
|
||||
if ( null !== $upload ) {
|
||||
$extra_setting['login_image'] = array(
|
||||
'path' => $upload['path'],
|
||||
'url' => $upload['url'],
|
||||
);
|
||||
$extra_setting['login_image'] = array( 'path' => $upload['path'], 'url' => $upload['url'] );
|
||||
if ( isset( $current_extra_setting['login_image']['path'] ) ) {
|
||||
$old_file = $current_extra_setting['login_image']['path'];
|
||||
if ( ! empty( $old_file ) && file_exists( $old_file ) ) {
|
||||
|
@ -283,7 +280,7 @@ class MainWP_Child_Branding {
|
|||
$information['error']['login_image'] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
} elseif ( isset( $current_extra_setting['login_image'] ) ) {
|
||||
} else if ( isset( $current_extra_setting['login_image'] ) ) {
|
||||
$extra_setting['login_image'] = $current_extra_setting['login_image'];
|
||||
}
|
||||
|
||||
|
@ -292,12 +289,9 @@ class MainWP_Child_Branding {
|
|||
$extra_setting['favico_image'] = array();
|
||||
} else {
|
||||
try {
|
||||
$upload = $this->uploadImage( $settings['child_favico_image_url'] ); // Upload image to WP
|
||||
$upload = $this->uploadImage( $settings['child_favico_image_url'] ); //Upload image to WP
|
||||
if ( null !== $upload ) {
|
||||
$extra_setting['favico_image'] = array(
|
||||
'path' => $upload['path'],
|
||||
'url' => $upload['url'],
|
||||
);
|
||||
$extra_setting['favico_image'] = array( 'path' => $upload['path'], 'url' => $upload['url'] );
|
||||
if ( isset( $current_extra_setting['favico_image']['path'] ) ) {
|
||||
$old_file = $current_extra_setting['favico_image']['path'];
|
||||
if ( ! empty( $old_file ) && file_exists( $old_file ) ) {
|
||||
|
@ -309,11 +303,11 @@ class MainWP_Child_Branding {
|
|||
$information['error']['favico_image'] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
} elseif ( isset( $current_extra_setting['favico_image'] ) ) {
|
||||
} else if ( isset( $current_extra_setting['favico_image'] ) ) {
|
||||
$extra_setting['favico_image'] = $current_extra_setting['favico_image'];
|
||||
}
|
||||
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
|
||||
//MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
|
||||
$current_settings['extra_settings'] = $extra_setting;
|
||||
|
||||
// keep it to compatible with old version of child reports plugin
|
||||
|
@ -322,27 +316,27 @@ class MainWP_Child_Branding {
|
|||
} else {
|
||||
MainWP_Helper::update_option( 'mainwp_branding_child_hide', '' );
|
||||
}
|
||||
//
|
||||
// if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_show_support', '' );
|
||||
// }
|
||||
//
|
||||
// if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_show_support', '' );
|
||||
// }
|
||||
|
||||
// if ( $settings['child_disable_change'] ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' );
|
||||
// }
|
||||
// if ( $settings['child_disable_change'] ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' );
|
||||
// }
|
||||
|
||||
// if ( $settings['child_disable_switching_theme'] ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
|
||||
// }
|
||||
// if ( $settings['child_disable_switching_theme'] ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
|
||||
// }
|
||||
|
||||
$current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
|
||||
$current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : '';
|
||||
$current_settings['show_support'] = ( $settings['child_show_support_button'] && !empty($settings['child_support_email']) ) ? 'T' : '';
|
||||
$current_settings['disable_change'] = $settings['child_disable_change'] ? 'T' : '';
|
||||
$current_settings['disable_switching_theme'] = $settings['child_disable_switching_theme'] ? 'T' : '';
|
||||
|
||||
|
@ -354,10 +348,10 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
|
||||
static function uploadImage( $img_url ) {
|
||||
include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
|
||||
include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
|
||||
global $mainWPChild;
|
||||
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||
// Download $img_url
|
||||
//Download $img_url
|
||||
$temporary_file = download_url( $img_url );
|
||||
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||
|
||||
|
@ -365,15 +359,12 @@ class MainWP_Child_Branding {
|
|||
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
|
||||
} else {
|
||||
$upload_dir = wp_upload_dir();
|
||||
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); // Local name
|
||||
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); //Local name
|
||||
$local_img_path = dirname( $local_img_path ) . '/' . wp_unique_filename( dirname( $local_img_path ), basename( $local_img_path ) );
|
||||
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
|
||||
$moved = @rename( $temporary_file, $local_img_path );
|
||||
if ( $moved ) {
|
||||
return array(
|
||||
'path' => $local_img_path,
|
||||
'url' => $local_img_url,
|
||||
);
|
||||
return array( 'path' => $local_img_path, 'url' => $local_img_url );
|
||||
}
|
||||
}
|
||||
if ( file_exists( $temporary_file ) ) {
|
||||
|
@ -389,10 +380,10 @@ class MainWP_Child_Branding {
|
|||
$extra_setting = $this->get_extra_options();
|
||||
|
||||
// to hide updates notice
|
||||
if ( is_admin() ) {
|
||||
if (is_admin()) {
|
||||
// back end
|
||||
add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) );
|
||||
} elseif ( is_user_logged_in() ) {
|
||||
} else if (is_user_logged_in()) {
|
||||
// front end
|
||||
add_action( 'wp_after_admin_bar_render', array( $this, 'after_admin_bar_render' ));
|
||||
}
|
||||
|
@ -411,40 +402,37 @@ class MainWP_Child_Branding {
|
|||
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
|
||||
}
|
||||
|
||||
if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
|
||||
if ( !isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 );
|
||||
|
||||
if ( 'T' === $opts['disable_change'] ) {
|
||||
if ( 'T' === $opts['disable_change']) {
|
||||
|
||||
// Disable the WordPress plugin update notifications
|
||||
// Disable the wordpress plugin update notifications
|
||||
remove_action('load-update-core.php', 'wp_update_plugins');
|
||||
add_filter('pre_site_transient_update_plugins', '__return_null');
|
||||
|
||||
// Disable the WordPress theme update notifications
|
||||
// Disable the wordpress theme update notifications
|
||||
remove_action('load-update-core.php', 'wp_update_themes');
|
||||
add_filter('pre_site_transient_update_themes', ( $func = function( $a ) {
|
||||
return null;
|
||||
} ));
|
||||
add_filter('pre_site_transient_update_themes', ( $func = function($a){ return null;} ));
|
||||
|
||||
// Disable the WordPress core update notifications
|
||||
// Disable the wordpress core update notifications
|
||||
add_action('after_setup_theme', 'remove_core_updates');
|
||||
function remove_core_updates() {
|
||||
add_action('init', ( $func = function( $a ) {
|
||||
remove_action( 'wp_version_check', 'wp_version_check' );
|
||||
} ), 2);
|
||||
add_action('init', ( $func = function($a){ remove_action( 'wp_version_check', 'wp_version_check' );} ), 2);
|
||||
add_filter('pre_option_update_core', '__return_null');
|
||||
add_filter('pre_site_transient_update_core', '__return_null');
|
||||
}
|
||||
|
||||
add_action( 'admin_head', array( &$this, 'admin_head_hide_elements' ), 15 );
|
||||
add_action( 'admin_menu', array( $this, 'branding_redirect' ), 9);
|
||||
add_action( 'admin_menu', array($this, 'branding_redirect' ), 9);
|
||||
}
|
||||
|
||||
// to fix
|
||||
add_action( 'admin_menu', array( &$this, 'admin_menu' ) ); if ( ! isset($opts['disable_wp_branding']) || $opts['disable_wp_branding'] !== 'Y' ) {
|
||||
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );//
|
||||
if ( !isset($opts['disable_wp_branding']) || $opts['disable_wp_branding'] !== 'Y' ) {
|
||||
add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
|
||||
add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
|
||||
// branding site generator
|
||||
|
@ -460,13 +448,13 @@ class MainWP_Child_Branding {
|
|||
add_filter( 'login_headertext', array( &$this, 'custom_login_headertitle' ) );
|
||||
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
|
||||
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
||||
// remove_filter( 'update_footer', 'core_update_footer' );
|
||||
//remove_filter( 'update_footer', 'core_update_footer' );
|
||||
add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 );
|
||||
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
|
||||
}
|
||||
|
||||
if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) {
|
||||
add_action( 'admin_init', array( $this, 'admin_init' ));
|
||||
add_action( 'admin_init', array($this, 'admin_init'));
|
||||
}
|
||||
|
||||
add_action( 'admin_menu', array( &$this, 'remove_default_post_metaboxes' ) );
|
||||
|
@ -482,8 +470,9 @@ class MainWP_Child_Branding {
|
|||
// to fix conflict with other plugin
|
||||
function admin_menu() {
|
||||
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
|
||||
if ( $allow_contact ) {; // ok
|
||||
} elseif ( ! current_user_can( 'administrator' ) ) {
|
||||
if ( $allow_contact ) {
|
||||
; // ok
|
||||
} else if ( !current_user_can( 'administrator' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -511,6 +500,7 @@ class MainWP_Child_Branding {
|
|||
add_action( 'admin_bar_menu', array( $this, 'add_support_button_in_top_admin_bar' ), 100 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function remove_default_post_metaboxes() {
|
||||
|
@ -640,8 +630,7 @@ class MainWP_Child_Branding {
|
|||
el.parentElement.innerHTML = '';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
</script><?php
|
||||
}
|
||||
|
||||
function core_update_footer() {
|
||||
|
@ -808,22 +797,22 @@ class MainWP_Child_Branding {
|
|||
$email = $this->child_branding_options['support_email'];
|
||||
$sub = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_subject'] ) ) );
|
||||
$from = trim($_POST['mainwp_branding_contact_send_from']);
|
||||
$subject = ! empty( $sub ) ? $sub : 'MainWP - Support Contact';
|
||||
$subject = !empty( $sub ) ? $sub : "MainWP - Support Contact";
|
||||
$content = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_content'] ) ) );
|
||||
$mail = $headers = '';
|
||||
if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) {
|
||||
global $current_user;
|
||||
$headers .= "Content-Type: text/html;charset=utf-8\r\n";
|
||||
if ( ! empty($from) ) {
|
||||
$headers .= 'From: "' . $from . '" <' . $from . ">\r\n";
|
||||
}
|
||||
if (!empty($from))
|
||||
$headers .= "From: \"" . $from . "\" <" . $from . ">\r\n";
|
||||
$mail .= "<p>Support Email from: <a href='" . site_url() . "'>" . site_url() . "</a></p>\r\n\r\n";
|
||||
$mail .= '<p>Sent from WordPress page: ' . ( ! empty( $_POST['mainwp_branding_send_from_page'] ) ? "<a href='" . esc_url( $_POST['mainwp_branding_send_from_page'] ) . "'>" . esc_url( $_POST['mainwp_branding_send_from_page'] ) . "</a></p>\r\n\r\n" : '' );
|
||||
$mail .= '<p>Client Email: ' . $current_user->user_email . " </p>\r\n\r\n";
|
||||
$mail .= "<p>Sent from WordPress page: " . ( ! empty( $_POST["mainwp_branding_send_from_page"] ) ? "<a href='" . esc_url( $_POST["mainwp_branding_send_from_page"] ) . "'>" . esc_url( $_POST["mainwp_branding_send_from_page"] ) . "</a></p>\r\n\r\n" : "" );
|
||||
$mail .= "<p>Client Email: " . $current_user->user_email . " </p>\r\n\r\n";
|
||||
$mail .= "<p>Support Text:</p>\r\n\r\n";
|
||||
$mail .= '<p>' . $content . "</p>\r\n\r\n";
|
||||
$mail .= "<p>" . $content . "</p>\r\n\r\n";
|
||||
|
||||
if ( @wp_mail( $email, $subject, $mail, $headers ) ) {;
|
||||
if ( @wp_mail( $email, $subject, $mail, $headers ) ) {
|
||||
;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -871,8 +860,7 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
?>
|
||||
<div
|
||||
class="mainwp_info-box-yellow"><?php echo esc_html( $send_email_message ) . '  ' . $back_link; ?></div>
|
||||
<?php
|
||||
class="mainwp_info-box-yellow"><?php echo esc_html( $send_email_message ) . "  " . $back_link; ?></div><?php
|
||||
} else {
|
||||
$from_page = '';
|
||||
if ( isset( $_GET['from_page'] ) ) {
|
||||
|
@ -925,8 +913,7 @@ class MainWP_Child_Branding {
|
|||
value="<?php echo esc_url( $from_page ); ?>"/>
|
||||
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( '_contactNonce' ) ); ?>"/>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
<?php }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -934,8 +921,9 @@ class MainWP_Child_Branding {
|
|||
*/
|
||||
public function add_support_button_in_top_admin_bar( $wp_admin_bar ) {
|
||||
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
|
||||
if ( $allow_contact ) {; // ok
|
||||
} elseif ( ! current_user_can( 'administrator' ) ) {
|
||||
if ( $allow_contact ) {
|
||||
; // ok
|
||||
} else if ( !current_user_can( 'administrator' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -963,7 +951,7 @@ class MainWP_Child_Branding {
|
|||
public function is_branding() {
|
||||
$opts = $this->child_branding_options;
|
||||
|
||||
if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
|
||||
if (!isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -978,7 +966,7 @@ class MainWP_Child_Branding {
|
|||
if ( 'T' === $is_hide ) {
|
||||
return true;
|
||||
}
|
||||
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
|
||||
if ( is_array( $branding_header ) && !empty( $branding_header['name'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -997,38 +985,37 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
|
||||
public function save_branding_options( $name, $val ) {
|
||||
$this->child_branding_options[ $name ] = $val;
|
||||
$this->child_branding_options[$name] = $val;
|
||||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
|
||||
}
|
||||
|
||||
public function after_admin_bar_render() {
|
||||
|
||||
$hide_slugs = apply_filters('mainwp_child_hide_update_notice', array());
|
||||
$hide_slugs = apply_filters('mainwp_child_hide_update_notice' , array());
|
||||
|
||||
if ( ! is_array($hide_slugs) ) {
|
||||
if (!is_array($hide_slugs))
|
||||
$hide_slugs = array();
|
||||
}
|
||||
|
||||
if ( count($hide_slugs) == 0 ) {
|
||||
if (count($hide_slugs) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! function_exists('get_plugin_updates') ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/update.php';
|
||||
if (!function_exists('get_plugin_updates')) {
|
||||
include_once( ABSPATH . '/wp-admin/includes/update.php' );
|
||||
}
|
||||
|
||||
$count_hide = 0;
|
||||
|
||||
$updates = get_plugin_updates();
|
||||
if ( is_array($updates) ) {
|
||||
foreach ( $updates as $slug => $data ) {
|
||||
if ( in_array($slug, $hide_slugs) ) {
|
||||
if (is_array($updates)) {
|
||||
foreach($updates as $slug => $data) {
|
||||
if (in_array($slug, $hide_slugs)) {
|
||||
$count_hide++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $count_hide == 0 ) {
|
||||
if ( $count_hide == 0) {
|
||||
return;
|
||||
}
|
||||
// js for front end
|
||||
|
@ -1050,30 +1037,29 @@ class MainWP_Child_Branding {
|
|||
$adminBarUpdates.textContent = itemCount;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
</script><?php
|
||||
|
||||
}
|
||||
|
||||
public function in_admin_footer() {
|
||||
|
||||
$hide_slugs = apply_filters('mainwp_child_hide_update_notice', array());
|
||||
$hide_slugs = apply_filters('mainwp_child_hide_update_notice' , array());
|
||||
|
||||
if ( ! is_array($hide_slugs) ) {
|
||||
if (!is_array($hide_slugs))
|
||||
$hide_slugs = array();
|
||||
}
|
||||
|
||||
$count_hide = 0;
|
||||
|
||||
$updates = get_plugin_updates();
|
||||
if ( is_array($updates) ) {
|
||||
foreach ( $updates as $slug => $data ) {
|
||||
if ( in_array($slug, $hide_slugs) ) {
|
||||
if (is_array($updates)) {
|
||||
foreach($updates as $slug => $data) {
|
||||
if (in_array($slug, $hide_slugs)) {
|
||||
$count_hide++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $count_hide == 0 ) {
|
||||
if ( $count_hide == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1086,7 +1072,7 @@ class MainWP_Child_Branding {
|
|||
if (typeof(pagenow) !== 'undefined' && pagenow == 'plugins') {
|
||||
<?php
|
||||
// hide update notice row
|
||||
if ( in_array('mainwp-child/mainwp-child.php', $hide_slugs) ) {
|
||||
if (in_array('mainwp-child/mainwp-child.php', $hide_slugs)) {
|
||||
?>
|
||||
var el = document.querySelector('tr#mainwp-child-update');
|
||||
if (typeof(el) !== 'undefined' && el !== null) {
|
||||
|
@ -1095,7 +1081,7 @@ class MainWP_Child_Branding {
|
|||
<?php
|
||||
}
|
||||
// hide update notice row
|
||||
if ( in_array('mainwp-child-reports/mainwp-child-reports.php', $hide_slugs) ) {
|
||||
if (in_array('mainwp-child-reports/mainwp-child-reports.php', $hide_slugs)) {
|
||||
?>
|
||||
var el = document.querySelector('tr#mainwp-child-reports-update');
|
||||
if (typeof(el) !== 'undefined' && el !== null) {
|
||||
|
@ -1129,8 +1115,7 @@ class MainWP_Child_Branding {
|
|||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
</script><?php
|
||||
}
|
||||
|
||||
public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
||||
|
@ -1164,7 +1149,7 @@ class MainWP_Child_Branding {
|
|||
return $plugins;
|
||||
}
|
||||
|
||||
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
|
||||
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) && is_array( $plugins ) ) {
|
||||
return $this->update_plugin_header( $plugins, $branding_header );
|
||||
} else {
|
||||
return $plugins;
|
||||
|
@ -1185,7 +1170,7 @@ class MainWP_Child_Branding {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if ( ! MainWP_Helper::is_screen_with_update() ) {
|
||||
if (! MainWP_Helper::is_screen_with_update()) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class MainWP_Child_DB {
|
||||
// Support old & new versions of WordPress (3.9+)
|
||||
//Support old & new versions of wordpress (3.9+)
|
||||
public static function use_mysqli() {
|
||||
/** @var $wpdb wpdb */
|
||||
if ( ! function_exists( 'mysqli_connect' ) ) {
|
||||
|
@ -90,9 +90,9 @@ class MainWP_Child_DB {
|
|||
/** @var $wpdb wpdb */
|
||||
global $wpdb;
|
||||
|
||||
$rows = self::_query( 'SHOW table STATUS', $wpdb->dbh );
|
||||
$rows = MainWP_Child_DB::_query( 'SHOW table STATUS', $wpdb->dbh );
|
||||
$size = 0;
|
||||
while ( $row = self::fetch_array( $rows ) ) {
|
||||
while ( $row = MainWP_Child_DB::fetch_array( $rows ) ) {
|
||||
$size += $row['Data_length'];
|
||||
}
|
||||
|
||||
|
|
|
@ -20,33 +20,32 @@ class MainWP_Child_iThemes_Security {
|
|||
public $is_plugin_installed = false;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_iThemes_Security();
|
||||
if ( null === MainWP_Child_iThemes_Security::$instance ) {
|
||||
MainWP_Child_iThemes_Security::$instance = new MainWP_Child_iThemes_Security();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_iThemes_Security::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
if ( is_plugin_active( 'better-wp-security/better-wp-security.php') || is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) {
|
||||
$this->is_plugin_installed = true;
|
||||
}
|
||||
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
if (!$this->is_plugin_installed)
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||
}
|
||||
// ok
|
||||
function syncOthersData( $information, $data = array() ) {
|
||||
if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) {
|
||||
try {
|
||||
try{
|
||||
$information['syncIThemeData'] = array(
|
||||
'users_and_roles' => $this->get_available_admin_users_and_roles(),
|
||||
'users_and_roles' => $this->get_available_admin_users_and_roles()
|
||||
);
|
||||
} catch ( Exception $e ) {
|
||||
} catch(Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +54,7 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
public function action() {
|
||||
$information = array();
|
||||
if ( ! class_exists( 'ITSEC_Core' ) || ! class_exists('ITSEC_Modules') ) {
|
||||
if ( ! class_exists( 'ITSEC_Core' ) || !class_exists('ITSEC_Modules')) {
|
||||
$information['error'] = 'NO_ITHEME';
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
@ -64,6 +63,7 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
$mainwp_itsec_modules_path = ITSEC_Core::get_core_dir() . '/modules/';
|
||||
|
||||
|
||||
if ( isset( $_POST['mwp_action'] ) ) {
|
||||
switch ( $_POST['mwp_action'] ) {
|
||||
case 'set_showhide':
|
||||
|
@ -131,16 +131,15 @@ class MainWP_Child_iThemes_Security {
|
|||
}
|
||||
|
||||
public function ithemes_init() {
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
if (!$this->is_plugin_installed)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( get_option( 'mainwp_ithemes_hide_plugin' ) === 'hide' ) {
|
||||
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
||||
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
|
||||
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
||||
add_action( 'admin_head', array( &$this, 'custom_admin_css' ) );
|
||||
if ( isset($_GET['page']) && ( $_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-security-check' ) ) {
|
||||
if ( isset($_GET['page']) && ($_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-security-check') ) {
|
||||
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
|
||||
exit();
|
||||
}
|
||||
|
@ -179,7 +178,7 @@ class MainWP_Child_iThemes_Security {
|
|||
function save_settings() {
|
||||
|
||||
if ( ! class_exists( 'ITSEC_Lib' ) ) {
|
||||
require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php';
|
||||
require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' );
|
||||
}
|
||||
|
||||
$_itsec_modules = array(
|
||||
|
@ -194,14 +193,14 @@ class MainWP_Child_iThemes_Security {
|
|||
'404-detection',
|
||||
'network-brute-force',
|
||||
'ssl',
|
||||
// 'strong-passwords',
|
||||
//'strong-passwords',
|
||||
'password-requirements',
|
||||
'system-tweaks',
|
||||
'wordpress-tweaks',
|
||||
'multisite-tweaks',
|
||||
'notification-center',
|
||||
// 'salts',
|
||||
// 'content-directory',
|
||||
//'salts',
|
||||
//'content-directory',
|
||||
);
|
||||
|
||||
$require_permalinks = false;
|
||||
|
@ -211,42 +210,42 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
$update_settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
||||
|
||||
foreach ( $update_settings as $module => $settings ) {
|
||||
foreach($update_settings as $module => $settings) {
|
||||
$do_not_save = false;
|
||||
if ( in_array($module, $_itsec_modules) ) {
|
||||
if ( $module == 'wordpress-salts' ) {
|
||||
if (in_array($module, $_itsec_modules)) {
|
||||
if ($module == 'wordpress-salts') {
|
||||
$settings['last_generated'] = ITSEC_Modules::get_setting( $module, 'last_generated' ); // not update
|
||||
} elseif ( $module == 'global' ) {
|
||||
$keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check', 'nginx_file' );
|
||||
foreach ( $keep_olds as $key ) {
|
||||
$settings[ $key ] = ITSEC_Modules::get_setting( $module, $key ); // not update
|
||||
} else if ($module == 'global') {
|
||||
$keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check' , 'nginx_file' );
|
||||
foreach($keep_olds as $key) {
|
||||
$settings[$key] = ITSEC_Modules::get_setting( $module, $key ); // not update
|
||||
}
|
||||
|
||||
if ( ! isset($settings['log_location']) || empty($settings['log_location']) ) {
|
||||
if (!isset($settings['log_location']) || empty($settings['log_location']) ) {
|
||||
$settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' );
|
||||
} else {
|
||||
$result = $this->validate_directory('log_location', $settings['log_location']);
|
||||
if ( $result !== true ) {
|
||||
if ($result !== true) {
|
||||
$errors[] = $result;
|
||||
$settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' ); // no change
|
||||
}
|
||||
}
|
||||
} elseif ( $module == 'backup' ) {
|
||||
if ( ! isset($settings['location']) || empty($settings['location']) ) {
|
||||
|
||||
} else if ($module == 'backup') {
|
||||
if (!isset($settings['location']) || empty($settings['location']) ) {
|
||||
$settings['location'] = ITSEC_Modules::get_setting( $module, 'location' );
|
||||
} else {
|
||||
$result = $this->validate_directory('location', $settings['location']);
|
||||
if ( $result !== true ) {
|
||||
if ($result !== true) {
|
||||
$errors[] = $result;
|
||||
$settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); // no change
|
||||
}
|
||||
}
|
||||
if ( ! isset($settings['exclude']) ) {
|
||||
$settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' );
|
||||
|
||||
if (!isset($settings['exclude']) ) {
|
||||
$settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' );;
|
||||
}
|
||||
} elseif ( $module == 'hide-backend' ) {
|
||||
if ( isset($settings['enabled']) && ! empty($settings['enabled']) ) {
|
||||
} else if ($module == 'hide-backend') {
|
||||
if (isset($settings['enabled']) && !empty($settings['enabled'])) {
|
||||
$permalink_structure = get_option( 'permalink_structure', false );
|
||||
if ( empty( $permalink_structure ) && ! is_multisite() ) {
|
||||
$errors[] = __( 'You must change <strong>WordPress permalinks</strong> to a setting other than "Plain" in order to use "Hide Backend" feature.', 'better-wp-security' );
|
||||
|
@ -254,11 +253,11 @@ class MainWP_Child_iThemes_Security {
|
|||
$do_not_save = true;
|
||||
}
|
||||
}
|
||||
} elseif ( $module == 'network-brute-force' ) {
|
||||
} else if ($module == 'network-brute-force') {
|
||||
|
||||
if ( isset( $settings['email'] ) ) {
|
||||
$result = $this->activate_api_key($settings);
|
||||
if ( $result === false ) {
|
||||
if ($result === false) {
|
||||
$nbf_settings = $settings;
|
||||
$errors[] = 'Error: Active iThemes Network Brute Force Protection Api Key';
|
||||
} else {
|
||||
|
@ -267,7 +266,7 @@ class MainWP_Child_iThemes_Security {
|
|||
} else {
|
||||
$previous_settings = ITSEC_Modules::get_settings( $module );
|
||||
// update 'enable_ban' field only
|
||||
if ( isset($settings['enable_ban']) ) {
|
||||
if (isset($settings['enable_ban'])) {
|
||||
$previous_settings['enable_ban'] = $settings['enable_ban'];
|
||||
$nbf_settings = $previous_settings;
|
||||
} else {
|
||||
|
@ -276,17 +275,17 @@ class MainWP_Child_iThemes_Security {
|
|||
}
|
||||
}
|
||||
$settings = $nbf_settings;
|
||||
} elseif ( $module == 'notification-center' ) {
|
||||
} else if ($module == 'notification-center') {
|
||||
$current_settings = ITSEC_Modules::get_settings( $module );
|
||||
if ( isset($settings['notifications']) ) {
|
||||
$update_fields = array( 'schedule', 'enabled', 'subject' );
|
||||
if ( isset($_POST['is_individual']) && $_POST['is_individual'] ) {
|
||||
$update_fields = array_merge($update_fields, array( 'user_list', 'email_list' ));
|
||||
if (isset($settings['notifications'])) {
|
||||
$update_fields = array( 'schedule', 'enabled', 'subject');
|
||||
if (isset($_POST['is_individual']) && $_POST['is_individual']) {
|
||||
$update_fields = array_merge($update_fields, array('user_list', 'email_list'));
|
||||
}
|
||||
foreach ( $settings['notifications'] as $key => $val ) {
|
||||
foreach ( $update_fields as $field ) {
|
||||
if ( isset($val[ $field ]) ) {
|
||||
$current_settings['notifications'][ $key ][ $field ] = $val[ $field ];
|
||||
foreach ($settings['notifications'] as $key => $val) {
|
||||
foreach ($update_fields as $field) {
|
||||
if(isset($val[$field])) {
|
||||
$current_settings['notifications'][$key][$field] = $val[$field];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +295,7 @@ class MainWP_Child_iThemes_Security {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( ! $do_not_save ) {
|
||||
if ( !$do_not_save ) {
|
||||
ITSEC_Modules::set_settings( $module, $settings );
|
||||
$updated = true;
|
||||
}
|
||||
|
@ -305,13 +304,13 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
if ( isset( $update_settings['itsec_active_modules'] ) ) {
|
||||
$current_val = get_site_option( 'itsec_active_modules', array() );
|
||||
foreach ( $update_settings['itsec_active_modules'] as $mod => $val ) {
|
||||
$current_val[ $mod ] = $val;
|
||||
foreach ($update_settings['itsec_active_modules'] as $mod => $val) {
|
||||
$current_val[$mod] = $val;
|
||||
}
|
||||
update_site_option( 'itsec_active_modules', $current_val );
|
||||
}
|
||||
|
||||
require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php';
|
||||
require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' );
|
||||
|
||||
$values = array(
|
||||
'permalink_structure' => get_option( 'permalink_structure' ),
|
||||
|
@ -328,28 +327,27 @@ class MainWP_Child_iThemes_Security {
|
|||
'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ),
|
||||
'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ),
|
||||
'excludable_tables' => $this->get_excludable_tables(),
|
||||
'users_and_roles' => $this->get_available_admin_users_and_roles(),
|
||||
'users_and_roles' => $this->get_available_admin_users_and_roles()
|
||||
);
|
||||
|
||||
$return = array(
|
||||
'site_status' => $values,
|
||||
'site_status' => $values
|
||||
);
|
||||
|
||||
if ( $require_permalinks ) {
|
||||
if ($require_permalinks) {
|
||||
$return['require_permalinks'] = 1;
|
||||
}
|
||||
|
||||
$return['nbf_settings'] = $nbf_settings;
|
||||
|
||||
if ( ! empty($errors) ) {
|
||||
if (!empty($errors)) {
|
||||
$return['extra_message'] = $errors;
|
||||
}
|
||||
|
||||
if ( $updated ) {
|
||||
if ($updated)
|
||||
$return['result'] = 'success';
|
||||
} else {
|
||||
else
|
||||
$return['error'] = __('Not Updated', 'mainwp-child' );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -357,7 +355,7 @@ class MainWP_Child_iThemes_Security {
|
|||
public static function activate_network_brute_force() {
|
||||
$data = maybe_unserialize( base64_decode( $_POST['data'] ) );
|
||||
$information = array();
|
||||
if ( is_array($data) ) {
|
||||
if (is_array($data)) {
|
||||
$settings = ITSEC_Modules::get_settings( 'network-brute-force' );
|
||||
$settings['email'] = $data['email'];
|
||||
$settings['updates_optin'] = $data['updates_optin'];
|
||||
|
@ -365,21 +363,21 @@ class MainWP_Child_iThemes_Security {
|
|||
$results = ITSEC_Modules::set_settings( 'network-brute-force', $settings );
|
||||
if ( is_wp_error( $results ) ) {
|
||||
$information['error'] = 'Error: Active iThemes Network Brute Force Protection Api Key';
|
||||
} elseif ( $results['saved'] ) {
|
||||
} else if ( $results['saved'] ) {
|
||||
ITSEC_Modules::activate( 'network-brute-force' );
|
||||
$nbf_settings = ITSEC_Modules::get_settings( 'network-brute-force' );
|
||||
// ITSEC_Response::set_response( '<p>' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '</p>' );
|
||||
// ITSEC_Response::set_response( '<p>' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '</p>' );
|
||||
}
|
||||
}
|
||||
if ( $nbf_settings !== null ) {
|
||||
if ($nbf_settings !== null) {
|
||||
$information['nbf_settings'] = $nbf_settings;
|
||||
$information['result'] = 'success';
|
||||
}
|
||||
return $information;
|
||||
}
|
||||
|
||||
private function validate_directory( $name, $folder ) {
|
||||
require_once ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php';
|
||||
private function validate_directory($name, $folder) {
|
||||
require_once( ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php' );
|
||||
$error = null;
|
||||
if ( ! ITSEC_Lib_Directory::is_dir( $folder ) ) {
|
||||
$result = ITSEC_Lib_Directory::create( $folder );
|
||||
|
@ -401,22 +399,22 @@ class MainWP_Child_iThemes_Security {
|
|||
}
|
||||
}
|
||||
|
||||
private function activate_api_key( $settings ) {
|
||||
private function activate_api_key($settings) {
|
||||
global $mainwp_itsec_modules_path;
|
||||
require_once $mainwp_itsec_modules_path . 'ipcheck/utilities.php';
|
||||
require_once ( $mainwp_itsec_modules_path . 'ipcheck/utilities.php' );
|
||||
|
||||
$key = ITSEC_Network_Brute_Force_Utilities::get_api_key( $settings['email'], $settings['updates_optin'] );
|
||||
if ( is_wp_error( $key ) ) {
|
||||
return false;
|
||||
// $this->set_can_save( false );
|
||||
// $this->add_error( $key );
|
||||
// $this->set_can_save( false );
|
||||
// $this->add_error( $key );
|
||||
} else {
|
||||
$secret = ITSEC_Network_Brute_Force_Utilities::activate_api_key( $key );
|
||||
|
||||
if ( is_wp_error( $secret ) ) {
|
||||
return false;
|
||||
// $this->set_can_save( false );
|
||||
// $this->add_error( $secret );
|
||||
// $this->set_can_save( false );
|
||||
// $this->add_error( $secret );
|
||||
} else {
|
||||
$settings['api_key'] = $key;
|
||||
$settings['api_secret'] = $secret;
|
||||
|
@ -485,6 +483,7 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function whitelist_release() {
|
||||
|
@ -497,7 +496,7 @@ class MainWP_Child_iThemes_Security {
|
|||
global $itsec_backup, $mainwp_itsec_modules_path;
|
||||
|
||||
if ( ! isset( $itsec_backup ) ) {
|
||||
require_once $mainwp_itsec_modules_path . 'backup/class-itsec-backup.php';
|
||||
require_once ( $mainwp_itsec_modules_path . 'backup/class-itsec-backup.php' );
|
||||
$itsec_backup = new ITSEC_Backup();
|
||||
$itsec_backup->run();
|
||||
}
|
||||
|
@ -513,14 +512,14 @@ class MainWP_Child_iThemes_Security {
|
|||
foreach ( $errors as $error ) {
|
||||
$str_error .= $error . '<br />';
|
||||
}
|
||||
} elseif ( is_string( $result ) ) {
|
||||
} else if ( is_string( $result ) ) {
|
||||
$return['result'] = 'success';
|
||||
$return['message'] = $result;
|
||||
} else {
|
||||
$str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type <code>%1$s</code>.', 'better-wp-security' ), gettype( $result ) );
|
||||
$str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type <code>%1$s</code>.', 'better-wp-security' ), gettype( $result ) ) ;
|
||||
}
|
||||
|
||||
if ( ! empty($str_error) ) {
|
||||
if (!empty($str_error)) {
|
||||
$return['error'] = $str_error;
|
||||
}
|
||||
|
||||
|
@ -531,7 +530,7 @@ class MainWP_Child_iThemes_Security {
|
|||
private function wordpress_salts() {
|
||||
global $mainwp_itsec_modules_path;
|
||||
if ( ! class_exists( 'ITSEC_WordPress_Salts_Utilities' ) ) {
|
||||
require $mainwp_itsec_modules_path . 'salts/utilities.php';
|
||||
require( $mainwp_itsec_modules_path . 'salts/utilities.php' );
|
||||
}
|
||||
$result = ITSEC_WordPress_Salts_Utilities::generate_new_salts();
|
||||
$str_error = '';
|
||||
|
@ -543,18 +542,18 @@ class MainWP_Child_iThemes_Security {
|
|||
}
|
||||
} else {
|
||||
$return['result'] = 'success';
|
||||
$return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' );
|
||||
$return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' ) ;
|
||||
$last_generated = ITSEC_Core::get_current_time_gmt();
|
||||
ITSEC_Modules::set_setting( 'wordpress-salts', 'last_generated', $last_generated );
|
||||
}
|
||||
if ( ! empty($str_error) ) {
|
||||
if (!empty($str_error)) {
|
||||
$return['error'] = $str_error;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function file_permissions() {
|
||||
require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php';
|
||||
require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' );
|
||||
|
||||
$wp_upload_dir = ITSEC_Core::get_wp_upload_dir();
|
||||
|
||||
|
@ -585,7 +584,7 @@ class MainWP_Child_iThemes_Security {
|
|||
),
|
||||
array(
|
||||
WP_PLUGIN_DIR,
|
||||
0755,
|
||||
0755
|
||||
),
|
||||
array(
|
||||
$wp_upload_dir['basedir'],
|
||||
|
@ -601,6 +600,7 @@ class MainWP_Child_iThemes_Security {
|
|||
),
|
||||
);
|
||||
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ( $path_data as $path ) {
|
||||
|
@ -632,6 +632,7 @@ class MainWP_Child_iThemes_Security {
|
|||
$rows[] = $row;
|
||||
}
|
||||
|
||||
|
||||
$class = 'entry-row';
|
||||
ob_start();
|
||||
?>
|
||||
|
@ -669,16 +670,16 @@ class MainWP_Child_iThemes_Security {
|
|||
<br />
|
||||
<?php
|
||||
$html = ob_get_clean();
|
||||
return array( 'html' => $html );
|
||||
return array('html' => $html);
|
||||
}
|
||||
|
||||
public function file_change() {
|
||||
global $mainwp_itsec_modules_path;
|
||||
if ( ! class_exists( 'ITSEC_File_Change_Scanner' ) ) {
|
||||
require_once $mainwp_itsec_modules_path . 'file-change/scanner.php';
|
||||
require_once( $mainwp_itsec_modules_path . 'file-change/scanner.php' );
|
||||
}
|
||||
$result = ITSEC_File_Change_Scanner::run_scan( false );
|
||||
if ( $result === false || $result === true || $result === -1 ) {
|
||||
if ($result === false || $result === true || $result === -1) {
|
||||
$return['result'] = 'success';
|
||||
$return['scan_result'] = $result;
|
||||
}
|
||||
|
@ -689,32 +690,33 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
$settings = $_POST['settings'];
|
||||
|
||||
if ( ! is_array($settings) ) {
|
||||
if (!is_array($settings))
|
||||
$settings = array();
|
||||
}
|
||||
|
||||
$new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : '';
|
||||
$change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false;
|
||||
|
||||
// load utility functions
|
||||
|
||||
//load utility functions
|
||||
if ( ! class_exists( 'ITSEC_Lib' ) ) {
|
||||
global $itsec_globals;
|
||||
require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php';
|
||||
require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' );
|
||||
}
|
||||
|
||||
$username_exists = username_exists( 'admin' );
|
||||
$user_id_exists = ITSEC_Lib::user_id_exists( 1 );
|
||||
$msg = '';
|
||||
if ( strlen( $new_username ) >= 1 ) {
|
||||
if ( strlen( $new_username ) >= 1) {
|
||||
global $current_user;
|
||||
if ( ! $username_exists ) {
|
||||
$msg = __( 'Admin user already changes.', 'mainwp-child' );
|
||||
} elseif ( $current_user->user_login == 'admin' ) {
|
||||
} else if ($current_user->user_login == 'admin') {
|
||||
$return['result'] = 'CHILD_ADMIN';
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( true === $change_id && ! $user_id_exists ) {
|
||||
if ( ! empty( $msg ) ) {
|
||||
$msg .= '<br/>';
|
||||
|
@ -722,13 +724,13 @@ class MainWP_Child_iThemes_Security {
|
|||
$msg .= __( 'Admin user ID already changes.', 'mainwp-child' );
|
||||
}
|
||||
|
||||
// if ( $change_id ) {
|
||||
// $user = get_user_by( 'login', $new_username );
|
||||
// if ( $user && 1 === (int) $user->ID ) {
|
||||
// $return['result'] = 'CHILD_ADMIN';
|
||||
// return $return;
|
||||
// }
|
||||
// }
|
||||
// if ( $change_id ) {
|
||||
// $user = get_user_by( 'login', $new_username );
|
||||
// if ( $user && 1 === (int) $user->ID ) {
|
||||
// $return['result'] = 'CHILD_ADMIN';
|
||||
// return $return;
|
||||
// }
|
||||
// }
|
||||
|
||||
$admin_success = true;
|
||||
$return = array();
|
||||
|
@ -754,26 +756,26 @@ class MainWP_Child_iThemes_Security {
|
|||
$itsec_files = ITSEC_Core::get_itsec_files();
|
||||
|
||||
// do not need to check this
|
||||
// if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running
|
||||
//if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running
|
||||
|
||||
// sanitize the username
|
||||
//sanitize the username
|
||||
$new_user = sanitize_text_field( $username );
|
||||
|
||||
// Get the full user object
|
||||
//Get the full user object
|
||||
$user_object = get_user_by( 'id', '1' );
|
||||
|
||||
if ( null !== $username && validate_username( $new_user ) && false === username_exists( $new_user ) ) { // there is a valid username to change
|
||||
if ( null !== $username && validate_username( $new_user ) && false === username_exists( $new_user ) ) { //there is a valid username to change
|
||||
|
||||
if ( true === $id ) { // we're changing the id too so we'll set the username
|
||||
if ( true === $id ) { //we're changing the id too so we'll set the username
|
||||
|
||||
$user_login = $new_user;
|
||||
|
||||
} else { // we're only changing the username
|
||||
|
||||
// query main user table
|
||||
$wpdb->query( 'UPDATE `' . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" );
|
||||
//query main user table
|
||||
$wpdb->query( "UPDATE `" . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" );
|
||||
|
||||
if ( is_multisite() ) { // process sitemeta if we're in a multi-site situation
|
||||
if ( is_multisite() ) { //process sitemeta if we're in a multi-site situation
|
||||
|
||||
$oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" );
|
||||
$newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins );
|
||||
|
@ -786,19 +788,19 @@ class MainWP_Child_iThemes_Security {
|
|||
return true;
|
||||
|
||||
}
|
||||
} elseif ( null !== $username ) { // username didn't validate
|
||||
} elseif ( null !== $username ) { //username didn't validate
|
||||
|
||||
$itsec_files->release_file_lock( 'admin_user' );
|
||||
|
||||
return false;
|
||||
|
||||
} else { // only changing the id
|
||||
} else { //only changing the id
|
||||
|
||||
$user_login = $user_object->user_login;
|
||||
|
||||
}
|
||||
|
||||
if ( true === $id ) { // change the user id
|
||||
if ( true === $id ) { //change the user id
|
||||
|
||||
$wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' );
|
||||
|
||||
|
@ -814,7 +816,7 @@ class MainWP_Child_iThemes_Security {
|
|||
'display_name' => $user_object->display_name,
|
||||
) );
|
||||
|
||||
if ( is_multisite() && null !== $username && validate_username( $new_user ) ) { // process sitemeta if we're in a multi-site situation
|
||||
if ( is_multisite() && null !== $username && validate_username( $new_user ) ) { //process sitemeta if we're in a multi-site situation
|
||||
|
||||
$oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" );
|
||||
$newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins );
|
||||
|
@ -824,10 +826,10 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
$new_user = $wpdb->insert_id;
|
||||
|
||||
$wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->posts . '` SET post_author = %s WHERE post_author = 1;', $new_user ) );
|
||||
$wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->usermeta . '` SET user_id = %s WHERE user_id = 1;', $new_user ) );
|
||||
$wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->comments . '` SET user_id = %s WHERE user_id = 1;', $new_user ) );
|
||||
$wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->links . '` SET link_owner = %s WHERE link_owner = 1;', $new_user ) );
|
||||
$wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->posts . "` SET post_author = %s WHERE post_author = 1;", $new_user ) );
|
||||
$wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->usermeta . "` SET user_id = %s WHERE user_id = 1;", $new_user ) );
|
||||
$wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->comments . "` SET user_id = %s WHERE user_id = 1;", $new_user ) );
|
||||
$wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->links . "` SET link_owner = %s WHERE link_owner = 1;", $new_user ) );
|
||||
|
||||
wp_clear_auth_cookie();
|
||||
$itsec_files->release_file_lock( 'admin_user' );
|
||||
|
@ -835,13 +837,14 @@ class MainWP_Child_iThemes_Security {
|
|||
return true;
|
||||
|
||||
}
|
||||
// }
|
||||
//}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public function build_wpconfig_rules( $rules_array, $input = null ) {
|
||||
// Get the rules from the database if input wasn't sent
|
||||
//Get the rules from the database if input wasn't sent
|
||||
if ( null === $input ) {
|
||||
return $rules_array;
|
||||
}
|
||||
|
@ -866,27 +869,24 @@ class MainWP_Child_iThemes_Security {
|
|||
'rule' => "define( 'WP_CONTENT_DIR', '" . $new_dir . "' );",
|
||||
);
|
||||
|
||||
$rules_array[] = array(
|
||||
'type' => 'wpconfig',
|
||||
'name' => 'Content Directory',
|
||||
'rules' => $rules,
|
||||
);
|
||||
$rules_array[] = array( 'type' => 'wpconfig', 'name' => 'Content Directory', 'rules' => $rules );
|
||||
|
||||
return $rules_array;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function change_database_prefix() {
|
||||
global $mainwp_itsec_modules_path;
|
||||
require_once $mainwp_itsec_modules_path . 'database-prefix/utility.php';
|
||||
require_once( $mainwp_itsec_modules_path . 'database-prefix/utility.php' );
|
||||
$str_error = '';
|
||||
$return = array();
|
||||
|
||||
if ( isset( $_POST['change_prefix'] ) && 'yes' === $_POST['change_prefix'] ) {
|
||||
$result = ITSEC_Database_Prefix_Utility::change_database_prefix();
|
||||
$return = $result['errors'];
|
||||
if ( is_array($result['errors']) ) {
|
||||
foreach ( $result['errors'] as $error ) {
|
||||
if (is_array($result['errors'])) {
|
||||
foreach ($result['errors'] as $error) {
|
||||
$arr_errors = ITSEC_Response::get_error_strings( $error );
|
||||
foreach ( $arr_errors as $er ) {
|
||||
$str_error .= $er . '<br />';
|
||||
|
@ -936,7 +936,7 @@ class MainWP_Child_iThemes_Security {
|
|||
if ( $results['saved'] ) {
|
||||
$information['result'] = 'success';
|
||||
$information['nbf_settings'] = ITSEC_Modules::get_settings( 'network-brute-force');
|
||||
} elseif ( empty( $results['errors'] ) ) {
|
||||
} else if ( empty( $results['errors'] ) ) {
|
||||
$information['error_reset_api'] = 1;
|
||||
}
|
||||
return $information;
|
||||
|
@ -946,8 +946,8 @@ class MainWP_Child_iThemes_Security {
|
|||
global $mainwp_itsec_modules_path;
|
||||
|
||||
if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) {
|
||||
require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php';
|
||||
require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php';
|
||||
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' );
|
||||
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' );
|
||||
}
|
||||
|
||||
$response = array();
|
||||
|
@ -965,11 +965,11 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
global $mainwp_itsec_modules_path;
|
||||
if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) {
|
||||
require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php';
|
||||
require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php';
|
||||
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' );
|
||||
require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' );
|
||||
}
|
||||
$response = array();
|
||||
$results = ITSEC_Malware_Scanner::scan();
|
||||
$results= ITSEC_Malware_Scanner::scan();
|
||||
$response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true );
|
||||
return $response;
|
||||
}
|
||||
|
@ -1068,7 +1068,7 @@ class MainWP_Child_iThemes_Security {
|
|||
global $wpdb;
|
||||
|
||||
if ( ! class_exists( 'ITSEC_Lib' ) ) {
|
||||
require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php';
|
||||
require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' );
|
||||
}
|
||||
|
||||
$lockout_ids = $_POST['lockout_ids'];
|
||||
|
@ -1095,7 +1095,7 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
if ( ! is_multisite() ) {
|
||||
if ( ! function_exists( 'add_settings_error' ) ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/template.php';
|
||||
require_once( ABSPATH . '/wp-admin/includes/template.php' );
|
||||
}
|
||||
|
||||
add_settings_error( 'itsec', esc_attr( 'settings_updated' ), $message, $type );
|
||||
|
@ -1110,28 +1110,28 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
$active_modules = $_POST['active_modules'];
|
||||
|
||||
if ( ! is_array($active_modules) ) {
|
||||
if (!is_array($active_modules))
|
||||
$active_modules = array();
|
||||
}
|
||||
|
||||
$current_val = get_site_option( 'itsec_active_modules', array() );
|
||||
foreach ( $active_modules as $mod => $val ) {
|
||||
$current_val[ $mod ] = $val;
|
||||
foreach ($active_modules as $mod => $val) {
|
||||
$current_val[$mod] = $val;
|
||||
}
|
||||
|
||||
update_site_option( 'itsec_active_modules', $current_val );
|
||||
return array( 'result' => 'success' );
|
||||
return array('result' => 'success');
|
||||
|
||||
}
|
||||
|
||||
private function reload_backup_exclude() {
|
||||
private function reload_backup_exclude( ) {
|
||||
return array(
|
||||
'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ),
|
||||
'excludable_tables' => $this->get_excludable_tables(),
|
||||
'result' => 'success',
|
||||
'result' => 'success'
|
||||
);
|
||||
}
|
||||
|
||||
private function get_excludable_tables() {
|
||||
private function get_excludable_tables( ) {
|
||||
global $wpdb;
|
||||
$all_sites = ITSEC_Modules::get_setting( 'backup', 'all_sites' );
|
||||
$ignored_tables = array(
|
||||
|
@ -1164,24 +1164,21 @@ class MainWP_Child_iThemes_Security {
|
|||
continue;
|
||||
}
|
||||
|
||||
$excludes[ $short_table ] = $table[0];
|
||||
$excludes[$short_table] = $table[0];
|
||||
}
|
||||
|
||||
return $excludes;
|
||||
return $excludes ;
|
||||
}
|
||||
|
||||
private function security_site() {
|
||||
global $mainwp_itsec_modules_path;
|
||||
require_once $mainwp_itsec_modules_path . 'security-check/scanner.php';
|
||||
require_once $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php';
|
||||
require_once( $mainwp_itsec_modules_path . 'security-check/scanner.php' );
|
||||
require_once( $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php' );
|
||||
$results = ITSEC_Security_Check_Scanner::get_results();
|
||||
ob_start();
|
||||
ITSEC_Security_Check_Feedback_Renderer::render( $results );
|
||||
$response = ob_get_clean();
|
||||
return array(
|
||||
'result' => 'success',
|
||||
'response' => $response,
|
||||
);
|
||||
return array('result' => 'success' , 'response' => $response);
|
||||
}
|
||||
|
||||
// source from itheme plugin
|
||||
|
@ -1198,7 +1195,7 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
foreach ( $roles->roles as $role => $details ) {
|
||||
if ( isset( $details['capabilities']['manage_options'] ) && ( true === $details['capabilities']['manage_options'] ) ) {
|
||||
$available_roles[ "role:$role" ] = translate_user_role( $details['name'] );
|
||||
$available_roles["role:$role"] = translate_user_role( $details['name'] );
|
||||
|
||||
$users = get_users( array( 'role' => $role ) );
|
||||
|
||||
|
|
|
@ -19,24 +19,24 @@ class MainWP_Child_Links_Checker {
|
|||
public $is_plugin_installed = false;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Links_Checker();
|
||||
if ( null === MainWP_Child_Links_Checker::$instance ) {
|
||||
MainWP_Child_Links_Checker::$instance = new MainWP_Child_Links_Checker();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_Links_Checker::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
if ( is_plugin_active( 'broken-link-checker/broken-link-checker.php' ) ) {
|
||||
$this->is_plugin_installed = true;
|
||||
}
|
||||
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
if ( !$this->is_plugin_installed )
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||
|
||||
}
|
||||
|
||||
public function action() {
|
||||
|
@ -82,8 +82,8 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
}
|
||||
MainWP_Helper::write( $information );
|
||||
} catch ( Exception $e ) {
|
||||
MainWP_Helper::write( array( 'error' => $e->getMessage() ) );
|
||||
} catch(Exception $e) {
|
||||
MainWP_Helper::write( array('error' => $e->getMessage()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,13 +137,13 @@ class MainWP_Child_Links_Checker {
|
|||
global $wpdb;
|
||||
/** @var wpdb $wpdb */
|
||||
|
||||
// Delete all discovered instances
|
||||
//Delete all discovered instances
|
||||
$wpdb->query( "TRUNCATE {$wpdb->prefix}blc_instances" );
|
||||
|
||||
// Delete all discovered links
|
||||
//Delete all discovered links
|
||||
$wpdb->query( "TRUNCATE {$wpdb->prefix}blc_links" );
|
||||
|
||||
// Mark all posts, custom fields and bookmarks for processing.
|
||||
//Mark all posts, custom fields and bookmarks for processing.
|
||||
blc_resynch( true );
|
||||
}
|
||||
|
||||
|
@ -158,18 +158,18 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
blc_init();
|
||||
|
||||
// Get the container type matching the type of the deleted post
|
||||
//Get the container type matching the type of the deleted post
|
||||
$post = get_post( $post_id );
|
||||
if ( ! $post ) {
|
||||
return;
|
||||
}
|
||||
// Get the associated container object
|
||||
//Get the associated container object
|
||||
$post_container = blcContainerHelper::get_container( array( $post->post_type, intval( $post_id ) ) );
|
||||
|
||||
if ( $post_container ) {
|
||||
// Delete it
|
||||
//Delete it
|
||||
$post_container->delete();
|
||||
// Clean up any dangling links
|
||||
//Clean up any dangling links
|
||||
blc_cleanup_links();
|
||||
}
|
||||
}
|
||||
|
@ -210,9 +210,9 @@ class MainWP_Child_Links_Checker {
|
|||
// ok
|
||||
public function syncOthersData( $information, $data = array() ) {
|
||||
if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) {
|
||||
try {
|
||||
try{
|
||||
$information['syncBrokenLinksCheckerData'] = $this->get_sync_data();
|
||||
} catch ( Exception $e ) {
|
||||
} catch(Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -223,17 +223,14 @@ class MainWP_Child_Links_Checker {
|
|||
function get_sync_data( $strategy = '' ) {
|
||||
$information = array();
|
||||
$data = $this->get_count_links();
|
||||
if ( is_array($data) ) {
|
||||
if (is_array($data))
|
||||
$information['data'] = $data;
|
||||
}
|
||||
return $information;
|
||||
}
|
||||
|
||||
function get_links_data() {
|
||||
|
||||
if ( ! defined('BLC_DIRECTORY') ) {
|
||||
return;
|
||||
}
|
||||
if (!defined('BLC_DIRECTORY')) return;
|
||||
|
||||
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
|
||||
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
|
||||
|
@ -251,15 +248,16 @@ class MainWP_Child_Links_Checker {
|
|||
|
||||
$total = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
|
||||
|
||||
|
||||
$max_results = isset($_POST['max_results']) ? intval($_POST['max_results']) : 50;
|
||||
$offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
|
||||
|
||||
$params = array(
|
||||
array( 'load_instances' => true ),
|
||||
'max_results' => $max_results,
|
||||
'max_results' => $max_results
|
||||
);
|
||||
|
||||
if ( empty($offset) ) {
|
||||
if (empty($offset)) {
|
||||
$first_sync = true;
|
||||
} else {
|
||||
$params['offset'] = $offset;
|
||||
|
@ -268,18 +266,18 @@ class MainWP_Child_Links_Checker {
|
|||
$link_data = $this->links_checker_data($params);
|
||||
|
||||
$total_sync = 0;
|
||||
if ( $offset ) {
|
||||
if ($offset){
|
||||
$total_sync = $offset;
|
||||
}
|
||||
$total_sync += ( is_array($link_data) ? count($link_data) : 0 );
|
||||
$total_sync += (is_array($link_data) ? count($link_data) : 0);
|
||||
|
||||
$information = array( 'links_data' => $link_data );
|
||||
$information = array('links_data' => $link_data);
|
||||
|
||||
if ( $first_sync ) {
|
||||
if ($first_sync) {
|
||||
$information['data'] = $this->get_count_links();
|
||||
}
|
||||
|
||||
if ( $total > $offset + $max_results ) {
|
||||
if ($total > $offset + $max_results ) {
|
||||
$information['sync_offset'] = $offset + $max_results;
|
||||
} else {
|
||||
$information['last_sync'] = 1;
|
||||
|
@ -292,9 +290,7 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
|
||||
function get_count_links() {
|
||||
if ( ! defined('BLC_DIRECTORY') ) {
|
||||
return;
|
||||
}
|
||||
if (!defined('BLC_DIRECTORY')) return;
|
||||
|
||||
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
|
||||
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
|
||||
|
@ -320,7 +316,7 @@ class MainWP_Child_Links_Checker {
|
|||
return $data;
|
||||
}
|
||||
|
||||
function links_checker_data( $params ) {
|
||||
function links_checker_data($params) {
|
||||
|
||||
MainWP_Helper::check_functions('blc_get_links');
|
||||
MainWP_Helper::check_classes_exists('blcLink');
|
||||
|
@ -345,11 +341,11 @@ class MainWP_Child_Links_Checker {
|
|||
'last_success',
|
||||
'may_recheck',
|
||||
'false_positive',
|
||||
// 'result_hash',
|
||||
//'result_hash',
|
||||
'dismissed',
|
||||
'status_text',
|
||||
'status_code',
|
||||
'log',
|
||||
'log'
|
||||
);
|
||||
$return = array();
|
||||
|
||||
|
@ -374,7 +370,7 @@ class MainWP_Child_Links_Checker {
|
|||
|
||||
$days_broken = 0;
|
||||
if ( $link->broken ) {
|
||||
// Add a highlight to broken links that appear to be permanently broken
|
||||
//Add a highlight to broken links that appear to be permanently broken
|
||||
$days_broken = intval( ( time() - $link->first_failure ) / ( 3600 * 24 ) );
|
||||
if ( $days_broken >= $blc_option['failure_duration_threshold'] ) {
|
||||
$extra_info['permanently_broken'] = 1;
|
||||
|
@ -395,7 +391,7 @@ class MainWP_Child_Links_Checker {
|
|||
if ( ! empty( $instances ) ) {
|
||||
$first_instance = reset( $instances );
|
||||
|
||||
MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable' ) );
|
||||
MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable') );
|
||||
|
||||
$new_link->link_text = $first_instance->ui_get_link_text();
|
||||
$extra_info['count_instance'] = count( $instances );
|
||||
|
@ -404,8 +400,8 @@ class MainWP_Child_Links_Checker {
|
|||
/** @var blcContainer $container */
|
||||
|
||||
if ( ! empty( $container ) /* && ($container instanceof blcAnyPostContainer) */ ) {
|
||||
if ( true === MainWP_Helper::check_properties($first_instance, array( 'container_field' ), true ) ) {
|
||||
if ( true === MainWP_Helper::check_properties($container, array( 'container_type', 'container_id' ), true ) ) {
|
||||
if (true === MainWP_Helper::check_properties($first_instance, array( 'container_field' ), true )) {
|
||||
if (true === MainWP_Helper::check_properties($container, array( 'container_type', 'container_id' ), true )) {
|
||||
$extra_info['container_type'] = $container->container_type;
|
||||
$extra_info['container_id'] = $container->container_id;
|
||||
$extra_info['source_data'] = $this->ui_get_source( $container, $first_instance->container_field );
|
||||
|
@ -433,7 +429,7 @@ class MainWP_Child_Links_Checker {
|
|||
$link_texts = $can_edit_text ? $editable_link_texts : $non_editable_link_texts;
|
||||
$data_link_text = '';
|
||||
if ( count( $link_texts ) === 1 ) {
|
||||
// All instances have the same text - use it.
|
||||
//All instances have the same text - use it.
|
||||
$link_text = key( $link_texts );
|
||||
$data_link_text = esc_attr( $link_text );
|
||||
}
|
||||
|
@ -453,6 +449,7 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
function edit_link() {
|
||||
|
@ -462,14 +459,14 @@ class MainWP_Child_Links_Checker {
|
|||
|
||||
return $information;
|
||||
}
|
||||
// Load the link
|
||||
//Load the link
|
||||
$link = new blcLink( intval( $_POST['link_id'] ) );
|
||||
if ( ! $link->valid() ) {
|
||||
$information['error'] = 'NOTFOUNDLINK'; // Oops, I can't find the link
|
||||
return $information;
|
||||
}
|
||||
|
||||
// Validate the new URL.
|
||||
//Validate the new URL.
|
||||
$new_url = stripslashes( $_POST['new_url'] );
|
||||
$parsed = @parse_url( $new_url );
|
||||
if ( ! $parsed ) {
|
||||
|
@ -482,7 +479,7 @@ class MainWP_Child_Links_Checker {
|
|||
$new_text = null;
|
||||
}
|
||||
if ( ! empty( $new_text ) && ! current_user_can( 'unfiltered_html' ) ) {
|
||||
$new_text = stripslashes( wp_filter_post_kses( addslashes( $new_text ) ) ); // wp_filter_post_kses expects slashed data.
|
||||
$new_text = stripslashes( wp_filter_post_kses( addslashes( $new_text ) ) ); //wp_filter_post_kses expects slashed data.
|
||||
}
|
||||
|
||||
$rez = $link->edit( $new_url, $new_text );
|
||||
|
@ -515,7 +512,7 @@ class MainWP_Child_Links_Checker {
|
|||
'ui_link_text' => isset( $new_text ) ? $ui_link_text : null,
|
||||
'errors' => array(),
|
||||
);
|
||||
// url, status text, status code, link text, editable link text
|
||||
//url, status text, status code, link text, editable link text
|
||||
|
||||
foreach ( $rez['errors'] as $error ) {
|
||||
/** @var $error WP_Error */
|
||||
|
@ -535,7 +532,7 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
|
||||
if ( isset( $_POST['link_id'] ) ) {
|
||||
// Load the link
|
||||
//Load the link
|
||||
$link = new blcLink( intval( $_POST['link_id'] ) );
|
||||
|
||||
if ( ! $link->valid() ) {
|
||||
|
@ -543,7 +540,7 @@ class MainWP_Child_Links_Checker {
|
|||
return $information;
|
||||
}
|
||||
|
||||
// Try and unlink it
|
||||
//Try and unlink it
|
||||
$rez = $link->unlink();
|
||||
|
||||
if ( false === $rez ) {
|
||||
|
@ -580,7 +577,7 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
|
||||
if ( isset( $_POST['link_id'] ) ) {
|
||||
// Load the link
|
||||
//Load the link
|
||||
$link = new blcLink( intval( $_POST['link_id'] ) );
|
||||
|
||||
if ( ! $link->valid() ) {
|
||||
|
@ -590,7 +587,7 @@ class MainWP_Child_Links_Checker {
|
|||
|
||||
$link->dismissed = $dismiss;
|
||||
|
||||
// Save the changes
|
||||
//Save the changes
|
||||
if ( $link->save() ) {
|
||||
$information = 'OK';
|
||||
} else {
|
||||
|
@ -613,7 +610,7 @@ class MainWP_Child_Links_Checker {
|
|||
return $information;
|
||||
}
|
||||
if ( isset( $_POST['link_id'] ) ) {
|
||||
// Load the link
|
||||
//Load the link
|
||||
$link = new blcLink( intval( $_POST['link_id'] ) );
|
||||
|
||||
if ( ! $link->valid() ) {
|
||||
|
@ -621,13 +618,13 @@ class MainWP_Child_Links_Checker {
|
|||
return $information;
|
||||
}
|
||||
|
||||
// Make it appear "not broken"
|
||||
//Make it appear "not broken"
|
||||
$link->broken = false;
|
||||
$link->false_positive = true;
|
||||
$link->last_check_attempt = time();
|
||||
$link->log = __( 'This link was manually marked as working by the user.', 'mainwp-child' );
|
||||
|
||||
// Save the changes
|
||||
//Save the changes
|
||||
if ( $link->save() ) {
|
||||
$information['status'] = 'OK';
|
||||
$information['last_check_attempt'] = $link->last_check_attempt;
|
||||
|
@ -644,7 +641,7 @@ class MainWP_Child_Links_Checker {
|
|||
function ui_get_source( $container, $container_field = '' ) {
|
||||
if ( 'comment' === $container->container_type ) {
|
||||
return $this->ui_get_source_comment( $container, $container_field );
|
||||
} elseif ( $container instanceof blcAnyPostContainer ) {
|
||||
} else if ( $container instanceof blcAnyPostContainer ) {
|
||||
return $this->ui_get_source_post( $container, $container_field );
|
||||
}
|
||||
|
||||
|
@ -652,20 +649,19 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
|
||||
function ui_get_source_comment( $container, $container_field = '' ) {
|
||||
// Display a comment icon.
|
||||
//Display a comment icon.
|
||||
if ( 'comment_author_url' === $container_field ) {
|
||||
$image = 'font-awesome/font-awesome-user.png';
|
||||
} else {
|
||||
$image = 'font-awesome/font-awesome-comment-alt.png';
|
||||
}
|
||||
|
||||
if ( true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object' ), true ) ) {
|
||||
if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object'), true ))
|
||||
return false;
|
||||
}
|
||||
|
||||
$comment = $container->get_wrapped_object();
|
||||
|
||||
// Display a small text sample from the comment
|
||||
//Display a small text sample from the comment
|
||||
$text_sample = strip_tags( $comment->comment_content );
|
||||
$text_sample = blcUtility::truncate( $text_sample, 65 );
|
||||
|
||||
|
|
|
@ -21,22 +21,21 @@ class MainWP_Child_Pagespeed {
|
|||
public $is_plugin_installed = false;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Pagespeed();
|
||||
if ( null === MainWP_Child_Pagespeed::$instance ) {
|
||||
MainWP_Child_Pagespeed::$instance = new MainWP_Child_Pagespeed();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_Pagespeed::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
if ( is_plugin_active( 'google-pagespeed-insights/google-pagespeed-insights.php' ) ) {
|
||||
$this->is_plugin_installed = true;
|
||||
}
|
||||
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
if (!$this->is_plugin_installed)
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||
|
||||
|
@ -61,7 +60,7 @@ class MainWP_Child_Pagespeed {
|
|||
case 'sync_data':
|
||||
$information = $this->get_sync_data();
|
||||
break;
|
||||
case 'check_pages':
|
||||
case "check_pages":
|
||||
$information = $this->check_pages();
|
||||
break;
|
||||
}
|
||||
|
@ -76,13 +75,12 @@ class MainWP_Child_Pagespeed {
|
|||
}
|
||||
|
||||
public function init() {
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
if (!$this->is_plugin_installed)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
|
||||
add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );
|
||||
add_action('admin_menu', array( $this, 'hide_menu' ), 999);
|
||||
add_action('admin_menu', array($this, 'hide_menu'), 999);
|
||||
}
|
||||
$this->init_cron();
|
||||
}
|
||||
|
@ -127,10 +125,10 @@ class MainWP_Child_Pagespeed {
|
|||
|
||||
public function hide_menu() {
|
||||
global $submenu;
|
||||
if ( isset($submenu['tools.php']) ) {
|
||||
foreach ( $submenu['tools.php'] as $key => $menu ) {
|
||||
if ( $menu[2] == 'google-pagespeed-insights' ) {
|
||||
unset($submenu['tools.php'][ $key ]);
|
||||
if (isset($submenu['tools.php'])) {
|
||||
foreach($submenu['tools.php'] as $key => $menu) {
|
||||
if ($menu[2] == 'google-pagespeed-insights') {
|
||||
unset($submenu['tools.php'][$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -240,43 +238,43 @@ class MainWP_Child_Pagespeed {
|
|||
|
||||
$result = $this->get_sync_data( $strategy );
|
||||
|
||||
// if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) {
|
||||
// if ( 'recheck_all_pages' === $_POST['doaction'] ) {
|
||||
// $recheck = true;
|
||||
// } else {
|
||||
// $recheck = false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if ($this->do_check_pages($recheck))
|
||||
// $information['checked_pages'] = 1;
|
||||
// }
|
||||
// if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) {
|
||||
// if ( 'recheck_all_pages' === $_POST['doaction'] ) {
|
||||
// $recheck = true;
|
||||
// } else {
|
||||
// $recheck = false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if ($this->do_check_pages($recheck))
|
||||
// $information['checked_pages'] = 1;
|
||||
// }
|
||||
$information['data'] = $result['data'];
|
||||
return $information;
|
||||
}
|
||||
|
||||
|
||||
function check_pages() {
|
||||
if ( isset($_POST['force_recheck']) && ! empty($_POST['force_recheck']) ) {
|
||||
if (isset($_POST['force_recheck']) && !empty($_POST['force_recheck'])) {
|
||||
$recheck = true;
|
||||
} else {
|
||||
$recheck = false;
|
||||
}
|
||||
$information = $this->do_check_pages($recheck);
|
||||
if ( isset($information['checked_pages']) && $information['checked_pages'] ) {
|
||||
if (isset($information['checked_pages']) && $information['checked_pages']) {
|
||||
$information['result'] = 'SUCCESS';
|
||||
}
|
||||
return $information;
|
||||
}
|
||||
|
||||
function do_check_pages( $forceRecheck = false ) {
|
||||
function do_check_pages($forceRecheck = false) {
|
||||
$information = array();
|
||||
if ( defined( 'GPI_DIRECTORY' ) ) {
|
||||
$checkstatus = apply_filters( 'gpi_check_status', false );
|
||||
if ( $checkstatus ) {
|
||||
$information['error'] = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
|
||||
} else {
|
||||
// do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
|
||||
//do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
|
||||
do_action( 'run_gpi', $forceRecheck ); // to fix
|
||||
$information['checked_pages'] = 1;
|
||||
}
|
||||
|
@ -286,9 +284,9 @@ class MainWP_Child_Pagespeed {
|
|||
|
||||
public function syncOthersData( $information, $data = array() ) {
|
||||
if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) {
|
||||
try {
|
||||
try{
|
||||
$information['syncPageSpeedData'] = $this->get_sync_data();
|
||||
} catch ( Exception $e ) {
|
||||
} catch(Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +310,7 @@ class MainWP_Child_Pagespeed {
|
|||
|
||||
if ( 'both' === $strategy || 'desktop' === $strategy ) {
|
||||
$result = self::cal_pagespeed_data( 'desktop' );
|
||||
if ( ! empty($result) && is_array($result) ) {
|
||||
if ( !empty($result) && is_array($result) ) {
|
||||
$data['desktop_score'] = $result['average_score'];
|
||||
$data['desktop_total_pages'] = $result['total_pages'];
|
||||
$data['desktop_last_modified'] = $result['last_modified'];
|
||||
|
@ -320,7 +318,7 @@ class MainWP_Child_Pagespeed {
|
|||
}
|
||||
if ( 'both' === $strategy || 'mobile' === $strategy ) {
|
||||
$result = self::cal_pagespeed_data( 'mobile' );
|
||||
if ( ! empty($result) && is_array($result) ) {
|
||||
if ( !empty($result) && is_array($result) ) {
|
||||
$data['mobile_score'] = $result['average_score'];
|
||||
$data['mobile_total_pages'] = $result['total_pages'];
|
||||
$data['mobile_last_modified'] = $result['last_modified'];
|
||||
|
@ -343,7 +341,8 @@ class MainWP_Child_Pagespeed {
|
|||
}
|
||||
|
||||
$score_column = $strategy . '_score';
|
||||
// $page_stats_column = $strategy . '_page_stats';
|
||||
//$page_stats_column = $strategy . '_page_stats';
|
||||
|
||||
|
||||
$data_typestocheck = self::get_filter_options( 'all' );
|
||||
|
||||
|
@ -438,59 +437,61 @@ class MainWP_Child_Pagespeed {
|
|||
);
|
||||
}
|
||||
|
||||
static function get_filter_options( $restrict_type = 'all' ) {
|
||||
static function get_filter_options($restrict_type = 'all') {
|
||||
|
||||
$types = array();
|
||||
$gpi_options = get_option('gpagespeedi_options');
|
||||
$typestocheck = array();
|
||||
|
||||
if ( $gpi_options['check_pages'] ) {
|
||||
if ( $restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'pages' ) {
|
||||
if($gpi_options['check_pages']) {
|
||||
if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'pages') {
|
||||
$typestocheck[] = 'type = %s';
|
||||
$types[1][] = 'page';
|
||||
$types[1][] = "page";
|
||||
}
|
||||
}
|
||||
|
||||
if ( $gpi_options['check_posts'] ) {
|
||||
if ( $restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'posts' ) {
|
||||
if($gpi_options['check_posts']) {
|
||||
if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'posts') {
|
||||
$typestocheck[] = 'type = %s';
|
||||
$types[1][] = 'post';
|
||||
$types[1][] = "post";
|
||||
}
|
||||
}
|
||||
|
||||
if ( $gpi_options['check_categories'] ) {
|
||||
if ( $restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'categories' ) {
|
||||
if($gpi_options['check_categories']) {
|
||||
if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'categories') {
|
||||
$typestocheck[] = 'type = %s';
|
||||
$types[1][] = 'category';
|
||||
$types[1][] = "category";
|
||||
}
|
||||
}
|
||||
if ( $gpi_options['cpt_whitelist'] ) {
|
||||
if ( $restrict_type == 'all' || $restrict_type == 'ignored' || stristr($restrict_type, 'gpi_custom_posts') ) {
|
||||
if($gpi_options['cpt_whitelist']) {
|
||||
if($restrict_type == 'all' || $restrict_type == 'ignored' || stristr($restrict_type, 'gpi_custom_posts')) {
|
||||
|
||||
$cpt_whitelist_arr = false;
|
||||
if ( ! empty($gpi_options['cpt_whitelist']) ) {
|
||||
if(!empty($gpi_options['cpt_whitelist'])) {
|
||||
$cpt_whitelist_arr = unserialize($gpi_options['cpt_whitelist']);
|
||||
}
|
||||
$args = array(
|
||||
$args=array(
|
||||
'public' => true,
|
||||
'_builtin' => false,
|
||||
'_builtin' => false
|
||||
);
|
||||
$custom_post_types = get_post_types($args, 'names', 'and');
|
||||
if ( $restrict_type != 'gpi_custom_posts' && $restrict_type != 'all' && $restrict_type != 'ignored' ) {
|
||||
$custom_post_types = get_post_types($args,'names','and');
|
||||
if($restrict_type != 'gpi_custom_posts' && $restrict_type != 'all' && $restrict_type != 'ignored') {
|
||||
$restrict_type = str_replace('gpi_custom_posts-', '', $restrict_type);
|
||||
foreach ( $custom_post_types as $post_type ) {
|
||||
if ( $cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr) ) {
|
||||
if ( $post_type == $restrict_type ) {
|
||||
foreach($custom_post_types as $post_type)
|
||||
{
|
||||
if($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) {
|
||||
if($post_type == $restrict_type) {
|
||||
$typestocheck[] = 'type = %s';
|
||||
$types[1][] = $custom_post_types[ $post_type ];
|
||||
$types[1][] = $custom_post_types[$post_type];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ( $custom_post_types as $post_type ) {
|
||||
if ( $cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr) ) {
|
||||
foreach($custom_post_types as $post_type)
|
||||
{
|
||||
if($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) {
|
||||
$typestocheck[] = 'type = %s';
|
||||
$types[1][] = $custom_post_types[ $post_type ];
|
||||
$types[1][] = $custom_post_types[$post_type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,13 +517,15 @@ class MainWP_Child_Pagespeed {
|
|||
}
|
||||
}
|
||||
|
||||
if ( ! empty($typestocheck) ) {
|
||||
if(!empty($typestocheck)) {
|
||||
$types[0] = '';
|
||||
foreach ( $typestocheck as $type ) {
|
||||
if ( ! is_array($type) ) {
|
||||
foreach($typestocheck as $type)
|
||||
{
|
||||
if(!is_array($type)) {
|
||||
$types[0] .= $type . ' OR ';
|
||||
} else {
|
||||
foreach ( $type as $custom_post_type ) {
|
||||
foreach($type as $custom_post_type)
|
||||
{
|
||||
$types[0] .= 'type = %s OR ';
|
||||
$types[1][] = $custom_post_type;
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ class MainWP_Child_Plugins_Check {
|
|||
private $option_name_last_daily_run = 'mainwp_child_plugin_last_daily_run';
|
||||
|
||||
public static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Plugins_Check();
|
||||
if ( null === MainWP_Child_Plugins_Check::$instance ) {
|
||||
MainWP_Child_Plugins_Check::$instance = new MainWP_Child_Plugins_Check();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_Plugins_Check::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
@ -45,7 +45,7 @@ class MainWP_Child_Plugins_Check {
|
|||
|
||||
add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
|
||||
|
||||
// add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
|
||||
//add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
|
||||
|
||||
add_filter( 'plugins_api_args', array( $this, 'modify_plugin_api_search_query' ), 10, 2 );
|
||||
|
||||
|
@ -97,7 +97,7 @@ class MainWP_Child_Plugins_Check {
|
|||
$last_run = new \DateTime( '@' . $last_run );
|
||||
}
|
||||
|
||||
// Get now
|
||||
//Get now
|
||||
$now = new \DateTime();
|
||||
|
||||
if ( false === $last_run || (int) $now->diff( $last_run )->format( '%h' ) >= 24 ) {
|
||||
|
@ -112,13 +112,14 @@ class MainWP_Child_Plugins_Check {
|
|||
}
|
||||
|
||||
public function schedule_watchdog() {
|
||||
// For testing
|
||||
// $this->cleanup_deactivation();
|
||||
//For testing
|
||||
//$this->cleanup_deactivation();
|
||||
|
||||
// Schedule a global watching cron just in case both other crons get killed
|
||||
//Schedule a global watching cron just in case both other crons get killed
|
||||
if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) {
|
||||
wp_schedule_event( time(), 'hourly', $this->cron_name_watcher );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function get_plugins_outdate_info() {
|
||||
|
@ -142,38 +143,44 @@ class MainWP_Child_Plugins_Check {
|
|||
}
|
||||
|
||||
return $plugins_outdate;
|
||||
|
||||
}
|
||||
|
||||
// for testing
|
||||
public function change_plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ) {
|
||||
// Grab our previously stored array of known last modified dates
|
||||
// Requires WP 2.8.0
|
||||
//Grab our previously stored array of known last modified dates
|
||||
//Requires WP 2.8.0
|
||||
$plugin_info = get_transient( $this->tran_name_plugin_timestamps );
|
||||
|
||||
// Sanity check the response
|
||||
if ( false === $plugin_info || ! is_array( $plugin_info ) && 0 === count( $plugin_info ) ) {
|
||||
//Sanity check the response
|
||||
if( false === $plugin_info || ! is_array( $plugin_info ) && 0 === count( $plugin_info ) )
|
||||
{
|
||||
return $plugin_meta;
|
||||
}
|
||||
|
||||
// See if this specific plugin is in the known list
|
||||
if ( array_key_exists( $plugin_file, $plugin_info ) ) {
|
||||
// Get now
|
||||
//See if this specific plugin is in the known list
|
||||
if( array_key_exists( $plugin_file, $plugin_info ) )
|
||||
{
|
||||
//Get now
|
||||
$now = new \DateTime();
|
||||
$last_updated = $plugin_info[ $plugin_file ]['last_updated'];
|
||||
|
||||
// Last updated is stored as timestamp, get a real date
|
||||
//Last updated is stored as timestamp, get a real date
|
||||
$plugin_last_updated_date = new \DateTime( '@' . $last_updated );
|
||||
|
||||
// Compute days between now and plugin last updated
|
||||
//Compute days between now and plugin last updated
|
||||
$diff_in_days = $now->diff( $plugin_last_updated_date )->format( '%a' );
|
||||
|
||||
// Customizable number of days for tolerance
|
||||
//Customizable number of days for tolerance
|
||||
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
|
||||
|
||||
// If we're outside the window for tolerance show a message
|
||||
if ( $diff_in_days > $tolerance_in_days ) {
|
||||
//If we're outside the window for tolerance show a message
|
||||
if( $diff_in_days > $tolerance_in_days )
|
||||
{
|
||||
$plugin_meta[] = sprintf( '<strong style="color: #f00;">This plugin has not been updated by the author in %1$d days!</strong>', $diff_in_days );
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin_meta[] = sprintf( '<span style="color: #090;">This plugin was last updated by the author in %1$d days ago.</span>', $diff_in_days );
|
||||
}
|
||||
}
|
||||
|
@ -186,17 +193,17 @@ class MainWP_Child_Plugins_Check {
|
|||
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
// Get our previous results
|
||||
//Get our previous results
|
||||
$responses = get_transient( $this->tran_name_plugin_timestamps );
|
||||
|
||||
if ( false === $responses || ! is_array( $responses ) ) {
|
||||
$responses = array();
|
||||
}
|
||||
|
||||
// Get our previous cache of plugins for batching
|
||||
//Get our previous cache of plugins for batching
|
||||
$all_plugins = get_transient( $this->tran_name_plugins_to_batch );
|
||||
|
||||
// If there wasn't a previous cache
|
||||
//If there wasn't a previous cache
|
||||
if ( false === $all_plugins || ! is_array( $all_plugins ) ) {
|
||||
$plugins = get_plugins();
|
||||
if ( is_array( $plugins ) ) {
|
||||
|
@ -215,29 +222,29 @@ class MainWP_Child_Plugins_Check {
|
|||
}
|
||||
|
||||
$avoid_plugins = array( 'sitepress-multilingual-cms/sitepress.php' );
|
||||
// Grab a small number of plugins to scan
|
||||
//Grab a small number of plugins to scan
|
||||
$plugins_to_scan = array_splice( $all_plugins, 0, apply_filters( 'mainwp_child_plugin_health_check_max_plugins_to_batch', 10 ) );
|
||||
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
|
||||
|
||||
// Loop through each known plugin
|
||||
//Loop through each known plugin
|
||||
foreach ( $plugins_to_scan as $slug => $v ) {
|
||||
if ( in_array( $slug, $avoid_plugins ) ) {
|
||||
continue;
|
||||
}
|
||||
// Try to get the raw information for this plugin
|
||||
//Try to get the raw information for this plugin
|
||||
$body = $this->try_get_response_body( $slug, false );
|
||||
|
||||
// We couldn't get any information, skip this plugin
|
||||
//We couldn't get any information, skip this plugin
|
||||
if ( false === $body ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Deserialize the response
|
||||
//Deserialize the response
|
||||
$obj = maybe_unserialize( $body );
|
||||
|
||||
$now = new \DateTime();
|
||||
|
||||
// Sanity check that deserialization worked and that our property exists
|
||||
//Sanity check that deserialization worked and that our property exists
|
||||
if ( false !== $obj && is_object( $obj ) && property_exists( $obj, 'last_updated' ) ) {
|
||||
if ( version_compare( $v['Version'], $obj->version, '>' ) ) {
|
||||
continue;
|
||||
|
@ -259,7 +266,7 @@ class MainWP_Child_Plugins_Check {
|
|||
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
|
||||
}
|
||||
|
||||
// Store the master response for usage in the plugin table
|
||||
//Store the master response for usage in the plugin table
|
||||
set_transient( $this->tran_name_plugin_timestamps, $responses, DAY_IN_SECONDS );
|
||||
|
||||
if ( 0 === count( $all_plugins ) ) {
|
||||
|
@ -271,26 +278,26 @@ class MainWP_Child_Plugins_Check {
|
|||
}
|
||||
|
||||
private function try_get_response_body( $plugin, $second_pass ) {
|
||||
// Some of this code is lifted from class-wp-upgrader
|
||||
//Some of this code is lifted from class-wp-upgrader
|
||||
|
||||
// Get the WordPress current version to be polite in the API call
|
||||
include ABSPATH . WPINC . '/version.php';
|
||||
//Get the WordPress current version to be polite in the API call
|
||||
include( ABSPATH . WPINC . '/version.php' );
|
||||
|
||||
global $wp_version;
|
||||
|
||||
// General options to be passed to wp_remote_get
|
||||
//General options to be passed to wp_remote_get
|
||||
$options = array(
|
||||
'timeout' => 60 * 60, // HOUR_IN_SECONDS
|
||||
'timeout' => 60 * 60, //HOUR_IN_SECONDS
|
||||
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
||||
);
|
||||
|
||||
// The URL for the endpoint
|
||||
//The URL for the endpoint
|
||||
$url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
|
||||
|
||||
// If we support SSL
|
||||
// Requires WP 3.2.0
|
||||
//If we support SSL
|
||||
//Requires WP 3.2.0
|
||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
||||
// Requires WP 3.4.0
|
||||
//Requires WP 3.4.0
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
}
|
||||
|
||||
|
@ -299,27 +306,27 @@ class MainWP_Child_Plugins_Check {
|
|||
$plugin_dir = dirname( $plugin );
|
||||
}
|
||||
|
||||
// Try to get the response (usually the SSL version)
|
||||
// Requires WP 2.7.0
|
||||
//Try to get the response (usually the SSL version)
|
||||
//Requires WP 2.7.0
|
||||
$raw_response = wp_remote_get( $url . $plugin_dir, $options );
|
||||
|
||||
// If we don't have an error and we received a valid response code
|
||||
// Requires WP 2.7.0
|
||||
//If we don't have an error and we received a valid response code
|
||||
//Requires WP 2.7.0
|
||||
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
|
||||
// Get the actual body
|
||||
// Requires WP 2.7.0
|
||||
//Get the actual body
|
||||
//Requires WP 2.7.0
|
||||
$body = wp_remote_retrieve_body( $raw_response );
|
||||
|
||||
// Make sure that it isn't empty and also not an empty serialized object
|
||||
//Make sure that it isn't empty and also not an empty serialized object
|
||||
if ( '' !== $body && 'N;' !== $body ) {
|
||||
// If valid, return that
|
||||
//If valid, return that
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
|
||||
// The above valid
|
||||
// If we previously tried an SSL version try without SSL
|
||||
// Code below same as above block
|
||||
//The above valid
|
||||
//If we previously tried an SSL version try without SSL
|
||||
//Code below same as above block
|
||||
if ( $ssl ) {
|
||||
$raw_response = wp_remote_get( $http_url . $plugin, $options );
|
||||
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
|
||||
|
@ -330,22 +337,22 @@ class MainWP_Child_Plugins_Check {
|
|||
}
|
||||
}
|
||||
|
||||
// The above failed
|
||||
// If we're on a second pass already then there's nothing left to do but bail
|
||||
//The above failed
|
||||
//If we're on a second pass already then there's nothing left to do but bail
|
||||
if ( true === $second_pass ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We're still on the first pass, try to get just the name of the directory of the plugin
|
||||
//We're still on the first pass, try to get just the name of the directory of the plugin
|
||||
$parts = explode( '/', $plugin );
|
||||
|
||||
// Sanity check that we have two parts, a directory and a file name
|
||||
//Sanity check that we have two parts, a directory and a file name
|
||||
if ( 2 === count( $parts ) ) {
|
||||
// Try this entire function using just the directory name
|
||||
//Try this entire function using just the directory name
|
||||
return $this->try_get_response_body( $parts[0], true );
|
||||
}
|
||||
|
||||
// Everything above failed, bail
|
||||
//Everything above failed, bail
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ class MainWP_Child_Robot {
|
|||
public static $instance = null;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Robot();
|
||||
if ( null === MainWP_Child_Robot::$instance ) {
|
||||
MainWP_Child_Robot::$instance = new MainWP_Child_Robot();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_Robot::$instance;
|
||||
}
|
||||
|
||||
public function wpr_insertcomments( $postid, $comments ) {
|
||||
|
|
|
@ -19,11 +19,10 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
|
||||
if ( $_POST['what'] == 'warning' ) {
|
||||
if ( isset($_POST['warnings']) ) {
|
||||
if (isset($_POST['warnings']))
|
||||
$warnings = intval($_POST['warnings']);
|
||||
} else {
|
||||
else
|
||||
$warnings = self::getWarnings();
|
||||
}
|
||||
$dismissWarnings['warnings'] = $warnings;
|
||||
}
|
||||
MainWP_Helper::update_option( 'mainwp_child_dismiss_warnings', $dismissWarnings );
|
||||
|
@ -31,7 +30,7 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
|
||||
public static function showWarnings() {
|
||||
if ( stristr( $_SERVER['REQUEST_URI'], 'mainwp_child_tab' ) || stristr( $_SERVER['REQUEST_URI'], 'mainwp-reports-page' ) || stristr( $_SERVER['REQUEST_URI'], 'mainwp-reports-settings' ) ) {
|
||||
if ( stristr( $_SERVER['REQUEST_URI'], 'mainwp_child_tab' ) || stristr( $_SERVER['REQUEST_URI'], 'mainwp-reports-page' ) || stristr( $_SERVER['REQUEST_URI'], 'mainwp-reports-settings' )) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -474,17 +473,12 @@ class MainWP_Child_Server_Information {
|
|||
</div>
|
||||
<br/>
|
||||
<div class="mwp_server_info_box">
|
||||
<h2><?php esc_html_e( 'Server Information' ); ?></h2>
|
||||
<?php
|
||||
self::render();
|
||||
?>
|
||||
<h2><?php esc_html_e( 'Cron Schedules' ); ?></h2>
|
||||
<?php
|
||||
self::renderCron();
|
||||
?>
|
||||
<h2><?php esc_html_e( 'Error Log' ); ?></h2>
|
||||
<?php
|
||||
self::renderErrorLogPage();
|
||||
<h2><?php esc_html_e( 'Server Information' ); ?></h2><?php
|
||||
MainWP_Child_Server_Information::render();
|
||||
?><h2><?php esc_html_e( 'Cron Schedules' ); ?></h2><?php
|
||||
MainWP_Child_Server_Information::renderCron();
|
||||
?><h2><?php esc_html_e( 'Error Log' ); ?></h2><?php
|
||||
MainWP_Child_Server_Information::renderErrorLogPage();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -589,9 +583,8 @@ class MainWP_Child_Server_Information {
|
|||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="background: #333; color: #fff;" colspan="5"><?php esc_html_e( 'WordPress', 'mainwp-child' ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
<td style="background: #333; color: #fff;" colspan="5"><?php esc_html_e( 'WORDPRESS', 'mainwp-child' ); ?></td>
|
||||
</tr><?php
|
||||
self::renderRow( 'WordPress Version', '>=', '3.4', 'getWordpressVersion' );
|
||||
self::renderRow( 'WordPress Memory Limit', '>=', '64M', 'getWordpressMemoryLimit' );
|
||||
self::renderRow( 'MultiSite Disabled', '=', true, 'checkIfMultisite' );
|
||||
|
@ -606,8 +599,7 @@ class MainWP_Child_Server_Information {
|
|||
<tr>
|
||||
<td style="background: #333; color: #fff;"
|
||||
colspan="5"><?php esc_html_e( 'PHP SETTINGS', 'mainwp-child' ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
</tr><?php
|
||||
self::renderRow( 'PHP Version', '>=', '5.6', 'getPHPVersion' );
|
||||
?>
|
||||
<tr>
|
||||
|
@ -637,15 +629,13 @@ class MainWP_Child_Server_Information {
|
|||
<tr>
|
||||
<td style="background: #333; color: #fff;"
|
||||
colspan="5"><?php esc_html_e( 'MySQL SETTINGS', 'mainwp-child' ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
</tr><?php
|
||||
self::renderRow( 'MySQL Version', '>=', '5.0', 'getMySQLVersion' );
|
||||
?>
|
||||
<tr>
|
||||
<td style="background: #333; color: #fff;"
|
||||
colspan="5"><?php esc_html_e( 'BACKUP ARCHIVE INFORMATION', 'mainwp-child' ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
</tr><?php
|
||||
self::renderRow( 'ZipArchive enabled in PHP', '=', true, 'getZipArchiveEnabled' );
|
||||
self::renderRow( 'Tar GZip supported', '=', true, 'getGZipEnabled' );
|
||||
self::renderRow( 'Tar BZip2 supported', '=', true, 'getBZipEnabled' );
|
||||
|
@ -818,16 +808,16 @@ class MainWP_Child_Server_Information {
|
|||
<td colspan="3"><?php echo esc_html( defined( 'DB_CHARSET' ) ? DB_CHARSET : '' ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="background: #333; color: #fff;" colspan="5"><?php _e( 'WordPress PLUGINS', 'mainwp-child' ); ?></td>
|
||||
<td style="background: #333; color: #fff;" colspan="5"><?php _e( 'WORDPRESS PLUGINS', 'mainwp-child' ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$all_plugins = get_plugins();
|
||||
foreach ( $all_plugins as $slug => $plugin ) {
|
||||
foreach ( $all_plugins as $slug => $plugin) {
|
||||
if ( $slug == 'mainwp-child/mainwp-child.php' || $slug == 'mainwp-child-reports/mainwp-child-reports.php' ) {
|
||||
if ( $isBranding ) {
|
||||
if ( $slug == 'mainwp-child/mainwp-child.php' ) {
|
||||
$plugin['Name'] = esc_html( stripslashes( $branding_title ) );
|
||||
} elseif ( $slug == 'mainwp-child-reports/mainwp-child-reports.php' ) {
|
||||
} else if ($slug == 'mainwp-child-reports/mainwp-child-reports.php') {
|
||||
$plugin['Name'] = esc_html( stripslashes( $branding_title ) ) . ' reports';
|
||||
}
|
||||
}
|
||||
|
@ -879,7 +869,7 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
|
||||
public static function mainwpRequiredFunctions() {
|
||||
// error_reporting(E_ALL);
|
||||
//error_reporting(E_ALL);
|
||||
$disabled_functions = ini_get( 'disable_functions' );
|
||||
if ( '' !== $disabled_functions ) {
|
||||
$arr = explode( ',', $disabled_functions );
|
||||
|
@ -906,7 +896,7 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
|
||||
protected static function getMainwpVersion() {
|
||||
include_once ABSPATH . '/wp-admin/includes/plugin-install.php';
|
||||
include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' );
|
||||
$api = plugins_api( 'plugin_information', array(
|
||||
'slug' => 'mainwp-child',
|
||||
'fields' => array( 'sections' => false ),
|
||||
|
@ -967,9 +957,8 @@ class MainWP_Child_Server_Information {
|
|||
|
||||
protected static function checkDirectoryMainWPDirectory( $write = true ) {
|
||||
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
|
||||
if ( $branding_title == '' ) {
|
||||
if ($branding_title == '')
|
||||
$branding_title = 'MainWP';
|
||||
}
|
||||
|
||||
$branding_title .= ' Upload Directory';
|
||||
|
||||
|
@ -1054,19 +1043,20 @@ class MainWP_Child_Server_Information {
|
|||
<td><?php echo( $currentVersion === true ? 'true' : $currentVersion ); ?></td>
|
||||
<?php if ( $whatType == 'filesize' ) { ?>
|
||||
<td><?php echo( self::filesize_compare( $currentVersion, $pVersion, $pCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
|
||||
<?php } elseif ( $whatType == 'curlssl' ) { ?>
|
||||
<?php } else if ( $whatType == 'curlssl' ) { ?>
|
||||
<td><?php echo( self::curlssl_compare( $pVersion, $pCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
|
||||
<?php } elseif ( ( $pGetter == 'getMaxInputTime' || $pGetter == 'getMaxExecutionTime' ) && $currentVersion == -1 ) { ?>
|
||||
<?php } else if (($pGetter == 'getMaxInputTime' || $pGetter == 'getMaxExecutionTime') && $currentVersion == -1) { ?>
|
||||
<td><?php echo '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>'; ?></td>
|
||||
<?php } else { ?>
|
||||
<td><?php echo ( version_compare($currentVersion, $pVersion, $pCompare) || ( ( $pExtraCompare != null ) && version_compare($currentVersion, $pExtraVersion, $pExtraCompare) ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
|
||||
<td><?php echo (version_compare($currentVersion, $pVersion, $pCompare) || (($pExtraCompare != null) && version_compare($currentVersion, $pExtraVersion, $pExtraCompare)) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType )); ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
private static function getWarningHTML( $errorType = self::WARNING ) {
|
||||
if ( self::WARNING == $errorType ) {
|
||||
private static function getWarningHTML($errorType = self::WARNING)
|
||||
{
|
||||
if (self::WARNING == $errorType) {
|
||||
return '<span class="mainwp-warning"><i class="fa fa-exclamation-circle"></i> Warning</span>';
|
||||
}
|
||||
return '<span class="mainwp-fail"><i class="fa fa-exclamation-circle"></i> Fail</span>';
|
||||
|
@ -1090,10 +1080,10 @@ class MainWP_Child_Server_Information {
|
|||
return version_compare( $value1, $value2, $operator );
|
||||
}
|
||||
|
||||
protected static function check( $pCompare, $pVersion, $pGetter, $pExtraCompare = null, $pExtraVersion = null, $sizeCompare = false ) {
|
||||
protected static function check( $pCompare, $pVersion, $pGetter, $pExtraCompare = null, $pExtraVersion = null, $sizeCompare = false) {
|
||||
$currentVersion = call_user_func( array( 'MainWP_Child_Server_Information', $pGetter ) );
|
||||
|
||||
if ( $sizeCompare ) {
|
||||
if ($sizeCompare) {
|
||||
return self::filesize_compare( $currentVersion, $pVersion, $pCompare );
|
||||
} else {
|
||||
return ( version_compare( $currentVersion, $pVersion, $pCompare ) || ( ( null !== $pExtraCompare ) && version_compare( $currentVersion, $pExtraVersion, $pExtraCompare ) ) );
|
||||
|
@ -1180,10 +1170,7 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
|
||||
protected static function getArchitecture() {
|
||||
echo esc_html( PHP_INT_SIZE * 8 )
|
||||
?>
|
||||
bit
|
||||
<?php
|
||||
echo esc_html( PHP_INT_SIZE * 8 ) ?> bit <?php
|
||||
}
|
||||
|
||||
protected static function memoryUsage() {
|
||||
|
@ -1329,33 +1316,31 @@ class MainWP_Child_Server_Information {
|
|||
|
||||
protected static function serverSelfConnect() {
|
||||
$url = site_url( 'wp-cron.php' );
|
||||
$query_args = array( 'mainwp_child_run' => 'test' );
|
||||
$query_args = array('mainwp_child_run' => 'test');
|
||||
$url = add_query_arg( $query_args, $url );
|
||||
$args = array(
|
||||
'blocking' => true,
|
||||
$args = array( 'blocking' => TRUE,
|
||||
'sslverify' => apply_filters( 'https_local_ssl_verify', true ),
|
||||
'timeout' => 15,
|
||||
'timeout' => 15
|
||||
);
|
||||
$response = wp_remote_post( $url, $args );
|
||||
$test_result = '';
|
||||
if ( is_wp_error( $response ) ) {
|
||||
$test_result .= sprintf( __( 'The HTTP response test get an error "%s"', 'mainwp-child' ), $response->get_error_message() );
|
||||
$test_result .= sprintf( __( 'The HTTP response test get an error "%s"','mainwp-child' ), $response->get_error_message() );
|
||||
}
|
||||
$response_code = wp_remote_retrieve_response_code( $response );
|
||||
if ( $response_code < 200 && $response_code > 204 ) {
|
||||
$test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)', 'mainwp-child' ), wp_remote_retrieve_response_code( $response ) );
|
||||
$test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)','mainwp-child' ), wp_remote_retrieve_response_code( $response ) );
|
||||
} else {
|
||||
$response_body = wp_remote_retrieve_body( $response );
|
||||
if ( false === strstr( $response_body, 'MainWP Test' ) ) {
|
||||
$test_result .= sprintf( __( 'Not expected HTTP response body: %s', 'mainwp-child' ), esc_attr( strip_tags( $response_body ) ) );
|
||||
if ( FALSE === strstr( $response_body, 'MainWP Test' ) ) {
|
||||
$test_result .= sprintf( __( 'Not expected HTTP response body: %s','mainwp-child' ), esc_attr( strip_tags( $response_body ) ) );
|
||||
}
|
||||
}
|
||||
if ( empty( $test_result ) ) {
|
||||
_e( 'Response Test O.K.', 'mainwp-child' );
|
||||
} else {
|
||||
} else
|
||||
echo $test_result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static function getRemoteAddress() {
|
||||
|
@ -1426,6 +1411,7 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
|
||||
return $bytes;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1482,7 +1468,7 @@ class MainWP_Child_Server_Information {
|
|||
|
||||
if ( empty( $lines ) ) {
|
||||
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
|
||||
if ( $branding_title == '' ) {
|
||||
if ($branding_title == '') {
|
||||
$branding_title = 'MainWP';
|
||||
}
|
||||
$msg = esc_html( stripslashes( $branding_title ) ) . ' is unable to find your error logs, please contact your host for server error logs.';
|
||||
|
@ -1518,6 +1504,7 @@ class MainWP_Child_Server_Information {
|
|||
echo wp_kses_post( "<tr><td>{$time}</td><td>{$error}</td></tr>" );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static function time_compare( $a, $b ) {
|
||||
|
@ -1602,7 +1589,7 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
}
|
||||
|
||||
if ( ! $configFound ) {
|
||||
if ( !$configFound ) {
|
||||
_e( 'wp-config.php not found', 'mainwp' );
|
||||
}
|
||||
}
|
||||
|
@ -1628,9 +1615,8 @@ class MainWP_Child_Server_Information {
|
|||
|
||||
public static function renderConnectionDetails() {
|
||||
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
|
||||
if ( $branding_title == '' ) {
|
||||
if ($branding_title == '')
|
||||
$branding_title = 'MainWP';
|
||||
}
|
||||
|
||||
global $current_user;
|
||||
$uniqueId = get_option('mainwp_child_uniqueId');
|
||||
|
@ -1638,27 +1624,27 @@ class MainWP_Child_Server_Information {
|
|||
'siteurl' => array(
|
||||
'title' => __('Site URL', 'mainwp-child'),
|
||||
'value' => get_bloginfo( 'url' ),
|
||||
'desc' => get_bloginfo( 'url' ),
|
||||
'desc' => get_bloginfo( 'url' )
|
||||
),
|
||||
'adminuser' => array(
|
||||
'title' => __('Administrator name', 'mainwp-child'),
|
||||
'value' => $current_user->user_login,
|
||||
'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'),
|
||||
'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child')
|
||||
),
|
||||
'friendly_name' => array(
|
||||
'title' => __('Friendly site name', 'mainwp-child'),
|
||||
'value' => get_bloginfo( 'name' ),
|
||||
'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'),
|
||||
'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child')
|
||||
),
|
||||
'uniqueid' => array(
|
||||
'title' => __('Child unique security id', 'mainwp-child'),
|
||||
'value' => ! empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'),
|
||||
'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ),
|
||||
'value' => !empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'),
|
||||
'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child') , stripslashes( $branding_title ) )
|
||||
),
|
||||
'verify_ssl' => array(
|
||||
'title' => __('Verify certificate', 'mainwp-child'),
|
||||
'value' => __('Yes', 'mainwp-child'),
|
||||
'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'),
|
||||
'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child')
|
||||
),
|
||||
'ssl_version' => array(
|
||||
'title' => __('SSL version', 'mainwp-child'),
|
||||
|
@ -1673,13 +1659,13 @@ class MainWP_Child_Server_Information {
|
|||
<div class="inside">
|
||||
<div class="mainwp-postbox-actions-top mainwp-padding-5">
|
||||
<?php
|
||||
echo sprintf(__('If you are trying to connect this child site to your %s Dashboard, you can use following details to do that. Please note that these are only suggested values.', 'mainwp-child'), stripslashes( $branding_title ));
|
||||
echo sprintf(__('If you are trying to connect this child site to your %s Dashboard, you can use following details to do that. Please note that these are only suggested values.', 'mainwp-child') , stripslashes( $branding_title ));
|
||||
?>
|
||||
</div>
|
||||
<table id="mainwp-table" class="wp-list-table widefat" cellspacing="0" style="border: 0">
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ( $details as $row ) {
|
||||
foreach ($details as $row) {
|
||||
?>
|
||||
<tr>
|
||||
<th style="width: 20%"><strong><?php echo esc_html($row['title']); ?></strong></th>
|
||||
|
|
|
@ -7,11 +7,11 @@ class MainWP_Child_Skeleton_Key {
|
|||
public $plugin_translate = 'mainwp-child';
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Skeleton_Key();
|
||||
if ( null === MainWP_Child_Skeleton_Key::$instance ) {
|
||||
MainWP_Child_Skeleton_Key::$instance = new MainWP_Child_Skeleton_Key();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_Skeleton_Key::$instance;
|
||||
}
|
||||
|
||||
public function action() {
|
||||
|
@ -19,13 +19,13 @@ class MainWP_Child_Skeleton_Key {
|
|||
error_reporting( 0 );
|
||||
function mainwp_skeleton_key_handle_fatal_error() {
|
||||
$error = error_get_last();
|
||||
if ( isset( $error['type'] ) && in_array($error['type'], array( 1, 4, 16, 64, 256 ) ) && isset( $error['message'] ) ) {
|
||||
if ( isset( $error['type'] ) && in_array($error['type'], array(1, 4, 16, 64, 256) ) && isset( $error['message'] ) ) {
|
||||
MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
|
||||
}
|
||||
// to fix issue double <mainwp></mainwp> header in response
|
||||
// else {
|
||||
// MainWP_Helper::write( MainWP_Child_Skeleton_Key::$information );
|
||||
// }
|
||||
// else {
|
||||
// MainWP_Helper::write( MainWP_Child_Skeleton_Key::$information );
|
||||
// }
|
||||
}
|
||||
|
||||
register_shutdown_function( 'mainwp_skeleton_key_handle_fatal_error' );
|
||||
|
@ -42,7 +42,7 @@ class MainWP_Child_Skeleton_Key {
|
|||
}
|
||||
|
||||
MainWP_Helper::write( $information );
|
||||
// MainWP_Child_Skeleton_Key::$information = $information;
|
||||
//MainWP_Child_Skeleton_Key::$information = $information;
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ class MainWP_Child_Skeleton_Key {
|
|||
$manager = WP_Session_Tokens::get_instance( $current_user->ID );
|
||||
$token = $manager->create( $expiration );
|
||||
|
||||
|
||||
$secure = is_ssl();
|
||||
if ( $secure ) {
|
||||
$auth_cookie_name = SECURE_AUTH_COOKIE;
|
||||
|
@ -84,14 +85,8 @@ class MainWP_Child_Skeleton_Key {
|
|||
$post_args['redirection'] = 5;
|
||||
$post_args['decompress'] = false; // For gzinflate() data error bug
|
||||
$post_args['cookies'] = array(
|
||||
new WP_Http_Cookie( array(
|
||||
'name' => $auth_cookie_name,
|
||||
'value' => $auth_cookie,
|
||||
) ),
|
||||
new WP_Http_Cookie( array(
|
||||
'name' => LOGGED_IN_COOKIE,
|
||||
'value' => $logged_in_cookie,
|
||||
) ),
|
||||
new WP_Http_Cookie( array( 'name' => $auth_cookie_name, 'value' => $auth_cookie ) ),
|
||||
new WP_Http_Cookie( array( 'name' => LOGGED_IN_COOKIE, 'value' => $logged_in_cookie ) ),
|
||||
);
|
||||
|
||||
if ( isset( $args['get'] ) ) {
|
||||
|
@ -195,33 +190,30 @@ class MainWP_Child_Skeleton_Key {
|
|||
public function save_settings() {
|
||||
$settings = isset($_POST['settings']) ? $_POST['settings'] : array();
|
||||
|
||||
if ( ! is_array($settings) || empty($settings) ) {
|
||||
return array( 'error' => 'Invalid data. Please check and try again.' );
|
||||
}
|
||||
if (!is_array($settings) || empty($settings))
|
||||
return array('error' => 'Invalid data. Please check and try again.');
|
||||
|
||||
$whitelist_options = array(
|
||||
'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ),
|
||||
);
|
||||
|
||||
if ( ! is_multisite() ) {
|
||||
if ( ! defined( 'WP_SITEURL' ) ) {
|
||||
if ( !is_multisite() ) {
|
||||
if ( !defined( 'WP_SITEURL' ) )
|
||||
$whitelist_options['general'][] = 'siteurl';
|
||||
}
|
||||
if ( ! defined( 'WP_HOME' ) ) {
|
||||
if ( !defined( 'WP_HOME' ) )
|
||||
$whitelist_options['general'][] = 'home';
|
||||
}
|
||||
|
||||
$whitelist_options['general'][] = 'admin_email';
|
||||
$whitelist_options['general'][] = 'users_can_register';
|
||||
$whitelist_options['general'][] = 'default_role';
|
||||
}
|
||||
|
||||
// $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
|
||||
$whitelist_general = $whitelist_options['general'];
|
||||
//$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
|
||||
$whitelist_general = $whitelist_options[ 'general' ];
|
||||
|
||||
// Handle translation install.
|
||||
if ( ! empty( $settings['WPLANG'] ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
|
||||
if ( wp_can_install_language_pack() ) {
|
||||
$language = wp_download_language_pack( $settings['WPLANG'] );
|
||||
if ( $language ) {
|
||||
|
@ -231,22 +223,20 @@ class MainWP_Child_Skeleton_Key {
|
|||
}
|
||||
|
||||
$updated = false;
|
||||
foreach ( $settings as $option => $value ) {
|
||||
if ( in_array($option, $whitelist_general) ) {
|
||||
if ( ! is_array( $value ) ) {
|
||||
foreach($settings as $option => $value) {
|
||||
if (in_array($option, $whitelist_general)) {
|
||||
if ( ! is_array( $value ) )
|
||||
$value = trim( $value );
|
||||
}
|
||||
$value = wp_unslash( $value );
|
||||
update_option($option, $value);
|
||||
$updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $updated ) {
|
||||
if (!$updated)
|
||||
return false;
|
||||
}
|
||||
|
||||
return array( 'result' => 'ok' );
|
||||
return array('result' => 'ok');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,36 +22,33 @@ class MainWP_Child_Staging {
|
|||
public $is_plugin_installed = false;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Staging();
|
||||
if ( null === MainWP_Child_Staging::$instance ) {
|
||||
MainWP_Child_Staging::$instance = new MainWP_Child_Staging();
|
||||
}
|
||||
return self::$instance;
|
||||
return MainWP_Child_Staging::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
if ( is_plugin_active( 'wp-staging/wp-staging.php' ) && defined('WPSTG_PLUGIN_DIR') ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
if ( is_plugin_active( 'wp-staging/wp-staging.php' ) && defined('WPSTG_PLUGIN_DIR')) {
|
||||
$this->is_plugin_installed = true;
|
||||
} elseif ( is_plugin_active( 'wp-staging-pro/wp-staging-pro.php' ) ) {
|
||||
} else if ( is_plugin_active( 'wp-staging-pro/wp-staging-pro.php' ) ) {
|
||||
$this->is_plugin_installed = true;
|
||||
}
|
||||
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
if (!$this->is_plugin_installed)
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||
}
|
||||
|
||||
|
||||
public function init() {
|
||||
if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) {
|
||||
if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
if (!$this->is_plugin_installed)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( get_option( 'mainwp_wp_staging_hide_plugin' ) === 'hide' ) {
|
||||
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
||||
|
@ -63,9 +60,9 @@ class MainWP_Child_Staging {
|
|||
|
||||
public function syncOthersData( $information, $data = array() ) {
|
||||
if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) {
|
||||
try {
|
||||
try{
|
||||
$information['syncWPStaging'] = $this->get_sync_data();
|
||||
} catch ( Exception $e ) {
|
||||
} catch(Exception $e) {
|
||||
// do not exit
|
||||
}
|
||||
}
|
||||
|
@ -77,17 +74,17 @@ class MainWP_Child_Staging {
|
|||
}
|
||||
|
||||
public function action() {
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
MainWP_Helper::write( array( 'error' => 'Please install WP Staging plugin on child website' ) );
|
||||
if (!$this->is_plugin_installed) {
|
||||
MainWP_Helper::write( array('error' => 'Please install WP Staging plugin on child website') );
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WPStaging\WPStaging' ) ) {
|
||||
require_once WPSTG_PLUGIN_DIR . 'apps/Core/WPStaging.php';
|
||||
if (!class_exists( 'WPStaging\WPStaging' )){
|
||||
require_once WPSTG_PLUGIN_DIR . "apps/Core/WPStaging.php";
|
||||
}
|
||||
\WPStaging\WPStaging::getInstance();
|
||||
|
||||
$information = array();
|
||||
if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) {
|
||||
if (get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y') {
|
||||
MainWP_Helper::update_option( 'mainwp_wp_staging_ext_enabled', 'Y', 'yes' );
|
||||
}
|
||||
|
||||
|
@ -167,27 +164,27 @@ class MainWP_Child_Staging {
|
|||
'disableAdminLogin',
|
||||
'querySRLimit',
|
||||
'maxFileSize',
|
||||
// 'wpSubDirectory', // removed
|
||||
//'wpSubDirectory', // removed
|
||||
'debugMode',
|
||||
'unInstallOnDelete',
|
||||
'checkDirectorySize',
|
||||
'optimizer',
|
||||
// 'loginSlug' // removed
|
||||
//'loginSlug' // removed
|
||||
);
|
||||
|
||||
$save_fields = array();
|
||||
foreach ( $filters as $field ) {
|
||||
if ( isset($settings[ $field ]) ) {
|
||||
$save_fields[ $field ] = $settings[ $field ];
|
||||
foreach($filters as $field) {
|
||||
if (isset($settings[$field])) {
|
||||
$save_fields[$field] = $settings[$field];
|
||||
}
|
||||
}
|
||||
update_option('wpstg_settings', $save_fields );
|
||||
return array( 'result' => 'success' );
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
public function get_overview() {
|
||||
$return = array(
|
||||
'availableClones' => get_option( 'wpstg_existing_clones_beta', array()),
|
||||
'availableClones' => get_option( "wpstg_existing_clones_beta", array())
|
||||
);
|
||||
return $return;
|
||||
}
|
||||
|
@ -203,31 +200,31 @@ class MainWP_Child_Staging {
|
|||
$return = array(
|
||||
'options' => serialize($options),
|
||||
'directoryListing' => $scan->directoryListing(),
|
||||
'prefix' => WPStaging\WPStaging::getTablePrefix(),
|
||||
'prefix' => WPStaging\WPStaging::getTablePrefix()
|
||||
);
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
public function ajaxCheckCloneName() {
|
||||
$cloneName = sanitize_key( $_POST['cloneID'] );
|
||||
$cloneName = sanitize_key( $_POST["cloneID"] );
|
||||
$cloneNameLength = strlen( $cloneName );
|
||||
$clones = get_option( 'wpstg_existing_clones_beta', array() );
|
||||
$clones = get_option( "wpstg_existing_clones_beta", array() );
|
||||
|
||||
// Check clone name length
|
||||
if ( $cloneNameLength < 1 || $cloneNameLength > 16 ) {
|
||||
if( $cloneNameLength < 1 || $cloneNameLength > 16 ) {
|
||||
echo array(
|
||||
'status' => 'failed',
|
||||
'message' => 'Clone name must be between 1 - 16 characters',
|
||||
"status" => "failed",
|
||||
"message" => "Clone name must be between 1 - 16 characters"
|
||||
);
|
||||
} elseif ( array_key_exists( $cloneName, $clones ) ) {
|
||||
} elseif( array_key_exists( $cloneName, $clones ) ) {
|
||||
return array(
|
||||
'status' => 'failed',
|
||||
'message' => 'Clone name is already in use, please choose an another clone name',
|
||||
"status" => "failed",
|
||||
"message" => "Clone name is already in use, please choose an another clone name"
|
||||
);
|
||||
}
|
||||
|
||||
return array( 'status' => 'success' );
|
||||
return array("status" => "success");
|
||||
}
|
||||
|
||||
public function ajaxStartClone() {
|
||||
|
@ -235,12 +232,13 @@ class MainWP_Child_Staging {
|
|||
$this->url = ''; // to fix warning
|
||||
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
|
||||
|
||||
if ( ! $cloning->save() ) {
|
||||
|
||||
if( !$cloning->save() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
require_once WPSTG_PLUGIN_DIR . 'apps/Backend/views/clone/ajax/start.php';
|
||||
require_once WPSTG_PLUGIN_DIR . "apps/Backend/views/clone/ajax/start.php";
|
||||
$result = ob_get_clean();
|
||||
return $result;
|
||||
}
|
||||
|
@ -288,7 +286,7 @@ class MainWP_Child_Staging {
|
|||
$cloning = new WPStaging\Backend\Modules\Jobs\Cloning();
|
||||
$this->url = ''; // to fix warning
|
||||
$return = $cloning->start();
|
||||
$return->blogInfoName = get_bloginfo('name');
|
||||
$return->blogInfoName = get_bloginfo("name");
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -303,7 +301,7 @@ class MainWP_Child_Staging {
|
|||
$clone = $delete->getClone();
|
||||
$result = array(
|
||||
'clone' => $clone,
|
||||
'deleteTables' => $delete->getTables(),
|
||||
'deleteTables' => $delete->getTables()
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
@ -334,12 +332,12 @@ class MainWP_Child_Staging {
|
|||
|
||||
$cloning = new WPStaging\Backend\Modules\Jobs\Updating();
|
||||
|
||||
if ( ! $cloning->save() ) {
|
||||
if( !$cloning->save() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
require_once WPSTG_PLUGIN_DIR . 'apps/Backend/views/clone/ajax/update.php';
|
||||
require_once WPSTG_PLUGIN_DIR . "apps/Backend/views/clone/ajax/update.php";
|
||||
$result = ob_get_clean();
|
||||
return $result;
|
||||
}
|
||||
|
@ -350,20 +348,20 @@ class MainWP_Child_Staging {
|
|||
|
||||
// from wp-staging plugin
|
||||
public function hasFreeDiskSpace() {
|
||||
if ( ! function_exists( 'disk_free_space' ) ) {
|
||||
if( !function_exists( "disk_free_space" ) ) {
|
||||
return null;
|
||||
}
|
||||
$freeSpace = @disk_free_space( ABSPATH );
|
||||
if ( false === $freeSpace ) {
|
||||
if( false === $freeSpace ) {
|
||||
$data = array(
|
||||
'freespace' => false,
|
||||
'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)),
|
||||
'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH))
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
$data = array(
|
||||
'freespace' => $this->formatSize($freeSpace),
|
||||
'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)),
|
||||
'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH))
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
@ -378,18 +376,20 @@ class MainWP_Child_Staging {
|
|||
}
|
||||
|
||||
// from wp-staging plugin
|
||||
public function formatSize( $bytes, $precision = 2 ) {
|
||||
if ( (float) $bytes < 1 ) {
|
||||
public function formatSize($bytes, $precision = 2)
|
||||
{
|
||||
if ((double) $bytes < 1)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
|
||||
$units = array('B', "KB", "MB", "GB", "TB");
|
||||
|
||||
$bytes = (float) $bytes;
|
||||
$bytes = (double) $bytes;
|
||||
$base = log($bytes) / log(1000); // 1024 would be for MiB KiB etc
|
||||
$pow = pow(1000, $base - floor($base)); // Same rule for 1000
|
||||
|
||||
return round($pow, $precision) . ' ' . $units[ (int) floor($base) ];
|
||||
return round($pow, $precision) . ' ' . $units[(int) floor($base)];
|
||||
}
|
||||
|
||||
|
||||
|
@ -423,7 +423,7 @@ class MainWP_Child_Staging {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if ( ! MainWP_Helper::is_screen_with_update() ) {
|
||||
if (! MainWP_Helper::is_screen_with_update()) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ class MainWP_Child_Themes_Check {
|
|||
private $option_name_last_daily_run = 'mainwp_child_theme_last_daily_run';
|
||||
|
||||
public static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Themes_Check();
|
||||
if ( null === MainWP_Child_Themes_Check::$instance ) {
|
||||
MainWP_Child_Themes_Check::$instance = new MainWP_Child_Themes_Check();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_Themes_Check::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
@ -49,6 +49,7 @@ class MainWP_Child_Themes_Check {
|
|||
|
||||
add_action( 'mainwp_child_deactivation', array( $this, 'cleanup_deactivation' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function cleanup_basic() {
|
||||
|
@ -95,7 +96,7 @@ class MainWP_Child_Themes_Check {
|
|||
$last_run = new \DateTime( '@' . $last_run );
|
||||
}
|
||||
|
||||
// Get now
|
||||
//Get now
|
||||
$now = new \DateTime();
|
||||
|
||||
if ( false === $last_run || (int) $now->diff( $last_run )->format( '%h' ) >= 24 ) {
|
||||
|
@ -110,13 +111,14 @@ class MainWP_Child_Themes_Check {
|
|||
}
|
||||
|
||||
public function schedule_watchdog() {
|
||||
// For testing
|
||||
// $this->cleanup_deactivation();
|
||||
//For testing
|
||||
//$this->cleanup_deactivation();
|
||||
|
||||
// Schedule a global watching cron just in case both other crons get killed
|
||||
//Schedule a global watching cron just in case both other crons get killed
|
||||
if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) {
|
||||
wp_schedule_event( time(), 'hourly', $this->cron_name_watcher );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function get_themes_outdate_info() {
|
||||
|
@ -125,7 +127,7 @@ class MainWP_Child_Themes_Check {
|
|||
$themes_outdate = array();
|
||||
}
|
||||
if ( ! function_exists( 'wp_get_themes' ) ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/theme.php';
|
||||
require_once( ABSPATH . '/wp-admin/includes/theme.php' );
|
||||
}
|
||||
$themes = wp_get_themes();
|
||||
$update = false;
|
||||
|
@ -144,10 +146,10 @@ class MainWP_Child_Themes_Check {
|
|||
|
||||
public function run_check() {
|
||||
if ( ! function_exists( 'wp_get_themes' ) ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/theme.php';
|
||||
require_once( ABSPATH . '/wp-admin/includes/theme.php' );
|
||||
}
|
||||
|
||||
// Get our previous results
|
||||
//Get our previous results
|
||||
$responses = get_transient( $this->tran_name_theme_timestamps );
|
||||
|
||||
if ( false === $responses || ! is_array( $responses ) ) {
|
||||
|
@ -155,7 +157,7 @@ class MainWP_Child_Themes_Check {
|
|||
}
|
||||
|
||||
$all_themes = get_transient( $this->tran_name_themes_to_batch );
|
||||
// If there wasn't a previous cache
|
||||
//If there wasn't a previous cache
|
||||
if ( false === $all_themes || ! is_array( $all_themes ) ) {
|
||||
$all_themes = array();
|
||||
$themes = wp_get_themes();
|
||||
|
@ -177,9 +179,7 @@ class MainWP_Child_Themes_Check {
|
|||
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
|
||||
|
||||
foreach ( $themes_to_scan as $slug => $v ) {
|
||||
if ( in_array( $slug, $avoid_themes ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( in_array( $slug, $avoid_themes ) ) continue;
|
||||
|
||||
$body = $this->try_get_response_body( $slug, false );
|
||||
|
||||
|
@ -187,18 +187,19 @@ class MainWP_Child_Themes_Check {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Deserialize the response
|
||||
//Deserialize the response
|
||||
$obj = maybe_unserialize( $body );
|
||||
|
||||
$now = new \DateTime();
|
||||
|
||||
// Sanity check that deserialization worked and that our property exists
|
||||
//Sanity check that deserialization worked and that our property exists
|
||||
if ( false !== $obj && is_object( $obj ) && property_exists( $obj, 'last_updated' ) ) {
|
||||
$last_updated = strtotime( $obj->last_updated );
|
||||
$theme_last_updated_date = new \DateTime( '@' . $last_updated );
|
||||
|
||||
$diff_in_days = $now->diff( $theme_last_updated_date )->format( '%a' );
|
||||
|
||||
|
||||
if ( $diff_in_days < $tolerance_in_days ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -213,7 +214,7 @@ class MainWP_Child_Themes_Check {
|
|||
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
|
||||
}
|
||||
|
||||
// Store the master response for usage in the plugin table
|
||||
//Store the master response for usage in the plugin table
|
||||
set_transient( $this->tran_name_theme_timestamps, $responses, DAY_IN_SECONDS );
|
||||
|
||||
if ( 0 === count( $all_themes ) ) {
|
||||
|
@ -227,21 +228,15 @@ class MainWP_Child_Themes_Check {
|
|||
|
||||
|
||||
private function try_get_response_body( $theme ) {
|
||||
// Get the WordPress current version to be polite in the API call
|
||||
include ABSPATH . WPINC . '/version.php';
|
||||
//Get the WordPress current version to be polite in the API call
|
||||
include( ABSPATH . WPINC . '/version.php' );
|
||||
|
||||
$url = $http_url = 'http://api.wordpress.org/themes/info/1.0/';
|
||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'slug' => $theme,
|
||||
'fields' => array(
|
||||
'sections' => false,
|
||||
'tags' => false,
|
||||
),
|
||||
);
|
||||
$args = array( 'slug' => $theme, 'fields' => array( 'sections' => false, 'tags' => false ) );
|
||||
$args = (object) $args;
|
||||
|
||||
$http_args = array(
|
||||
|
@ -254,20 +249,20 @@ class MainWP_Child_Themes_Check {
|
|||
$raw_response = wp_remote_post( $url, $http_args );
|
||||
|
||||
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
|
||||
// Get the actual body
|
||||
// Requires WP 2.7.0
|
||||
//Get the actual body
|
||||
//Requires WP 2.7.0
|
||||
$body = wp_remote_retrieve_body( $raw_response );
|
||||
|
||||
// Make sure that it isn't empty and also not an empty serialized object
|
||||
//Make sure that it isn't empty and also not an empty serialized object
|
||||
if ( '' !== $body && 'N;' !== $body ) {
|
||||
// If valid, return that
|
||||
//If valid, return that
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
|
||||
// The above valid
|
||||
// If we previously tried an SSL version try without SSL
|
||||
// Code below same as above block
|
||||
//The above valid
|
||||
//If we previously tried an SSL version try without SSL
|
||||
//Code below same as above block
|
||||
if ( $ssl ) {
|
||||
$raw_response = wp_remote_post( $http_url, $http_args );
|
||||
|
||||
|
@ -279,7 +274,7 @@ class MainWP_Child_Themes_Check {
|
|||
}
|
||||
}
|
||||
|
||||
// Everything above failed, bail
|
||||
//Everything above failed, bail
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
|
||||
/*
|
||||
*
|
||||
* Credits
|
||||
*
|
||||
* Plugin-Name: Vulnerability Alerts
|
||||
|
@ -20,19 +22,20 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
private $wpvulndb_api = 'https://wpvulndb.com/api/v3/';
|
||||
private $wpvulndb_token = false;
|
||||
|
||||
public static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Vulnerability_Checker();
|
||||
static function Instance() {
|
||||
if ( null === MainWP_Child_Vulnerability_Checker::$instance ) {
|
||||
MainWP_Child_Vulnerability_Checker::$instance = new MainWP_Child_Vulnerability_Checker();
|
||||
}
|
||||
return self::$instance;
|
||||
return MainWP_Child_Vulnerability_Checker::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->wpvulndb_token = get_option( 'mainwp_child_wpvulndb_token', '' );
|
||||
$this->wpvulndb_token = get_option('mainwp_child_wpvulndb_token', '');
|
||||
}
|
||||
|
||||
public function action() {
|
||||
$information = array();
|
||||
|
||||
if ( ! empty( $this->wpvulndb_token ) ) {
|
||||
if ( isset( $_POST['mwp_action'] ) ) {
|
||||
switch ( $_POST['mwp_action'] ) {
|
||||
|
@ -46,87 +49,88 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
public function vulner_recheck() {
|
||||
function vulner_recheck(){
|
||||
$result = array();
|
||||
$force = ( isset( $_POST['force'] ) && ! empty( $_POST['force'] ) ) ? true : false;
|
||||
$result['plugin'] = $this->check_plugins( $force );
|
||||
$result['wp'] = $this->check_wp( $force );
|
||||
$result['theme'] = $this->check_themes( $force );
|
||||
$information = array(
|
||||
'result' => $result,
|
||||
'ok' => 1,
|
||||
);
|
||||
$force = (isset($_POST['force']) && !empty($_POST['force'])) ? true : false;
|
||||
$result['plugin'] = $this->check_plugins($force);
|
||||
$result['wp'] = $this->check_wp($force);
|
||||
$result['theme'] = $this->check_themes($force);
|
||||
$information = array( 'result' => $result, 'ok' => 1);
|
||||
return $information;
|
||||
}
|
||||
|
||||
public function check_plugins( $force = false ) {
|
||||
function check_plugins($force = false){
|
||||
$result = array();
|
||||
$active_plugins = get_option( 'active_plugins' );
|
||||
$active_plugins = get_option('active_plugins');
|
||||
|
||||
if ( ! empty( $active_plugins ) ) {
|
||||
foreach ( $active_plugins as $plug ) {
|
||||
if( !empty($active_plugins) ){
|
||||
foreach($active_plugins as $plug){
|
||||
|
||||
$plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug;
|
||||
$plugin_info = get_plugin_data( $plugin_file );
|
||||
$plugin_version = isset( $plugin_info['Version'] ) ? $plugin_info['Version'] : '';
|
||||
$string = explode( '/', $plug );
|
||||
$plug_vuln = get_transient( 'mainwp_vulnche_trans_plug_' . $string[0] );
|
||||
if ( false === $plug_vuln || $force ) {
|
||||
$plug_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'plugins/' . $string[0] );
|
||||
set_transient( 'mainwp_vulnche_trans_plug_' . $string[0], $plug_vuln, 1 * DAY_IN_SECONDS );
|
||||
$plugin_info = get_plugin_data($plugin_file);
|
||||
$plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : '';
|
||||
$string = explode('/',$plug);
|
||||
$plug_vuln = get_transient('mainwp_vulnche_trans_plug_'.$string[0]);
|
||||
if(false === $plug_vuln || $force) {
|
||||
$plug_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'plugins/' . $string[0]);
|
||||
set_transient('mainwp_vulnche_trans_plug_'.$string[0],$plug_vuln, 1 * DAY_IN_SECONDS);
|
||||
}
|
||||
if ( $plug_vuln ) {
|
||||
$plug_vuln = json_decode( $plug_vuln, true );
|
||||
if ($plug_vuln) {
|
||||
$plug_vuln = json_decode($plug_vuln, true);
|
||||
$plug_vuln_filter = $plug_vuln;
|
||||
foreach ( $plug_vuln as $slug => $pl_data ) {
|
||||
if ( isset( $pl_data['vulnerabilities'] ) && count( $pl_data['vulnerabilities'] ) > 0 ) {
|
||||
|
||||
foreach ($plug_vuln as $slug => $pl_data) {
|
||||
if (isset($pl_data['vulnerabilities']) && count($pl_data['vulnerabilities']) > 0) {
|
||||
$plug_vulner_data = array();
|
||||
foreach ( $pl_data['vulnerabilities'] as $vuln_data ) {
|
||||
if ( isset( $vuln_data['fixed_in'] ) && version_compare( $plugin_version, $vuln_data['fixed_in'] ) >= 0 ) {
|
||||
foreach($pl_data['vulnerabilities'] as $vuln_data) {
|
||||
if ( isset($vuln_data['fixed_in']) && version_compare( $plugin_version, $vuln_data['fixed_in'] ) >= 0 ) {
|
||||
continue;
|
||||
}
|
||||
$plug_vulner_data[] = $vuln_data;
|
||||
}
|
||||
|
||||
if ( 0 == count( $plug_vulner_data ) ) {
|
||||
unset( $plug_vuln_filter[ $slug ] );
|
||||
if(count($plug_vulner_data) == 0) {
|
||||
unset($plug_vuln_filter[$slug]);
|
||||
} else {
|
||||
$plug_vuln_filter[ $slug ]['vulnerabilities'] = $plug_vulner_data;
|
||||
$plug_vuln_filter[ $slug ]['detected_version'] = $plugin_version;
|
||||
$plug_vuln_filter[ $slug ]['plugin_slug'] = $plug;
|
||||
}
|
||||
} else {
|
||||
unset( $plug_vuln_filter[ $slug ] );
|
||||
}
|
||||
$plug_vuln_filter[$slug]['vulnerabilities'] = $plug_vulner_data;
|
||||
$plug_vuln_filter[$slug]['detected_version'] = $plugin_version;
|
||||
$plug_vuln_filter[$slug]['plugin_slug'] = $plug;
|
||||
}
|
||||
|
||||
if ( 0 == count( $plug_vuln_filter ) ) {
|
||||
} else {
|
||||
unset($plug_vuln_filter[$slug]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (count($plug_vuln_filter) == 0) {
|
||||
continue;
|
||||
}
|
||||
$plug_vuln = json_encode( $plug_vuln_filter );
|
||||
$plug_vuln = json_encode($plug_vuln_filter);
|
||||
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
$result[ $plug ] = $plug_vuln;
|
||||
$result[$plug] = $plug_vuln;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function check_wp( $force = false ) {
|
||||
$wp_vuln = get_transient( 'mainwp_vulnche_trans_wp_json' );
|
||||
$wp_version = str_replace( '.', '', get_bloginfo( 'version' ) );
|
||||
if ( false === $wp_vuln || $force ) {
|
||||
$wp_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'wordpresses/' . $wp_version );
|
||||
set_transient( 'mainwp_vulnche_trans_wp_json', $wp_vuln, 1 * DAY_IN_SECONDS );
|
||||
function check_wp($force = false){
|
||||
$wp_vuln = get_transient('mainwp_vulnche_trans_wp_json');
|
||||
$wp_version = str_replace('.', '', get_bloginfo('version'));
|
||||
if(false === $wp_vuln || $force) {
|
||||
$wp_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'wordpresses/' . $wp_version);
|
||||
set_transient('mainwp_vulnche_trans_wp_json', $wp_vuln, 1 * DAY_IN_SECONDS);
|
||||
}
|
||||
return $wp_vuln;
|
||||
}
|
||||
|
||||
public function check_themes( $force = false ) {
|
||||
function check_themes($force = false){
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/misc.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/theme.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/misc.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/theme.php' );
|
||||
|
||||
if ( current_user_can( 'switch_themes' ) ) {
|
||||
$themes = wp_prepare_themes_for_js();
|
||||
|
@ -135,50 +139,56 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
}
|
||||
wp_reset_vars( array( 'theme', 'search' ) );
|
||||
$result = array();
|
||||
if ( ! empty( $themes ) ) {
|
||||
foreach ( $themes as $th ) {
|
||||
if ( empty( $th['parent'] ) ) {
|
||||
$th_vuln = get_transient( 'mainwp_vulnche_trans_theme_' . $th['id'] );
|
||||
if ( false === $th_vuln || $force ) {
|
||||
$th_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'themes/' . $th['id'] );
|
||||
set_transient( 'mainwp_vulnche_trans_theme_' . $th['id'], $th_vuln, 1 * DAY_IN_SECONDS );
|
||||
if(!empty($themes)){
|
||||
foreach($themes as $th){
|
||||
if(empty($th['parent'])) {
|
||||
$th_vuln = get_transient('mainwp_vulnche_trans_theme_' . $th['id']);
|
||||
if (false === $th_vuln || $force) {
|
||||
$th_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'themes/' . $th['id']);
|
||||
set_transient('mainwp_vulnche_trans_theme_' . $th['id'], $th_vuln, 1 * DAY_IN_SECONDS);
|
||||
}
|
||||
|
||||
if ( $th_vuln ) {
|
||||
$th_vuln = json_decode( $th_vuln, true );
|
||||
if ($th_vuln) {
|
||||
$th_vuln = json_decode($th_vuln, true);
|
||||
$th_vuln_filter = $th_vuln;
|
||||
foreach ( $th_vuln as $slug => $th_data ) {
|
||||
if ( isset( $th_data['vulnerabilities'] ) && count( $th_data['vulnerabilities'] ) > 0 ) {
|
||||
foreach ($th_vuln as $slug => $th_data) {
|
||||
if (isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0) {
|
||||
|
||||
$th_vulner_data = array();
|
||||
foreach ( $th_data['vulnerabilities'] as $vuln_data ) {
|
||||
if ( empty( $vuln_data ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( isset( $vuln_data['fixed_in'] ) && version_compare( $th['version'], $vuln_data['fixed_in'] ) >= 0 ) {
|
||||
foreach($th_data['vulnerabilities'] as $vuln_data) {
|
||||
if (empty($vuln_data))
|
||||
continue;
|
||||
|
||||
if ( isset($vuln_data['fixed_in']) && version_compare( $th['version'], $vuln_data['fixed_in'] ) >= 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$th_vulner_data[] = $vuln_data;
|
||||
}
|
||||
if ( 0 == count( $th_vulner_data ) ) {
|
||||
unset( $th_vuln_filter[ $slug ] );
|
||||
|
||||
if(count($th_vulner_data) == 0) {
|
||||
unset($th_vuln_filter[$slug]);
|
||||
} else {
|
||||
$th_vuln_filter[ $slug ]['vulnerabilities'] = $th_vulner_data;
|
||||
$th_vuln_filter[$slug]['vulnerabilities'] = $th_vulner_data;
|
||||
}
|
||||
} else {
|
||||
unset( $th_vuln_filter[ $slug ] );
|
||||
unset($th_vuln_filter[$slug]);
|
||||
}
|
||||
}
|
||||
if ( 0 == count( $th_vuln_filter ) ) {
|
||||
|
||||
if (count($th_vuln_filter) == 0) {
|
||||
continue;
|
||||
}
|
||||
$th_vuln = json_encode( $th_vuln_filter );
|
||||
|
||||
$th_vuln = json_encode($th_vuln_filter);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
$result[ $th['id'] ]['vulner_data'] = $th_vuln;
|
||||
$result[ $th['id'] ]['name'] = $th['name'];
|
||||
$result[ $th['id'] ]['author'] = $th['author'];
|
||||
$result[ $th['id'] ]['detected_version'] = $th['version'];
|
||||
|
||||
$result[$th['id']]['vulner_data'] = $th_vuln;
|
||||
$result[$th['id']]['name'] = $th['name'];
|
||||
$result[$th['id']]['author'] = $th['author'];
|
||||
$result[$th['id']]['detected_version'] = $th['version'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,44 +196,48 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
}
|
||||
|
||||
|
||||
public function vulnche_get_content( $url ) {
|
||||
function vulnche_get_content ( $url ) {
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, $url );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, 0 );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Authorization: Token token=' . $this->wpvulndb_token ) );
|
||||
curl_setopt( $ch, CURLOPT_USERAGENT, $this->get_random_user_agent() );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
|
||||
$output = curl_exec( $ch );
|
||||
$info = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Token token=' . $this->wpvulndb_token));
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $this->get_random_user_agent());
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
||||
|
||||
curl_close( $ch );
|
||||
$output = curl_exec($ch);
|
||||
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
if ( false === $output || 200 != $info ) {
|
||||
curl_close($ch);
|
||||
if ($output === false || $info != 200) {
|
||||
$output = null;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function get_random_user_agent() {
|
||||
$someUA = array(
|
||||
'Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1',
|
||||
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0',
|
||||
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.18 Safari/525.19',
|
||||
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13',
|
||||
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)',
|
||||
'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)',
|
||||
'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322)',
|
||||
'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.0.3705; Media Center PC 3.1; Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
|
||||
'Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)',
|
||||
'Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)',
|
||||
'Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)',
|
||||
|
||||
function get_random_user_agent ( ) {
|
||||
|
||||
$someUA = array (
|
||||
"Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1",
|
||||
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0",
|
||||
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.18 Safari/525.19",
|
||||
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13",
|
||||
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)",
|
||||
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)",
|
||||
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322)",
|
||||
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.0.3705; Media Center PC 3.1; Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
|
||||
"Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)",
|
||||
"Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)",
|
||||
"Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)"
|
||||
);
|
||||
|
||||
srand( (float) microtime() * 1000000 );
|
||||
srand((double)microtime()*1000000);
|
||||
|
||||
return $someUA[ rand( 0, count( $someUA ) - 1 ) ];
|
||||
return $someUA[rand(0,count($someUA)-1)];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,23 +18,25 @@ class MainWP_Child_WooCommerce_Status {
|
|||
public static $instance = null;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_WooCommerce_Status();
|
||||
if ( null === MainWP_Child_WooCommerce_Status::$instance ) {
|
||||
MainWP_Child_WooCommerce_Status::$instance = new MainWP_Child_WooCommerce_Status();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_WooCommerce_Status::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
|
||||
|
||||
}
|
||||
|
||||
public function child_deactivation() {
|
||||
|
||||
}
|
||||
|
||||
public function action() {
|
||||
$information = array();
|
||||
if ( ! class_exists( 'WooCommerce' ) || ! defined('WC_VERSION')) {
|
||||
if ( ! class_exists( 'WooCommerce' ) || !defined('WC_VERSION')) {
|
||||
$information['error'] = 'NO_WOOCOMMERCE';
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
@ -64,7 +66,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
global $wpdb;
|
||||
$file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php';
|
||||
if ( file_exists( $file ) ) {
|
||||
include_once $file;
|
||||
include_once( $file );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -84,12 +86,14 @@ class MainWP_Child_WooCommerce_Status {
|
|||
'completed',
|
||||
'processing',
|
||||
'on-hold',
|
||||
) ) ) . "' )
|
||||
) ) ) . "' )
|
||||
AND postmeta.meta_key = '_order_total'
|
||||
AND posts.post_date >= %s
|
||||
AND posts.post_date <= %s
|
||||
", date( 'Y-m-01', $start_date ), date( 'Y-m-d H:i:s', $end_date ) ) );
|
||||
|
||||
|
||||
|
||||
// Get top seller
|
||||
$top_seller = $wpdb->get_row( $wpdb->prepare( "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
|
||||
FROM {$wpdb->posts} as posts
|
||||
|
@ -106,7 +110,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
'completed',
|
||||
'processing',
|
||||
'on-hold',
|
||||
) ) ) . "' )
|
||||
) ) ) . "' )
|
||||
AND order_item_meta.meta_key = '_qty'
|
||||
AND order_item_meta_2.meta_key = '_product_id'
|
||||
AND posts.post_date >= %s
|
||||
|
@ -180,7 +184,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
global $wpdb;
|
||||
$file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php';
|
||||
if ( file_exists( $file ) ) {
|
||||
include_once $file;
|
||||
include_once( $file );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -205,12 +209,15 @@ class MainWP_Child_WooCommerce_Status {
|
|||
'completed',
|
||||
'processing',
|
||||
'on-hold',
|
||||
) ) ) . "' )
|
||||
) ) ) . "' )
|
||||
AND postmeta.meta_key = '_order_total'
|
||||
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
|
||||
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')
|
||||
" );
|
||||
|
||||
|
||||
|
||||
|
||||
// Get top seller
|
||||
$top_seller = $wpdb->get_row( "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
|
||||
FROM {$wpdb->posts} as posts
|
||||
|
@ -227,7 +234,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
'completed',
|
||||
'processing',
|
||||
'on-hold',
|
||||
) ) ) . "' )
|
||||
) ) ) . "' )
|
||||
AND order_item_meta.meta_key = '_qty'
|
||||
AND order_item_meta_2.meta_key = '_product_id'
|
||||
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
|
||||
|
@ -326,7 +333,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
global $wpdb;
|
||||
$file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php';
|
||||
if ( file_exists( $file ) ) {
|
||||
include_once $file;
|
||||
include_once( $file );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -346,8 +353,8 @@ class MainWP_Child_WooCommerce_Status {
|
|||
'on-hold',
|
||||
) ) ) . "' ) ";
|
||||
$query['where'] .= "AND postmeta.meta_key = '_order_total' ";
|
||||
$query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||
$query['where'] .= 'AND posts.post_date <= STR_TO_DATE(' . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||
$query['where'] .= "AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||
$query['where'] .= "AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||
|
||||
$sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) );
|
||||
|
||||
|
@ -366,14 +373,15 @@ class MainWP_Child_WooCommerce_Status {
|
|||
) ) ) . "' ) ";
|
||||
$query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
|
||||
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
|
||||
$query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||
$query['where'] .= 'AND posts.post_date <= STR_TO_DATE(' . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||
$query['where'] .= "AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||
$query['where'] .= "AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') ";
|
||||
$query['groupby'] = 'GROUP BY product_id';
|
||||
$query['orderby'] = 'ORDER BY qty DESC';
|
||||
$query['limits'] = 'LIMIT 1';
|
||||
|
||||
$top_seller = $wpdb->get_row( implode( ' ', $query ) );
|
||||
|
||||
|
||||
if ( ! empty( $top_seller ) ) {
|
||||
$top_seller->name = get_the_title( $top_seller->product_id );
|
||||
}
|
||||
|
@ -433,7 +441,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
'stock' => $stock,
|
||||
'nostock' => $nostock,
|
||||
'lowstock' => $lowinstock_count,
|
||||
'outstock' => $outofstock_count,
|
||||
'outstock' => $outofstock_count
|
||||
);
|
||||
$information['data'] = $data;
|
||||
$information['need_db_update'] = $this->check_db_update();
|
||||
|
@ -441,7 +449,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
}
|
||||
|
||||
private static function update_wc_db() {
|
||||
include_once WC()->plugin_path() . '/includes/class-wc-background-updater.php';
|
||||
include_once( WC()->plugin_path() . '/includes/class-wc-background-updater.php' );
|
||||
$background_updater = new WC_Background_Updater();
|
||||
|
||||
$current_db_version = get_option( 'woocommerce_db_version' );
|
||||
|
@ -465,7 +473,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
$background_updater->save()->dispatch();
|
||||
}
|
||||
|
||||
return array( 'result' => 'success' );
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -20,11 +20,11 @@ class MainWP_Child_WP_Rocket {
|
|||
public $is_plugin_installed = false;
|
||||
|
||||
public static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_WP_Rocket();
|
||||
if ( null === MainWP_Child_WP_Rocket::$instance ) {
|
||||
MainWP_Child_WP_Rocket::$instance = new MainWP_Child_WP_Rocket();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_WP_Rocket::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
@ -34,9 +34,9 @@ class MainWP_Child_WP_Rocket {
|
|||
}
|
||||
|
||||
public function init() {
|
||||
// if ( get_option( 'mainwp_wprocket_ext_enabled' ) !== 'Y' ) {
|
||||
// return;
|
||||
// }
|
||||
// if ( get_option( 'mainwp_wprocket_ext_enabled' ) !== 'Y' ) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
return;
|
||||
|
@ -99,18 +99,18 @@ class MainWP_Child_WP_Rocket {
|
|||
'deferred_js_files' => array(),
|
||||
'lazyload' => 0,
|
||||
'lazyload_iframes' => 0,
|
||||
'lazyload_youtube' => 0,
|
||||
'lazyload_youtube' =>0,
|
||||
'minify_css' => 0,
|
||||
// 'minify_css_key' => $minify_css_key,
|
||||
// 'minify_css_key' => $minify_css_key,
|
||||
'minify_concatenate_css' => 0,
|
||||
// 'minify_css_combine_all' => 0,
|
||||
//'minify_css_combine_all' => 0,
|
||||
'minify_css_legacy' => 0,
|
||||
'minify_js' => 0,
|
||||
// 'minify_js_key' => $minify_js_key,
|
||||
// 'minify_js_key' => $minify_js_key,
|
||||
'minify_js_in_footer' => array(),
|
||||
'minify_concatenate_js' => 0,
|
||||
'minify_js_combine_all' => 0,
|
||||
// 'minify_js_legacy' => 0,
|
||||
//'minify_js_legacy' => 0,
|
||||
'minify_google_fonts' => 0,
|
||||
'minify_html' => 0,
|
||||
'remove_query_strings' => 0,
|
||||
|
@ -118,13 +118,13 @@ class MainWP_Child_WP_Rocket {
|
|||
'cdn' => 0,
|
||||
'cdn_cnames' => array(),
|
||||
'cdn_zone' => array(),
|
||||
// 'cdn_ssl' => 0,
|
||||
//'cdn_ssl' => 0,
|
||||
'cdn_reject_files' => array(),
|
||||
'do_cloudflare' => 0,
|
||||
'cloudflare_email' => '',
|
||||
'cloudflare_api_key' => '',
|
||||
'cloudflare_domain' => '',
|
||||
// 'cloudflare_zone_id' => '',
|
||||
//'cloudflare_zone_id' => '',
|
||||
'cloudflare_devmode' => 0,
|
||||
'cloudflare_protocol_rewrite' => 0,
|
||||
'cloudflare_auto_settings' => 0,
|
||||
|
@ -137,10 +137,10 @@ class MainWP_Child_WP_Rocket {
|
|||
// ok
|
||||
public function syncOthersData( $information, $data = array() ) {
|
||||
if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) {
|
||||
try {
|
||||
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) );
|
||||
try{
|
||||
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ));
|
||||
$information['syncWPRocketData'] = $data;
|
||||
} catch (Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
}
|
||||
return $information;
|
||||
|
@ -192,7 +192,7 @@ class MainWP_Child_WP_Rocket {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if ( ! MainWP_Helper::is_screen_with_update()) {
|
||||
if (! MainWP_Helper::is_screen_with_update()) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -207,9 +207,9 @@ class MainWP_Child_WP_Rocket {
|
|||
if ( ! $this->is_plugin_installed ) {
|
||||
return false;
|
||||
}
|
||||
// if ( ! defined( 'WP_ROCKET_VERSION' ) || ! defined( 'WP_ROCKET_SLUG' ) ) {
|
||||
// return false;
|
||||
// }
|
||||
// if ( ! defined( 'WP_ROCKET_VERSION' ) || ! defined( 'WP_ROCKET_SLUG' ) ) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -251,8 +251,9 @@ class MainWP_Child_WP_Rocket {
|
|||
|
||||
$information = array();
|
||||
|
||||
|
||||
if ( isset( $_POST['mwp_action'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_wprocket_ext_enabled', 'Y' );
|
||||
// MainWP_Helper::update_option( 'mainwp_wprocket_ext_enabled', 'Y' );
|
||||
try {
|
||||
switch ( $_POST['mwp_action'] ) {
|
||||
case 'set_showhide':
|
||||
|
@ -273,7 +274,7 @@ class MainWP_Child_WP_Rocket {
|
|||
case 'save_settings':
|
||||
$information = $this->save_settings();
|
||||
break;
|
||||
case 'load_existing_settings':
|
||||
case "load_existing_settings":
|
||||
$information = $this->load_existing_settings();
|
||||
break;
|
||||
case 'optimize_database':
|
||||
|
@ -286,7 +287,7 @@ class MainWP_Child_WP_Rocket {
|
|||
$information = $this->do_admin_post_rocket_purge_opcache();
|
||||
break;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
$information = array( 'error' => $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
@ -305,9 +306,9 @@ class MainWP_Child_WP_Rocket {
|
|||
if ( function_exists( 'opcache_reset' ) ) {
|
||||
@opcache_reset();
|
||||
} else {
|
||||
return array( 'error' => 'The host do not support the function reset opcache.' );
|
||||
return array('error' => 'The host do not support the function reset opcache.');
|
||||
}
|
||||
return array( 'result' => 'SUCCESS' );
|
||||
return array('result' => 'SUCCESS');
|
||||
}
|
||||
|
||||
function purge_cloudflare() {
|
||||
|
@ -335,12 +336,12 @@ class MainWP_Child_WP_Rocket {
|
|||
rocket_clean_cache_busting();
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'rocket_dismiss_boxes' ) && defined('WP_ROCKET_ADMIN_PATH')) {
|
||||
if ( !function_exists( 'rocket_dismiss_boxes' ) && defined('WP_ROCKET_ADMIN_PATH')) {
|
||||
require_once WP_ROCKET_ADMIN_PATH . 'admin.php';
|
||||
}
|
||||
|
||||
// to fix
|
||||
include_once ABSPATH . '/wp-admin/includes/template.php';
|
||||
include_once( ABSPATH . '/wp-admin/includes/template.php' );
|
||||
|
||||
// Generate a new random key for minify cache file
|
||||
$options = get_option( WP_ROCKET_SLUG );
|
||||
|
@ -361,7 +362,7 @@ class MainWP_Child_WP_Rocket {
|
|||
MainWP_Helper::check_classes_exists('WP_Rocket\Preload\Full_Process');
|
||||
|
||||
$preload_process = new WP_Rocket\Preload\Full_Process();
|
||||
MainWP_Helper::check_methods($preload_process, array( 'is_process_running' ));
|
||||
MainWP_Helper::check_methods($preload_process, array( 'is_process_running'));
|
||||
|
||||
if ( $preload_process->is_process_running() ) {
|
||||
return array( 'result' => 'RUNNING' );
|
||||
|
@ -374,12 +375,11 @@ class MainWP_Child_WP_Rocket {
|
|||
}
|
||||
|
||||
function generate_critical_css() {
|
||||
MainWP_Helper::check_classes_exists( array(
|
||||
'WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber',
|
||||
MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber',
|
||||
'WP_Rocket\Optimization\CSS\Critical_CSS',
|
||||
'WP_Rocket\Optimization\CSS\Critical_CSS_Generation',
|
||||
'WP_Rocket\Admin\Options',
|
||||
'WP_Rocket\Admin\Options_Data',
|
||||
'WP_Rocket\Admin\Options_Data'
|
||||
));
|
||||
|
||||
$critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() );
|
||||
|
@ -411,9 +411,10 @@ class MainWP_Child_WP_Rocket {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
update_option( WP_ROCKET_SLUG, $options );
|
||||
|
||||
if (isset($_POST['do_database_optimization']) && ! empty($_POST['do_database_optimization'])) {
|
||||
if (isset($_POST['do_database_optimization']) && !empty($_POST['do_database_optimization'])) {
|
||||
$this->optimize_database();
|
||||
}
|
||||
|
||||
|
@ -422,11 +423,10 @@ class MainWP_Child_WP_Rocket {
|
|||
|
||||
function optimize_database() {
|
||||
|
||||
MainWP_Helper::check_classes_exists( array(
|
||||
'WP_Rocket\Admin\Database\Optimization',
|
||||
MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization',
|
||||
'WP_Rocket\Admin\Database\Optimization_Process',
|
||||
'WP_Rocket\Admin\Options',
|
||||
'WP_Rocket\Admin\Options_Data',
|
||||
'WP_Rocket\Admin\Options_Data'
|
||||
));
|
||||
|
||||
$process = new WP_Rocket\Admin\Database\Optimization_Process();
|
||||
|
@ -436,9 +436,9 @@ class MainWP_Child_WP_Rocket {
|
|||
$options_api = new WP_Rocket\Admin\Options( 'wp_rocket_' );
|
||||
$options = new WP_Rocket\Admin\Options_Data( $options_api->get( 'settings', array() ) );
|
||||
|
||||
$items = array_filter( array_keys( $optimization->get_options() ), array( $options, 'get' ) );
|
||||
$items = array_filter( array_keys( $optimization->get_options() ), [ $options, 'get' ] );
|
||||
|
||||
if ( ! empty( $items ) ) {
|
||||
if ( !empty( $items ) ) {
|
||||
$optimization->process_handler( $items );
|
||||
}
|
||||
|
||||
|
@ -448,9 +448,8 @@ class MainWP_Child_WP_Rocket {
|
|||
|
||||
function get_optimize_info() {
|
||||
|
||||
MainWP_Helper::check_classes_exists( array(
|
||||
'WP_Rocket\Admin\Database\Optimization',
|
||||
'WP_Rocket\Admin\Database\Optimization_Process',
|
||||
MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization',
|
||||
'WP_Rocket\Admin\Database\Optimization_Process'
|
||||
));
|
||||
|
||||
$process = new WP_Rocket\Admin\Database\Optimization_Process();
|
||||
|
@ -465,7 +464,7 @@ class MainWP_Child_WP_Rocket {
|
|||
'total_trashed_comments' => $optimization->count_cleanup_items( 'database_trashed_comments' ),
|
||||
'total_expired_transients' => $optimization->count_cleanup_items( 'database_expired_transients' ),
|
||||
'total_all_transients' => $optimization->count_cleanup_items( 'database_all_transients' ),
|
||||
'total_optimize_tables' => $optimization->count_cleanup_items( 'database_optimize_tables' ),
|
||||
'total_optimize_tables' => $optimization->count_cleanup_items( 'database_optimize_tables' )
|
||||
);
|
||||
|
||||
$information['result'] = 'SUCCESS';
|
||||
|
@ -474,10 +473,7 @@ class MainWP_Child_WP_Rocket {
|
|||
|
||||
function load_existing_settings() {
|
||||
$options = get_option( WP_ROCKET_SLUG );
|
||||
return array(
|
||||
'result' => 'SUCCESS',
|
||||
'options' => $options,
|
||||
);
|
||||
return array('result' => 'SUCCESS', 'options' => $options);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,63 +1,74 @@
|
|||
<?php
|
||||
|
||||
class MainWP_Child_WPvivid_BackupRestore {
|
||||
|
||||
class MainWP_Child_WPvivid_BackupRestore
|
||||
{
|
||||
public static $instance = null;
|
||||
public $is_plugin_installed = false;
|
||||
public $public_intetface;
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_WPvivid_BackupRestore();
|
||||
static function Instance()
|
||||
{
|
||||
if ( null === MainWP_Child_WPvivid_BackupRestore::$instance )
|
||||
{
|
||||
MainWP_Child_WPvivid_BackupRestore::$instance = new MainWP_Child_WPvivid_BackupRestore();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Child_WPvivid_BackupRestore::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR') ) {
|
||||
public function __construct()
|
||||
{
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR'))
|
||||
{
|
||||
$this->is_plugin_installed = true;
|
||||
}
|
||||
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
if (!$this->is_plugin_installed)
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||
$this->public_intetface = new WPvivid_Public_Interface();
|
||||
}
|
||||
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function syncOthersData( $information, $data = array() ) {
|
||||
try {
|
||||
function syncOthersData( $information, $data = array() )
|
||||
{
|
||||
try{
|
||||
|
||||
if ( isset( $data['syncWPvividData'] ) ) {
|
||||
$information['syncWPvividData'] = 1;
|
||||
if ( isset( $data['syncWPvividData'] ))
|
||||
{
|
||||
$information['syncWPvividData']=1;
|
||||
$data = WPvivid_Setting::get_sync_data();
|
||||
$information['syncWPvividSettingData'] = $data['setting'];
|
||||
$information['syncWPvividRemoteData'] = $data['remote'];
|
||||
$information['syncWPvividScheduleData'] = $data['schedule'];
|
||||
$information['syncWPvividSettingData']=$data['setting'];
|
||||
$information['syncWPvividRemoteData']=$data['remote'];
|
||||
$information['syncWPvividScheduleData']=$data['schedule'];
|
||||
$information['syncWPvividSetting'] = $data;
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
|
||||
} catch(Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
return $information;
|
||||
}
|
||||
|
||||
public function action() {
|
||||
public function action()
|
||||
{
|
||||
$information = array();
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
if ( ! $this->is_plugin_installed )
|
||||
{
|
||||
$information['error'] = 'NO_WPVIVIDBACKUP';
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['mwp_action'] ) ) {
|
||||
if ( isset( $_POST['mwp_action'] ) )
|
||||
{
|
||||
try {
|
||||
switch ( $_POST['mwp_action'] ) {
|
||||
switch ($_POST['mwp_action']) {
|
||||
case 'prepare_backup':
|
||||
$information = $this->prepare_backup();
|
||||
break;
|
||||
|
@ -122,155 +133,175 @@ class MainWP_Child_WPvivid_BackupRestore {
|
|||
$information = $this->post_mainwp_data($_POST);
|
||||
break;
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
$information = array( 'error' => $e->getMessage() );
|
||||
} catch (Exception $e) {
|
||||
$information = array('error' => $e->getMessage());
|
||||
}
|
||||
|
||||
MainWP_Helper::write($information);
|
||||
}
|
||||
}
|
||||
|
||||
public function post_mainwp_data( $data ) {
|
||||
public function post_mainwp_data($data){
|
||||
global $wpvivid_plugin;
|
||||
|
||||
$ret = $wpvivid_plugin->wpvivid_handle_mainwp_action($data);
|
||||
$ret =$wpvivid_plugin->wpvivid_handle_mainwp_action($data);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function prepare_backup() {
|
||||
public function prepare_backup()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->prepare_backup($_POST['backup']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function backup_now() {
|
||||
public function backup_now()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->backup_now($_POST['task_id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_status() {
|
||||
public function get_status()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->get_status();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_backup_schedule() {
|
||||
public function get_backup_schedule()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->get_backup_schedule();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_backup_list() {
|
||||
public function get_backup_list()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->get_backup_list();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_default_remote() {
|
||||
public function get_default_remote()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->get_default_remote();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete_backup() {
|
||||
public function delete_backup()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->delete_backup($_POST['backup_id'], $_POST['force']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete_backup_array() {
|
||||
public function delete_backup_array()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->delete_backup_array($_POST['backup_id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function set_security_lock() {
|
||||
public function set_security_lock()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->set_security_lock($_POST['backup_id'], $_POST['lock']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function view_log() {
|
||||
public function view_log()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->view_log($_POST['id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function read_last_backup_log() {
|
||||
public function read_last_backup_log()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->read_last_backup_log($_POST['log_file_name']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function view_backup_task_log() {
|
||||
public function view_backup_task_log()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->view_backup_task_log($_POST['id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function backup_cancel() {
|
||||
public function backup_cancel()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->backup_cancel($_POST['task_id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function init_download_page() {
|
||||
public function init_download_page()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->init_download_page($_POST['backup_id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function prepare_download_backup() {
|
||||
public function prepare_download_backup()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->prepare_download_backup($_POST['backup_id'], $_POST['file_name']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_download_task() {
|
||||
public function get_download_task()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->get_download_task($_POST['backup_id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function download_backup() {
|
||||
public function download_backup()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->download_backup($_POST['backup_id'], $_POST['file_name']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function set_general_setting() {
|
||||
public function set_general_setting()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->set_general_setting($_POST['setting']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function set_schedule() {
|
||||
public function set_schedule()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->set_schedule($_POST['schedule']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function set_remote() {
|
||||
public function set_remote()
|
||||
{
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->set_remote($_POST['remote']);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,15 +5,15 @@ class MainWP_Client_Report {
|
|||
public static $instance = null;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Client_Report();
|
||||
if ( null === MainWP_Client_Report::$instance ) {
|
||||
MainWP_Client_Report::$instance = new MainWP_Client_Report();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Client_Report::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
add_filter( 'wp_mainwp_stream_current_agent', array( $this, 'current_agent' ), 10, 1 );
|
||||
add_filter( 'wp_mainwp_stream_current_agent', array($this, 'current_agent' ), 10, 1 );
|
||||
}
|
||||
|
||||
public function init() {
|
||||
|
@ -22,9 +22,8 @@ class MainWP_Client_Report {
|
|||
}
|
||||
|
||||
public function current_agent( $agent ) {
|
||||
if ( isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) ) {
|
||||
if ( isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) )
|
||||
$agent = '';
|
||||
}
|
||||
return $agent;
|
||||
}
|
||||
|
||||
|
@ -35,7 +34,7 @@ class MainWP_Client_Report {
|
|||
if ( ( $firsttime = get_option( 'mainwp_creport_first_time_activated' ) ) !== false ) {
|
||||
$creport_sync_data['firsttime_activated'] = $firsttime;
|
||||
}
|
||||
if ( ! empty( $creport_sync_data ) ) {
|
||||
if ( !empty( $creport_sync_data ) ) {
|
||||
$information['syncClientReportData'] = $creport_sync_data;
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +42,7 @@ class MainWP_Client_Report {
|
|||
}
|
||||
|
||||
public static function do_reports_log( $ext = '' ) {
|
||||
switch ( $ext ) {
|
||||
switch( $ext ) {
|
||||
case 'backupbuddy':
|
||||
MainWP_Child_Back_Up_Buddy::Instance()->do_reports_log( $ext );
|
||||
break;
|
||||
|
@ -66,7 +65,7 @@ class MainWP_Client_Report {
|
|||
|
||||
$information = array();
|
||||
|
||||
if ( ! function_exists( 'wp_mainwp_stream_get_instance' ) ) {
|
||||
if ( !function_exists( 'wp_mainwp_stream_get_instance' ) ) {
|
||||
$information['error'] = __( 'Error: No MainWP Client Reports plugin installed.' );
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
@ -103,9 +102,8 @@ class MainWP_Client_Report {
|
|||
}
|
||||
|
||||
public function is_backup_action( $action ) {
|
||||
if ( in_array( $action, array( 'mainwp_backup', 'backupbuddy_backup', 'backupwordpress_backup', 'backwpup_backup', 'updraftplus_backup', 'wptimecapsule_backup', 'wpvivid_backup' ) ) ) {
|
||||
if ( in_array( $action, array( 'mainwp_backup', 'backupbuddy_backup', 'backupwordpress_backup', 'backwpup_backup', 'updraftplus_backup', 'wptimecapsule_backup', 'wpvivid_backup' ) ) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -132,7 +130,7 @@ class MainWP_Client_Report {
|
|||
'wordfence' => 'wordfence_scan',
|
||||
'backups' => 'backups',
|
||||
'backup' => 'backups',
|
||||
'media' => 'media',
|
||||
'media' => 'media'
|
||||
);
|
||||
|
||||
$context = isset( $mapping_contexts[ $context ] ) ? $mapping_contexts[ $context ] : $context;
|
||||
|
@ -142,35 +140,35 @@ class MainWP_Client_Report {
|
|||
|
||||
public function get_connector_by_compatible_context( $context ) {
|
||||
|
||||
$connector = '';
|
||||
if ( $context == 'plugins' || $context == 'themes' || $context == 'WordPress' ) {
|
||||
$connector = 'installer';
|
||||
} elseif ( $context == 'profiles' ) {
|
||||
$connector = 'users';
|
||||
} elseif ( $context == 'comments' ) { // multi values
|
||||
$connector = 'comments';
|
||||
$connector = "";
|
||||
if ( $context == "plugins" || $context == "themes" || $context == "wordpress" ) {
|
||||
$connector = "installer";
|
||||
} else if ( $context == 'profiles' ) {
|
||||
$connector = "users";
|
||||
} else if ( $context == 'comments' ) { // multi values
|
||||
$connector = "comments";
|
||||
}
|
||||
// else if ( $context == 'sessions' ) {
|
||||
// $connector = "users";
|
||||
// }
|
||||
elseif ( $context == 'settings' ) {
|
||||
$connector = 'settings';
|
||||
} elseif ( $context == 'post' || $context == 'page' ) {
|
||||
$connector = 'posts';
|
||||
} elseif ( $context == 'widgets' ) {
|
||||
$connector = 'widgets';
|
||||
} elseif ( $context == 'menus' ) {
|
||||
$connector = 'menus';
|
||||
} elseif ( $context == 'backups' ) {
|
||||
$connector = 'mainwp_backups';
|
||||
} elseif ( $context == 'sucuri_scan' ) {
|
||||
$connector = 'mainwp_sucuri';
|
||||
} elseif ( $context == 'mainwp_maintenance' ) {
|
||||
$connector = 'mainwp_maintenance';
|
||||
} elseif ( $context == 'wordfence_scan' ) {
|
||||
$connector = 'mainwp_wordfence';
|
||||
} elseif ( $context == 'media' ) {
|
||||
$connector = 'media';
|
||||
// else if ( $context == 'sessions' ) {
|
||||
// $connector = "users";
|
||||
// }
|
||||
else if ( $context == 'settings' ) {
|
||||
$connector = "settings";
|
||||
} else if ( $context == 'post' || $context == 'page') {
|
||||
$connector = "posts";
|
||||
} else if ( $context == 'widgets' ) {
|
||||
$connector = "widgets";
|
||||
} else if ( $context == 'menus' ) {
|
||||
$connector = "menus";
|
||||
} else if ( $context == 'backups' ) {
|
||||
$connector = "mainwp_backups";
|
||||
} else if ( $context == 'sucuri_scan' ) {
|
||||
$connector = "mainwp_sucuri";
|
||||
} else if ( $context == 'mainwp_maintenance' ) {
|
||||
$connector = "mainwp_maintenance";
|
||||
} else if ( $context == 'wordfence_scan' ) {
|
||||
$connector = "mainwp_wordfence";
|
||||
} else if ( $context == 'media' ) {
|
||||
$connector = "media";
|
||||
}
|
||||
|
||||
return $connector;
|
||||
|
@ -183,23 +181,19 @@ class MainWP_Client_Report {
|
|||
'spam' => 'spammed',
|
||||
);
|
||||
|
||||
if ( isset($mapping_actions[ $action ]) ) {
|
||||
if (isset($mapping_actions[ $action ]))
|
||||
return $mapping_actions[ $action ];
|
||||
}
|
||||
|
||||
if ( $context == 'mainwp_maintenance' ) {
|
||||
if ( $action == 'process' ) {
|
||||
if ( $action == 'process')
|
||||
$action = 'maintenance';
|
||||
}
|
||||
} elseif ( $context == 'sucuri_scan' ) {
|
||||
if ( $action == 'checks' ) {
|
||||
} else if ( $context == 'sucuri_scan' ) {
|
||||
if ( $action == 'checks')
|
||||
$action = 'sucuri_scan';
|
||||
}
|
||||
} elseif ( $context == 'wordfence_scan' ) {
|
||||
if ( $action == 'scan' ) {
|
||||
} else if ($context == 'wordfence_scan') {
|
||||
if ( $action == 'scan')
|
||||
$action = 'wordfence_scan';
|
||||
}
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
|
||||
|
@ -225,13 +219,13 @@ class MainWP_Client_Report {
|
|||
if ( ! is_array( $sections ) ) {
|
||||
$sections = array();
|
||||
}
|
||||
// return $sections;
|
||||
//return $sections;
|
||||
|
||||
$other_tokens = isset( $_POST['other_tokens'] ) ? maybe_unserialize( base64_decode( $_POST['other_tokens'] ) ) : array();
|
||||
if ( ! is_array( $other_tokens ) ) {
|
||||
$other_tokens = array();
|
||||
}
|
||||
// return $other_tokens;
|
||||
//return $other_tokens;
|
||||
|
||||
unset( $_POST['sections'] );
|
||||
unset( $_POST['other_tokens'] );
|
||||
|
@ -253,67 +247,66 @@ class MainWP_Client_Report {
|
|||
// to fix bug
|
||||
$exclude_connector_posts = true;
|
||||
if ( isset( $sections['body'] ) && isset( $sections['body']['section_token'] ) && is_array($sections['body']['section_token']) ) {
|
||||
foreach ( $sections['body']['section_token'] as $sec ) {
|
||||
if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) {
|
||||
foreach ($sections['body']['section_token'] as $sec) {
|
||||
if (strpos($sec, "[section.posts") !== false || strpos($sec, "[section.pages") !== false) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $exclude_connector_posts ) {
|
||||
if ($exclude_connector_posts) {
|
||||
if ( isset( $sections['header'] ) && isset( $sections['header']['section_token'] ) && is_array($sections['header']['section_token']) ) {
|
||||
foreach ( $sections['header']['section_token'] as $sec ) {
|
||||
if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) {
|
||||
foreach ($sections['header']['section_token'] as $sec) {
|
||||
if (strpos($sec, "[section.posts") !== false || strpos($sec, "[section.pages") !== false) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $exclude_connector_posts ) {
|
||||
if ($exclude_connector_posts) {
|
||||
if ( isset( $sections['footer'] ) && isset( $sections['footer']['section_token'] ) && is_array($sections['footer']['section_token']) ) {
|
||||
foreach ( $sections['footer']['section_token'] as $sec ) {
|
||||
if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) {
|
||||
foreach ($sections['footer']['section_token'] as $sec) {
|
||||
if (strpos($sec, "[section.posts") !== false || strpos($sec, "[section.pages") !== false) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $exclude_connector_posts ) {
|
||||
if ($exclude_connector_posts) {
|
||||
if ( isset( $other_tokens['body'] ) && is_array( $other_tokens['body'] ) ) {
|
||||
foreach ( $other_tokens['body'] as $sec ) {
|
||||
if ( strpos( $sec, '[post.' ) !== false || strpos($sec, '[page.') !== false ) {
|
||||
if ( strpos( $sec, "[post." ) !== false || strpos($sec, "[page.") !== false) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $exclude_connector_posts ) {
|
||||
if ($exclude_connector_posts) {
|
||||
if ( isset( $other_tokens['header'] ) && is_array($other_tokens['header']) ) {
|
||||
foreach ( $other_tokens['header'] as $sec ) {
|
||||
if ( strpos($sec, '[post.') !== false || strpos($sec, '[page.') !== false ) {
|
||||
foreach ($other_tokens['header'] as $sec) {
|
||||
if (strpos($sec, "[post.") !== false || strpos($sec, "[page.") !== false) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $exclude_connector_posts ) {
|
||||
if ($exclude_connector_posts) {
|
||||
if ( isset( $other_tokens['footer'] ) && is_array($other_tokens['footer']) ) {
|
||||
foreach ( $other_tokens['footer'] as $sec ) {
|
||||
if ( strpos($sec, '[post.') !== false || strpos($sec, '[page.') !== false ) {
|
||||
foreach ($other_tokens['footer'] as $sec) {
|
||||
if (strpos($sec, "[post.") !== false || strpos($sec, "[page.") !== false) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $exclude_connector_posts ) {
|
||||
$args['connector__not_in'] = array( 'posts' );
|
||||
}
|
||||
// end fix /////
|
||||
if ($exclude_connector_posts)
|
||||
$args['connector__not_in'] = array('posts');
|
||||
///// end fix /////
|
||||
|
||||
$args['action__not_in'] = array( 'login' );
|
||||
|
||||
|
@ -333,37 +326,38 @@ class MainWP_Client_Report {
|
|||
|
||||
$args['records_per_page'] = 9999;
|
||||
|
||||
// $records = mainwp_wp_stream_query( $args );
|
||||
// $records = mainwp_wp_stream_query( $args );
|
||||
$records = wp_mainwp_stream_get_instance()->db->query( $args );
|
||||
|
||||
if ( ! is_array( $records ) ) {
|
||||
$records = array();
|
||||
}
|
||||
|
||||
|
||||
// to fix invalid data, or skip records
|
||||
$skip_records = array();
|
||||
|
||||
// to fix for incorrect posts created logging
|
||||
// query created posts from WP posts data to simulate records logging for created posts
|
||||
if ( isset($_POST['direct_posts']) && ! empty($_POST['direct_posts']) ) {
|
||||
if ( isset($_POST['direct_posts']) && !empty($_POST['direct_posts']) ) {
|
||||
$query_string = array(
|
||||
'post_type' => 'post',
|
||||
'date_query' => array(
|
||||
'column' => 'post_date',
|
||||
'after' => $args['date_from'],
|
||||
'before' => $args['date_to'],
|
||||
'before' => $args['date_to']
|
||||
),
|
||||
'post_status' => 'publish',
|
||||
'post_status' => 'publish'
|
||||
);
|
||||
|
||||
$records_created_posts = query_posts( $query_string );
|
||||
|
||||
if ( $records_created_posts ) {
|
||||
if ($records_created_posts) {
|
||||
|
||||
for ( $i = 0; $i < count($records); $i++ ) {
|
||||
$record = $records[ $i ];
|
||||
if ( $record->connector == 'posts' && $record->context == 'post' && $record->action == 'created' ) {
|
||||
if ( ! in_array($record->ID, $skip_records) ) {
|
||||
for( $i = 0; $i < count($records); $i++ ) {
|
||||
$record = $records[$i];
|
||||
if ($record->connector == 'posts' && $record->context == 'post' && $record->action == 'created') {
|
||||
if (!in_array($record->ID, $skip_records)) {
|
||||
$skip_records[] = $record->ID; // so avoid this created logging, will use logging query from posts data
|
||||
}
|
||||
}
|
||||
|
@ -371,16 +365,16 @@ class MainWP_Client_Report {
|
|||
|
||||
$post_authors = array();
|
||||
|
||||
foreach ( $records_created_posts as $_post ) {
|
||||
foreach( $records_created_posts as $_post){
|
||||
$au_id = $_post->post_author;
|
||||
if ( ! isset($post_authors[ $au_id ]) ) {
|
||||
if ( !isset($post_authors[$au_id]) ) {
|
||||
$au = get_user_by( 'id', $au_id );
|
||||
$post_authors[ $au_id ] = $au->display_name;
|
||||
$post_authors[$au_id] = $au->display_name;
|
||||
}
|
||||
$au_name = $post_authors[ $au_id ];
|
||||
$au_name = $post_authors[$au_id];
|
||||
|
||||
// simulate logging created posts record
|
||||
$stdObj = new stdClass();
|
||||
//simulate logging created posts record
|
||||
$stdObj = new stdClass;
|
||||
$stdObj->ID = 0; // simulate ID value
|
||||
$stdObj->connector = 'posts';
|
||||
$stdObj->context = 'post';
|
||||
|
@ -388,12 +382,13 @@ class MainWP_Client_Report {
|
|||
$stdObj->created = $_post->post_date;
|
||||
$stdObj->meta = array(
|
||||
'post_title' => array( $_post->post_title ),
|
||||
'user_meta' => array( $au_name ),
|
||||
'user_meta' => array( $au_name )
|
||||
);
|
||||
|
||||
$records[] = $stdObj;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $other_tokens['header'] ) && is_array( $other_tokens['header'] ) ) {
|
||||
|
@ -448,9 +443,8 @@ class MainWP_Client_Report {
|
|||
$backups_created_time_to_fix = array();
|
||||
foreach ( $tokens as $token ) {
|
||||
|
||||
if ( isset( $token_values[ $token ] ) ) {
|
||||
if ( isset( $token_values[ $token ] ) )
|
||||
continue;
|
||||
}
|
||||
|
||||
$str_tmp = str_replace( array( '[', ']' ), '', $token );
|
||||
$array_tmp = explode( '.', $str_tmp );
|
||||
|
@ -459,7 +453,7 @@ class MainWP_Client_Report {
|
|||
$context = $action = $data = '';
|
||||
if ( 2 === count( $array_tmp ) ) {
|
||||
list( $context, $data ) = $array_tmp;
|
||||
} elseif ( 3 === count( $array_tmp ) ) {
|
||||
} else if ( 3 === count( $array_tmp ) ) {
|
||||
list( $context, $action, $data ) = $array_tmp;
|
||||
}
|
||||
|
||||
|
@ -477,18 +471,19 @@ class MainWP_Client_Report {
|
|||
$context = 'users'; // see class-connector-user.php
|
||||
}
|
||||
}
|
||||
////
|
||||
|
||||
switch ( $data ) {
|
||||
case 'count':
|
||||
|
||||
$count = 0;
|
||||
foreach ( $records as $record ) {
|
||||
|
||||
// check connector
|
||||
if ( $record->connector == 'editor' ) {
|
||||
if ( ! in_array( $context, array( 'plugins', 'themes' ) ) || $action !== 'updated' ) {
|
||||
if ( !in_array( $context, array('plugins', 'themes') ) || $action !== 'updated' )
|
||||
continue;
|
||||
}
|
||||
} elseif ( $connector !== $record->connector ) {
|
||||
} else if ( $connector !== $record->connector ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -498,28 +493,29 @@ class MainWP_Client_Report {
|
|||
if ( ! in_array( $record->context, $comment_contexts ) ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( 'post' === $context && 'created' === $action ) {
|
||||
} else if ( 'post' === $context && 'created' === $action ) {
|
||||
if ( in_array($record->ID, $skip_records) ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $context == 'menus' ) {
|
||||
} else if ( $context == "menus") {
|
||||
// ok, pass, don't check context
|
||||
} elseif ( $record->connector == 'editor' ) {
|
||||
} else if ( $record->connector == 'editor' ) {
|
||||
// ok, pass, checked above
|
||||
} elseif ( $connector == 'media' && $record->connector == 'media' ) {
|
||||
} else if ( $connector == 'media' && $record->connector == 'media' ) {
|
||||
// ok, pass, do not check context
|
||||
} elseif ( $connector == 'widgets' && $record->connector == 'widgets' ) {
|
||||
} else if ( $connector == "widgets" && $record->connector == 'widgets') {
|
||||
// ok, pass, don't check context
|
||||
} elseif ( $context !== strtolower( $record->context ) ) {
|
||||
} else if ( $context !== strtolower( $record->context )) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// custom action value
|
||||
if ( $connector == 'widgets' ) {
|
||||
if ( $action == 'deleted' ) {
|
||||
$action = 'removed'; // action saved in database
|
||||
if ( $connector == "widgets" ) {
|
||||
if ( $action == "deleted" ) {
|
||||
$action = "removed"; // action saved in database
|
||||
}
|
||||
}
|
||||
////
|
||||
|
||||
// check action
|
||||
if ( 'backups' === $context ) {
|
||||
|
@ -545,20 +541,18 @@ class MainWP_Client_Report {
|
|||
if ( 'draft' === $new_status ) { // avoid auto save post
|
||||
continue;
|
||||
}
|
||||
} elseif ( 'updated' === $action && ( 'themes' === $context || 'plugins' === $context ) ) {
|
||||
} else if ( 'updated' === $action && ('themes' === $context || 'plugins' === $context)) {
|
||||
$name = $this->get_stream_meta_data( $record, 'name' );
|
||||
if ( empty($name) ) { // to fix empty value
|
||||
if ( ! in_array($record->ID, $skip_records) ) {
|
||||
if (!in_array($record->ID, $skip_records))
|
||||
$skip_records[] = $record->ID;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
$old_version = $this->get_stream_meta_data( $record, 'old_version' );
|
||||
$version = $this->get_stream_meta_data( $record, 'version' );
|
||||
if ( version_compare($version, $old_version, '<=') ) { // to fix
|
||||
if ( ! in_array($record->ID, $skip_records) ) {
|
||||
if (version_compare($version, $old_version, '<=')) { // to fix
|
||||
if (!in_array($record->ID, $skip_records))
|
||||
$skip_records[] = $record->ID;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -577,6 +571,7 @@ class MainWP_Client_Report {
|
|||
|
||||
function get_section_loop_data( $records, $tokens, $section, $skip_records = array() ) {
|
||||
|
||||
|
||||
$maintenance_details = array(
|
||||
'revisions' => __( 'Delete all post revisions', 'mainwp-child' ),
|
||||
'autodraft' => __( 'Delete all auto draft posts', 'mainwp-child' ),
|
||||
|
@ -586,7 +581,7 @@ class MainWP_Client_Report {
|
|||
'trashcomment' => __( 'Delete trash comments', 'mainwp-child' ),
|
||||
'tags' => __( 'Delete tags with 0 posts associated', 'mainwp-child' ),
|
||||
'categories' => __( 'Delete categories with 0 posts associated', 'mainwp-child' ),
|
||||
'optimize' => __( 'Optimize database tables', 'mainwp-child' ),
|
||||
'optimize' => __( 'Optimize database tables', 'mainwp-child' )
|
||||
);
|
||||
|
||||
$context = $action = '';
|
||||
|
@ -597,7 +592,7 @@ class MainWP_Client_Report {
|
|||
if ( is_array( $array_tmp ) ) {
|
||||
if ( 2 === count( $array_tmp ) ) {
|
||||
list( $str1, $context ) = $array_tmp;
|
||||
} elseif ( 3 === count( $array_tmp ) ) {
|
||||
} else if ( 3 === count( $array_tmp ) ) {
|
||||
list( $str1, $context, $action ) = $array_tmp;
|
||||
}
|
||||
}
|
||||
|
@ -628,45 +623,45 @@ class MainWP_Client_Report {
|
|||
|
||||
// check connector
|
||||
if ( $record->connector == 'editor' ) {
|
||||
if ( ! in_array( $context, array( 'plugins', 'themes' ) ) || $action !== 'updated' ) {
|
||||
if ( !in_array( $context, array('plugins', 'themes') ) || $action !== 'updated' )
|
||||
continue;
|
||||
}
|
||||
} elseif ( $connector !== $record->connector ) {
|
||||
} else if ( $connector !== $record->connector ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check context
|
||||
if ( $context == 'comments' ) { // multi values
|
||||
$comment_contexts = array( 'post', 'page' );
|
||||
if ( $context == "comments" ) { // multi values
|
||||
$comment_contexts = array('post', 'page');
|
||||
if ( ! in_array( $record->context, $comment_contexts ) ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $context == 'menus' ) {
|
||||
} else if ( $context == "menus") {
|
||||
// ok, pass, don't check context
|
||||
} elseif ( $record->connector == 'editor' ) {
|
||||
} else if ( $record->connector == 'editor' ) {
|
||||
// ok, pass, checked above
|
||||
} elseif ( $connector == 'media' && $record->connector == 'media' ) {
|
||||
} else if ( $connector == 'media' && $record->connector == 'media' ) {
|
||||
// ok, pass, do not check context
|
||||
} elseif ( $connector == 'widgets' && $record->connector == 'widgets' ) {
|
||||
} else if ( $connector == "widgets" && $record->connector == 'widgets') {
|
||||
// ok, pass, don't check context
|
||||
//
|
||||
} elseif ( $context !== strtolower( $record->context ) ) {
|
||||
} else if ( $context !== strtolower( $record->context ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// custom action value
|
||||
if ( $connector == 'widgets' ) {
|
||||
if ( $action == 'deleted' ) {
|
||||
$action = 'removed'; // action saved in database
|
||||
if ( $connector == "widgets" ) {
|
||||
if ( $action == "deleted" ) {
|
||||
$action = "removed"; // action saved in database
|
||||
}
|
||||
}
|
||||
////
|
||||
|
||||
// check action
|
||||
if ( $context == 'backups' ) {
|
||||
if ( ! $this->is_backup_action($record->action) ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $action !== $record->action ) {
|
||||
} else if ( $action !== $record->action ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -677,7 +672,7 @@ class MainWP_Client_Report {
|
|||
}
|
||||
}
|
||||
|
||||
// $skip_this_loop = false;
|
||||
//$skip_this_loop = false;
|
||||
$token_values = array();
|
||||
|
||||
foreach ( $tokens as $token ) {
|
||||
|
@ -691,16 +686,16 @@ class MainWP_Client_Report {
|
|||
} else {
|
||||
if ( 1 === count( $array_tmp ) ) {
|
||||
list( $data ) = $array_tmp;
|
||||
} elseif ( 2 === count( $array_tmp ) ) {
|
||||
} else if ( 2 === count( $array_tmp ) ) {
|
||||
list( $str1, $data ) = $array_tmp;
|
||||
} elseif ( 3 === count( $array_tmp ) ) {
|
||||
} else if ( 3 === count( $array_tmp ) ) {
|
||||
list( $str1, $str2, $data ) = $array_tmp;
|
||||
}
|
||||
|
||||
if ( 'version' === $data ) {
|
||||
if ( 'old' === $str2 ) {
|
||||
$data = 'old_version';
|
||||
} elseif ( 'current' === $str2 && 'WordPress' === $str1 ) {
|
||||
} else if ( 'current' === $str2 && 'wordpress' === $str1 ) {
|
||||
$data = 'new_version';
|
||||
}
|
||||
}
|
||||
|
@ -731,10 +726,9 @@ class MainWP_Client_Report {
|
|||
case 'display_name':
|
||||
case 'roles':
|
||||
if ( $data == 'name' ) {
|
||||
if ( $context == 'profiles' ) {
|
||||
if ( $context == 'profiles' )
|
||||
$data = 'display_name';
|
||||
}
|
||||
}
|
||||
$tok_value = $this->get_stream_meta_data( $record, $data );
|
||||
break;
|
||||
case 'title':
|
||||
|
@ -743,14 +737,14 @@ class MainWP_Client_Report {
|
|||
} else {
|
||||
if ( 'page' === $context || 'post' === $context ) {
|
||||
$data = 'post_title';
|
||||
} elseif ( 'menus' === $record->connector ) {
|
||||
} else if ( 'menus' === $record->connector ) {
|
||||
$data = 'name';
|
||||
}
|
||||
$tok_value = $this->get_stream_meta_data( $record, $data );
|
||||
}
|
||||
break;
|
||||
case 'author':
|
||||
if ( $connector == 'comment' ) {
|
||||
if ( $connector == "comment" ) {
|
||||
$data = 'user_name';
|
||||
} else {
|
||||
$data = 'user_meta';
|
||||
|
@ -763,7 +757,7 @@ class MainWP_Client_Report {
|
|||
}
|
||||
|
||||
// to check may compatible with old meta data
|
||||
if ( empty( $value ) ) {
|
||||
if ( empty( $value )) {
|
||||
$value = $this->get_stream_meta_data( $record, 'author_meta' );
|
||||
}
|
||||
|
||||
|
@ -773,7 +767,7 @@ class MainWP_Client_Report {
|
|||
case 'webtrust':
|
||||
if ( 'sucuri_scan' === $context ) {
|
||||
$scan_data = $this->get_stream_meta_data( $record, 'scan_data' );
|
||||
if ( ! empty($scan_data) ) {
|
||||
if (!empty($scan_data)) {
|
||||
$scan_data = maybe_unserialize( base64_decode( $scan_data ) );
|
||||
if ( is_array( $scan_data ) ) {
|
||||
|
||||
|
@ -786,12 +780,13 @@ class MainWP_Client_Report {
|
|||
if ( $malware_exists ) {
|
||||
$status[] = __( 'Site With Warnings', 'mainwp-child' ); }
|
||||
|
||||
if ( $data == 'status' ) {
|
||||
if ($data == 'status') {
|
||||
$tok_value = count( $status ) > 0 ? implode( ', ', $status ) : __( 'Verified Clear', 'mainwp-child' );
|
||||
} elseif ( $data == 'webtrust' ) {
|
||||
} else if ($data == 'webtrust') {
|
||||
$tok_value = $blacklisted ? __( 'Site Blacklisted', 'mainwp-child' ) : __( 'Trusted', 'mainwp-child' );
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$tok_value = $this->get_stream_meta_data( $record, $data );
|
||||
}
|
||||
|
@ -801,31 +796,32 @@ class MainWP_Client_Report {
|
|||
break;
|
||||
case 'details':
|
||||
case 'result':
|
||||
if ( 'mainwp_maintenance' === $context && 'details' == $data ) {
|
||||
|
||||
if ('mainwp_maintenance' === $context && 'details' == $data) {
|
||||
|
||||
$meta_value = $this->get_stream_meta_data( $record, $data );
|
||||
$meta_value = explode(',', $meta_value);
|
||||
$meta_value = explode(",", $meta_value);
|
||||
|
||||
$details = array();
|
||||
|
||||
if ( is_array( $meta_value) ) {
|
||||
foreach ( $meta_value as $mt ) {
|
||||
if ( isset($maintenance_details[ $mt ]) ) {
|
||||
$details[] = $maintenance_details[ $mt ];
|
||||
foreach($meta_value as $mt) {
|
||||
if ( isset($maintenance_details[$mt]) ) {
|
||||
$details[] = $maintenance_details[$mt];
|
||||
}
|
||||
}
|
||||
}
|
||||
$tok_value = implode(', ', $details);
|
||||
$tok_value = implode(", ", $details);
|
||||
|
||||
} elseif ( 'wordfence_scan' === $context || 'mainwp_maintenance' === $context ) {
|
||||
} else if ( 'wordfence_scan' === $context || 'mainwp_maintenance' === $context ) {
|
||||
$meta_value = $this->get_stream_meta_data( $record, $data );
|
||||
// to fix
|
||||
if ( 'wordfence_scan' === $context && $data == 'result' ) {
|
||||
if ('wordfence_scan' === $context && $data == 'result') {
|
||||
// SUM_FINAL:Scan complete. You have xxx new issues to fix. See below.
|
||||
// SUM_FINAL:Scan complete. Congratulations, no new problems found
|
||||
if ( stripos($meta_value, 'Congratulations') ) {
|
||||
if (stripos($meta_value, 'Congratulations')) {
|
||||
$meta_value = 'No issues detected';
|
||||
} elseif ( stripos($meta_value, 'You have') ) {
|
||||
} else if (stripos($meta_value, 'You have')) {
|
||||
$meta_value = 'Issues Detected';
|
||||
} else {
|
||||
$meta_value = '';
|
||||
|
@ -834,7 +830,7 @@ class MainWP_Client_Report {
|
|||
$tok_value = $meta_value;
|
||||
}
|
||||
break;
|
||||
// case 'destination': // for backup tokens
|
||||
//case 'destination': // for backup tokens
|
||||
case 'type':
|
||||
if ( 'backups' === $context ) {
|
||||
$tok_value = $this->get_stream_meta_data( $record, $data );
|
||||
|
@ -850,18 +846,20 @@ class MainWP_Client_Report {
|
|||
$token_values[ $token ] = $tok_value;
|
||||
|
||||
if ( empty( $tok_value ) ) {
|
||||
// $skip_this_loop = true;
|
||||
if ( defined( 'MAINWP_CHILD_DEBUG' ) && MAINWP_CHILD_DEBUG === true ) {
|
||||
error_log('MainWP Child Report:: skip empty value :: token :: ' . $token . ' :: record :: ' . print_r( $record, true ));
|
||||
//$skip_this_loop = true;
|
||||
if ( defined( 'MAINWP_CHILD_DEBUG' ) && MAINWP_CHILD_DEBUG === TRUE ) {
|
||||
error_log("MainWP Child Report:: skip empty value :: token :: " . $token . " :: record :: " . print_r( $record, true ));
|
||||
}
|
||||
// break;
|
||||
//break;
|
||||
}
|
||||
|
||||
} // foreach $tokens
|
||||
|
||||
if ( ! empty( $token_values ) ) {
|
||||
$loops[ $loop_count ] = $token_values;
|
||||
$loop_count ++;
|
||||
}
|
||||
|
||||
} // foreach $records
|
||||
return $loops;
|
||||
}
|
||||
|
@ -887,16 +885,16 @@ class MainWP_Client_Report {
|
|||
// to compatible with old meta data
|
||||
if ( 'author_meta' === $meta_key ) {
|
||||
$value = maybe_unserialize( $value );
|
||||
if ( is_array($value) ) {
|
||||
if (is_array($value)) {
|
||||
$value = $value['display_name'];
|
||||
// to fix empty author value
|
||||
if ( empty($value) ) {
|
||||
if ( isset($value['agent']) && ! empty($value['agent']) ) {
|
||||
if (isset($value['agent']) && !empty($value['agent'])) {
|
||||
$value = $value['agent'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! is_string($value) ) {
|
||||
if (!is_string($value)) {
|
||||
$value = '';
|
||||
}
|
||||
}
|
||||
|
@ -910,7 +908,7 @@ class MainWP_Client_Report {
|
|||
function set_showhide() {
|
||||
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
|
||||
MainWP_Child_Branding::Instance()->save_branding_options('hide_child_reports', $hide);
|
||||
// MainWP_Helper::update_option( 'mainwp_creport_branding_stream_hide', $hide, 'yes' ); // to compatible with old child reports
|
||||
//MainWP_Helper::update_option( 'mainwp_creport_branding_stream_hide', $hide, 'yes' ); // to compatible with old child reports
|
||||
$information['result'] = 'SUCCESS';
|
||||
|
||||
return $information;
|
||||
|
@ -935,7 +933,7 @@ class MainWP_Client_Report {
|
|||
}
|
||||
}
|
||||
|
||||
if ( $hide_nag ) {
|
||||
if ($hide_nag) {
|
||||
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
|
||||
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
|
||||
}
|
||||
|
@ -951,7 +949,7 @@ class MainWP_Client_Report {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if ( ! MainWP_Helper::is_screen_with_update() ) {
|
||||
if (! MainWP_Helper::is_screen_with_update()) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,16 +12,16 @@ class MainWP_Clone_Install {
|
|||
* @param string $file The zip backup file path
|
||||
*/
|
||||
public function __construct( $file ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
||||
|
||||
$this->file = $file;
|
||||
if ( '.zip' === substr( $this->file, - 4 ) ) {
|
||||
$this->archiver = null;
|
||||
} elseif ( '.tar.gz' === substr( $this->file, - 7 ) ) {
|
||||
} else if ( '.tar.gz' === substr( $this->file, - 7 ) ) {
|
||||
$this->archiver = new Tar_Archiver( null, 'tar.gz' );
|
||||
} elseif ( '.tar.bz2' === substr( $this->file, - 8 ) ) {
|
||||
} else if ( '.tar.bz2' === substr( $this->file, - 8 ) ) {
|
||||
$this->archiver = new Tar_Archiver( null, 'tar.bz2' );
|
||||
} elseif ( '.tar' === substr( $this->file, - 4 ) ) {
|
||||
} else if ( '.tar' === substr( $this->file, - 4 ) ) {
|
||||
$this->archiver = new Tar_Archiver( null, 'tar' );
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class MainWP_Clone_Install {
|
|||
* @return bool
|
||||
*/
|
||||
public function checkZipConsole() {
|
||||
// todo: implement
|
||||
//todo: implement
|
||||
// return function_exists('system');
|
||||
return false;
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ class MainWP_Clone_Install {
|
|||
|
||||
if ( null !== $this->archiver ) {
|
||||
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
// todo: implement
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
} else if ( $this->checkZipConsole() ) {
|
||||
//todo: implement
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
$zip = new ZipArchive();
|
||||
$zipRes = $zip->open( $this->file );
|
||||
if ( $zipRes ) {
|
||||
|
@ -73,7 +73,7 @@ class MainWP_Clone_Install {
|
|||
|
||||
return false;
|
||||
} else {
|
||||
// use pclzip
|
||||
//use pclzip
|
||||
$zip = new PclZip( $this->file );
|
||||
$list = $zip->delete( PCLZIP_OPT_BY_NAME, 'wp-config.php' );
|
||||
$list2 = $zip->delete( PCLZIP_OPT_BY_NAME, 'clone' );
|
||||
|
@ -114,9 +114,9 @@ class MainWP_Clone_Install {
|
|||
}
|
||||
|
||||
return $this->archiver->file_exists( $file );
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
// todo: implement
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
} else if ( $this->checkZipConsole() ) {
|
||||
//todo: implement
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
$zip = new ZipArchive();
|
||||
$zipRes = $zip->open( $this->file );
|
||||
if ( $zipRes ) {
|
||||
|
@ -236,7 +236,7 @@ class MainWP_Clone_Install {
|
|||
$readline = '';
|
||||
while ( ( $line = fgets( $handle, 81920 ) ) !== false ) {
|
||||
if ( time() - $lastRun > 20 ) {
|
||||
@set_time_limit( 0 ); // reset timer..
|
||||
@set_time_limit( 0 ); //reset timer..
|
||||
$lastRun = time();
|
||||
}
|
||||
|
||||
|
@ -331,16 +331,16 @@ class MainWP_Clone_Install {
|
|||
}
|
||||
$token = $data[0];
|
||||
switch ( $token ) {
|
||||
case 's':
|
||||
case 's' :
|
||||
if ( '"' !== $data[ $length - 2 ] ) {
|
||||
return false;
|
||||
}
|
||||
case 'a':
|
||||
case 'O':
|
||||
case 'a' :
|
||||
case 'O' :
|
||||
return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
|
||||
case 'b':
|
||||
case 'i':
|
||||
case 'd':
|
||||
case 'b' :
|
||||
case 'i' :
|
||||
case 'd' :
|
||||
return (bool) preg_match( "/^{$token}:[0-9.E-]+;\$/", $data );
|
||||
}
|
||||
|
||||
|
@ -373,8 +373,8 @@ class MainWP_Clone_Install {
|
|||
return $content;
|
||||
} else {
|
||||
if ( $this->checkZipConsole() ) {
|
||||
// todo: implement
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
//todo: implement
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
$zip = new ZipArchive();
|
||||
$zipRes = $zip->open( $this->file );
|
||||
if ( $zipRes ) {
|
||||
|
@ -388,7 +388,7 @@ class MainWP_Clone_Install {
|
|||
|
||||
return false;
|
||||
} else {
|
||||
// use pclzip
|
||||
//use pclzip
|
||||
$zip = new PclZip( $this->file );
|
||||
$content = $zip->extract( PCLZIP_OPT_BY_NAME, 'clone/config.txt',
|
||||
PCLZIP_OPT_EXTRACT_AS_STRING );
|
||||
|
@ -419,13 +419,13 @@ class MainWP_Clone_Install {
|
|||
}
|
||||
|
||||
return $this->archiver->extractTo( ABSPATH );
|
||||
} elseif ( ( filesize( $this->file ) >= 50000000 ) && $this->checkWPZip() ) {
|
||||
} else if ( ( filesize( $this->file ) >= 50000000 ) && $this->checkWPZip() ) {
|
||||
return $this->extractWPZipBackup();
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
} else if ( $this->checkZipConsole() ) {
|
||||
return $this->extractZipConsoleBackup();
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
return $this->extractZipBackup();
|
||||
} elseif ( ( filesize( $this->file ) < 50000000 ) && $this->checkWPZip() ) {
|
||||
} else if ( ( filesize( $this->file ) < 50000000 ) && $this->checkWPZip() ) {
|
||||
return $this->extractWPZipBackup();
|
||||
} else {
|
||||
return $this->extractZipPclBackup();
|
||||
|
@ -484,8 +484,8 @@ class MainWP_Clone_Install {
|
|||
* @return bool
|
||||
*/
|
||||
public function extractZipConsoleBackup() {
|
||||
// todo implement
|
||||
// system('zip');
|
||||
//todo implement
|
||||
//system('zip');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -654,7 +654,7 @@ class MainWP_Clone_Install {
|
|||
// some unseriliased data cannot be re-serialised eg. SimpleXMLElements
|
||||
try {
|
||||
|
||||
if ( is_string( $data ) && is_serialized( $data ) && ! is_serialized_string( $data ) && ( $unserialized = @unserialize( $data ) ) !== false ) {
|
||||
if ( is_string( $data ) && is_serialized( $data ) && !is_serialized_string( $data ) && ( $unserialized = @unserialize( $data ) ) !== false ) {
|
||||
$data = $this->recursive_unserialize_replace( $from, $to, $unserialized, true );
|
||||
} elseif ( is_array( $data ) ) {
|
||||
$_tmp = array();
|
||||
|
@ -675,7 +675,7 @@ class MainWP_Clone_Install {
|
|||
unset( $_tmp );
|
||||
} elseif (is_serialized_string($data) && is_serialized($data)) {
|
||||
// TODO: apply solution like phpmyadmin project have!
|
||||
if ( ( $data = @unserialize( $data ) ) !== false ) {
|
||||
if ( ($data = @unserialize( $data )) !== false ) {
|
||||
$data = str_replace( $from, $to, $data );
|
||||
$data = serialize( $data );
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class MainWP_Clone {
|
|||
}
|
||||
|
||||
if ( ! function_exists( 'wp_create_nonce' ) ) {
|
||||
include_once ABSPATH . WPINC . '/pluggable.php';
|
||||
include_once( ABSPATH . WPINC . '/pluggable.php' );
|
||||
}
|
||||
$this->security_nonces[ $action ] = wp_create_nonce( $action );
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class MainWP_Clone {
|
|||
$ajaxPosts = array();
|
||||
}
|
||||
|
||||
// If already processed, just quit!
|
||||
//If already processed, just quit!
|
||||
if ( isset( $ajaxPosts[ $action ] ) && ( $ajaxPosts[ $action ] == $_POST['dts'] ) ) {
|
||||
die( json_encode( array( 'error' => __( 'Double request!', 'mainwp-child' ) ) ) );
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ class MainWP_Clone {
|
|||
if ( isset( $_REQUEST['upload'] ) && wp_verify_nonce( $_POST['_nonce'], 'cloneRestore' ) ) {
|
||||
if ( isset( $_FILES['file'] ) ) {
|
||||
if ( ! function_exists( 'wp_handle_upload' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
}
|
||||
$uploadedfile = $_FILES['file'];
|
||||
$upload_overrides = array( 'test_form' => false );
|
||||
|
@ -153,17 +153,13 @@ class MainWP_Clone {
|
|||
|
||||
<?php
|
||||
if ( $uploadFile ) {
|
||||
esc_html_e( 'Upload successful.', 'mainwp-child' );
|
||||
?>
|
||||
<a href="#" id="mainwp-child_uploadclonebutton"
|
||||
esc_html_e( 'Upload successful.', 'mainwp-child' ); ?> <a href="#" id="mainwp-child_uploadclonebutton"
|
||||
class="button-primary"
|
||||
file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Clone/Restore website', 'mainwp-child' ); ?></a>
|
||||
<?php
|
||||
file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Clone/Restore website', 'mainwp-child' ); ?></a><?php
|
||||
} else {
|
||||
if ( $uploadError ) {
|
||||
?>
|
||||
<div class="mainwp-child_info-box-red"><?php echo esc_html( $uploadError ); ?></div>
|
||||
<?php
|
||||
<div class="mainwp-child_info-box-red"><?php echo esc_html( $uploadError ); ?></div><?php
|
||||
}
|
||||
|
||||
if ( empty( $sitesToClone ) ) {
|
||||
|
@ -254,7 +250,7 @@ class MainWP_Clone {
|
|||
if ( isset( $_REQUEST['upload'] ) && wp_verify_nonce( $_POST['_nonce'], 'cloneRestore' ) ) {
|
||||
if ( isset( $_FILES['file'] ) ) {
|
||||
if ( ! function_exists( 'wp_handle_upload' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
}
|
||||
$uploadedfile = $_FILES['file'];
|
||||
$upload_overrides = array( 'test_form' => false );
|
||||
|
@ -291,13 +287,10 @@ class MainWP_Clone {
|
|||
</div>
|
||||
<?php
|
||||
if ( $uploadFile ) {
|
||||
esc_html_e( 'Upload successful.', 'mainwp-child' );
|
||||
?>
|
||||
<a href="#"
|
||||
esc_html_e( 'Upload successful.', 'mainwp-child' ); ?> <a href="#"
|
||||
id="mainwp-child_uploadclonebutton"
|
||||
class="button-primary"
|
||||
file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?></a>
|
||||
<?php
|
||||
file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?></a><?php
|
||||
} else {
|
||||
if ( $uploadError ) {
|
||||
?>
|
||||
|
@ -314,7 +307,7 @@ class MainWP_Clone {
|
|||
$branding_msg = esc_html__( 'If you have a FULL backup created by basic MainWP Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.', 'mainwp-child' );
|
||||
}
|
||||
?>
|
||||
<em> <?php echo $branding_msg; ?> <br/>
|
||||
<em> <?php echo $branding_msg ; ?> <br/>
|
||||
<?php esc_html_e( 'A database only backup will not work.', 'mainwp-child' ); ?></em><br/><br/>
|
||||
<form action="<?php echo esc_attr( admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone&upload=yes' ) ); ?>"
|
||||
method="post"
|
||||
|
@ -455,7 +448,7 @@ class MainWP_Clone {
|
|||
<div class="clonesite_select_site_item">
|
||||
<div class="mainwp-child_name_label">
|
||||
<a href="<?php echo esc_url( add_query_arg( array( 'dir' => rawurlencode( $parent ) ), $url ) ); ?>"
|
||||
title="<?php echo esc_attr( dirname( $current_dir ) ); ?>"><?php esc_html_e( 'Parent Folder', 'mainwp-child' ); ?></a>
|
||||
title="<?php echo esc_attr( dirname( $current_dir ) ) ?>"><?php esc_html_e( 'Parent Folder', 'mainwp-child' ) ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -466,7 +459,7 @@ class MainWP_Clone {
|
|||
?>
|
||||
<div class="clonesite_select_site_item">
|
||||
<div class="mainwp-child_name_label">
|
||||
<a href="<?php echo esc_attr( $folder_url ); ?>"><?php echo esc_html( rtrim( $filename, '/' ) . DIRECTORY_SEPARATOR ); ?></a>
|
||||
<a href="<?php echo esc_attr( $folder_url ) ?>"><?php echo esc_html( rtrim( $filename, '/' ) . DIRECTORY_SEPARATOR ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -476,7 +469,7 @@ class MainWP_Clone {
|
|||
?>
|
||||
<div class="clonesite_select_site_item">
|
||||
<div class="mainwp-child_name_label">
|
||||
<span><?php echo esc_html( $file ); ?></span>
|
||||
<span><?php echo esc_html( $file ) ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -486,7 +479,7 @@ class MainWP_Clone {
|
|||
?>
|
||||
<div class="mainwp_rejected_files">
|
||||
<div class="mainwp-child_name_label">
|
||||
<span><?php echo esc_html( $file ); ?></span>
|
||||
<span><?php echo esc_html( $file ) ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -517,9 +510,10 @@ class MainWP_Clone {
|
|||
<script language="javascript">
|
||||
var child_security_nonces = [];
|
||||
<?php
|
||||
$security_nonces = self::get()->getSecurityNonces();
|
||||
foreach ($security_nonces as $k => $v) {
|
||||
echo 'child_security_nonces[' . "'" . $k . "'" . '] = ' . "'" . $v . "';\n";
|
||||
$security_nonces = MainWP_Clone::get()->getSecurityNonces();
|
||||
foreach ($security_nonces as $k => $v)
|
||||
{
|
||||
echo 'child_security_nonces['."'" .$k . "'". '] = ' . "'" . $v . "';\n";
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -591,8 +585,8 @@ class MainWP_Clone {
|
|||
var translations = [];
|
||||
translations['large_site'] = "<?php esc_html_e( 'This is a large site (%dMB), the restore process will more than likely fail.', 'mainwp-child' ); ?>";
|
||||
translations['continue_anyway'] = "<?php esc_html_e( 'Continue Anyway?', 'mainwp-child' ); ?>";
|
||||
translations['creating_backup'] = "<?php esc_html_e( 'Creating backup on %1$s expected size: %2$dMB (estimated time: %3$d seconds)', 'mainwp-child' ); ?>";
|
||||
translations['backup_created'] = "<?php esc_html_e( 'Backup created on %1$s total size to download: %2$dMB', 'mainwp-child' ); ?>";
|
||||
translations['creating_backup'] = "<?php esc_html_e( 'Creating backup on %s expected size: %dMB (estimated time: %d seconds)', 'mainwp-child' ); ?>";
|
||||
translations['backup_created'] = "<?php esc_html_e( 'Backup created on %s total size to download: %dMB', 'mainwp-child' ); ?>";
|
||||
translations['downloading_backup'] = "<?php esc_html_e( 'Downloading backup', 'mainwp-child' ); ?>";
|
||||
translations['backup_downloaded'] = "<?php esc_html_e( 'Backup downloaded', 'mainwp-child' ); ?>";
|
||||
translations['extracting_backup'] = "<?php esc_html_e( 'Extracting backup and updating your database, this might take a while. Please be patient.', 'mainwp-child' ); ?>";
|
||||
|
@ -1205,7 +1199,7 @@ class MainWP_Clone {
|
|||
$key = $siteToClone['extauth'];
|
||||
|
||||
MainWP_Helper::endSession();
|
||||
// Send request to the childsite!
|
||||
//Send request to the childsite!
|
||||
global $wp_version;
|
||||
$method = ( function_exists( 'gzopen' ) ? 'tar.gz' : 'zip' );
|
||||
$result = MainWP_Helper::fetchUrl( $url, array(
|
||||
|
@ -1214,7 +1208,7 @@ class MainWP_Clone {
|
|||
'f' => $rand,
|
||||
'wpversion' => $wp_version,
|
||||
'zipmethod' => $method,
|
||||
'json_result' => true,
|
||||
'json_result' => true
|
||||
) );
|
||||
|
||||
if ( ! $result['backup'] ) {
|
||||
|
@ -1225,10 +1219,7 @@ class MainWP_Clone {
|
|||
MainWP_Helper::update_option( 'mainwp_temp_clone_plugins', $result['plugins'] );
|
||||
MainWP_Helper::update_option( 'mainwp_temp_clone_themes', $result['themes'] );
|
||||
|
||||
$output = array(
|
||||
'url' => $result['backup'],
|
||||
'size' => round( $result['size'] / 1024, 0 ),
|
||||
);
|
||||
$output = array( 'url' => $result['backup'], 'size' => round( $result['size'] / 1024, 0 ) );
|
||||
} catch ( Exception $e ) {
|
||||
$output = array( 'error' => $e->getMessage() );
|
||||
}
|
||||
|
@ -1257,12 +1248,12 @@ class MainWP_Clone {
|
|||
$key = $siteToClone['extauth'];
|
||||
|
||||
MainWP_Helper::endSession();
|
||||
// Send request to the childsite!
|
||||
//Send request to the childsite!
|
||||
$result = MainWP_Helper::fetchUrl( $url, array(
|
||||
'cloneFunc' => 'createCloneBackupPoll',
|
||||
'key' => $key,
|
||||
'f' => $rand,
|
||||
'json_result' => true,
|
||||
'json_result' => true
|
||||
) );
|
||||
|
||||
if ( ! isset( $result['size'] ) ) {
|
||||
|
@ -1273,7 +1264,7 @@ class MainWP_Clone {
|
|||
} catch ( Exception $e ) {
|
||||
$output = array( 'error' => $e->getMessage() );
|
||||
}
|
||||
// Return size in kb
|
||||
//Return size in kb
|
||||
die( json_encode( $output ) );
|
||||
}
|
||||
|
||||
|
@ -1304,7 +1295,7 @@ class MainWP_Clone {
|
|||
$url = $file;
|
||||
}
|
||||
MainWP_Helper::endSession();
|
||||
// Send request to the childsite!
|
||||
//Send request to the childsite!
|
||||
$split = explode( '=', $file );
|
||||
$file = urldecode( $split[ count( $split ) - 1 ] );
|
||||
$filename = 'download-' . basename( $file );
|
||||
|
@ -1322,11 +1313,7 @@ class MainWP_Clone {
|
|||
|
||||
$filename = $backupdir . $filename;
|
||||
|
||||
$response = wp_remote_get( $url, array(
|
||||
'timeout' => 300000,
|
||||
'stream' => true,
|
||||
'filename' => $filename,
|
||||
) );
|
||||
$response = wp_remote_get( $url, array( 'timeout' => 300000, 'stream' => true, 'filename' => $filename ) );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
unlink( $filename );
|
||||
|
@ -1342,7 +1329,7 @@ class MainWP_Clone {
|
|||
|
||||
$output = array( 'done' => $filename );
|
||||
|
||||
// Delete backup on child
|
||||
//Delete backup on child
|
||||
try {
|
||||
if ( isset( $_POST['siteId'] ) ) {
|
||||
$siteId = $_POST['siteId'];
|
||||
|
@ -1354,7 +1341,7 @@ class MainWP_Clone {
|
|||
'cloneFunc' => 'deleteCloneBackup',
|
||||
'key' => $siteToClone['extauth'],
|
||||
'f' => $_POST['file'],
|
||||
'json_result' => true,
|
||||
'json_result' => true
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
@ -1392,7 +1379,7 @@ class MainWP_Clone {
|
|||
} catch ( Exception $e ) {
|
||||
$output = array( 'error' => $e->getMessage() );
|
||||
}
|
||||
// return size in kb
|
||||
//return size in kb
|
||||
die( json_encode( $output ) );
|
||||
}
|
||||
|
||||
|
@ -1420,7 +1407,7 @@ class MainWP_Clone {
|
|||
throw new Exception( __( 'No download file found', 'mainwp-child' ) );
|
||||
}
|
||||
$file = $archiveFile;
|
||||
} elseif ( file_exists( $file ) ) {
|
||||
} else if ( file_exists( $file ) ) {
|
||||
$testFull = true;
|
||||
} else {
|
||||
$file = ABSPATH . $file;
|
||||
|
@ -1429,10 +1416,10 @@ class MainWP_Clone {
|
|||
}
|
||||
$testFull = true;
|
||||
}
|
||||
// return size in kb
|
||||
//return size in kb
|
||||
$cloneInstall = new MainWP_Clone_Install( $file );
|
||||
|
||||
// todo: RS: refactor to get those plugins after install (after .18 release)
|
||||
//todo: RS: refactor to get those plugins after install (after .18 release)
|
||||
$cloneInstall->readConfigurationFile();
|
||||
|
||||
$plugins = get_option( 'mainwp_temp_clone_plugins' );
|
||||
|
@ -1533,14 +1520,14 @@ class MainWP_Clone {
|
|||
delete_option( 'mainwp_temp_clone_themes' );
|
||||
}
|
||||
$output = array( 'result' => 'ok' );
|
||||
// todo: remove old tables if other prefix?
|
||||
//todo: remove old tables if other prefix?
|
||||
|
||||
wp_logout();
|
||||
wp_set_current_user( 0 );
|
||||
} catch ( Exception $e ) {
|
||||
$output = array( 'error' => $e->getMessage() );
|
||||
}
|
||||
// return size in kb
|
||||
//return size in kb
|
||||
die( json_encode( $output ) );
|
||||
}
|
||||
|
||||
|
@ -1571,15 +1558,11 @@ class MainWP_Clone {
|
|||
clear: both;
|
||||
}
|
||||
</style>
|
||||
<div class="mainwp-child_info-box-green">
|
||||
<?php
|
||||
if ( get_option( 'mainwp_child_restore_permalink' ) ) {
|
||||
<div class="mainwp-child_info-box-green"><?php if ( get_option( 'mainwp_child_restore_permalink' ) ) {
|
||||
esc_html_e( 'Restore process completed successfully! Check and re-save permalinks ', 'mainwp-child' );
|
||||
} else {
|
||||
} else {
|
||||
esc_html_e( 'Cloning process completed successfully! Check and re-save permalinks ', 'mainwp-child' );
|
||||
}
|
||||
?>
|
||||
<a
|
||||
} ?> <a
|
||||
href="<?php echo esc_attr( admin_url( 'options-permalink.php' ) ); ?>"><?php esc_html_e( 'here', 'mainwp-child' ); ?></a>.
|
||||
</div>
|
||||
<?php
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
class MainWP_Custom_Post_Type {
|
||||
public static $instance = null;
|
||||
public static $information = array();
|
||||
public $plugin_translate = 'mainwp-child';
|
||||
public $plugin_translate = "mainwp-child";
|
||||
|
||||
static function Instance() {
|
||||
if ( self::$instance == null ) {
|
||||
self::$instance = new MainWP_Custom_Post_Type();
|
||||
if ( MainWP_Custom_Post_Type::$instance == null ) {
|
||||
MainWP_Custom_Post_Type::$instance = new MainWP_Custom_Post_Type();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Custom_Post_Type::$instance;
|
||||
}
|
||||
|
||||
public function action() {
|
||||
|
@ -20,10 +20,10 @@ class MainWP_Custom_Post_Type {
|
|||
$error = error_get_last();
|
||||
if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) {
|
||||
$data = array( 'error' => 'MainWPChild fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] );
|
||||
// die( '<mainwp>' . base64_encode( serialize( ) ) . '</mainwp>' );
|
||||
// die( '<mainwp>' . base64_encode( serialize( ) ) . '</mainwp>' );
|
||||
} else {
|
||||
$data = self::$information;
|
||||
// die( '<mainwp>' . base64_encode( serialize( MainWP_Custom_Post_Type::$information ) ) . '</mainwp>' );
|
||||
$data = MainWP_Custom_Post_Type::$information;
|
||||
// die( '<mainwp>' . base64_encode( serialize( MainWP_Custom_Post_Type::$information ) ) . '</mainwp>' );
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] ) {
|
||||
|
@ -35,7 +35,7 @@ class MainWP_Custom_Post_Type {
|
|||
die('<mainwp>' . base64_encode( $data ) . '</mainwp>');
|
||||
}
|
||||
|
||||
register_shutdown_function( 'mainwp_custom_post_type_handle_fatal_error' );
|
||||
register_shutdown_function( "mainwp_custom_post_type_handle_fatal_error" );
|
||||
|
||||
$information = array();
|
||||
switch ( $_POST['action'] ) {
|
||||
|
@ -48,7 +48,7 @@ class MainWP_Custom_Post_Type {
|
|||
|
||||
}
|
||||
|
||||
self::$information = $information;
|
||||
MainWP_Custom_Post_Type::$information = $information;
|
||||
|
||||
exit();
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class MainWP_Custom_Post_Type {
|
|||
if ( empty( $data ) || ! is_array( $data ) || ! isset( $data['post'] ) ) {
|
||||
return array( 'error' => __( 'Cannot decode data', $this->plugin_translate ) );
|
||||
}
|
||||
$edit_id = ( isset($_POST['post_id']) && ! empty($_POST['post_id']) ) ? $_POST['post_id'] : 0;
|
||||
$edit_id = (isset($_POST['post_id']) && !empty($_POST['post_id'])) ? $_POST['post_id'] : 0;
|
||||
$return = $this->_insert_post($data, $edit_id, $parent_id = 0);
|
||||
if (isset($return['success']) && $return['success'] == 1) {
|
||||
if (isset($data['product_variation']) && is_array($data['product_variation'])) {
|
||||
|
@ -104,7 +104,7 @@ class MainWP_Custom_Post_Type {
|
|||
}
|
||||
|
||||
try {
|
||||
$downloadfile = MainWP_Helper::uploadImage( $originalImgUrl, array(), $check_image );
|
||||
$downloadfile = MainWP_Helper::uploadImage( $originalImgUrl , array(), $check_image );
|
||||
$localUrl = $downloadfile['url'];
|
||||
$linkToReplaceWith = dirname( $localUrl );
|
||||
if ( '' !== $hrefLink ) {
|
||||
|
@ -114,7 +114,7 @@ class MainWP_Custom_Post_Type {
|
|||
$serverHref = 'href="' . $serverHost;
|
||||
$replaceServerHref = 'href="' . parse_url( $localUrl, PHP_URL_SCHEME ) . '://' . parse_url( $localUrl, PHP_URL_HOST );
|
||||
$post_content = str_replace( $serverHref, $replaceServerHref, $post_content );
|
||||
} elseif ( strpos( $hrefLink, 'http' ) !== false ) {
|
||||
} else if ( strpos( $hrefLink, 'http' ) !== false ) {
|
||||
$lnkToReplace = dirname( $hrefLink );
|
||||
if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
|
||||
$post_content = str_replace( $lnkToReplace, $linkToReplaceWith, $post_content );
|
||||
|
@ -159,7 +159,7 @@ class MainWP_Custom_Post_Type {
|
|||
'post_modified_gmt',
|
||||
'post_content_filtered',
|
||||
'menu_order',
|
||||
'post_type',
|
||||
'post_type'
|
||||
);
|
||||
|
||||
foreach ( $data_keys as $key ) {
|
||||
|
@ -174,23 +174,23 @@ class MainWP_Custom_Post_Type {
|
|||
return array( 'error' => __( 'Please install', $this->plugin_translate ) . ' ' . $data_insert['post_type'] . ' ' . __( 'on child and try again', $this->plugin_translate ) );
|
||||
}
|
||||
|
||||
// $data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'] );
|
||||
//$data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'] );
|
||||
|
||||
$is_woocomerce = false;
|
||||
if ( ( $data_insert['post_type'] == 'product' || $data_insert['post_type'] == 'product_variation' ) && function_exists( 'wc_product_has_unique_sku' ) ) {
|
||||
if ( ($data_insert['post_type'] == 'product' || $data_insert['post_type'] == 'product_variation' )&& function_exists( 'wc_product_has_unique_sku' ) ) {
|
||||
$is_woocomerce = true;
|
||||
}
|
||||
|
||||
$check_image_existed = false;
|
||||
|
||||
// Support post_edit
|
||||
if ( ! empty( $edit_id ) ) {
|
||||
if ( !empty( $edit_id ) ) {
|
||||
$old_post_id = (int) $edit_id;
|
||||
$old_post = get_post( $old_post_id, ARRAY_A );
|
||||
if ( is_null( $old_post ) ) {
|
||||
return array(
|
||||
'delete_connection' => 1,
|
||||
'error' => __( 'Cannot get old post. Probably is deleted now. Please try again for create new post', $this->plugin_translate ),
|
||||
'error' => __( 'Cannot get old post. Probably is deleted now. Please try again for create new post', $this->plugin_translate )
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ class MainWP_Custom_Post_Type {
|
|||
|
||||
$data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'], $check_image_existed );
|
||||
|
||||
if ( ! empty($parent_id)) {
|
||||
if (!empty($parent_id)) {
|
||||
$data_insert['post_parent'] = $parent_id; // for product variation
|
||||
}
|
||||
$post_id = wp_insert_post( $data_insert, true );
|
||||
|
@ -286,7 +286,7 @@ class MainWP_Custom_Post_Type {
|
|||
// MainWP Categories
|
||||
if ( ! empty( $data['categories'] ) && is_array( $data['categories'] ) ) {
|
||||
// Contains wp_create_categories
|
||||
include_once ABSPATH . 'wp-admin/includes/taxonomy.php';
|
||||
include_once( ABSPATH . 'wp-admin/includes/taxonomy.php' );
|
||||
$categories = $data['categories'];
|
||||
if ( $data['post_only_existing'] == '0' ) {
|
||||
$post_category = wp_create_categories( $categories, $post_id );
|
||||
|
@ -303,7 +303,7 @@ class MainWP_Custom_Post_Type {
|
|||
}
|
||||
}
|
||||
|
||||
// Insert post terms except categories
|
||||
//Insert post terms except categories
|
||||
if ( ! empty( $data['terms'] ) && is_array( $data['terms'] ) ) {
|
||||
foreach ( $data['terms'] as $key ) {
|
||||
if ( ! taxonomy_exists( $key['taxonomy'] ) ) {
|
||||
|
@ -313,7 +313,7 @@ class MainWP_Custom_Post_Type {
|
|||
// @todo missing alias_of which means term_group
|
||||
$term = wp_insert_term( $key['name'], $key['taxonomy'], array(
|
||||
'description' => $key['description'],
|
||||
'slug' => $key['slug'],
|
||||
'slug' => $key['slug']
|
||||
) );
|
||||
|
||||
$term_taxonomy_id = 0;
|
||||
|
@ -337,9 +337,6 @@ class MainWP_Custom_Post_Type {
|
|||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'post_id' => $post_id,
|
||||
);
|
||||
return array( 'success' => 1, 'post_id' => $post_id );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ class MainWP_Debug {
|
|||
/**
|
||||
* @param $mainwpChild MainWP_Child
|
||||
*/
|
||||
public static function process( &$mainwpChild) {
|
||||
public static function process(&$mainwpChild) {
|
||||
if ( ! isset( $_GET['mainwpdebug'] ) || ! defined( 'MAINWP_DEBUG' ) || ( MAINWP_DEBUG !== true ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class MainWP_Debug {
|
|||
$start = microtime( true );
|
||||
|
||||
if ( 'fullbackup' == $_GET['mainwpdebug'] ) {
|
||||
// Full backup
|
||||
//Full backup
|
||||
$_POST['type'] = 'full';
|
||||
$_POST['excludebackup'] = '1';
|
||||
$_POST['excludecache'] = '1';
|
||||
|
@ -21,12 +21,13 @@ class MainWP_Debug {
|
|||
$_POST['excludenonwp'] = '1';
|
||||
$_POST['ext'] = 'tar.gz';
|
||||
print_r( $mainwpChild->backup( false ) );
|
||||
} elseif ( 'test' == $_GET['mainwpdebug'] ) {
|
||||
} else if ( 'test' == $_GET['mainwpdebug'] ) {
|
||||
print_r( get_included_files() );
|
||||
} else {
|
||||
print_r( $mainwpChild->getSiteStats( array(), false ) );
|
||||
}
|
||||
|
||||
|
||||
$stop = microtime( true );
|
||||
die( "\n\n\n" . 'duration: ' . ( $stop - $start ) . 's</pre>' );
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -13,11 +13,11 @@ class MainWP_Keyword_Links {
|
|||
protected $link_case_sensitive = 1;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Keyword_Links();
|
||||
if ( null === MainWP_Keyword_Links::$instance ) {
|
||||
MainWP_Keyword_Links::$instance = new MainWP_Keyword_Links();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Keyword_Links::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
@ -31,14 +31,14 @@ class MainWP_Keyword_Links {
|
|||
if ( empty( $this->keyword_links ) ) {
|
||||
$this->keyword_links = array();
|
||||
}
|
||||
// print_r($this->keyword_links);
|
||||
//print_r($this->keyword_links);
|
||||
$this->siteurl = get_option( 'home' );
|
||||
add_action( 'permalink_structure_changed', array( &$this, 'permalinkChanged' ), 10, 2 );
|
||||
}
|
||||
|
||||
|
||||
public function keywordLinksJS() {
|
||||
if ( ! is_admin() && get_option( 'mainwp_kwl_enable_statistic' ) && ! empty($this->keyword_links) ) {
|
||||
if ( ! is_admin() && get_option( 'mainwp_kwl_enable_statistic' ) && !empty($this->keyword_links) ) {
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'keywordLinks', plugins_url( '/js/keywordlinks.js', dirname( __FILE__ ) ) );
|
||||
add_action( 'wp_head', array( $this, 'head_loading' ), 1 );
|
||||
|
@ -79,7 +79,7 @@ class MainWP_Keyword_Links {
|
|||
$rules .= "RewriteEngine On\n";
|
||||
$rules .= "RewriteBase $home_root\n";
|
||||
|
||||
// add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
|
||||
//add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
|
||||
foreach ( $pRules as $match => $query ) {
|
||||
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
|
||||
$match = str_replace( '.+?', '.+', $match );
|
||||
|
@ -95,13 +95,13 @@ class MainWP_Keyword_Links {
|
|||
function update_htaccess( $force_update = false, $force_clear = false ) {
|
||||
if ( $force_clear ) {
|
||||
$this->do_update_htaccess( true );
|
||||
} elseif ( $force_update ) {
|
||||
} else if ( $force_update ) {
|
||||
return $this->do_update_htaccess();
|
||||
} else {
|
||||
if ( '' == get_option( 'permalink_structure' ) && 'yes' !== get_option( 'mainwp_keyword_links_htaccess_set' ) ) {
|
||||
$this->do_update_htaccess();
|
||||
} // need to update
|
||||
elseif ( '' != get_option( 'permalink_structure' ) && 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) {
|
||||
else if ( '' != get_option( 'permalink_structure' ) && 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) {
|
||||
$this->do_update_htaccess();
|
||||
} // need to update
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class MainWP_Keyword_Links {
|
|||
}
|
||||
|
||||
public static function clear_htaccess() {
|
||||
include_once ABSPATH . '/wp-admin/includes/misc.php';
|
||||
include_once( ABSPATH . '/wp-admin/includes/misc.php' );
|
||||
$home_path = ABSPATH;
|
||||
$htaccess_file = $home_path . '.htaccess';
|
||||
if ( function_exists( 'save_mod_rewrite_rules' ) ) {
|
||||
|
@ -125,15 +125,15 @@ class MainWP_Keyword_Links {
|
|||
self::clear_htaccess();
|
||||
|
||||
return true;
|
||||
} elseif ( '' === get_option( 'permalink_structure' ) ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/misc.php';
|
||||
} else if ( '' === get_option( 'permalink_structure' ) ) {
|
||||
include_once( ABSPATH . '/wp-admin/includes/misc.php' );
|
||||
$redirection_folder = $this->get_option( 'redirection_folder', '' );
|
||||
if ( empty( $redirection_folder ) ) {
|
||||
$rules = $this->get_cloak_rules();
|
||||
$rules = $this->mod_rewrite_rules( $rules );
|
||||
// self::clear_htaccess();
|
||||
//self::clear_htaccess();
|
||||
} else {
|
||||
// Create rewrite ruler
|
||||
//Create rewrite ruler
|
||||
$rules = $this->mod_rewrite_rules( array( $redirection_folder . '/' => 'index.php' ) );
|
||||
}
|
||||
$home_path = ABSPATH;
|
||||
|
@ -297,7 +297,7 @@ class MainWP_Keyword_Links {
|
|||
if ( is_array( $specific_link ) && count( $specific_link ) > 0 ) {
|
||||
$specific_link = current( $specific_link );
|
||||
$specific_link->post_id = $post->ID;
|
||||
// update_post_meta($post->ID, '_mainwp_kwl_specific_link_save', array($specific_link->id => $specific_link));
|
||||
//update_post_meta($post->ID, '_mainwp_kwl_specific_link_save', array($specific_link->id => $specific_link));
|
||||
update_post_meta( $post->ID, '_mainwp_kwl_specific_link_id', $specific_link->id );
|
||||
if ( $this->set_link( $specific_link->id, $specific_link ) ) {
|
||||
update_post_meta( $post->ID, '_mainwp_kwl_specific_link', '<saved>' );
|
||||
|
@ -313,7 +313,7 @@ class MainWP_Keyword_Links {
|
|||
|
||||
// print_r($this->keyword_links);
|
||||
// if ($post->ID == 751) {
|
||||
// print_r($links);
|
||||
// //print_r($links);
|
||||
// $custom = get_post_custom($post->ID);
|
||||
// print_r($custom);
|
||||
// }
|
||||
|
@ -343,10 +343,10 @@ class MainWP_Keyword_Links {
|
|||
$this->link_exact_match = $link->exact_match;
|
||||
$this->link_case_sensitive = $link->case_sensitive;
|
||||
$keywords = $this->explode_multi( $link->keyword );
|
||||
// usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
|
||||
usort( $keywords, array( $this, 'usort_callback_func' ) );
|
||||
//usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
|
||||
usort( $keywords, array($this, 'usort_callback_func') );
|
||||
$replace_cs = $link->case_sensitive ? 's' : 'is';
|
||||
// print_r($keywords);
|
||||
//print_r($keywords);
|
||||
foreach ( $keywords as $keyword ) {
|
||||
$keyword = trim( $keyword );
|
||||
if ( empty( $keyword ) ) {
|
||||
|
@ -361,15 +361,15 @@ class MainWP_Keyword_Links {
|
|||
$keyword = preg_replace( '/([$^\/?+.*\]\[)(}{])/is', '\\\\\1', $keyword );
|
||||
|
||||
if ( ( $link->case_sensitive && strpos( $content, $keyword ) !== false ) || ( ! $link->case_sensitive && stripos( $content, $keyword ) !== false ) ) {
|
||||
// Replace keyword in H tag
|
||||
//Replace keyword in H tag
|
||||
if ( $this->get_option( 'replace_keyword_in_h_tag' ) ) {
|
||||
// $content = preg_replace_callback('/(<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content);
|
||||
//$content = preg_replace_callback('/(<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content);
|
||||
$content = preg_replace_callback( '/(<a[^>]*>[^<]*?' . $keyword . '[^<]*?<\/a>|<[^>]*' . $keyword . '[^>]*>|\{[^\}]*' . $keyword . '[^\}]*\}|\w*(' . $keyword . ')\w*)/' . $replace_cs, array(
|
||||
&$this,
|
||||
'keyword_mark',
|
||||
), $content );
|
||||
} else {
|
||||
// $content = preg_replace_callback('/(<h[123456][^>]*>.*?'.$keyword.'.*?<\/h[123456]>|<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content);
|
||||
//$content = preg_replace_callback('/(<h[123456][^>]*>.*?'.$keyword.'.*?<\/h[123456]>|<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content);
|
||||
$content = preg_replace_callback( '/(<h[123456][^>]*>[^<]*?' . $keyword . '[^<]*?<\/h[123456]>|<a[^>]*>[^<]*?' . $keyword . '[^<]*?<\/a>|<[^>]*' . $keyword . '[^>]*>|\{[^\}]*' . $keyword . '[^\}]*\}|\w*(' . $keyword . ')\w*)/' . $replace_cs, array(
|
||||
&$this,
|
||||
'keyword_mark',
|
||||
|
@ -378,7 +378,7 @@ class MainWP_Keyword_Links {
|
|||
}
|
||||
}
|
||||
}
|
||||
// $content = preg_replace_callback('/\{MAINWP_LINK +HREF="(.*?)" +TARGET="(.*?)" +REL="(.*?)" +LINK-ID="(.*?)" +CLASS="(.*?)" +TEXT="(.*?)" *\}/is', array(&$this, 'keyword_replace'), $content);
|
||||
//$content = preg_replace_callback('/\{MAINWP_LINK +HREF="(.*?)" +TARGET="(.*?)" +REL="(.*?)" +LINK-ID="(.*?)" +CLASS="(.*?)" +TEXT="(.*?)" *\}/is', array(&$this, 'keyword_replace'), $content);
|
||||
$content = preg_replace_callback( '/\{MAINWP_LINK +HREF="(.*?)" +TARGET="(.*?)" +REL="(.*?)" +LINK-ID="(.*?)" +CLASS="(.*?)" +TEXT="(.*?)" +FULL_TEXT="(.*?)" *\}/is', array(
|
||||
&$this,
|
||||
'keyword_replace',
|
||||
|
@ -387,8 +387,8 @@ class MainWP_Keyword_Links {
|
|||
return $content;
|
||||
}
|
||||
|
||||
private function usort_callback_func( $a, $b) {
|
||||
return strlen($a) < strlen($b);
|
||||
private function usort_callback_func($a, $b) {
|
||||
return strlen($a)<strlen($b);
|
||||
}
|
||||
|
||||
public function keyword_mark( $matches ) {
|
||||
|
@ -416,12 +416,12 @@ class MainWP_Keyword_Links {
|
|||
}
|
||||
|
||||
// if (isset($this->link_temp->type) && $this->link_temp->type == 'post_type') {
|
||||
// $post = get_post($this->link_temp->id);
|
||||
// if ($post) {
|
||||
// $disable_linking = $this->get_option('disable_linking_automatically', array());
|
||||
// if (in_array($post->post_name, $disable_linking[$post->post_type]))
|
||||
// return $matches[1]; // do not link to this post
|
||||
// }
|
||||
//// $post = get_post($this->link_temp->id);
|
||||
//// if ($post) {
|
||||
//// $disable_linking = $this->get_option('disable_linking_automatically', array());
|
||||
//// if (in_array($post->post_name, $disable_linking[$post->post_type]))
|
||||
//// return $matches[1]; // do not link to this post
|
||||
//// }
|
||||
// $link_target = get_post_meta($this->link_temp->id, '_mainwp_kl_link_newtab', true);
|
||||
// $this->link_temp->link_target = ( $link_target != -1 && $link_target == 1 ? '_blank' : '' );
|
||||
// $link_rel = get_post_meta($this->link_temp->id, '_mainwp_kl_link_nofollow', true);
|
||||
|
@ -456,7 +456,7 @@ class MainWP_Keyword_Links {
|
|||
$class .= ' kwl-regular-link';
|
||||
}
|
||||
|
||||
// return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . (isset($this->link_temp->id) ? $this->link_temp->id : 0) . '" CLASS="' . $class . '" TEXT="' . $matches[1] . '"}';
|
||||
//return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . (isset($this->link_temp->id) ? $this->link_temp->id : 0) . '" CLASS="' . $class . '" TEXT="' . $matches[1] . '"}';
|
||||
return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url ) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . ( isset( $this->link_temp->id ) ? $this->link_temp->id : 0 ) . '" CLASS="' . $class . '" TEXT="' . $matches[2] . '" FULL_TEXT="' . $matches[1] . '"}';
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ class MainWP_Keyword_Links {
|
|||
}
|
||||
$links = array();
|
||||
// $disable_add_links = $this->get_option('disable_add_links_automatically');
|
||||
// if disabled add links automatically in this post, avoid
|
||||
// // if disabled add links automatically in this post, avoid
|
||||
// if (in_array($post->post_name, (array) $disable_add_links[$post->post_type])) {
|
||||
// return $links;
|
||||
// }
|
||||
|
@ -514,7 +514,7 @@ class MainWP_Keyword_Links {
|
|||
} else {
|
||||
$links_post_type = (array) $this->get_post_keywords( $post_type );
|
||||
}
|
||||
// print_r($links_post_type);
|
||||
//print_r($links_post_type);
|
||||
if ( count( $links_post_type ) > 0 ) {
|
||||
$links = array_merge( $links, $links_post_type );
|
||||
}
|
||||
|
@ -534,7 +534,7 @@ class MainWP_Keyword_Links {
|
|||
} else {
|
||||
$links[] = $link;
|
||||
}
|
||||
} elseif ( $spec_link_id && $spec_link_id === $link->id ) { // type 2 is specific link
|
||||
} else if ( $spec_link_id && $spec_link_id === $link->id ) { // type 2 is specific link
|
||||
if ( $link->check_post_date ) {
|
||||
if ( $post_timestamp < $link->check_post_date ) {
|
||||
$links[] = $link;
|
||||
|
@ -557,7 +557,7 @@ class MainWP_Keyword_Links {
|
|||
$join = "JOIN $wpdb->term_relationships tr ON tr.object_id = p.ID";
|
||||
$where = " AND (tr.term_taxonomy_id = '" . implode( "' OR tr.term_taxonomy_id = '", $cats ) . "')";
|
||||
}
|
||||
// $results = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->posts as p LEFT JOIN $wpdb->postmeta as pm ON p.ID=pm.post_id $join WHERE p.post_status='publish' AND p.post_type='%s' AND pm.meta_key='_mainwp_kl_post_keyword' $where", $post_type));
|
||||
//$results = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->posts as p LEFT JOIN $wpdb->postmeta as pm ON p.ID=pm.post_id $join WHERE p.post_status='publish' AND p.post_type='%s' AND pm.meta_key='_mainwp_kl_post_keyword' $where", $post_type));
|
||||
$results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts as p $join WHERE p.post_status='publish' AND p.post_type= %s $where", $post_type ) );
|
||||
$links = array();
|
||||
if ( ! is_array( $results ) ) {
|
||||
|
@ -571,13 +571,13 @@ class MainWP_Keyword_Links {
|
|||
if ( in_array( $result->post_name, (array) $paths_blocked ) ) {
|
||||
continue;
|
||||
}
|
||||
$link = new stdClass();
|
||||
$link = new stdClass;
|
||||
// This is on-fly link so have not ID
|
||||
// $link->id = $result->ID;
|
||||
//$link->id = $result->ID;
|
||||
$link->name = $result->post_title;
|
||||
// if ($result->post_type == 'page')
|
||||
//if ($result->post_type == 'page')
|
||||
// $link->destination_url = get_permalink($result->ID);
|
||||
// else
|
||||
//else
|
||||
// $link->destination_url = $result->guid;
|
||||
$link->destination_url = get_permalink( $result->ID );
|
||||
$link->cloak_path = '';
|
||||
|
@ -616,7 +616,7 @@ class MainWP_Keyword_Links {
|
|||
if ( ! preg_match( '|^[a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]+$|i', $request ) ) {
|
||||
return;
|
||||
}
|
||||
// Check to see if WordPress is installed in sub folder
|
||||
// Check to see if Wordpress is installed in sub folder
|
||||
$siteurl = parse_url( $this->siteurl );
|
||||
$sitepath = ( isset( $siteurl['path'] ) ) ? $siteurl['path'] : '';
|
||||
$filter_request = preg_replace( '|^' . $sitepath . '/?|i', '', $request );
|
||||
|
@ -625,7 +625,7 @@ class MainWP_Keyword_Links {
|
|||
$redirection_folder = $this->get_option( 'redirection_folder', '' );
|
||||
|
||||
if ( ! empty( $redirection_folder ) ) {
|
||||
// if the request doesn't' containt the redirection folder we will return immediately
|
||||
//if the request doesn't' containt the redirection folder we will return immediately
|
||||
if ( strpos( $filter_request, $redirection_folder . '/' ) === false ) {
|
||||
return;
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ class MainWP_Keyword_Links {
|
|||
// $stat_data = get_option('mainwp_kwl_statistic_data_' . $link_id, array());
|
||||
// if ($stat_data) {
|
||||
// $return['stat_data'] = $stat_data;
|
||||
// $wpdb->query("UPDATE {$wpdb->prefix}options SET option_name = 'mainwp_kwl_statistic_data_done_" . $link_id . "' WHERE option_name = 'mainwp_kwl_statistic_data_" . $link_id . "'");
|
||||
// //$wpdb->query("UPDATE {$wpdb->prefix}options SET option_name = 'mainwp_kwl_statistic_data_done_" . $link_id . "' WHERE option_name = 'mainwp_kwl_statistic_data_" . $link_id . "'");
|
||||
// update_option('mainwp_kwl_statistic_data_' . $link_id, '');
|
||||
// } else
|
||||
// $return['stat_data'] = 'EMPTY';
|
||||
|
@ -741,7 +741,7 @@ class MainWP_Keyword_Links {
|
|||
if ( $remove_settings ) {
|
||||
$this->clear_settings();
|
||||
$return['status'] = 'SUCCESS';
|
||||
} elseif ( is_array( $remove_kws ) && is_array( $this->keyword_links ) ) {
|
||||
} else if ( is_array( $remove_kws ) && is_array( $this->keyword_links ) ) {
|
||||
$new_keyword_links = array();
|
||||
foreach ( $this->keyword_links as $link_id => $link ) {
|
||||
$lnk_kws = $link->keyword;
|
||||
|
@ -853,7 +853,7 @@ class MainWP_Keyword_Links {
|
|||
if ( 3 === (int) $clear_link->type ) {
|
||||
$clear_link->type = 2;
|
||||
$cleared = $this->set_link( $clear_link->id, $clear_link );
|
||||
} elseif ( 1 === (int) $clear_link->type ) {
|
||||
} else if ( 1 === (int) $clear_link->type ) {
|
||||
$cleared = $this->set_link( $clear_link->id, '' ); // delete link
|
||||
}
|
||||
$this->update_htaccess_for_change_cloak_links( $clear_link );
|
||||
|
@ -885,7 +885,7 @@ class MainWP_Keyword_Links {
|
|||
}
|
||||
|
||||
$old = $this->get_link( $link_id );
|
||||
$link = new stdClass();
|
||||
$link = new stdClass;
|
||||
$link->id = intval( $link_id );
|
||||
$link->name = sanitize_text_field( $_POST['name'] );
|
||||
$link->destination_url = esc_url( $_POST['destination_url'] );
|
||||
|
@ -901,7 +901,7 @@ class MainWP_Keyword_Links {
|
|||
if ( 2 === (int) $link->type || 3 === (int) $link->type ) {
|
||||
if ( intval( $_POST['post_id'] ) ) {
|
||||
$link->post_id = intval( $_POST['post_id'] );
|
||||
} elseif ( $old && $old->post_id ) {
|
||||
} else if ( $old && $old->post_id ) {
|
||||
$link->post_id = $old->post_id;
|
||||
}
|
||||
if ( $link->post_id ) {
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
class MainWP_Security {
|
||||
public static function fixAll() {
|
||||
self::remove_wp_version();
|
||||
self::remove_rsd();
|
||||
self::remove_wlw();
|
||||
MainWP_Security::remove_wp_version();
|
||||
MainWP_Security::remove_rsd();
|
||||
MainWP_Security::remove_wlw();
|
||||
// MainWP_Security::remove_core_update();
|
||||
// MainWP_Security::remove_plugin_update();
|
||||
// MainWP_Security::remove_theme_update();
|
||||
self::remove_php_reporting();
|
||||
self::remove_registered_versions();
|
||||
self::remove_generator_version();
|
||||
self::remove_readme();
|
||||
MainWP_Security::remove_php_reporting();
|
||||
MainWP_Security::remove_registered_versions();
|
||||
MainWP_Security::remove_generator_version();
|
||||
MainWP_Security::remove_readme();
|
||||
|
||||
add_filter( 'style_loader_src', array( 'MainWP_Security', 'remove_script_versions' ), PHP_INT_MAX );
|
||||
add_filter( 'style_loader_src', array( 'MainWP_Security', 'remove_theme_versions' ), PHP_INT_MAX );
|
||||
|
@ -19,13 +19,13 @@ class MainWP_Security {
|
|||
add_filter( 'script_loader_src', array( 'MainWP_Security', 'remove_theme_versions' ), PHP_INT_MAX );
|
||||
}
|
||||
|
||||
// Prevent listing wp-content, wp-content/plugins, wp-content/themes, wp-content/uploads
|
||||
//Prevent listing wp-content, wp-content/plugins, wp-content/themes, wp-content/uploads
|
||||
private static $listingDirectories = null;
|
||||
|
||||
private static function init_listingDirectories() {
|
||||
if ( null === self::$listingDirectories ) {
|
||||
if ( null === MainWP_Security::$listingDirectories ) {
|
||||
$wp_upload_dir = wp_upload_dir();
|
||||
self::$listingDirectories = array(
|
||||
MainWP_Security::$listingDirectories = array(
|
||||
WP_CONTENT_DIR,
|
||||
WP_PLUGIN_DIR,
|
||||
get_theme_root(),
|
||||
|
@ -35,8 +35,8 @@ class MainWP_Security {
|
|||
}
|
||||
|
||||
public static function prevent_listing_ok() {
|
||||
self::init_listingDirectories();
|
||||
foreach ( self::$listingDirectories as $directory ) {
|
||||
MainWP_Security::init_listingDirectories();
|
||||
foreach ( MainWP_Security::$listingDirectories as $directory ) {
|
||||
$file = $directory . DIRECTORY_SEPARATOR . 'index.php';
|
||||
if ( ! file_exists( $file ) ) {
|
||||
return false;
|
||||
|
@ -47,8 +47,8 @@ class MainWP_Security {
|
|||
}
|
||||
|
||||
public static function prevent_listing() {
|
||||
self::init_listingDirectories();
|
||||
foreach ( self::$listingDirectories as $directory ) {
|
||||
MainWP_Security::init_listingDirectories();
|
||||
foreach ( MainWP_Security::$listingDirectories as $directory ) {
|
||||
$file = $directory . DIRECTORY_SEPARATOR . 'index.php';
|
||||
if ( ! file_exists( $file ) ) {
|
||||
$h = fopen( $file, 'w' );
|
||||
|
@ -66,7 +66,7 @@ class MainWP_Security {
|
|||
return ! empty( $security ) && isset( $security[ $option ] ) && ( true === $security[ $option ] );
|
||||
}
|
||||
|
||||
// Removed wp-version
|
||||
//Removed wp-version
|
||||
public static function remove_wp_version_ok() {
|
||||
return ! ( has_action( 'wp_head', 'wp_generator' ) || has_filter( 'wp_head', 'wp_generator' ) );
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class MainWP_Security {
|
|||
}
|
||||
}
|
||||
|
||||
// Removed Really Simple Discovery meta tag
|
||||
//Removed Really Simple Discovery meta tag
|
||||
public static function remove_rsd_ok() {
|
||||
return ( ! has_action( 'wp_head', 'rsd_link' ) );
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class MainWP_Security {
|
|||
}
|
||||
}
|
||||
|
||||
// Removed Windows Live Writer meta tag
|
||||
//Removed Windows Live Writer meta tag
|
||||
public static function remove_wlw_ok() {
|
||||
return ( ! has_action( 'wp_head', 'wlwmanifest_link' ) );
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class MainWP_Security {
|
|||
}
|
||||
}
|
||||
|
||||
// Removed core update information for non-admins
|
||||
//Removed core update information for non-admins
|
||||
// public static function remove_core_update_ok()
|
||||
// {
|
||||
// return self::get_security_option('core_updates');
|
||||
|
@ -125,7 +125,7 @@ class MainWP_Security {
|
|||
// }
|
||||
// }
|
||||
|
||||
// Removed plugin-update information for non-admins
|
||||
//Removed plugin-update information for non-admins
|
||||
// public static function remove_plugin_update_ok()
|
||||
// {
|
||||
// return self:get_security_option('plugin_updates');
|
||||
|
@ -153,7 +153,7 @@ class MainWP_Security {
|
|||
// }
|
||||
// }
|
||||
|
||||
// Removed theme-update information for non-admins
|
||||
//Removed theme-update information for non-admins
|
||||
// public static function remove_theme_update_ok()
|
||||
// {
|
||||
// return self::get_security_option('theme_updates');
|
||||
|
@ -175,12 +175,12 @@ class MainWP_Security {
|
|||
// }
|
||||
// }
|
||||
|
||||
// File permissions not secure
|
||||
//File permissions not secure
|
||||
private static $permission_checks = null;
|
||||
|
||||
private static function init_permission_checks() {
|
||||
if ( null === self::$permission_checks ) {
|
||||
self::$permission_checks = array(
|
||||
if ( null === MainWP_Security::$permission_checks ) {
|
||||
MainWP_Security::$permission_checks = array(
|
||||
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../' => '0755',
|
||||
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../wp-includes' => '0755',
|
||||
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../.htaccess' => '0644',
|
||||
|
@ -225,7 +225,7 @@ class MainWP_Security {
|
|||
// return $success;
|
||||
// }
|
||||
|
||||
// Database error reporting turned on/off
|
||||
//Database error reporting turned on/off
|
||||
public static function remove_database_reporting_ok() {
|
||||
global $wpdb;
|
||||
|
||||
|
@ -239,7 +239,7 @@ class MainWP_Security {
|
|||
$wpdb->suppress_errors();
|
||||
}
|
||||
|
||||
// PHP error reporting turned on/off
|
||||
//PHP error reporting turned on/off
|
||||
public static function remove_php_reporting_ok() {
|
||||
return ! ( ( ( 0 != ini_get( 'display_errors' ) ) && ( 'off' != ini_get( 'display_errors' ) ) ) || ( ( 0 != ini_get( 'display_startup_errors' ) ) && ( 'off' != ini_get( 'display_startup_errors' ) ) ) );
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ class MainWP_Security {
|
|||
}
|
||||
}
|
||||
|
||||
// Removed version information for scripts/stylesheets
|
||||
//Removed version information for scripts/stylesheets
|
||||
public static function remove_scripts_version_ok() {
|
||||
return self::get_security_option( 'scripts_version' );
|
||||
}
|
||||
|
@ -320,9 +320,8 @@ class MainWP_Security {
|
|||
public static function remove_readme( $force = false ) {
|
||||
|
||||
// to prevent remove readme.html file on WPE hosts
|
||||
if ( MainWP_Helper::is_wp_engine() ) {
|
||||
if ( MainWP_Helper::is_wp_engine() )
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( $force || self::get_security_option( 'readme' ) ) {
|
||||
if ( @file_exists( ABSPATH . 'readme.html' ) ) {
|
||||
|
@ -349,12 +348,10 @@ class MainWP_Security {
|
|||
return self::get_security_option( 'styles_version' );
|
||||
}
|
||||
|
||||
// Admin user name is not admin
|
||||
//Admin user name is not admin
|
||||
public static function admin_user_ok() {
|
||||
$user = get_user_by( 'login', 'admin' );
|
||||
if ( ! $user ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! $user ) return true;
|
||||
|
||||
if ( 10 !== $user->wp_user_level && ( ! isset( $user->user_level ) || 10 !== $user->user_level ) && ! user_can( $user, 'level_10' ) ) {
|
||||
return true;
|
||||
|
@ -365,9 +362,8 @@ class MainWP_Security {
|
|||
|
||||
public static function update_security_option( $key, $value ) {
|
||||
$security = get_option( 'mainwp_security' );
|
||||
if ( ! empty($key) ) {
|
||||
$security[ $key ] = $value;
|
||||
}
|
||||
if ( !empty($key) )
|
||||
$security[$key] = $value;
|
||||
MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ class MainWP_Wordpress_SEO {
|
|||
public static $instance = null;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Wordpress_SEO();
|
||||
if ( null === MainWP_Wordpress_SEO::$instance ) {
|
||||
MainWP_Wordpress_SEO::$instance = new MainWP_Wordpress_SEO();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
return MainWP_Wordpress_SEO::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
@ -57,9 +57,14 @@ class MainWP_Wordpress_SEO {
|
|||
if ( isset($_POST['file_url']) ) {
|
||||
$file_url = base64_decode( $_POST['file_url'] );
|
||||
$temporary_file = '';
|
||||
|
||||
global $mainWPChild;
|
||||
|
||||
try {
|
||||
include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
|
||||
include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
|
||||
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||
$temporary_file = download_url( $file_url );
|
||||
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||
|
||||
if ( is_wp_error( $temporary_file ) ) {
|
||||
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
|
||||
|
@ -78,7 +83,7 @@ class MainWP_Wordpress_SEO {
|
|||
unlink( $temporary_file );
|
||||
}
|
||||
|
||||
} elseif ( isset( $_POST['settings'] ) ) {
|
||||
} else if ( isset( $_POST['settings'] ) ) {
|
||||
try {
|
||||
$settings = base64_decode( $_POST['settings'] );
|
||||
// @codingStandardsIgnoreLine
|
||||
|
@ -175,10 +180,12 @@ class MainWP_Wordpress_SEO {
|
|||
$rank = new WPSEO_Rank( WPSEO_Rank::NO_INDEX );
|
||||
$title = __( 'Post is set to noindex.', 'wordpress-seo' );
|
||||
WPSEO_Meta::set_value( 'linkdex', 0, $post_id );
|
||||
} elseif ( '' === WPSEO_Meta::get_value( 'focuskw', $post_id ) ) {
|
||||
}
|
||||
elseif ( '' === WPSEO_Meta::get_value( 'focuskw', $post_id ) ) {
|
||||
$rank = new WPSEO_Rank( WPSEO_Rank::NO_FOCUS );
|
||||
$title = __( 'Focus keyword not set.', 'wordpress-seo' );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$score = (int) WPSEO_Meta::get_value( 'linkdex', $post_id );
|
||||
$rank = WPSEO_Rank::from_numeric_score( $score );
|
||||
$title = $rank->get_label();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
// todo: BZ2; support fseek!
|
||||
//todo: BZ2; support fseek!
|
||||
|
||||
class Tar_Archiver {
|
||||
const IDLE = 0;
|
||||
|
@ -16,16 +16,16 @@ class Tar_Archiver {
|
|||
|
||||
protected $debug;
|
||||
|
||||
protected $chunk = ''; // 1024 * 1024 * 4
|
||||
protected $chunkSize = 4194304; // 1024 * 1024 * 4
|
||||
protected $chunk = ''; //1024 * 1024 * 4
|
||||
protected $chunkSize = 4194304; //1024 * 1024 * 4
|
||||
|
||||
/** @var $backup MainWP_Backup */
|
||||
protected $backup;
|
||||
|
||||
protected $type;
|
||||
protected $pidFile; // filepath of pid file
|
||||
protected $pidContent; // content of pid file
|
||||
protected $pidUpdated; // last updated pid file
|
||||
protected $pidFile; //filepath of pid file
|
||||
protected $pidContent; //content of pid file
|
||||
protected $pidUpdated; //last updated pid file
|
||||
|
||||
protected $mode = self::IDLE;
|
||||
|
||||
|
@ -127,7 +127,7 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
public function createFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp, $append = false ) {
|
||||
// $this->logHandle = fopen($filepath . ".log", "a+");
|
||||
//$this->logHandle = fopen($filepath . ".log", "a+");
|
||||
$this->createPidFile( $filepath );
|
||||
|
||||
$this->excludeZip = $excludezip;
|
||||
|
@ -139,7 +139,7 @@ class Tar_Archiver {
|
|||
// $this->limit = true;
|
||||
// }
|
||||
|
||||
if ( $append && @file_exists( $filepath ) ) { // todo: use wpFS
|
||||
if ( $append && @file_exists( $filepath ) ) { //todo: use wpFS
|
||||
$this->mode = self::APPEND;
|
||||
$this->prepareAppend( $filepath );
|
||||
} else {
|
||||
|
@ -176,7 +176,7 @@ class Tar_Archiver {
|
|||
foreach ( $nodes as $key => $node ) {
|
||||
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
} else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else {
|
||||
foreach ( $coreFiles as $coreFile ) {
|
||||
|
@ -209,7 +209,7 @@ class Tar_Archiver {
|
|||
if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) {
|
||||
if ( is_dir( $node ) ) {
|
||||
$this->addDir( $node, $excludes );
|
||||
} elseif ( is_file( $node ) ) {
|
||||
} else if ( is_file( $node ) ) {
|
||||
$this->addFile( $node, str_replace( ABSPATH, '', $node ) );
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ class Tar_Archiver {
|
|||
'home' => get_option( 'home' ),
|
||||
'abspath' => ABSPATH,
|
||||
'prefix' => $wpdb->prefix,
|
||||
'lang' => get_bloginfo('language'),
|
||||
'lang' => get_bloginfo("language"),
|
||||
'plugins' => $plugins,
|
||||
'themes' => $themes,
|
||||
) ) );
|
||||
|
@ -328,12 +328,12 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
if ( 'tar.gz' == $this->type ) {
|
||||
// if (@fwrite($this->archive, $data, strlen($data)) === false)
|
||||
//if (@fwrite($this->archive, $data, strlen($data)) === false)
|
||||
if ( false === @gzwrite( $this->archive, $data, strlen( $data ) ) ) {
|
||||
throw new Exception( 'Could not write to archive' );
|
||||
}
|
||||
// @fflush($this->archive);
|
||||
} elseif ( 'tar.bz2' == $this->type ) {
|
||||
//@fflush($this->archive);
|
||||
} else if ( 'tar.bz2' == $this->type ) {
|
||||
if ( false === @bzwrite( $this->archive, $data, strlen( $data ) ) ) {
|
||||
throw new Exception( 'Could not write to archive' );
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ class Tar_Archiver {
|
|||
throw new Exception( 'Could not write to archive' );
|
||||
}
|
||||
@fflush( $this->archive );
|
||||
} elseif ( 'tar.bz2' == $this->type ) {
|
||||
} else if ( 'tar.bz2' == $this->type ) {
|
||||
if ( false === @bzwrite( $this->archive, $this->chunk, strlen( $len ) ) ) {
|
||||
throw new Exception( 'Could not write to archive' );
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ class Tar_Archiver {
|
|||
$stat = @stat( $path );
|
||||
$fp = @fopen( $path, 'rb' );
|
||||
if ( ! $fp ) {
|
||||
// todo: add some error feedback!
|
||||
//todo: add some error feedback!
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -616,7 +616,7 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
while ( ! feof( $fp ) ) {
|
||||
// 0.1MB = 1024 000
|
||||
//0.1MB = 1024 000
|
||||
$this->tempContent = fread( $fp, 1024000 * 5 );
|
||||
|
||||
$read = strlen( $this->tempContent );
|
||||
|
@ -725,14 +725,14 @@ class Tar_Archiver {
|
|||
private function checkBeforeAppend( $entryName ) {
|
||||
$rslt = $this->isNextFile( $entryName );
|
||||
|
||||
// Correct file
|
||||
//Correct file
|
||||
if ( true === $rslt ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$out = false;
|
||||
|
||||
// close, reopen with append & ftruncate
|
||||
//close, reopen with append & ftruncate
|
||||
$this->close( false );
|
||||
$this->log( 'Reopen archive to append from here' );
|
||||
$this->append( $this->archivePath );
|
||||
|
@ -741,19 +741,19 @@ class Tar_Archiver {
|
|||
$startOffset = $rslt['startOffset'];
|
||||
@fseek( $this->archive, $startOffset );
|
||||
@ftruncate( $this->archive, $startOffset );
|
||||
} elseif ( 'tar.gz' == $this->type ) {
|
||||
} else if ( 'tar.gz' == $this->type ) {
|
||||
$readOffset = $rslt['readOffset'];
|
||||
$bytesRead = $rslt['bytesRead'];
|
||||
// @fseek($this->archive, $readOffset + $bytesRead);
|
||||
//@fseek($this->archive, $readOffset + $bytesRead);
|
||||
|
||||
$out = array( 'bytesRead' => $bytesRead );
|
||||
}
|
||||
} elseif ( false === $rslt ) {
|
||||
} else if ( false === $rslt ) {
|
||||
if ( 'tar' == $this->type ) {
|
||||
@fseek( $this->archive, 0, SEEK_END );
|
||||
}
|
||||
} else {
|
||||
// todo: check for tar.gz & tar!
|
||||
//todo: check for tar.gz & tar!
|
||||
@fseek( $this->archive, $rslt );
|
||||
@ftruncate( $this->archive, $rslt );
|
||||
}
|
||||
|
@ -790,7 +790,7 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
|
||||
// Check for long file!!
|
||||
//Check for long file!!
|
||||
if ( 'L' == $temp['type'] ) {
|
||||
$fname = trim( @fread( $this->archive, 512 ) );
|
||||
$block = @fread( $this->archive, 512 );
|
||||
|
@ -820,7 +820,7 @@ class Tar_Archiver {
|
|||
} else {
|
||||
throw new Exception( 'Unexpected directory [' . $file['name'] . ']' );
|
||||
}
|
||||
} elseif ( 0 == $file['type'] ) {
|
||||
} else if ( 0 == $file['type'] ) {
|
||||
if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) {
|
||||
$previousFtell = @ftell( $this->archive );
|
||||
|
||||
|
@ -862,7 +862,7 @@ class Tar_Archiver {
|
|||
|
||||
return $rslt;
|
||||
}
|
||||
} elseif ( ( 'tar' == $this->type ) && ( ( false === $ftell ) || ( -1 == $ftell ) ) ) {
|
||||
} else if ( ( 'tar' == $this->type ) && ( ( false === $ftell ) || ( -1 == $ftell ) ) ) {
|
||||
$this->log( 'Will append this: ' . print_r( $rslt, 1 ) );
|
||||
|
||||
return $rslt;
|
||||
|
@ -904,9 +904,9 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
if ( 'tar.gz' == $this->type ) {
|
||||
// $this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
|
||||
//$this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
|
||||
$this->archive = @gzopen( $filepath, 'wb' );
|
||||
} elseif ( 'tar.bz2' == $this->type ) {
|
||||
} else if ( 'tar.bz2' == $this->type ) {
|
||||
$this->archive = @bzopen( $filepath, 'w' );
|
||||
} else {
|
||||
$this->archive = @fopen( $filepath, 'wb+' );
|
||||
|
@ -926,9 +926,9 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
if ( 'tar.gz' == $this->type ) {
|
||||
// $this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
|
||||
//$this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
|
||||
$this->archive = @gzopen( $filepath, 'ab' );
|
||||
} elseif ( $this->type == 'tar.bz2' ) {
|
||||
} else if ( $this->type == 'tar.bz2' ) {
|
||||
$this->archive = @bzopen( $filepath, 'a' );
|
||||
} else {
|
||||
$this->archive = @fopen( $filepath, 'ab+' );
|
||||
|
@ -942,9 +942,9 @@ class Tar_Archiver {
|
|||
function prepareAppend( $filepath ) {
|
||||
if ( $this->debug ) {
|
||||
if ( 'tar.gz' == substr( $filepath, - 6 ) ) {
|
||||
$text = chr( 31 ) . chr( 139 ) . chr( 8 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ); // magic header!!
|
||||
$text = chr( 31 ) . chr( 139 ) . chr( 8 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ); //magic header!!
|
||||
|
||||
// Check if valid, if not, crop to valid!
|
||||
//Check if valid, if not, crop to valid!
|
||||
$fh = @fopen( $filepath, 'rb' );
|
||||
$read = '';
|
||||
$lastCorrect = 0;
|
||||
|
@ -972,7 +972,7 @@ class Tar_Archiver {
|
|||
@fclose( $fh );
|
||||
} catch ( Exception $e ) {
|
||||
@fclose( $fh );
|
||||
// reopen & truncate
|
||||
//reopen & truncate
|
||||
$fh = @fopen( $filepath, 'ab+' );
|
||||
@fseek( $fh, $lastCorrect );
|
||||
@ftruncate( $fh, $lastCorrect );
|
||||
|
@ -992,7 +992,7 @@ class Tar_Archiver {
|
|||
$this->type = 'tar.gz';
|
||||
// $this->archive = @fopen('compress.zlib://' . $filepath, 'rb');
|
||||
$this->archive = @gzopen( $filepath, 'r' );
|
||||
} elseif ( 'tar.bz2' == substr( $filepath, - 7 ) ) {
|
||||
} else if ( 'tar.bz2' == substr( $filepath, - 7 ) ) {
|
||||
$this->type = 'tar.bz2';
|
||||
$this->archive = @bzopen( $filepath, 'r' );
|
||||
} else {
|
||||
|
@ -1009,7 +1009,7 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
function close( $closeLog = true ) {
|
||||
// Write chunk if it's not empty..
|
||||
//Write chunk if it's not empty..
|
||||
$this->writeChunk();
|
||||
|
||||
$this->log( 'Closing archive' );
|
||||
|
@ -1020,9 +1020,9 @@ class Tar_Archiver {
|
|||
|
||||
if ( $this->archive ) {
|
||||
if ( 'tar.gz' == $this->type ) {
|
||||
// @fclose($this->archive);
|
||||
//@fclose($this->archive);
|
||||
@gzclose( $this->archive );
|
||||
} elseif ( 'tar.bz2' == $this->type ) {
|
||||
} else if ( 'tar.bz2' == $this->type ) {
|
||||
@bzclose( $this->archive );
|
||||
} else {
|
||||
@fclose( $this->archive );
|
||||
|
@ -1041,7 +1041,7 @@ class Tar_Archiver {
|
|||
@fseek( $this->archive, 0 );
|
||||
while ( $block = @fread( $this->archive, 512 ) ) {
|
||||
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
|
||||
// Check for long file!!
|
||||
//Check for long file!!
|
||||
if ( 'L' == $temp['type'] ) {
|
||||
$fname = trim( @fread( $this->archive, 512 ) );
|
||||
$block = @fread( $this->archive, 512 );
|
||||
|
@ -1065,7 +1065,7 @@ class Tar_Archiver {
|
|||
|
||||
if ( $file['checksum'] == 0x00000000 ) {
|
||||
break;
|
||||
} elseif ( substr( $file['magic'], 0, 5 ) != 'ustar' ) {
|
||||
} else if ( substr( $file['magic'], 0, 5 ) != 'ustar' ) {
|
||||
// $this->error[] = "This script does not support extracting this type of tar file.";
|
||||
break;
|
||||
}
|
||||
|
@ -1110,7 +1110,7 @@ class Tar_Archiver {
|
|||
@fseek( $this->archive, 0 );
|
||||
while ( $block = @fread( $this->archive, 512 ) ) {
|
||||
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
|
||||
// Check for long file!!
|
||||
//Check for long file!!
|
||||
if ( 'L' == $temp['type'] ) {
|
||||
$fname = trim( @fread( $this->archive, 512 ) );
|
||||
$block = @fread( $this->archive, 512 );
|
||||
|
@ -1134,7 +1134,7 @@ class Tar_Archiver {
|
|||
|
||||
if ( $file['checksum'] == 0x00000000 ) {
|
||||
break;
|
||||
} elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) {
|
||||
} else if ( 'ustar' != substr( $file['magic'], 0, 5 ) ) {
|
||||
// $this->error[] = "This script does not support extracting this type of tar file.";
|
||||
break;
|
||||
}
|
||||
|
@ -1151,7 +1151,7 @@ class Tar_Archiver {
|
|||
if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) {
|
||||
return true;
|
||||
}
|
||||
} elseif ( 0 == $file['type'] ) {
|
||||
} else if ( 0 == $file['type'] ) {
|
||||
if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -1174,7 +1174,7 @@ class Tar_Archiver {
|
|||
@fseek( $this->archive, 0 );
|
||||
while ( $block = fread( $this->archive, 512 ) ) {
|
||||
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
|
||||
// Check for long file!!
|
||||
//Check for long file!!
|
||||
if ( 'L' == $temp['type'] ) {
|
||||
$fname = trim( @fread( $this->archive, 512 ) );
|
||||
$block = @fread( $this->archive, 512 );
|
||||
|
@ -1198,7 +1198,7 @@ class Tar_Archiver {
|
|||
|
||||
if ( $file['checksum'] == 0x00000000 ) {
|
||||
break;
|
||||
} elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) {
|
||||
} else if ( 'ustar' != substr( $file['magic'], 0, 5 ) ) {
|
||||
// $this->error[] = "This script does not support extracting this type of tar file.";
|
||||
break;
|
||||
}
|
||||
|
@ -1217,7 +1217,7 @@ class Tar_Archiver {
|
|||
mkdir( $to . $file['name'], 0777, true );
|
||||
}
|
||||
}
|
||||
} elseif ( 0 == $file['type'] ) {
|
||||
} else if ( 0 == $file['type'] ) {
|
||||
if ( ! is_dir( dirname( $to . $file['name'] ) ) ) {
|
||||
if ( ! empty( $wp_filesystem ) ) {
|
||||
$wp_filesystem->mkdir( dirname( $to . $file['name'] ), FS_CHMOD_DIR );
|
||||
|
@ -1302,20 +1302,20 @@ if ( class_exists( 'SplHeap' ) ) {
|
|||
$dirnameA = ( is_file( $pathA ) ? dirname( $pathA ) : $pathA );
|
||||
$dirnameB = ( is_file( $pathB ) ? dirname( $pathB ) : $pathB );
|
||||
|
||||
// if both are in the same folder, first show the files, then the directories
|
||||
//if both are in the same folder, first show the files, then the directories
|
||||
if ( dirname( $pathA ) == dirname( $pathB ) ) {
|
||||
if ( is_file( $pathA ) && ! is_file( $pathB ) ) {
|
||||
return - 1;
|
||||
} elseif ( ! is_file( $pathA ) && is_file( $pathB ) ) {
|
||||
} else if ( ! is_file( $pathA ) && is_file( $pathB ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return strcmp( $pathA, $pathB );
|
||||
} elseif ( $dirnameA == $dirnameB ) {
|
||||
} else if ( $dirnameA == $dirnameB ) {
|
||||
return strcmp( $pathA, $pathB );
|
||||
} elseif ( MainWP_Helper::startsWith( $dirnameA, $dirnameB ) ) {
|
||||
} else if ( MainWP_Helper::startsWith( $dirnameA, $dirnameB ) ) {
|
||||
return 1;
|
||||
} elseif ( MainWP_Helper::startsWith( $dirnameB, $dirnameA ) ) {
|
||||
} else if ( MainWP_Helper::startsWith( $dirnameB, $dirnameA ) ) {
|
||||
return - 1;
|
||||
} else {
|
||||
$cmp = strcmp( $dirnameA, $dirnameB );
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
{
|
||||
"name": "mainwp/mainwp-child",
|
||||
"description": "This is the Child plugin for the MainWP Dashboard",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"type": "wordpress-plugin",
|
||||
"prefer-stable": true,
|
||||
"minimum-stability": "dev",
|
||||
"readme": "README.md",
|
||||
"authors": [
|
||||
{
|
||||
"name": "MainWP",
|
||||
"homepage": "https://mainwp.com"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/mainwp/mainwp-child/issues",
|
||||
"source": "https://github.com/mainwp/mainwp"
|
||||
},
|
||||
"require": {
|
||||
"composer/installers": "^1.6",
|
||||
"php": ">=5.6|>=7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.5",
|
||||
"phpcompatibility/php-compatibility": "^9.0",
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"wp-cli/wp-cli": "^2.0"
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"tests"
|
||||
],
|
||||
"files": [
|
||||
"tests/test-sample.php"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"phpunit --testsuite=plugin --testdox"
|
||||
],
|
||||
"test:all": [
|
||||
"phpunit --testdox"
|
||||
],
|
||||
"test-coverage": [
|
||||
"phpunit --testsuite=plugin --coverage-html=tests/coverage"
|
||||
]
|
||||
},
|
||||
"scripts-descriptions": {
|
||||
"test": "Run the plugin test suite",
|
||||
"test:all": "Run all test suites.",
|
||||
"test-coverage": "Generate test coverage for the plugin"
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.4"
|
||||
},
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
2479
composer.lock
generated
2479
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -6,11 +6,11 @@
|
|||
Author: MainWP
|
||||
Author URI: https://mainwp.com
|
||||
Text Domain: mainwp-child
|
||||
Version: 4.0.7
|
||||
Version: 4.0.7.1
|
||||
*/
|
||||
require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php'; // Version information from WordPress
|
||||
include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php' ); //Version information from wordpress
|
||||
|
||||
define( 'MAINWP_DEBUG', false );
|
||||
define( 'MAINWP_DEBUG', FALSE );
|
||||
|
||||
if ( ! defined( 'MAINWP_CHILD_FILE' ) ) {
|
||||
define( 'MAINWP_CHILD_FILE', __FILE__ );
|
||||
|
@ -25,7 +25,7 @@ function mainwp_child_autoload( $class_name ) {
|
|||
$autoload_path = sprintf( '%sclass-%s.php', $autoload_dir, strtolower( str_replace( '_', '-', $class_name ) ) );
|
||||
|
||||
if ( file_exists( $autoload_path ) ) {
|
||||
require_once $autoload_path;
|
||||
require_once( $autoload_path );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
75
phpcs.xml
75
phpcs.xml
|
@ -1,75 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
|
||||
|
||||
<description>The Coding standard for the MainWP Child plugin.</description>
|
||||
|
||||
<file>.</file>
|
||||
|
||||
<arg value="sp"/>
|
||||
<arg name="extensions" value="php"/>
|
||||
<arg name="basepath" value="."/>
|
||||
<arg name="parallel" value="8"/>
|
||||
|
||||
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||
<exclude-pattern>*/bin/*</exclude-pattern>
|
||||
<exclude-pattern>*/.github/*</exclude-pattern>
|
||||
<exclude-pattern>*/tests/*</exclude-pattern>
|
||||
|
||||
<rule ref="WordPress">
|
||||
<exclude name="WordPress.Files.FileName"/>
|
||||
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
|
||||
<exclude name="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/>
|
||||
|
||||
<!-- Disable Nonce verification due to large number of false positives. -->
|
||||
<exclude name="WordPress.Security.NonceVerification"/>
|
||||
|
||||
<!-- Disable Escaping output check due to large number of false positives. -->
|
||||
<exclude name="WordPress.Security.EscapeOutput"/>
|
||||
|
||||
<!-- Disable Strict comparison check. Not applicable in the mojority of cases. -->
|
||||
<exclude name="WordPress.PHP.StrictComparisons"/>
|
||||
|
||||
<!-- Disable Strict comparison in array check. Not applicable in the mojority of cases. -->
|
||||
<exclude name="WordPress.PHP.StrictInArray"/>
|
||||
|
||||
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
|
||||
|
||||
<exclude name="Squiz.ControlStructures.ControlSignature"/>
|
||||
|
||||
<exclude name="WordPress.Arrays.ArrayIndentation"/>
|
||||
</rule>
|
||||
|
||||
<!-- Enforce PSR1 compatible namespaces. -->
|
||||
<rule ref="PSR1.Classes.ClassDeclaration"/>
|
||||
|
||||
<rule ref="WordPress.Arrays.MultipleStatementAlignment">
|
||||
<properties>
|
||||
<property name="alignMultilineItems" value="!=100"/>
|
||||
<property name="exact" value="false" phpcs-only="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<rule ref="PSR2.Methods.FunctionClosingBrace"/>
|
||||
|
||||
<!-- Check code for cross-version PHP compatibility. -->
|
||||
<config name="testVersion" value="5.4-"/>
|
||||
<rule ref="PHPCompatibility">
|
||||
<!-- Exclude PHP constants back-filled by PHPCS. -->
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_finallyFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_yieldFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_ellipsisFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_powFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_pow_equalFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_spaceshipFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_coalesceFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_coalesce_equalFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_yield_fromFound"/>
|
||||
</rule>
|
||||
|
||||
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.DeprecatedWhitelistCommentFound">
|
||||
<!-- False positive for whitelist comment recognition, but no use fixing this now
|
||||
as the WPCS native whitelist comments are deprecated anyhow. -->
|
||||
<exclude-pattern>/WordPress/AbstractClassRestrictionsSniff\.php$</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
16
readme.txt
16
readme.txt
|
@ -5,9 +5,9 @@ Author: mainwp
|
|||
Author URI: https://mainwp.com
|
||||
Plugin URI: https://mainwp.com
|
||||
Requires at least: 3.6
|
||||
Tested up to: 5.3.2
|
||||
Tested up to: 5.4.1
|
||||
Requires PHP: 5.6
|
||||
Stable tag: 4.0.7
|
||||
Stable tag: 4.0.7.1
|
||||
License: GPLv3 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
|
@ -71,6 +71,18 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 4.0.7.1 - 4-30-20 =
|
||||
* Fixed: JSON decoding issues on specific setups
|
||||
* Fixed: an issue with incorrect images URL
|
||||
* Fixed: conflict with the Download Manager plugin
|
||||
* Fixed: multiple PHP warnings
|
||||
* Fixed: MySQL query compatibility problems
|
||||
* Fixed: an issue with saving Wordfence settings
|
||||
* Fixed: an issue with showing correct post and page creating time
|
||||
* Fixed: an issue with displaying correct author in reports
|
||||
* Added: support for WPVivid backups in the reporting system
|
||||
* Preventative: security improvements
|
||||
|
||||
= 4.0.7 - 2-25-20 =
|
||||
* Fixed: an issue with saving Bulk Setting Manager keys
|
||||
* Fixed: an issue with saving Wordfence extension settings
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPUnit bootstrap file
|
||||
*
|
||||
* @package Mainwp_Child
|
||||
*/
|
||||
|
||||
$_tests_dir = getenv( 'WP_TESTS_DIR' );
|
||||
|
||||
if ( ! $_tests_dir ) {
|
||||
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
|
||||
}
|
||||
|
||||
if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) {
|
||||
echo "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // WPCS: XSS ok.
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
// Give access to tests_add_filter() function.
|
||||
require_once $_tests_dir . '/includes/functions.php';
|
||||
|
||||
/**
|
||||
* Manually load the plugin being tested.
|
||||
*/
|
||||
function _manually_load_plugin() {
|
||||
require dirname( dirname( __FILE__ ) ) . '/mainwp-child.php';
|
||||
}
|
||||
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
||||
|
||||
// Start up the WP testing environment.
|
||||
require $_tests_dir . '/includes/bootstrap.php';
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Class SampleTest
|
||||
*
|
||||
* @package Mainwp_Child
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sample test case.
|
||||
*/
|
||||
class SampleTest extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* A single example test.
|
||||
*/
|
||||
public function test_sample() {
|
||||
// Replace this with some actual testing code.
|
||||
$this->assertTrue( true );
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue