get_website_by_id( $id );
if ( ! MainWP_System_Utility::can_edit_website( $website ) ) {
exit();
}
$location = '';
if ( isset( $_GET['location'] ) ) {
$location = base64_decode( wp_unslash( $_GET['location'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_decode used for HTTP compatible char.
}
if ( isset( $_GET['openUrl'] ) && 'yes' === $_GET['openUrl'] ) {
static::open_site_location( $website, $location );
} else {
$allow_params = array();
$allow_vars = array(
'filedl',
'dirdl',
);
$allow_vars = apply_filters( 'mainwp_open_site_allow_vars', $allow_vars );
if ( is_array( $allow_vars ) ) {
foreach ( $allow_vars as $var ) {
if ( is_string( $var ) && isset( $_GET[ $var ] ) ) {
$allow_params[ $var ] = $_GET[ $var ]; // phpcs:ignore -- ok.
}
}
}
static::open_site( $website, $location, $allow_params );
}
// phpcs:enable
}
/**
* This method opens the requested Child Site Admin.
*
* @param mixed $website Website ID.
* @param mixed $location Website Location.
* @param array $params others params.
*
* @uses \MainWP\Dashboard\MainWP_Connect::get_get_data_authed()
*/
private static function open_site( $website, $location, $params = array() ) {
if ( MainWP_Demo_Handle::get_instance()->is_demo_website( $website ) ) {
$action = $website->url . 'wp-admin.html';
} else {
$action = MainWP_Connect::get_get_data_authed( $website, ( null === $location || '' === $location ) ? 'index.php' : $location, 'where', false, $params );
}
$open_download = ! empty( $params['filedl'] ) ? true : false;
$close_window = ! empty( $_GET['closeWindow'] ) ? true : false; //phpcs:ignore -- ok.
?>
get_website_by_id( $id );
if ( ! MainWP_System_Utility::can_edit_website( $website ) ) {
exit();
}
$file = '';
if ( isset( $_GET['f'] ) ) {
$file = base64_decode( esc_html( wp_unslash( $_GET['f'] ) ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
}
$site = isset( $_GET['size'] ) ? esc_html( wp_unslash( $_GET['size'] ) ) : '';
// phpcs:enable
static::open_site_restore( $website, $file, $site );
}
/**
* This opens the site restore.
*
* @param mixed $website Website ID.
* @param mixed $file Restore File.
* @param mixed $size Post data size.
*
* @uses \MainWP\Dashboard\MainWP_Connect::get_get_data_authed()
*/
public static function open_site_restore( $website, $file, $size ) {
?>
url ) && '' !== $website->url ? $website->url : $website->siteurl );
$url .= ( '/' !== substr( $url, - 1 ) ? '/' : '' );
$postdata = MainWP_Connect::get_get_data_authed( $website, $file, 'f', true );
$postdata['size'] = $size;
?>
url ) && '' !== $website->url ? $website->url : $website->siteurl );
$url .= ( '/' !== substr( $url, - 1 ) ? '/' : '' );
$postdata = MainWP_Connect::get_get_data_authed( $website, 'index.php', 'where', true );
$postdata['open_location'] = $open_location; // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode used for http encoding compatible.
?>
id;
} else {
return '';
}
$open_url = '';
if ( MainWP_Demo_Handle::get_instance()->is_demo_website( $site_id ) ) {
$open_url = MainWP_Demo_Handle::get_instance()->get_open_site_demo_url( $site_id );
} else {
$open_url = 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . $site_id . '&_opennonce=' . esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) );
if ( ! empty( $location ) ) {
$open_url .= '&location=' . $location;
}
}
if ( $echo_out ) {
echo $open_url; //phpcs:ignore WordPress.Security.EscapeOutput
}
return $open_url;
}
}