/** * Handle the request */ public function request() { if (empty($_GET['auth_key'])) { $this->trigger_error(__('Authentication key is required!', 'woocommerce-shipstation')); } if (!hash_equals(sanitize_text_field($_GET['auth_key']), WC_ShipStation_Integration::$auth_key)) { $this->trigger_error(__('Invalid authentication key', 'woocommerce-shipstation')); } $request = $_GET; if (isset($request['action'])) { $this->request = array_map('sanitize_text_field', $request); } else { $this->trigger_error(__('Invalid request', 'woocommerce-shipstation')); } self::$authenticated = true; if (in_array($this->request['action'], array('export', 'shipnotify'))) { $this->log(sprintf(__('Input params: %s', 'woocommerce-shipstation'), http_build_query($this->request))); $request_class = (include 'api-requests/class-wc-shipstation-api-' . $this->request['action'] . '.php'); $request_class->request(); } else { $this->trigger_error(__('Invalid request', 'woocommerce-shipstation')); } exit; }
/** * Constructor */ public function __construct() { if (!WC_Shipstation_API::authenticated()) { exit; } }