mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-08-31 03:53:15 +08:00
Refactoring
This commit is contained in:
parent
159205b55d
commit
bca98c3a1a
35 changed files with 340 additions and 285 deletions
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Backup {
|
||||
protected static $instance = null;
|
||||
protected $excludeZip;
|
||||
|
@ -790,9 +792,7 @@ class MainWP_Backup {
|
|||
foreach ( $db_files as $db_file ) {
|
||||
unlink( $db_file );
|
||||
}
|
||||
} else {
|
||||
// todo: throw exception!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ( false !== $archiveExt ? array( 'filepath' => $archivefilePath ) : $db_files );
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/mainwpbuddy/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Back_Up_Buddy {
|
||||
public static $instance = null;
|
||||
public $plugin_translate = 'mainwp-child';
|
||||
|
@ -148,9 +150,12 @@ class MainWP_Child_Back_Up_Buddy {
|
|||
continue;
|
||||
}
|
||||
|
||||
$check_finished = false;
|
||||
if ( ( $backup['finish_time'] >= $backup['start_time'] ) && ( 0 != $backup['start_time'] ) ) {
|
||||
// ok!
|
||||
} else {
|
||||
$check_finished = true;
|
||||
}
|
||||
|
||||
if ( ! $check_finished ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -630,7 +635,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|||
return array( 'error' => __( 'Error: not found the backup schedule or invalid data', 'mainwp-child' ) );
|
||||
}
|
||||
|
||||
pb_backupbuddy::alert( 'Manually running scheduled backup "' . pb_backupbuddy::$options['schedules'][ $schedule_id ]['title'] . '" in the background.' . '<br>' . __( 'Note: If there is no site activity there may be delays between steps in the backup. Access the site or use a 3rd party service, such as a free pinging service, to generate site activity.', 'mainwp-child' ) );
|
||||
pb_backupbuddy::alert( 'Manually running scheduled backup "' . pb_backupbuddy::$options['schedules'][ $schedule_id ]['title'] . '" in the background.<br>' . __( 'Note: If there is no site activity there may be delays between steps in the backup. Access the site or use a 3rd party service, such as a free pinging service, to generate site activity.', 'mainwp-child' ) );
|
||||
pb_backupbuddy_cron::_run_scheduled_backup( $schedule_id );
|
||||
|
||||
$information['result'] = 'SUCCESS';
|
||||
|
@ -2843,9 +2848,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|||
if ( ( ( 0 == $stats['files_total'] ) || ( $stats['files_sent'] < $stats['files_total'] ) ) && ( 'wait_on_transfers' != $stats['current_function'] ) ) { // ( Files to send not yet calculated OR more remain to send ) AND not on the wait_on_transfers step.
|
||||
$time_since_last_activity = microtime( true ) - $stats['last_periodic_activity'];
|
||||
|
||||
if ( $time_since_last_activity < 30 ) { // Don't even bother getting max execution time if it's been less than 30 seconds since run.
|
||||
// do nothing!
|
||||
} else { // More than 30 seconds since last activity.
|
||||
if ( $time_since_last_activity >= 30 ) { // More than 30 seconds since last activity.
|
||||
|
||||
// Detect max PHP execution time. If TESTED value is higher than PHP value then go with that since we want to err on not overlapping processes here.
|
||||
$detected_execution = backupbuddy_core::detectLikelyHighestExecutionTime();
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/backupwordpress/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Back_Up_Wordpress {
|
||||
public static $instance = null;
|
||||
public $is_plugin_installed = false;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/backwpup/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
if ( ! defined( 'MAINWP_BACKWPUP_DEVELOPMENT' ) ) {
|
||||
define( 'MAINWP_BACKWPUP_DEVELOPMENT', false );
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Branding {
|
||||
public static $instance = null;
|
||||
|
||||
|
@ -445,10 +447,9 @@ class MainWP_Child_Branding {
|
|||
|
||||
// prevent conflicts with other plugins.
|
||||
public function admin_menu() {
|
||||
$allow_contact = apply_filters( 'mainwp_branding_role_cap_enable_contact_form', false );
|
||||
if ( $allow_contact ) {
|
||||
// skip!
|
||||
} elseif ( ! current_user_can( 'administrator' ) ) {
|
||||
$enable_contact = apply_filters( 'mainwp_branding_role_cap_enable_contact_form', false );
|
||||
|
||||
if ( ! $enable_contact && ! current_user_can( 'administrator' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -914,10 +915,8 @@ class MainWP_Child_Branding {
|
|||
* @param WP_Admin_Bar $wp_admin_bar
|
||||
*/
|
||||
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 ) {
|
||||
// skip!
|
||||
} elseif ( ! current_user_can( 'administrator' ) ) {
|
||||
$enable_contact = apply_filters( 'mainwp_branding_role_cap_enable_contact_form', false );
|
||||
if ( ! $enable_contact && ! current_user_can( 'administrator' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_DB {
|
||||
// Support old & new versions of WordPress (3.9+).
|
||||
public static function use_mysqli() {
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/ithemes-security/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_IThemes_Security {
|
||||
public static $instance = null;
|
||||
public $is_plugin_installed = false;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
* The code is used for the MainWP Broken Links Checker Extension (Retired Extension)
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Links_Checker {
|
||||
|
||||
public static $instance = null;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/page-speed/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Pagespeed {
|
||||
|
||||
public static $instance = null;
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
* Author URI: https://wp-staging.com
|
||||
* License: GPLv2
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Plugins_Check {
|
||||
public static $instance = null;
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
class MainWP_Child_Robot {
|
||||
public static $instance = null;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Robot();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function wpr_insertcomments( $postid, $comments ) {
|
||||
remove_filter( 'comment_text', 'make_clickable', 9 );
|
||||
foreach ( $comments as $comment ) {
|
||||
$comment_post_ID = $postid;
|
||||
$comment_date = $comment['dts'];
|
||||
$comment_date = date( 'Y-m-d H:i:s', $comment_date );
|
||||
$comment_date_gmt = $comment_date;
|
||||
$rnd = rand( 1, 9999 );
|
||||
$comment_author_email = "someone$rnd@domain.com";
|
||||
$comment_author = $comment['author'];
|
||||
$comment_author_url = '';
|
||||
$comment_content = '';
|
||||
$comment_content .= $comment['content'];
|
||||
$comment_type = '';
|
||||
$user_ID = '';
|
||||
$comment_approved = 1;
|
||||
$commentdata = compact( 'comment_post_ID', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID', 'comment_approved' );
|
||||
$comment_id = wp_insert_comment( $commentdata );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Server_Information {
|
||||
const WARNING = 1;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Skeleton_Key {
|
||||
public static $instance = null;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/staging/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Staging {
|
||||
|
||||
public static $instance = null;
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
* Author URI: https://wp-staging.com
|
||||
* License: GPLv2
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Themes_Check {
|
||||
public static $instance = null;
|
||||
private $cron_name_watcher = 'mainwp_child_cron_theme_health_check_watcher';
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/time-capsule/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Timecapsule {
|
||||
public static $instance = null;
|
||||
public $is_plugin_installed = false;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/updraftplus/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Updraft_Plus_Backups {
|
||||
public static $instance = null;
|
||||
public $is_plugin_installed = false;
|
||||
|
@ -324,7 +326,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
return new WP_Error( 'unknown_response', sprintf( __( 'UpdraftPlus.Com returned a response which we could not understand (data: %s)', 'updraftplus' ), $result['body'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$return = false;
|
||||
switch ( $response['loggedin'] ) {
|
||||
case 'connected':
|
||||
if ( ! empty( $response['token'] ) ) {
|
||||
|
@ -357,15 +360,15 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
}
|
||||
}
|
||||
|
||||
return new WP_Error( 'authfailed', __( 'Your email address and password were not recognised by UpdraftPlus.Com', 'updraftplus' ) );
|
||||
$return = new WP_Error( 'authfailed', __( 'Your email address and password were not recognised by UpdraftPlus.Com', 'updraftplus' ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
return new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
|
||||
$return = new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
// This method also gets called directly, so don't add code that assumes that it's definitely an AJAX situation.
|
||||
|
@ -428,7 +431,10 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
$updated = false;
|
||||
if ( is_array( $settings ) ) {
|
||||
if ( class_exists( 'UpdraftPlus_Options' ) ) {
|
||||
foreach ( $keys_filter as $key ) {
|
||||
foreach ( $keys_filter as $key ) {
|
||||
if ( 'updraft_googledrive' === $key || 'updraft_googlecloud' === $key || 'updraft_onedrive' === $key ) {
|
||||
continue; // skip
|
||||
}
|
||||
if ( isset( $settings[ $key ] ) ) {
|
||||
$settings_key = null;
|
||||
if ( 'updraft_dropbox' === $key && is_array( $settings[ $key ] ) ) {
|
||||
|
@ -451,12 +457,6 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
}
|
||||
}
|
||||
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
||||
} elseif ( 'updraft_googledrive' === $key ) {
|
||||
|
||||
} elseif ( 'updraft_googlecloud' === $key ) {
|
||||
|
||||
} elseif ( 'updraft_onedrive' === $key ) {
|
||||
|
||||
} elseif ( 'updraft_email' === $key ) {
|
||||
$value = $settings[ $key ];
|
||||
if ( ! is_array( $value ) ) {
|
||||
|
@ -1289,12 +1289,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
$remote_obj = new $objname();
|
||||
$deleted = $remote_obj->delete( $files );
|
||||
}
|
||||
if ( -1 === $deleted ) {
|
||||
|
||||
} elseif ( false !== $deleted ) {
|
||||
|
||||
if ( -1 !== $deleted && false !== $deleted ) {
|
||||
$remote_deleted = $remote_deleted + count( $files );
|
||||
} else {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1771,9 +1768,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
$updraftplus->log( 'Restore failed' );
|
||||
$updraftplus->list_errors();
|
||||
|
||||
} elseif ( false === $backup_success ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$output = ob_get_clean();
|
||||
|
||||
|
@ -2701,7 +2696,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
if ( 'multisite' == $key ) {
|
||||
$info['multisite'] = $val ? true : false;
|
||||
if ( $val ) {
|
||||
$mess[] = '<strong>' . __( 'Site information:', 'updraftplus' ) . '</strong> ' . 'backup is of a WordPress Network';
|
||||
$mess[] = '<strong>' . __( 'Site information:', 'updraftplus' ) . '</strong> backup is of a WordPress Network';
|
||||
}
|
||||
}
|
||||
$old_siteinfo[ $key ] = $val;
|
||||
|
@ -2780,7 +2775,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
}
|
||||
if ( $db_charset_forbidden ) {
|
||||
$db_unsupported_charset_unique = array_unique( $db_unsupported_charset );
|
||||
$warn[] = sprintf( _n( "The database server that this WordPress site is running on doesn't support the character set (%s) which you are trying to import.", "The database server that this WordPress site is running on doesn't support the character sets (%s) which you are trying to import.", count( $db_unsupported_charset_unique ), 'updraftplus' ), implode( ', ', $db_unsupported_charset_unique ) ) . ' ' . __( 'You can choose another suitable character set instead and continue with the restoration at your own risk.', 'updraftplus' ) . ' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">' . __( 'Go here for more information.', 'updraftplus' ) . '</a>' . ' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">' . __( 'Go here for more information.', 'updraftplus' ) . '</a>';
|
||||
$warn[] = sprintf( _n( "The database server that this WordPress site is running on doesn't support the character set (%s) which you are trying to import.", "The database server that this WordPress site is running on doesn't support the character sets (%s) which you are trying to import.", count( $db_unsupported_charset_unique ), 'updraftplus' ), implode( ', ', $db_unsupported_charset_unique ) ) . ' ' . __( 'You can choose another suitable character set instead and continue with the restoration at your own risk.', 'updraftplus' ) . ' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">' . __( 'Go here for more information.', 'updraftplus' ) . '</a> <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">' . __( 'Go here for more information.', 'updraftplus' ) . '</a>';
|
||||
$db_supported_character_sets = array_keys( $db_supported_character_sets );
|
||||
$similar_type_charset = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems( $db_unsupported_charset_unique, $db_supported_character_sets, true );
|
||||
if ( empty( $similar_type_charset ) ) {
|
||||
|
@ -3050,11 +3045,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
$backup['service'] = array( $backup['service'] );
|
||||
}
|
||||
foreach ( $backup['service'] as $service ) {
|
||||
if ( 'none' === $service || '' === $service || ( is_array( $service ) && ( empty( $service ) || array( 'none' ) === $service || array( '' ) === $service ) ) ) {
|
||||
// Do nothing.
|
||||
} else {
|
||||
$emptyCheck = ( 'none' === $service || '' === $service || ( is_array( $service ) && ( empty( $service ) || array( 'none' ) === $service || array( '' ) === $service ) ) );
|
||||
if ( ! empty( $emptyCheck ) ) {
|
||||
$remote_storage = ( 'remotesend' === $service ) ? __( 'remote site', 'updraftplus' ) : $updraftplus->backup_methods[ $service ];
|
||||
|
||||
$service_title = '<br>' . esc_attr( sprintf( __( 'Remote storage: %s', 'updraftplus' ), $remote_storage ) );
|
||||
}
|
||||
}
|
||||
|
@ -3183,7 +3176,7 @@ ENDHERE;
|
|||
<input type="submit" class="mwp-updraft-backupentitybutton ui button" value="$dbt" />
|
||||
</form>
|
||||
</div>
|
||||
ENDHERE;
|
||||
ENDHERE;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -3301,7 +3294,7 @@ ENDHERE;
|
|||
<input type="submit" class="mwp-updraft-backupentitybutton ui button" title="$ide" value="$pdescrip" />
|
||||
</form>
|
||||
</div>
|
||||
ENDHERE;
|
||||
ENDHERE;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -3323,7 +3316,7 @@ ENDHERE;
|
|||
<input type="submit" value="$lt" class="updraft-log-link ui button" onclick="event.preventDefault(); mainwp_updraft_popuplog( '$nval', this );" />
|
||||
</form>
|
||||
</div>
|
||||
ENDHERE;
|
||||
ENDHERE;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/vulnerability-checker/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Vulnerability_Checker {
|
||||
|
||||
public static $instance = null;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/woocommerce-status/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_WooCommerce_Status {
|
||||
public static $instance = null;
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/wordfence/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_Wordfence {
|
||||
public static $instance = null;
|
||||
public $is_wordfence_installed = false;
|
||||
|
@ -836,7 +838,7 @@ class MainWP_Child_Wordfence {
|
|||
return $wpdb->get_var(
|
||||
<<<SQL
|
||||
SELECT SUM(blockCount) as blockCount FROM {$table_wfBlockedIPLog} WHERE unixday >= {$interval}
|
||||
SQL
|
||||
SQL
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/rocket/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_WP_Rocket {
|
||||
public static $instance = null;
|
||||
public $is_plugin_installed = false;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Child_WPvivid_BackupRestore {
|
||||
|
||||
public static $instance = null;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) {
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', true );
|
||||
|
@ -10,111 +13,9 @@ if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) {
|
|||
}
|
||||
}
|
||||
|
||||
define( 'MAINWP_CHILD_NR_OF_COMMENTS', 50 );
|
||||
define( 'MAINWP_CHILD_NR_OF_PAGES', 50 );
|
||||
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
||||
|
||||
|
||||
if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyuse_nonce_hmac'] ) ) {
|
||||
$skeleton_keyuse_nonce_key = intval( $_GET['skeleton_keyuse_nonce_key'] );
|
||||
$skeleton_keyuse_nonce_hmac = $_GET['skeleton_keyuse_nonce_hmac'];
|
||||
$skeleton_keycurrent_time = intval( time() );
|
||||
|
||||
if ( $skeleton_keycurrent_time >= $skeleton_keyuse_nonce_key && $skeleton_keycurrent_time <= ( $skeleton_keyuse_nonce_key + 30 ) ) {
|
||||
|
||||
if ( strcmp( $skeleton_keyuse_nonce_hmac, hash_hmac( 'sha256', $skeleton_keyuse_nonce_key, NONCE_KEY ) ) === 0 ) {
|
||||
|
||||
if ( ! function_exists( 'wp_verify_nonce' ) ) :
|
||||
|
||||
/**
|
||||
* Verify that correct nonce was used with time limit.
|
||||
*
|
||||
* The user is given an amount of time to use the token, so therefore, since the
|
||||
* UID and $action remain the same, the independent variable is the time.
|
||||
*
|
||||
* @since 2.0.3
|
||||
*
|
||||
* @param string $nonce Nonce that was used in the form to verify
|
||||
* @param string|int $action Should give context to what is taking place and be the same when nonce was created.
|
||||
*
|
||||
* @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
|
||||
* 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
|
||||
*/
|
||||
function wp_verify_nonce( $nonce, $action = - 1 ) {
|
||||
$nonce = (string) $nonce;
|
||||
$user = wp_get_current_user();
|
||||
$uid = (int) $user->ID;
|
||||
if ( ! $uid ) {
|
||||
/**
|
||||
* Filter whether the user who generated the nonce is logged out.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param int $uid ID of the nonce-owning user.
|
||||
* @param string $action The nonce action.
|
||||
*/
|
||||
$uid = apply_filters( 'nonce_user_logged_out', $uid, $action );
|
||||
}
|
||||
|
||||
if ( empty( $nonce ) ) {
|
||||
|
||||
// To fix verify nonce conflict #1.
|
||||
// this is fake post field to fix some conflict of wp_verify_nonce().
|
||||
// just return false to unverify nonce, does not exit.
|
||||
if ( isset( $_POST[ $action ] ) && ( 'mainwp-bsm-unverify-nonce' == $_POST[ $action ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// to help tracing the conflict verify nonce with other plugins.
|
||||
ob_start();
|
||||
debug_print_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS );
|
||||
$stackTrace = "\n" . ob_get_clean();
|
||||
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action . '<br/>Trace: ' . $stackTrace ) ) ) . '</mainwp>' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
|
||||
}
|
||||
|
||||
// To fix verify nonce conflict #2.
|
||||
// this is fake nonce to fix some conflict of wp_verify_nonce().
|
||||
// just return false to unverify nonce, does not exit.
|
||||
if ( 'mainwp-bsm-unverify-nonce' == $nonce ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$token = wp_get_session_token();
|
||||
$i = wp_nonce_tick();
|
||||
|
||||
// Nonce generated 0-12 hours ago.
|
||||
$expected = substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), - 12, 10 );
|
||||
if ( hash_equals( $expected, $nonce ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Nonce generated 12-24 hours ago.
|
||||
$expected = substr( wp_hash( ( $i - 1 ) . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), - 12, 10 );
|
||||
if ( hash_equals( $expected, $nonce ) ) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
// To fix verify nonce conflict #3.
|
||||
// this is fake post field to fix some conflict of wp_verify_nonce().
|
||||
// just return false to unverify nonce, does not exit.
|
||||
if ( isset( $_POST[ $action ] ) && ( 'mainwp-bsm-unverify-nonce' == $_POST[ $action ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
debug_print_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS );
|
||||
$stackTrace = "\n" . ob_get_clean();
|
||||
|
||||
// Invalid nonce.
|
||||
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '<br/>Trace: ' . $stackTrace ) ) ) . '</mainwp>' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
|
||||
}
|
||||
endif;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MainWP_Child {
|
||||
public static $version = '4.0.7.1';
|
||||
private $update_version = '1.5';
|
||||
|
@ -492,9 +393,9 @@ class MainWP_Child {
|
|||
return;
|
||||
}
|
||||
session_write_close();
|
||||
@header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ), true );
|
||||
@header( 'X-Robots-Tag: noindex, nofollow', true );
|
||||
@header( 'X-MainWP-Child-Version: ' . self::$version, true );
|
||||
header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ), true );
|
||||
header( 'X-Robots-Tag: noindex, nofollow', true );
|
||||
header( 'X-MainWP-Child-Version: ' . self::$version, true );
|
||||
nocache_headers();
|
||||
if ( 'test' == $_GET['mainwp_child_run'] ) {
|
||||
die( 'MainWP Test' );
|
||||
|
@ -673,7 +574,7 @@ class MainWP_Child {
|
|||
|
||||
$settingsPage = add_submenu_page( 'options-general.php', $child_menu_title, $child_menu_title, 'manage_options', 'mainwp_child_tab', array( &$this, 'render_pages' ) );
|
||||
|
||||
add_action( 'admin_print_scripts-' . $settingsPage, array( 'MainWP_Clone', 'print_scripts' ) );
|
||||
add_action( 'admin_print_scripts-' . $settingsPage, array( MainWP_Clone::get_class_name(), 'print_scripts' ) );
|
||||
$subpageargs = array(
|
||||
'child_slug' => 'options-general.php',
|
||||
'branding' => ( null === self::$brandingTitle ) ? 'MainWP' : self::$brandingTitle,
|
||||
|
@ -4400,7 +4301,10 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
$maxPages = MAINWP_CHILD_NR_OF_PAGES;
|
||||
$maxPages = 50;
|
||||
if ( defined( 'MAINWP_CHILD_NR_OF_PAGES' ) )
|
||||
$maxPages = MAINWP_CHILD_NR_OF_PAGES;
|
||||
|
||||
if ( isset( $_POST['maxRecords'] ) ) {
|
||||
$maxPages = $_POST['maxRecords'];
|
||||
}
|
||||
|
@ -4448,7 +4352,10 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
$maxComments = MAINWP_CHILD_NR_OF_COMMENTS;
|
||||
$maxComments = 50;
|
||||
if ( defined( 'MAINWP_CHILD_NR_OF_COMMENTS' ) )
|
||||
$maxComments = MAINWP_CHILD_NR_OF_COMMENTS; // to compatible.
|
||||
|
||||
if ( isset( $_POST['maxRecords'] ) ) {
|
||||
$maxComments = $_POST['maxRecords'];
|
||||
}
|
||||
|
@ -5267,15 +5174,15 @@ class MainWP_Child {
|
|||
// log time.
|
||||
$time = MainWP_Helper::clean( date( 'F jS Y, h:ia', time() ) );
|
||||
|
||||
$mail = '<div>' . 'TIME: ' . $time . '</div>' .
|
||||
'<div>' . '*404: ' . $request . '</div>' .
|
||||
'<div>' . 'SITE: ' . $site . '</div>' .
|
||||
'<div>' . 'REFERRER: ' . $referer . '</div>' .
|
||||
'<div>' . 'QUERY STRING: ' . $string . '</div>' .
|
||||
'<div>' . 'REMOTE ADDRESS: ' . $address . '</div>' .
|
||||
'<div>' . 'REMOTE IDENTITY: ' . $remote . '</div>' .
|
||||
'<div>' . 'USER AGENT: ' . $agent . '</div>';
|
||||
$mail = '<div>404 alert</div><div></div>' . $mail;
|
||||
$mail = '<div>404 alert</div><div></div>' .
|
||||
'<div>TIME: ' . $time . '</div>' .
|
||||
'<div>*404: ' . $request . '</div>' .
|
||||
'<div>SITE: ' . $site . '</div>' .
|
||||
'<div>REFERRER: ' . $referer . '</div>' .
|
||||
'<div>QUERY STRING: ' . $string . '</div>' .
|
||||
'<div>REMOTE ADDRESS: ' . $address . '</div>' .
|
||||
'<div>REMOTE IDENTITY: ' . $remote . '</div>' .
|
||||
'<div>USER AGENT: ' . $agent . '</div>';
|
||||
wp_mail(
|
||||
$email,
|
||||
'MainWP - 404 Alert: ' . $blog,
|
||||
|
@ -5304,7 +5211,7 @@ class MainWP_Child {
|
|||
}
|
||||
$code = stripslashes( $_POST['code'] );
|
||||
if ( 'run_snippet' === $action ) {
|
||||
$information = MainWP_Tools::execute_snippet( $code );
|
||||
$information = MainWP_Helper::execute_snippet( $code );
|
||||
} elseif ( 'save_snippet' === $action ) {
|
||||
$type = $_POST['type'];
|
||||
$slug = $_POST['slug'];
|
||||
|
@ -5391,7 +5298,7 @@ class MainWP_Child {
|
|||
$snippets = get_option( 'mainwp_ext_code_snippets' );
|
||||
if ( is_array( $snippets ) && count( $snippets ) > 0 ) {
|
||||
foreach ( $snippets as $code ) {
|
||||
MainWP_Tools::execute_snippet( $code );
|
||||
MainWP_Helper::execute_snippet( $code );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Client_Report {
|
||||
|
||||
public static $instance = null;
|
||||
|
@ -612,7 +614,7 @@ class MainWP_Client_Report {
|
|||
$loop_count = 0;
|
||||
|
||||
foreach ( $records as $record ) {
|
||||
|
||||
|
||||
if ( in_array( $record->ID, $skip_records ) ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -625,21 +627,25 @@ class MainWP_Client_Report {
|
|||
continue;
|
||||
}
|
||||
|
||||
$valid_context = false;
|
||||
|
||||
if ( 'comments' == $context ) {
|
||||
$comment_contexts = array( 'post', 'page' );
|
||||
if ( ! in_array( $record->context, $comment_contexts ) ) {
|
||||
continue;
|
||||
}
|
||||
$valid_context = true;
|
||||
} elseif ( 'menus' == $context ) {
|
||||
// ok, pass, don't check context.
|
||||
$valid_context = true; // ok, pass, don't check context.
|
||||
} elseif ( 'editor' == $record->connector ) {
|
||||
// ok, pass, checked above.
|
||||
$valid_context = true; // ok, pass, checked above.
|
||||
} elseif ( 'media' == $connector && 'media' == $record->connector ) {
|
||||
// ok, pass, do not check context.
|
||||
$valid_context = true; // ok, pass, do not check context.
|
||||
} elseif ( 'widgets' == $connector && 'widgets' == $record->connector ) {
|
||||
// ok, pass, don't check context.
|
||||
//
|
||||
} elseif ( strtolower( $record->context ) !== $context ) {
|
||||
$valid_context = true; // ok, pass, don't check context.
|
||||
}
|
||||
|
||||
if ( ! $valid_context || strtolower( $record->context ) !== $context ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Clone_Install {
|
||||
protected $file;
|
||||
public $config;
|
||||
|
@ -54,9 +56,9 @@ class MainWP_Clone_Install {
|
|||
}
|
||||
|
||||
if ( null !== $this->archiver ) {
|
||||
|
||||
return false;
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
// skip.
|
||||
return false;
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
$zip = new ZipArchive();
|
||||
$zipRes = $zip->open( $this->file );
|
||||
|
@ -111,7 +113,7 @@ class MainWP_Clone_Install {
|
|||
|
||||
return $this->archiver->file_exists( $file );
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
// skip.
|
||||
return false;
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
$zip = new ZipArchive();
|
||||
$zipRes = $zip->open( $this->file );
|
||||
|
@ -371,7 +373,9 @@ class MainWP_Clone_Install {
|
|||
|
||||
return $content;
|
||||
} else {
|
||||
|
||||
if ( $this->checkZipConsole() ) {
|
||||
return false;
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
$zip = new ZipArchive();
|
||||
$zipRes = $zip->open( $this->file );
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Clone {
|
||||
protected static $instance = null;
|
||||
protected $security_nonces;
|
||||
|
||||
/**
|
||||
* Method get_class_name()
|
||||
*
|
||||
* Get Class Name.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function get_class_name() {
|
||||
return __CLASS__;
|
||||
}
|
||||
|
||||
|
||||
public static function get() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Clone();
|
||||
|
@ -76,9 +90,9 @@ class MainWP_Clone {
|
|||
}
|
||||
|
||||
public function init() {
|
||||
add_action( 'check_admin_referer', array( 'MainWP_Clone', 'permalinkChanged' ) );
|
||||
add_action( 'check_admin_referer', array( MainWP_Clone::get_class_name(), 'permalinkChanged' ) );
|
||||
if ( get_option( 'mainwp_child_clone_permalink' ) || get_option( 'mainwp_child_restore_permalink' ) ) {
|
||||
add_action( 'admin_notices', array( 'MainWP_Clone', 'permalinkAdminNotice' ) );
|
||||
add_action( 'admin_notices', array( MainWP_Clone::get_class_name(), 'permalinkAdminNotice' ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,9 +106,9 @@ class MainWP_Clone {
|
|||
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
||||
$version = $ui->ver;
|
||||
if ( MainWP_Helper::startsWith( $version, '1.10' ) ) {
|
||||
wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.10.4/jquery-ui.min.css', dirname( __FILE__ ) ), array(), null, 'all' );
|
||||
wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.10.4/jquery-ui.min.css', dirname( __FILE__ ) ), array(), '1.10', 'all' );
|
||||
} else {
|
||||
wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.11.1/jquery-ui.min.css', dirname( __FILE__ ) ), array(), null, 'all' );
|
||||
wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.11.1/jquery-ui.min.css', dirname( __FILE__ ) ), array(), '1.11', 'all' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +130,7 @@ class MainWP_Clone {
|
|||
}
|
||||
$uploadedfile = $_FILES['file'];
|
||||
$upload_overrides = array( 'test_form' => false );
|
||||
add_filter( 'upload_mimes', array( 'MainWP_Clone', 'upload_mimes' ) );
|
||||
add_filter( 'upload_mimes', array( MainWP_Clone::get_class_name(), 'upload_mimes' ) );
|
||||
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
|
||||
if ( $movefile ) {
|
||||
$uploadFile = str_replace( ABSPATH, '', $movefile['file'] );
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Custom_Post_Type {
|
||||
public static $instance = null;
|
||||
public static $information = array();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Debug {
|
||||
/**
|
||||
* @param $mainwpChild MainWP_Child
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Helper {
|
||||
|
||||
public static function write( $val ) {
|
||||
|
@ -411,27 +413,9 @@ class MainWP_Helper {
|
|||
$current_uid = $current_user->ID;
|
||||
// Set up a new post (adding addition information).
|
||||
|
||||
$is_robot_post = false;
|
||||
if ( isset( $_POST['isMainWPRobot'] ) && ! empty( $_POST['isMainWPRobot'] ) ) {
|
||||
$is_robot_post = true;
|
||||
}
|
||||
|
||||
$post_author = isset( $new_post['post_author'] ) ? $new_post['post_author'] : $current_uid;
|
||||
if ( $is_robot_post ) {
|
||||
if ( 1 === $post_author ) {
|
||||
$new_post['post_author'] = $current_uid;
|
||||
} elseif ( ! is_numeric( $post_author ) ) {
|
||||
$user_author = get_user_by( 'login', $post_author );
|
||||
if ( $user_author ) {
|
||||
$post_author = $user_author->ID;
|
||||
} else {
|
||||
$length = 12;
|
||||
$include_standard_special_chars = false;
|
||||
$random_password = wp_generate_password( $length, $include_standard_special_chars );
|
||||
$post_author = wp_create_user( $post_author, $random_password, $post_author . '@asdf.com' );
|
||||
}
|
||||
}
|
||||
} elseif ( isset( $new_post['custom_post_author'] ) && ! empty( $new_post['custom_post_author'] ) ) {
|
||||
|
||||
if ( isset( $new_post['custom_post_author'] ) && ! empty( $new_post['custom_post_author'] ) ) {
|
||||
$_author = get_user_by( 'login', $new_post['custom_post_author'] );
|
||||
if ( ! empty( $_author ) ) {
|
||||
$new_post['post_author'] = $_author->ID;
|
||||
|
@ -444,14 +428,13 @@ class MainWP_Helper {
|
|||
$post_author = ! empty( $post_author ) ? $post_author : $current_uid;
|
||||
$new_post['post_author'] = $post_author;
|
||||
|
||||
$is_ezine_post = ! empty( $post_custom['_ezine_post_article_source'] ) ? true : false;
|
||||
$terms = isset( $new_post['_ezin_post_category'] ) ? $new_post['_ezin_post_category'] : false;
|
||||
unset( $new_post['_ezin_post_category'] );
|
||||
$is_post_plus = isset( $post_custom['_mainwp_post_plus'] ) ? true : false;
|
||||
|
||||
$wp_error = null;
|
||||
|
||||
if ( $is_ezine_post || $is_post_plus ) {
|
||||
if ( $is_post_plus ) {
|
||||
if ( isset( $new_post['post_date_gmt'] ) && ! empty( $new_post['post_date_gmt'] ) && '0000-00-00 00:00:00' != $new_post['post_date_gmt'] ) {
|
||||
$post_date_timestamp = strtotime( $new_post['post_date_gmt'] ) + get_option( 'gmt_offset' ) * 60 * 60;
|
||||
$new_post['post_date'] = date( 'Y-m-d H:i:s', $post_date_timestamp );
|
||||
|
@ -485,7 +468,7 @@ class MainWP_Helper {
|
|||
|
||||
// Search for all the images added to the new post. Some images have a href tag to click to navigate to the image.. we need to replace this too.
|
||||
$foundMatches = preg_match_all( '/(<a[^>]+href=\"(.*?)\"[^>]*>)?(<img[^>\/]*src=\"((.*?)(png|gif|jpg|jpeg))\")/ix', $new_post['post_content'], $matches, PREG_SET_ORDER );
|
||||
if ( ( $foundMatches > 0 || ( $is_robot_post && isset( $wpr_options['wpr_save_images'] ) && 'Yes' === $wpr_options['wpr_save_images'] ) ) && ( ! $is_ezine_post ) ) {
|
||||
if ( $foundMatches > 0 ) {
|
||||
// We found images, now to download them so we can start balbal.
|
||||
foreach ( $matches as $match ) {
|
||||
$hrefLink = $match[2];
|
||||
|
@ -682,8 +665,7 @@ class MainWP_Helper {
|
|||
$not_allowed[] = '_saved_draft_random_publish_date';
|
||||
$not_allowed[] = '_saved_draft_publish_date_from';
|
||||
$not_allowed[] = '_saved_draft_publish_date_to';
|
||||
$not_allowed[] = '_post_to_only_existing_categories';
|
||||
$not_allowed[] = '_mainwp_robot_post_comments';
|
||||
$not_allowed[] = '_post_to_only_existing_categories';
|
||||
$not_allowed[] = '_mainwp_edit_post_site_id';
|
||||
$not_allowed[] = '_mainwp_edit_post_id';
|
||||
$not_allowed[] = '_edit_post_status';
|
||||
|
@ -857,12 +839,6 @@ class MainWP_Helper {
|
|||
);
|
||||
}
|
||||
|
||||
// MainWP Robot.
|
||||
if ( $is_robot_post ) {
|
||||
$all_comments = $post_custom['_mainwp_robot_post_comments'];
|
||||
MainWP_Child_Robot::Instance()->wpr_insertcomments( $new_post_id, $all_comments );
|
||||
}
|
||||
|
||||
// unlock if edit post.
|
||||
if ( $edit_post_id ) {
|
||||
update_post_meta( $edit_post_id, '_edit_lock', '' );
|
||||
|
@ -1055,11 +1031,8 @@ class MainWP_Helper {
|
|||
public static function clean( $string ) {
|
||||
$string = trim( $string );
|
||||
$string = htmlentities( $string, ENT_QUOTES );
|
||||
$string = str_replace( "\n", '<br>', $string );
|
||||
if ( get_magic_quotes_gpc() ) {
|
||||
$string = stripslashes( $string );
|
||||
}
|
||||
|
||||
$string = str_replace( "\n", '<br>', $string );
|
||||
$string = stripslashes( $string );
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
@ -1312,40 +1285,48 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
public static function get_lasttime_backup( $by ) {
|
||||
|
||||
if ( 'backupwp' == $by ) {
|
||||
$by = 'backupwordpress';
|
||||
}
|
||||
|
||||
$activated = true;
|
||||
switch ( $by ) {
|
||||
case 'backupbuddy':
|
||||
if ( ! is_plugin_active( 'backupbuddy/backupbuddy.php' ) && ! is_plugin_active( 'Backupbuddy/backupbuddy.php' ) ) {
|
||||
return 0;
|
||||
$activated = false;
|
||||
}
|
||||
break;
|
||||
case 'backupwordpress':
|
||||
if ( ! is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
|
||||
return 0;
|
||||
$activated = false;
|
||||
}
|
||||
break;
|
||||
case 'backwpup':
|
||||
if ( ! is_plugin_active( 'backwpup/backwpup.php' ) && ! is_plugin_active( 'backwpup-pro/backwpup.php' ) ) {
|
||||
return 0;
|
||||
$activated = false;
|
||||
}
|
||||
break;
|
||||
case 'updraftplus':
|
||||
if ( ! is_plugin_active( 'updraftplus/updraftplus.php' ) ) {
|
||||
return 0;
|
||||
$activated = false;
|
||||
}
|
||||
break;
|
||||
case 'wptimecapsule':
|
||||
if ( ! is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' ) ) {
|
||||
return 0;
|
||||
$activated = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
$activated = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! $activated )
|
||||
return 0;
|
||||
|
||||
return get_option( 'mainwp_lasttime_backup_' . $by, 0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1749,4 +1730,30 @@ class MainWP_Helper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method execute_snippet()
|
||||
*
|
||||
* Execute snippet code
|
||||
*
|
||||
* @param string $code The code *
|
||||
*
|
||||
* @return array result
|
||||
*/
|
||||
public static function execute_snippet( $code ) {
|
||||
ob_start();
|
||||
$result = eval( $code ); // phpcs:ignore Squiz.PHP.Eval -- eval() used safely.
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$return = array();
|
||||
$error = error_get_last();
|
||||
if ( ( false === $result ) && $error ) {
|
||||
$return['status'] = 'FAIL';
|
||||
$return['result'] = $error['message'];
|
||||
} else {
|
||||
$return['status'] = 'SUCCESS';
|
||||
$return['result'] = $output;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Keyword_Links {
|
||||
public static $instance = null;
|
||||
protected $config;
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Security {
|
||||
|
||||
/**
|
||||
* Method get_class_name()
|
||||
*
|
||||
* Get Class Name.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function get_class_name() {
|
||||
return __CLASS__;
|
||||
}
|
||||
|
||||
public static function fixAll() {
|
||||
self::remove_wp_version();
|
||||
self::remove_rsd();
|
||||
|
@ -10,10 +24,10 @@ class MainWP_Security {
|
|||
self::remove_generator_version();
|
||||
self::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 );
|
||||
add_filter( 'script_loader_src', array( 'MainWP_Security', 'remove_script_versions' ), PHP_INT_MAX );
|
||||
add_filter( 'script_loader_src', array( 'MainWP_Security', 'remove_theme_versions' ), PHP_INT_MAX );
|
||||
add_filter( 'style_loader_src', array( self::get_class_name(), 'remove_script_versions' ), PHP_INT_MAX );
|
||||
add_filter( 'style_loader_src', array( self::get_class_name(), 'remove_theme_versions' ), PHP_INT_MAX );
|
||||
add_filter( 'script_loader_src', array( self::get_class_name(), 'remove_script_versions' ), PHP_INT_MAX );
|
||||
add_filter( 'script_loader_src', array( self::get_class_name(), 'remove_theme_versions' ), PHP_INT_MAX );
|
||||
}
|
||||
|
||||
// Prevent listing wp-content, wp-content/plugins, wp-content/themes, wp-content/uploads.
|
||||
|
@ -49,9 +63,9 @@ class MainWP_Security {
|
|||
$file = $directory . DIRECTORY_SEPARATOR . 'index.php';
|
||||
if ( ! file_exists( $file ) ) {
|
||||
$h = fopen( $file, 'w' );
|
||||
fwrite( $h, '<?php ' . "\n" );
|
||||
fwrite( $h, "header(\$_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );" . "\n" );
|
||||
fwrite( $h, "die( '403 Forbidden' );" . "\n" );
|
||||
fwrite( $h, "<?php \n" );
|
||||
fwrite( $h, "header(\$_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );\n" );
|
||||
fwrite( $h, "die( '403 Forbidden' );\n" );
|
||||
fclose( $h );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
class MainWP_Tools {
|
||||
public static function execute_snippet( $code ) {
|
||||
ob_start();
|
||||
$result = eval( $code ); // phpcs:ignore Squiz.PHP.Eval -- eval() used safely.
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$return = array();
|
||||
$error = error_get_last();
|
||||
if ( ( false === $result ) && $error ) {
|
||||
$return['status'] = 'FAIL';
|
||||
$return['result'] = $error['message'];
|
||||
} else {
|
||||
$return['status'] = 'SUCCESS';
|
||||
$return['result'] = $output;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
|
@ -12,6 +12,8 @@
|
|||
* Extension URL: https://mainwp.com/extension/wordpress-seo/
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
class MainWP_Wordpress_SEO {
|
||||
public static $instance = null;
|
||||
|
||||
|
|
104
includes/functions.php
Normal file
104
includes/functions.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* MainWP Child Functions.
|
||||
*
|
||||
* @package MainWP/Child
|
||||
*/
|
||||
|
||||
if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyuse_nonce_hmac'] ) ) {
|
||||
$skeleton_keyuse_nonce_key = intval( $_GET['skeleton_keyuse_nonce_key'] );
|
||||
$skeleton_keyuse_nonce_hmac = $_GET['skeleton_keyuse_nonce_hmac'];
|
||||
$skeleton_keycurrent_time = intval( time() );
|
||||
|
||||
if ( $skeleton_keycurrent_time >= $skeleton_keyuse_nonce_key && $skeleton_keycurrent_time <= ( $skeleton_keyuse_nonce_key + 30 ) ) {
|
||||
|
||||
if ( strcmp( $skeleton_keyuse_nonce_hmac, hash_hmac( 'sha256', $skeleton_keyuse_nonce_key, NONCE_KEY ) ) === 0 ) {
|
||||
|
||||
if ( ! function_exists( 'wp_verify_nonce' ) ) :
|
||||
|
||||
/**
|
||||
* Verify that correct nonce was used with time limit.
|
||||
*
|
||||
* The user is given an amount of time to use the token, so therefore, since the
|
||||
* UID and $action remain the same, the independent variable is the time.
|
||||
*
|
||||
* @since 2.0.3
|
||||
*
|
||||
* @param string $nonce Nonce that was used in the form to verify
|
||||
* @param string|int $action Should give context to what is taking place and be the same when nonce was created.
|
||||
*
|
||||
* @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
|
||||
* 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
|
||||
*/
|
||||
function wp_verify_nonce( $nonce, $action = - 1 ) {
|
||||
$nonce = (string) $nonce;
|
||||
$user = wp_get_current_user();
|
||||
$uid = (int) $user->ID;
|
||||
if ( ! $uid ) {
|
||||
/**
|
||||
* Filter whether the user who generated the nonce is logged out.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param int $uid ID of the nonce-owning user.
|
||||
* @param string $action The nonce action.
|
||||
*/
|
||||
$uid = apply_filters( 'nonce_user_logged_out', $uid, $action );
|
||||
}
|
||||
|
||||
if ( empty( $nonce ) ) {
|
||||
|
||||
// To fix verify nonce conflict #1.
|
||||
// this is fake post field to fix some conflict of wp_verify_nonce().
|
||||
// just return false to unverify nonce, does not exit.
|
||||
if ( isset( $_POST[ $action ] ) && ( 'mainwp-bsm-unverify-nonce' == $_POST[ $action ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// to help tracing the conflict verify nonce with other plugins.
|
||||
ob_start();
|
||||
debug_print_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS );
|
||||
$stackTrace = "\n" . ob_get_clean();
|
||||
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action . '<br/>Trace: ' . $stackTrace ) ) ) . '</mainwp>' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
|
||||
}
|
||||
|
||||
// To fix verify nonce conflict #2.
|
||||
// this is fake nonce to fix some conflict of wp_verify_nonce().
|
||||
// just return false to unverify nonce, does not exit.
|
||||
if ( 'mainwp-bsm-unverify-nonce' == $nonce ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$token = wp_get_session_token();
|
||||
$i = wp_nonce_tick();
|
||||
|
||||
// Nonce generated 0-12 hours ago.
|
||||
$expected = substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), - 12, 10 );
|
||||
if ( hash_equals( $expected, $nonce ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Nonce generated 12-24 hours ago.
|
||||
$expected = substr( wp_hash( ( $i - 1 ) . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), - 12, 10 );
|
||||
if ( hash_equals( $expected, $nonce ) ) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
// To fix verify nonce conflict #3.
|
||||
// this is fake post field to fix some conflict of wp_verify_nonce().
|
||||
// just return false to unverify nonce, does not exit.
|
||||
if ( isset( $_POST[ $action ] ) && ( 'mainwp-bsm-unverify-nonce' == $_POST[ $action ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
debug_print_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS );
|
||||
$stackTrace = "\n" . ob_get_clean();
|
||||
|
||||
// Invalid nonce.
|
||||
die( '<mainwp>' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '<br/>Trace: ' . $stackTrace ) ) ) . '</mainwp>' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
|
||||
}
|
||||
endif;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,11 +16,25 @@ if ( ! defined( 'MAINWP_CHILD_FILE' ) ) {
|
|||
define( 'MAINWP_CHILD_FILE', __FILE__ );
|
||||
}
|
||||
|
||||
if ( ! defined( 'MAINWP_CHILD_PLUGIN_DIR' ) ) {
|
||||
define( 'MAINWP_CHILD_PLUGIN_DIR', plugin_dir_path( MAINWP_CHILD_FILE ) );
|
||||
}
|
||||
|
||||
if ( ! defined( 'MAINWP_CHILD_URL' ) ) {
|
||||
define( 'MAINWP_CHILD_URL', plugin_dir_url( MAINWP_CHILD_FILE ) );
|
||||
}
|
||||
|
||||
function mainwp_child_autoload( $class_name ) {
|
||||
|
||||
if ( 0 !== strpos( $class_name, 'MainWP\Child' ) )
|
||||
return;
|
||||
|
||||
// trip the namespace prefix: MainWP\Child\ .
|
||||
$class_name = substr( $class_name, 13 );
|
||||
if ( 0 !== strpos( $class_name, 'MainWP_' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$autoload_dir = \trailingslashit( dirname( __FILE__ ) . '/class' );
|
||||
$autoload_path = sprintf( '%sclass-%s.php', $autoload_dir, strtolower( str_replace( '_', '-', $class_name ) ) );
|
||||
|
||||
|
@ -33,6 +47,8 @@ if ( function_exists( 'spl_autoload_register' ) ) {
|
|||
spl_autoload_register( 'mainwp_child_autoload' );
|
||||
}
|
||||
|
||||
$mainWPChild = new MainWP_Child( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename( __FILE__ ) );
|
||||
require_once MAINWP_CHILD_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'functions.php';
|
||||
|
||||
$mainWPChild = new MainWP\Child\MainWP_Child( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename( __FILE__ ) );
|
||||
register_activation_hook( __FILE__, array( $mainWPChild, 'activation' ) );
|
||||
register_deactivation_hook( __FILE__, array( $mainWPChild, 'deactivation' ) );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue