mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- fixed user registration;
- phpDoc;
This commit is contained in:
@@ -4,35 +4,42 @@ namespace um\core;
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'Router' ) ) {
|
||||
class Router {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function backend_requests() {
|
||||
$ip = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '';
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
if ( empty( $_REQUEST['um_action'] ) )
|
||||
exit( __( 'Wrong action', 'ultimate-member' ) );
|
||||
/**
|
||||
* Class Router
|
||||
* @package um\core
|
||||
*/
|
||||
class Router {
|
||||
|
||||
if ( empty( $_REQUEST['um_resource'] ) )
|
||||
exit( __( 'Wrong resource', 'ultimate-member' ) );
|
||||
|
||||
if ( $_REQUEST['um_action'] == 'route' )
|
||||
$verify = wp_verify_nonce( $_REQUEST['um_verify'], $ip . $user_id . $_REQUEST['um_resource'] . $_REQUEST['um_method'] );
|
||||
else
|
||||
$verify = wp_verify_nonce( $_REQUEST['um_verify'], $ip . $user_id . $_REQUEST['um_action'] . $_REQUEST['um_resource'] );
|
||||
/**
|
||||
* Run backend process
|
||||
*/
|
||||
function backend_requests() {
|
||||
$ip = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '';
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
if ( empty( $verify ) )
|
||||
exit( __( 'Wrong nonce', 'ultimate-member' ) );
|
||||
if ( empty( $_REQUEST['um_action'] ) )
|
||||
exit( __( 'Wrong action', 'ultimate-member' ) );
|
||||
|
||||
$this->request_process( array(
|
||||
'route' => $_REQUEST['um_resource'],
|
||||
'method' => $_REQUEST['um_method']
|
||||
) );
|
||||
if ( empty( $_REQUEST['um_resource'] ) )
|
||||
exit( __( 'Wrong resource', 'ultimate-member' ) );
|
||||
|
||||
/*if ($_REQUEST['um_action'] == 'download' || $_REQUEST['um_action'] == 'view') {
|
||||
if ( $_REQUEST['um_action'] == 'route' )
|
||||
$verify = wp_verify_nonce( $_REQUEST['um_verify'], $ip . $user_id . $_REQUEST['um_resource'] . $_REQUEST['um_method'] );
|
||||
else
|
||||
$verify = wp_verify_nonce( $_REQUEST['um_verify'], $ip . $user_id . $_REQUEST['um_action'] . $_REQUEST['um_resource'] );
|
||||
|
||||
if ( empty( $verify ) )
|
||||
exit( __( 'Wrong nonce', 'ultimate-member' ) );
|
||||
|
||||
$this->request_process( array(
|
||||
'route' => $_REQUEST['um_resource'],
|
||||
'method' => $_REQUEST['um_method']
|
||||
) );
|
||||
|
||||
/*if ($_REQUEST['um_action'] == 'download' || $_REQUEST['um_action'] == 'view') {
|
||||
WO()->downloader()->set_type( $_REQUEST['um_action'] )->process( array(
|
||||
'id' => $_REQUEST['um_id'],
|
||||
'resource' => $_REQUEST['um_resource'],
|
||||
@@ -44,60 +51,65 @@ if ( ! class_exists( 'Router' ) ) {
|
||||
'method' => $_REQUEST['um_method']
|
||||
) );
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $params array
|
||||
* @return bool
|
||||
*/
|
||||
function request_process( $params ) {
|
||||
if ( empty( $params['route'] ) || empty( $params['method'] ) )
|
||||
return false;
|
||||
/**
|
||||
* Request process
|
||||
*
|
||||
* @param $params array
|
||||
* @return bool
|
||||
*/
|
||||
function request_process( $params ) {
|
||||
if ( empty( $params['route'] ) || empty( $params['method'] ) )
|
||||
return false;
|
||||
|
||||
$route = str_replace( array( '!', '/' ), '\\', $params['route'] );
|
||||
$route = str_replace( array( '!', '/' ), '\\', $params['route'] );
|
||||
|
||||
if ( ! class_exists( $route ) )
|
||||
return false;
|
||||
if ( ! class_exists( $route ) )
|
||||
return false;
|
||||
|
||||
if ( method_exists( $route, 'instance' ) )
|
||||
$object = $route::instance();
|
||||
else
|
||||
$object = new $route();
|
||||
if ( method_exists( $route, 'instance' ) )
|
||||
$object = $route::instance();
|
||||
else
|
||||
$object = new $route();
|
||||
|
||||
if ( ! method_exists( $object, $params['method'] ) )
|
||||
return false;
|
||||
if ( ! method_exists( $object, $params['method'] ) )
|
||||
return false;
|
||||
|
||||
|
||||
call_user_func( array( &$object, $params['method'] ) );
|
||||
return true;
|
||||
}
|
||||
call_user_func( array( &$object, $params['method'] ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function frontend_requests() {
|
||||
$ip = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '';
|
||||
$user_id = get_current_user_id();
|
||||
if ( ! get_query_var( 'um_action' ) )
|
||||
exit( __( 'Wrong action', 'ultimate-member' ) );
|
||||
/**
|
||||
* Run frontend process
|
||||
*/
|
||||
function frontend_requests() {
|
||||
$ip = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '';
|
||||
$user_id = get_current_user_id();
|
||||
if ( ! get_query_var( 'um_action' ) )
|
||||
exit( __( 'Wrong action', 'ultimate-member' ) );
|
||||
|
||||
if ( ! get_query_var( 'um_resource' ) )
|
||||
exit( __( 'Wrong resource', 'ultimate-member' ) );
|
||||
if ( ! get_query_var( 'um_resource' ) )
|
||||
exit( __( 'Wrong resource', 'ultimate-member' ) );
|
||||
|
||||
$verify = false;
|
||||
if ( get_query_var( 'um_action' ) == 'route' )
|
||||
$verify = wp_verify_nonce( get_query_var( 'um_verify' ), $ip . $user_id . get_query_var( 'um_resource' ) . get_query_var( 'um_method' ) );
|
||||
$verify = false;
|
||||
if ( get_query_var( 'um_action' ) == 'route' )
|
||||
$verify = wp_verify_nonce( get_query_var( 'um_verify' ), $ip . $user_id . get_query_var( 'um_resource' ) . get_query_var( 'um_method' ) );
|
||||
|
||||
if ( $verify ) {
|
||||
if ( get_query_var( 'um_action' ) == 'route' ) {
|
||||
$this->request_process( array(
|
||||
'route' => get_query_var( 'um_resource' ),
|
||||
'method' => get_query_var( 'um_method' )
|
||||
) );
|
||||
}
|
||||
} else {
|
||||
exit( __( 'Wrong nonce', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
if ( $verify ) {
|
||||
if ( get_query_var( 'um_action' ) == 'route' ) {
|
||||
$this->request_process( array(
|
||||
'route' => get_query_var( 'um_resource' ),
|
||||
'method' => get_query_var( 'um_method' )
|
||||
) );
|
||||
}
|
||||
} else {
|
||||
exit( __( 'Wrong nonce', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user