PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.19.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.19.2
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / API / Controller / EntryController.php

EntryController.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.19.2, at includes/API/Controller/EntryController.php

59 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\API\Controller;
4
5 use BitCode\BitForm\Core\Database\FormModel;
6 use WP_Error;
7 use WP_REST_Controller;
8 use WP_REST_Request;
9
10 class EntryController extends WP_REST_Controller
11 {
12 protected static $form;
13 protected $formModel;
14 protected $form_id;
15
16 public function __construct()
17 {
18 $this->formModel = new FormModel();
19 }
20
21 // public function oneDriveAuth()
22 // {
23 // $state = $_GET['state'];
24 // $code = urlencode($_GET['code']);
25 // // echo $code;
26 // if (wp_redirect($state . '&code=' . $code, 302)) {
27 // exit;
28 // }
29 // }
30
31 public function authRedirect(WP_REST_Request $request)
32 {
33 $state = $request->get_param('state');
34 $site_url = $this->getDomain(get_site_url());
35 $state_domain = $this->getDomain($state);
36
37 if ($site_url !== $state_domain) {
38 return new WP_Error('404', 'Invalid redirect URL: ' . $state_domain);
39 }
40
41 $params = $request->get_params();
42 unset($params['rest_route'], $params['state']);
43
44 $redirect_url = $state . '&' . http_build_query($params);
45
46 if (wp_redirect($redirect_url, 302)) {
47 exit;
48 }
49 }
50
51 private function getDomain($url)
52 {
53 $parsed_url = wp_parse_url($url);
54 $domain = $parsed_url['scheme'] . '://' . $parsed_url['host'];
55 $domain .= empty($parsed_url['port']) ? null : ':' . $parsed_url['port'];
56 return $domain;
57 }
58 }
59