@@ -19,57 +19,57 @@ |
||
19 | 19 | class TicketSelectorSimple extends TicketSelector |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var EE_Ticket $ticket |
|
24 | - */ |
|
25 | - protected $ticket; |
|
22 | + /** |
|
23 | + * @var EE_Ticket $ticket |
|
24 | + */ |
|
25 | + protected $ticket; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * TicketSelectorSimple constructor. |
|
30 | - * |
|
31 | - * @param EE_Event $event |
|
32 | - * @param EE_Ticket $ticket |
|
33 | - * @param int $max_attendees |
|
34 | - * @param array $template_args |
|
35 | - * @throws EE_Error |
|
36 | - */ |
|
37 | - public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args) |
|
38 | - { |
|
39 | - $this->ticket = $ticket; |
|
40 | - parent::__construct( |
|
41 | - $event, |
|
42 | - array($this->ticket), |
|
43 | - $max_attendees, |
|
44 | - $template_args |
|
45 | - ); |
|
46 | - } |
|
28 | + /** |
|
29 | + * TicketSelectorSimple constructor. |
|
30 | + * |
|
31 | + * @param EE_Event $event |
|
32 | + * @param EE_Ticket $ticket |
|
33 | + * @param int $max_attendees |
|
34 | + * @param array $template_args |
|
35 | + * @throws EE_Error |
|
36 | + */ |
|
37 | + public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args) |
|
38 | + { |
|
39 | + $this->ticket = $ticket; |
|
40 | + parent::__construct( |
|
41 | + $event, |
|
42 | + array($this->ticket), |
|
43 | + $max_attendees, |
|
44 | + $template_args |
|
45 | + ); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * sets any and all template args that are required for this Ticket Selector |
|
51 | - * |
|
52 | - * @return void |
|
53 | - * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
54 | - * @throws EE_Error |
|
55 | - */ |
|
56 | - protected function addTemplateArgs() |
|
57 | - { |
|
58 | - unset($this->template_args['tickets']); |
|
59 | - $this->template_args['ticket'] = $this->ticket; |
|
60 | - $ticket_selector_row = new TicketSelectorRowSimple( |
|
61 | - $this->ticket, |
|
62 | - $this->max_attendees, |
|
63 | - $this->template_args['date_format'], |
|
64 | - $this->template_args['event_status'] |
|
65 | - ); |
|
66 | - $this->template_args['TKT_ID'] = $this->ticket->ID(); |
|
67 | - $ticket_selector_row->setupTicketStatusDisplay(); |
|
68 | - $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
|
69 | - if (empty($this->template_args['ticket_status_display'])) { |
|
70 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
71 | - } |
|
72 | - $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription(); |
|
73 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
74 | - } |
|
49 | + /** |
|
50 | + * sets any and all template args that are required for this Ticket Selector |
|
51 | + * |
|
52 | + * @return void |
|
53 | + * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
54 | + * @throws EE_Error |
|
55 | + */ |
|
56 | + protected function addTemplateArgs() |
|
57 | + { |
|
58 | + unset($this->template_args['tickets']); |
|
59 | + $this->template_args['ticket'] = $this->ticket; |
|
60 | + $ticket_selector_row = new TicketSelectorRowSimple( |
|
61 | + $this->ticket, |
|
62 | + $this->max_attendees, |
|
63 | + $this->template_args['date_format'], |
|
64 | + $this->template_args['event_status'] |
|
65 | + ); |
|
66 | + $this->template_args['TKT_ID'] = $this->ticket->ID(); |
|
67 | + $ticket_selector_row->setupTicketStatusDisplay(); |
|
68 | + $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
|
69 | + if (empty($this->template_args['ticket_status_display'])) { |
|
70 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
71 | + } |
|
72 | + $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription(); |
|
73 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
74 | + } |
|
75 | 75 | } |
@@ -70,6 +70,6 @@ |
||
70 | 70 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
71 | 71 | } |
72 | 72 | $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription(); |
73 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
73 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'simple_ticket_selector.template.php'; |
|
74 | 74 | } |
75 | 75 | } |
@@ -12,107 +12,107 @@ |
||
12 | 12 | abstract class TicketSelector |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @var \EE_Event $event |
|
17 | - */ |
|
18 | - protected $event; |
|
19 | - |
|
20 | - /** |
|
21 | - * @var \EE_Ticket[] $tickets |
|
22 | - */ |
|
23 | - protected $tickets; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var int max_attendees |
|
27 | - */ |
|
28 | - protected $max_attendees; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var array $template_args |
|
32 | - */ |
|
33 | - protected $template_args; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * TicketSelectorSimple constructor. |
|
38 | - * |
|
39 | - * @param \EE_Event $event |
|
40 | - * @param \EE_Ticket[] $tickets |
|
41 | - * @param int $max_attendees |
|
42 | - * @param array $template_args |
|
43 | - * @throws \EE_Error |
|
44 | - */ |
|
45 | - public function __construct(\EE_Event $event, array $tickets, $max_attendees, array $template_args) |
|
46 | - { |
|
47 | - $this->event = $event; |
|
48 | - $this->tickets = $tickets; |
|
49 | - $this->max_attendees = $max_attendees; |
|
50 | - $this->template_args = $template_args; |
|
51 | - $this->template_args['hidden_inputs'] = $this->getHiddenInputs(); |
|
52 | - $this->addTemplateArgs(); |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * sets any and all template args that are required for this Ticket Selector |
|
58 | - * |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - abstract protected function addTemplateArgs(); |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * loadTicketSelectorTemplate |
|
66 | - * |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - protected function loadTicketSelectorTemplate() |
|
70 | - { |
|
71 | - try { |
|
72 | - return \EEH_Template::locate_template( |
|
73 | - apply_filters( |
|
74 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', |
|
75 | - $this->template_args['template_path'], |
|
76 | - $this->event |
|
77 | - ), |
|
78 | - $this->template_args |
|
79 | - ); |
|
80 | - } catch (\Exception $e) { |
|
81 | - \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
82 | - } |
|
83 | - return ''; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * The __toString method allows a class to decide how it will react when it is converted to a string. |
|
89 | - * |
|
90 | - * @return string |
|
91 | - * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring |
|
92 | - */ |
|
93 | - public function __toString() |
|
94 | - { |
|
95 | - return $this->loadTicketSelectorTemplate(); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * getHiddenInputs |
|
101 | - * |
|
102 | - * @return string |
|
103 | - * @throws \EE_Error |
|
104 | - */ |
|
105 | - public function getHiddenInputs() |
|
106 | - { |
|
107 | - // $rows = count($this->tickets); |
|
108 | - $html = '<input type="hidden" name="noheader" value="true"/>'; |
|
109 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"'; |
|
110 | - $html .= ' value="' . \EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>'; |
|
111 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID(); |
|
112 | - $html .= '" value="' . count($this->tickets) . '"/>'; |
|
113 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID(); |
|
114 | - $html .= '" value="' . $this->template_args['max_atndz'] . '"/>'; |
|
115 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>'; |
|
116 | - return $html; |
|
117 | - } |
|
15 | + /** |
|
16 | + * @var \EE_Event $event |
|
17 | + */ |
|
18 | + protected $event; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var \EE_Ticket[] $tickets |
|
22 | + */ |
|
23 | + protected $tickets; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var int max_attendees |
|
27 | + */ |
|
28 | + protected $max_attendees; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var array $template_args |
|
32 | + */ |
|
33 | + protected $template_args; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * TicketSelectorSimple constructor. |
|
38 | + * |
|
39 | + * @param \EE_Event $event |
|
40 | + * @param \EE_Ticket[] $tickets |
|
41 | + * @param int $max_attendees |
|
42 | + * @param array $template_args |
|
43 | + * @throws \EE_Error |
|
44 | + */ |
|
45 | + public function __construct(\EE_Event $event, array $tickets, $max_attendees, array $template_args) |
|
46 | + { |
|
47 | + $this->event = $event; |
|
48 | + $this->tickets = $tickets; |
|
49 | + $this->max_attendees = $max_attendees; |
|
50 | + $this->template_args = $template_args; |
|
51 | + $this->template_args['hidden_inputs'] = $this->getHiddenInputs(); |
|
52 | + $this->addTemplateArgs(); |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * sets any and all template args that are required for this Ticket Selector |
|
58 | + * |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + abstract protected function addTemplateArgs(); |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * loadTicketSelectorTemplate |
|
66 | + * |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + protected function loadTicketSelectorTemplate() |
|
70 | + { |
|
71 | + try { |
|
72 | + return \EEH_Template::locate_template( |
|
73 | + apply_filters( |
|
74 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', |
|
75 | + $this->template_args['template_path'], |
|
76 | + $this->event |
|
77 | + ), |
|
78 | + $this->template_args |
|
79 | + ); |
|
80 | + } catch (\Exception $e) { |
|
81 | + \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
82 | + } |
|
83 | + return ''; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * The __toString method allows a class to decide how it will react when it is converted to a string. |
|
89 | + * |
|
90 | + * @return string |
|
91 | + * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring |
|
92 | + */ |
|
93 | + public function __toString() |
|
94 | + { |
|
95 | + return $this->loadTicketSelectorTemplate(); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * getHiddenInputs |
|
101 | + * |
|
102 | + * @return string |
|
103 | + * @throws \EE_Error |
|
104 | + */ |
|
105 | + public function getHiddenInputs() |
|
106 | + { |
|
107 | + // $rows = count($this->tickets); |
|
108 | + $html = '<input type="hidden" name="noheader" value="true"/>'; |
|
109 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"'; |
|
110 | + $html .= ' value="' . \EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>'; |
|
111 | + $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID(); |
|
112 | + $html .= '" value="' . count($this->tickets) . '"/>'; |
|
113 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID(); |
|
114 | + $html .= '" value="' . $this->template_args['max_atndz'] . '"/>'; |
|
115 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>'; |
|
116 | + return $html; |
|
117 | + } |
|
118 | 118 | } |
@@ -106,13 +106,13 @@ |
||
106 | 106 | { |
107 | 107 | // $rows = count($this->tickets); |
108 | 108 | $html = '<input type="hidden" name="noheader" value="true"/>'; |
109 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"'; |
|
110 | - $html .= ' value="' . \EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>'; |
|
111 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID(); |
|
112 | - $html .= '" value="' . count($this->tickets) . '"/>'; |
|
113 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID(); |
|
114 | - $html .= '" value="' . $this->template_args['max_atndz'] . '"/>'; |
|
115 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>'; |
|
109 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-'.$this->event->ID().'"'; |
|
110 | + $html .= ' value="'.\EEH_URL::current_url().$this->template_args['anchor_id'].'"/>'; |
|
111 | + $html .= '<input type="hidden" name="tkt-slctr-rows-'.$this->event->ID(); |
|
112 | + $html .= '" value="'.count($this->tickets).'"/>'; |
|
113 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-'.$this->event->ID(); |
|
114 | + $html .= '" value="'.$this->template_args['max_atndz'].'"/>'; |
|
115 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="'.$this->event->ID().'"/>'; |
|
116 | 116 | return $html; |
117 | 117 | } |
118 | 118 | } |
@@ -15,55 +15,55 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * EventsArchiveIframe constructor. |
|
20 | - * |
|
21 | - * @param \EED_Events_Archive $EED_Events_Archive |
|
22 | - * @throws \DomainException |
|
23 | - */ |
|
24 | - public function __construct($EED_Events_Archive) |
|
25 | - { |
|
26 | - \EE_Registry::instance()->REQ->set_espresso_page(true); |
|
27 | - add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true'); |
|
28 | - $EED_Events_Archive->event_list(); |
|
29 | - /** @var \EventEspresso\core\domain\entities\shortcodes\EspressoEvents $event_list */ |
|
30 | - $event_list = \EE_Registry::instance()->create('EventEspresso\core\domain\entities\shortcodes\EspressoEvents'); |
|
31 | - parent::__construct( |
|
32 | - esc_html__('Event List', 'event_espresso'), |
|
33 | - $event_list->processShortcode() |
|
34 | - ); |
|
35 | - $this->addStylesheets( |
|
36 | - apply_filters( |
|
37 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
38 | - array( |
|
39 | - 'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
40 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
41 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
42 | - ), |
|
43 | - $this |
|
44 | - ) |
|
45 | - ); |
|
46 | - $this->addScripts( |
|
47 | - apply_filters( |
|
48 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
49 | - array( |
|
50 | - 'gmap_api' => sprintf( |
|
51 | - 'https://maps.googleapis.com/maps/api/js?key=%s', |
|
52 | - apply_filters( |
|
53 | - 'FHEE__EEH_Maps__espresso_google_maps_js__api_key', |
|
54 | - \EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
55 | - ) |
|
56 | - ), |
|
57 | - 'ee_gmap' => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0', |
|
58 | - ), |
|
59 | - $this |
|
60 | - ) |
|
61 | - ); |
|
62 | - $this->addLocalizedVars( |
|
63 | - array( |
|
64 | - 'ee_gmap' => \EEH_Maps::$gmap_vars, |
|
65 | - ), |
|
66 | - 'ee_gmap_vars' |
|
67 | - ); |
|
68 | - } |
|
18 | + /** |
|
19 | + * EventsArchiveIframe constructor. |
|
20 | + * |
|
21 | + * @param \EED_Events_Archive $EED_Events_Archive |
|
22 | + * @throws \DomainException |
|
23 | + */ |
|
24 | + public function __construct($EED_Events_Archive) |
|
25 | + { |
|
26 | + \EE_Registry::instance()->REQ->set_espresso_page(true); |
|
27 | + add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true'); |
|
28 | + $EED_Events_Archive->event_list(); |
|
29 | + /** @var \EventEspresso\core\domain\entities\shortcodes\EspressoEvents $event_list */ |
|
30 | + $event_list = \EE_Registry::instance()->create('EventEspresso\core\domain\entities\shortcodes\EspressoEvents'); |
|
31 | + parent::__construct( |
|
32 | + esc_html__('Event List', 'event_espresso'), |
|
33 | + $event_list->processShortcode() |
|
34 | + ); |
|
35 | + $this->addStylesheets( |
|
36 | + apply_filters( |
|
37 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
38 | + array( |
|
39 | + 'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
40 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
41 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
42 | + ), |
|
43 | + $this |
|
44 | + ) |
|
45 | + ); |
|
46 | + $this->addScripts( |
|
47 | + apply_filters( |
|
48 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
49 | + array( |
|
50 | + 'gmap_api' => sprintf( |
|
51 | + 'https://maps.googleapis.com/maps/api/js?key=%s', |
|
52 | + apply_filters( |
|
53 | + 'FHEE__EEH_Maps__espresso_google_maps_js__api_key', |
|
54 | + \EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
55 | + ) |
|
56 | + ), |
|
57 | + 'ee_gmap' => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0', |
|
58 | + ), |
|
59 | + $this |
|
60 | + ) |
|
61 | + ); |
|
62 | + $this->addLocalizedVars( |
|
63 | + array( |
|
64 | + 'ee_gmap' => \EEH_Maps::$gmap_vars, |
|
65 | + ), |
|
66 | + 'ee_gmap_vars' |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | apply_filters( |
37 | 37 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
38 | 38 | array( |
39 | - 'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
40 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
41 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
39 | + 'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css') |
|
40 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION |
|
41 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION, |
|
42 | 42 | ), |
43 | 43 | $this |
44 | 44 | ) |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | \EE_Registry::instance()->CFG->map_settings->google_map_api_key |
55 | 55 | ) |
56 | 56 | ), |
57 | - 'ee_gmap' => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0', |
|
57 | + 'ee_gmap' => EE_HELPERS_ASSETS.'ee_gmap.js?ver=1.0', |
|
58 | 58 | ), |
59 | 59 | $this |
60 | 60 | ) |
@@ -27,241 +27,241 @@ |
||
27 | 27 | class InvisibleRecaptcha |
28 | 28 | { |
29 | 29 | |
30 | - const URL_GOOGLE_RECAPTCHA_API = 'https://www.google.com/recaptcha/api/siteverify'; |
|
30 | + const URL_GOOGLE_RECAPTCHA_API = 'https://www.google.com/recaptcha/api/siteverify'; |
|
31 | 31 | |
32 | - const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed'; |
|
32 | + const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed'; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var EE_Registration_Config $config |
|
36 | - */ |
|
37 | - private $config; |
|
34 | + /** |
|
35 | + * @var EE_Registration_Config $config |
|
36 | + */ |
|
37 | + private $config; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var EE_Session $session |
|
41 | - */ |
|
42 | - private $session; |
|
39 | + /** |
|
40 | + * @var EE_Session $session |
|
41 | + */ |
|
42 | + private $session; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var boolean $recaptcha_passed |
|
46 | - */ |
|
47 | - private $recaptcha_passed; |
|
44 | + /** |
|
45 | + * @var boolean $recaptcha_passed |
|
46 | + */ |
|
47 | + private $recaptcha_passed; |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * InvisibleRecaptcha constructor. |
|
52 | - * |
|
53 | - * @param EE_Registration_Config $registration_config |
|
54 | - * @param EE_Session $session |
|
55 | - */ |
|
56 | - public function __construct(EE_Registration_Config $registration_config, EE_Session $session) |
|
57 | - { |
|
58 | - $this->config = $registration_config; |
|
59 | - $this->session = $session; |
|
60 | - } |
|
50 | + /** |
|
51 | + * InvisibleRecaptcha constructor. |
|
52 | + * |
|
53 | + * @param EE_Registration_Config $registration_config |
|
54 | + * @param EE_Session $session |
|
55 | + */ |
|
56 | + public function __construct(EE_Registration_Config $registration_config, EE_Session $session) |
|
57 | + { |
|
58 | + $this->config = $registration_config; |
|
59 | + $this->session = $session; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return boolean |
|
65 | - */ |
|
66 | - public function useInvisibleRecaptcha() |
|
67 | - { |
|
68 | - return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible'; |
|
69 | - } |
|
63 | + /** |
|
64 | + * @return boolean |
|
65 | + */ |
|
66 | + public function useInvisibleRecaptcha() |
|
67 | + { |
|
68 | + return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible'; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * @param array $input_settings |
|
74 | - * @return EE_Invisible_Recaptcha_Input |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - * @throws InvalidArgumentException |
|
78 | - * @throws DomainException |
|
79 | - */ |
|
80 | - public function getInput(array $input_settings = array()) |
|
81 | - { |
|
82 | - return new EE_Invisible_Recaptcha_Input( |
|
83 | - $input_settings, |
|
84 | - $this->config |
|
85 | - ); |
|
86 | - } |
|
72 | + /** |
|
73 | + * @param array $input_settings |
|
74 | + * @return EE_Invisible_Recaptcha_Input |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + * @throws InvalidArgumentException |
|
78 | + * @throws DomainException |
|
79 | + */ |
|
80 | + public function getInput(array $input_settings = array()) |
|
81 | + { |
|
82 | + return new EE_Invisible_Recaptcha_Input( |
|
83 | + $input_settings, |
|
84 | + $this->config |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * @param array $input_settings |
|
91 | - * @return string |
|
92 | - * @throws EE_Error |
|
93 | - * @throws InvalidDataTypeException |
|
94 | - * @throws InvalidInterfaceException |
|
95 | - * @throws InvalidArgumentException |
|
96 | - * @throws DomainException |
|
97 | - */ |
|
98 | - public function getInputHtml(array $input_settings = array()) |
|
99 | - { |
|
100 | - return $this->getInput($input_settings)->get_html_for_input(); |
|
101 | - } |
|
89 | + /** |
|
90 | + * @param array $input_settings |
|
91 | + * @return string |
|
92 | + * @throws EE_Error |
|
93 | + * @throws InvalidDataTypeException |
|
94 | + * @throws InvalidInterfaceException |
|
95 | + * @throws InvalidArgumentException |
|
96 | + * @throws DomainException |
|
97 | + */ |
|
98 | + public function getInputHtml(array $input_settings = array()) |
|
99 | + { |
|
100 | + return $this->getInput($input_settings)->get_html_for_input(); |
|
101 | + } |
|
102 | 102 | |
103 | 103 | |
104 | - /** |
|
105 | - * @param EE_Form_Section_Proper $form |
|
106 | - * @param array $input_settings |
|
107 | - * @throws EE_Error |
|
108 | - * @throws InvalidArgumentException |
|
109 | - * @throws InvalidDataTypeException |
|
110 | - * @throws InvalidInterfaceException |
|
111 | - * @throws DomainException |
|
112 | - */ |
|
113 | - public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array()) |
|
114 | - { |
|
115 | - $form->add_subsections( |
|
116 | - array( |
|
117 | - 'espresso_recaptcha' => $this->getInput($input_settings), |
|
118 | - ), |
|
119 | - null, |
|
120 | - false |
|
121 | - ); |
|
122 | - } |
|
104 | + /** |
|
105 | + * @param EE_Form_Section_Proper $form |
|
106 | + * @param array $input_settings |
|
107 | + * @throws EE_Error |
|
108 | + * @throws InvalidArgumentException |
|
109 | + * @throws InvalidDataTypeException |
|
110 | + * @throws InvalidInterfaceException |
|
111 | + * @throws DomainException |
|
112 | + */ |
|
113 | + public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array()) |
|
114 | + { |
|
115 | + $form->add_subsections( |
|
116 | + array( |
|
117 | + 'espresso_recaptcha' => $this->getInput($input_settings), |
|
118 | + ), |
|
119 | + null, |
|
120 | + false |
|
121 | + ); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * @param EE_Request $request |
|
127 | - * @return boolean |
|
128 | - * @throws RuntimeException |
|
129 | - */ |
|
130 | - public function verifyToken(EE_Request $request) |
|
131 | - { |
|
132 | - static $previous_recaptcha_response = array(); |
|
133 | - $grecaptcha_response = $request->get('g-recaptcha-response'); |
|
134 | - // if this token has already been verified, then return previous response |
|
135 | - if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
136 | - return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
137 | - } |
|
138 | - // will update to true if everything passes |
|
139 | - $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
140 | - $response = wp_safe_remote_post( |
|
141 | - InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
|
142 | - array( |
|
143 | - 'body' => array( |
|
144 | - 'secret' => $this->config->recaptcha_privatekey, |
|
145 | - 'response' => $grecaptcha_response, |
|
146 | - 'remoteip' => $request->ip_address(), |
|
147 | - ), |
|
148 | - ) |
|
149 | - ); |
|
150 | - if ($response instanceof WP_Error) { |
|
151 | - $this->generateError($response->get_error_messages()); |
|
152 | - return false; |
|
153 | - } |
|
154 | - $results = json_decode(wp_remote_retrieve_body($response), true); |
|
155 | - if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
|
156 | - $errors = array_map( |
|
157 | - array($this, 'getErrorCode'), |
|
158 | - $results['error-codes'] |
|
159 | - ); |
|
160 | - if (isset($results['challenge_ts'])) { |
|
161 | - $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
162 | - } |
|
163 | - $this->generateError(implode(' ', $errors)); |
|
164 | - } |
|
165 | - $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
166 | - add_action('shutdown', array($this, 'setSessionData')); |
|
167 | - return true; |
|
168 | - } |
|
125 | + /** |
|
126 | + * @param EE_Request $request |
|
127 | + * @return boolean |
|
128 | + * @throws RuntimeException |
|
129 | + */ |
|
130 | + public function verifyToken(EE_Request $request) |
|
131 | + { |
|
132 | + static $previous_recaptcha_response = array(); |
|
133 | + $grecaptcha_response = $request->get('g-recaptcha-response'); |
|
134 | + // if this token has already been verified, then return previous response |
|
135 | + if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
136 | + return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
137 | + } |
|
138 | + // will update to true if everything passes |
|
139 | + $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
140 | + $response = wp_safe_remote_post( |
|
141 | + InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
|
142 | + array( |
|
143 | + 'body' => array( |
|
144 | + 'secret' => $this->config->recaptcha_privatekey, |
|
145 | + 'response' => $grecaptcha_response, |
|
146 | + 'remoteip' => $request->ip_address(), |
|
147 | + ), |
|
148 | + ) |
|
149 | + ); |
|
150 | + if ($response instanceof WP_Error) { |
|
151 | + $this->generateError($response->get_error_messages()); |
|
152 | + return false; |
|
153 | + } |
|
154 | + $results = json_decode(wp_remote_retrieve_body($response), true); |
|
155 | + if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
|
156 | + $errors = array_map( |
|
157 | + array($this, 'getErrorCode'), |
|
158 | + $results['error-codes'] |
|
159 | + ); |
|
160 | + if (isset($results['challenge_ts'])) { |
|
161 | + $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
162 | + } |
|
163 | + $this->generateError(implode(' ', $errors)); |
|
164 | + } |
|
165 | + $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
166 | + add_action('shutdown', array($this, 'setSessionData')); |
|
167 | + return true; |
|
168 | + } |
|
169 | 169 | |
170 | 170 | |
171 | - /** |
|
172 | - * @param string $error_response |
|
173 | - * @return void |
|
174 | - * @throws RuntimeException |
|
175 | - */ |
|
176 | - public function generateError($error_response = '') |
|
177 | - { |
|
178 | - throw new RuntimeException( |
|
179 | - sprintf( |
|
180 | - esc_html__( |
|
181 | - 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.', |
|
182 | - 'event_espresso' |
|
183 | - ), |
|
184 | - '<br />', |
|
185 | - current_user_can('manage_options') ? $error_response : '' |
|
186 | - ) |
|
187 | - ); |
|
188 | - } |
|
171 | + /** |
|
172 | + * @param string $error_response |
|
173 | + * @return void |
|
174 | + * @throws RuntimeException |
|
175 | + */ |
|
176 | + public function generateError($error_response = '') |
|
177 | + { |
|
178 | + throw new RuntimeException( |
|
179 | + sprintf( |
|
180 | + esc_html__( |
|
181 | + 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.', |
|
182 | + 'event_espresso' |
|
183 | + ), |
|
184 | + '<br />', |
|
185 | + current_user_can('manage_options') ? $error_response : '' |
|
186 | + ) |
|
187 | + ); |
|
188 | + } |
|
189 | 189 | |
190 | 190 | |
191 | - /** |
|
192 | - * @param string $error_code |
|
193 | - * @return string |
|
194 | - */ |
|
195 | - public function getErrorCode(&$error_code) |
|
196 | - { |
|
197 | - $error_codes = array( |
|
198 | - 'missing-input-secret' => 'The secret parameter is missing.', |
|
199 | - 'invalid-input-secret' => 'The secret parameter is invalid or malformed.', |
|
200 | - 'missing-input-response' => 'The response parameter is missing.', |
|
201 | - 'invalid-input-response' => 'The response parameter is invalid or malformed.', |
|
202 | - 'bad-request' => 'The request is invalid or malformed.', |
|
203 | - 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
|
204 | - ); |
|
205 | - return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
206 | - } |
|
191 | + /** |
|
192 | + * @param string $error_code |
|
193 | + * @return string |
|
194 | + */ |
|
195 | + public function getErrorCode(&$error_code) |
|
196 | + { |
|
197 | + $error_codes = array( |
|
198 | + 'missing-input-secret' => 'The secret parameter is missing.', |
|
199 | + 'invalid-input-secret' => 'The secret parameter is invalid or malformed.', |
|
200 | + 'missing-input-response' => 'The response parameter is missing.', |
|
201 | + 'invalid-input-response' => 'The response parameter is invalid or malformed.', |
|
202 | + 'bad-request' => 'The request is invalid or malformed.', |
|
203 | + 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
|
204 | + ); |
|
205 | + return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
206 | + } |
|
207 | 207 | |
208 | 208 | |
209 | - /** |
|
210 | - * @return array |
|
211 | - * @throws InvalidInterfaceException |
|
212 | - * @throws InvalidDataTypeException |
|
213 | - * @throws InvalidArgumentException |
|
214 | - */ |
|
215 | - public function getLocalizedVars() |
|
216 | - { |
|
217 | - return (array) apply_filters( |
|
218 | - 'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars', |
|
219 | - array( |
|
220 | - 'siteKey' => $this->config->recaptcha_publickey, |
|
221 | - 'recaptcha_passed' => $this->recaptchaPassed(), |
|
222 | - 'wp_debug' => WP_DEBUG, |
|
223 | - 'disable_submit' => defined('EE_EVENT_QUEUE_BASE_URL'), |
|
224 | - ) |
|
225 | - ); |
|
226 | - } |
|
209 | + /** |
|
210 | + * @return array |
|
211 | + * @throws InvalidInterfaceException |
|
212 | + * @throws InvalidDataTypeException |
|
213 | + * @throws InvalidArgumentException |
|
214 | + */ |
|
215 | + public function getLocalizedVars() |
|
216 | + { |
|
217 | + return (array) apply_filters( |
|
218 | + 'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars', |
|
219 | + array( |
|
220 | + 'siteKey' => $this->config->recaptcha_publickey, |
|
221 | + 'recaptcha_passed' => $this->recaptchaPassed(), |
|
222 | + 'wp_debug' => WP_DEBUG, |
|
223 | + 'disable_submit' => defined('EE_EVENT_QUEUE_BASE_URL'), |
|
224 | + ) |
|
225 | + ); |
|
226 | + } |
|
227 | 227 | |
228 | 228 | |
229 | - /** |
|
230 | - * @return boolean |
|
231 | - * @throws InvalidInterfaceException |
|
232 | - * @throws InvalidDataTypeException |
|
233 | - * @throws InvalidArgumentException |
|
234 | - */ |
|
235 | - public function recaptchaPassed() |
|
236 | - { |
|
237 | - if ($this->recaptcha_passed !== null) { |
|
238 | - return $this->recaptcha_passed; |
|
239 | - } |
|
240 | - // logged in means you have already passed a turing test of sorts |
|
241 | - if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) { |
|
242 | - $this->recaptcha_passed = true; |
|
243 | - return $this->recaptcha_passed; |
|
244 | - } |
|
245 | - // was test already passed? |
|
246 | - $this->recaptcha_passed = filter_var( |
|
247 | - $this->session->get_session_data( |
|
248 | - InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED |
|
249 | - ), |
|
250 | - FILTER_VALIDATE_BOOLEAN |
|
251 | - ); |
|
252 | - return $this->recaptcha_passed; |
|
253 | - } |
|
229 | + /** |
|
230 | + * @return boolean |
|
231 | + * @throws InvalidInterfaceException |
|
232 | + * @throws InvalidDataTypeException |
|
233 | + * @throws InvalidArgumentException |
|
234 | + */ |
|
235 | + public function recaptchaPassed() |
|
236 | + { |
|
237 | + if ($this->recaptcha_passed !== null) { |
|
238 | + return $this->recaptcha_passed; |
|
239 | + } |
|
240 | + // logged in means you have already passed a turing test of sorts |
|
241 | + if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) { |
|
242 | + $this->recaptcha_passed = true; |
|
243 | + return $this->recaptcha_passed; |
|
244 | + } |
|
245 | + // was test already passed? |
|
246 | + $this->recaptcha_passed = filter_var( |
|
247 | + $this->session->get_session_data( |
|
248 | + InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED |
|
249 | + ), |
|
250 | + FILTER_VALIDATE_BOOLEAN |
|
251 | + ); |
|
252 | + return $this->recaptcha_passed; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | |
256 | - /** |
|
257 | - * @throws InvalidArgumentException |
|
258 | - * @throws InvalidDataTypeException |
|
259 | - * @throws InvalidInterfaceException |
|
260 | - */ |
|
261 | - public function setSessionData() |
|
262 | - { |
|
263 | - $this->session->set_session_data( |
|
264 | - array(InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true) |
|
265 | - ); |
|
266 | - } |
|
256 | + /** |
|
257 | + * @throws InvalidArgumentException |
|
258 | + * @throws InvalidDataTypeException |
|
259 | + * @throws InvalidInterfaceException |
|
260 | + */ |
|
261 | + public function setSessionData() |
|
262 | + { |
|
263 | + $this->session->set_session_data( |
|
264 | + array(InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true) |
|
265 | + ); |
|
266 | + } |
|
267 | 267 | } |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | static $previous_recaptcha_response = array(); |
133 | 133 | $grecaptcha_response = $request->get('g-recaptcha-response'); |
134 | 134 | // if this token has already been verified, then return previous response |
135 | - if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
136 | - return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
135 | + if (isset($previous_recaptcha_response[$grecaptcha_response])) { |
|
136 | + return $previous_recaptcha_response[$grecaptcha_response]; |
|
137 | 137 | } |
138 | 138 | // will update to true if everything passes |
139 | - $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
139 | + $previous_recaptcha_response[$grecaptcha_response] = false; |
|
140 | 140 | $response = wp_safe_remote_post( |
141 | 141 | InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
142 | 142 | array( |
@@ -153,16 +153,16 @@ discard block |
||
153 | 153 | } |
154 | 154 | $results = json_decode(wp_remote_retrieve_body($response), true); |
155 | 155 | if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
156 | - $errors = array_map( |
|
156 | + $errors = array_map( |
|
157 | 157 | array($this, 'getErrorCode'), |
158 | 158 | $results['error-codes'] |
159 | 159 | ); |
160 | 160 | if (isset($results['challenge_ts'])) { |
161 | - $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
161 | + $errors[] = 'challenge timestamp: '.$results['challenge_ts'].'.'; |
|
162 | 162 | } |
163 | 163 | $this->generateError(implode(' ', $errors)); |
164 | 164 | } |
165 | - $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
165 | + $previous_recaptcha_response[$grecaptcha_response] = true; |
|
166 | 166 | add_action('shutdown', array($this, 'setSessionData')); |
167 | 167 | return true; |
168 | 168 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | 'bad-request' => 'The request is invalid or malformed.', |
203 | 203 | 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
204 | 204 | ); |
205 | - return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
205 | + return isset($error_codes[$error_code]) ? $error_codes[$error_code] : ''; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 |
@@ -19,35 +19,35 @@ |
||
19 | 19 | class RecaptchaFactory implements FactoryInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @param array $arguments |
|
24 | - * @return InvisibleRecaptcha |
|
25 | - * @throws InvalidDataTypeException |
|
26 | - * @throws InvalidInterfaceException |
|
27 | - * @throws InvalidArgumentException |
|
28 | - */ |
|
29 | - public static function create($arguments = array()) |
|
30 | - { |
|
31 | - return LoaderFactory::getLoader()->getShared( |
|
32 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha', |
|
33 | - $arguments |
|
34 | - ); |
|
35 | - } |
|
22 | + /** |
|
23 | + * @param array $arguments |
|
24 | + * @return InvisibleRecaptcha |
|
25 | + * @throws InvalidDataTypeException |
|
26 | + * @throws InvalidInterfaceException |
|
27 | + * @throws InvalidArgumentException |
|
28 | + */ |
|
29 | + public static function create($arguments = array()) |
|
30 | + { |
|
31 | + return LoaderFactory::getLoader()->getShared( |
|
32 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha', |
|
33 | + $arguments |
|
34 | + ); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @param array $arguments |
|
41 | - * @return RecaptchaAdminSettings |
|
42 | - * @throws InvalidDataTypeException |
|
43 | - * @throws InvalidInterfaceException |
|
44 | - * @throws InvalidArgumentException |
|
45 | - */ |
|
46 | - public static function getAdminModule($arguments = array()) |
|
47 | - { |
|
48 | - return LoaderFactory::getLoader()->getShared( |
|
49 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings', |
|
50 | - $arguments |
|
51 | - ); |
|
52 | - } |
|
39 | + /** |
|
40 | + * @param array $arguments |
|
41 | + * @return RecaptchaAdminSettings |
|
42 | + * @throws InvalidDataTypeException |
|
43 | + * @throws InvalidInterfaceException |
|
44 | + * @throws InvalidArgumentException |
|
45 | + */ |
|
46 | + public static function getAdminModule($arguments = array()) |
|
47 | + { |
|
48 | + return LoaderFactory::getLoader()->getShared( |
|
49 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings', |
|
50 | + $arguments |
|
51 | + ); |
|
52 | + } |
|
53 | 53 | } |
@@ -31,361 +31,361 @@ |
||
31 | 31 | class RecaptchaAdminSettings |
32 | 32 | { |
33 | 33 | |
34 | - /** |
|
35 | - * @var EE_Registration_Config $config |
|
36 | - */ |
|
37 | - private $config; |
|
34 | + /** |
|
35 | + * @var EE_Registration_Config $config |
|
36 | + */ |
|
37 | + private $config; |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * RecaptchaAdminSettings constructor. |
|
42 | - * |
|
43 | - * @param EE_Registration_Config $registration_config |
|
44 | - */ |
|
45 | - public function __construct(EE_Registration_Config $registration_config) |
|
46 | - { |
|
47 | - $this->config = $registration_config; |
|
48 | - } |
|
40 | + /** |
|
41 | + * RecaptchaAdminSettings constructor. |
|
42 | + * |
|
43 | + * @param EE_Registration_Config $registration_config |
|
44 | + */ |
|
45 | + public function __construct(EE_Registration_Config $registration_config) |
|
46 | + { |
|
47 | + $this->config = $registration_config; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @throws InvalidArgumentException |
|
53 | - * @throws InvalidInterfaceException |
|
54 | - * @throws InvalidDataTypeException |
|
55 | - * @throws EE_Error |
|
56 | - */ |
|
57 | - public function adminSettings() |
|
58 | - { |
|
59 | - echo $this->settingsForm()->get_html_and_js(); |
|
60 | - } |
|
51 | + /** |
|
52 | + * @throws InvalidArgumentException |
|
53 | + * @throws InvalidInterfaceException |
|
54 | + * @throws InvalidDataTypeException |
|
55 | + * @throws EE_Error |
|
56 | + */ |
|
57 | + public function adminSettings() |
|
58 | + { |
|
59 | + echo $this->settingsForm()->get_html_and_js(); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return EE_Form_Section_Proper |
|
65 | - * @throws EE_Error |
|
66 | - */ |
|
67 | - protected function settingsForm() |
|
68 | - { |
|
69 | - return new EE_Form_Section_Proper( |
|
70 | - array( |
|
71 | - 'name' => 'recaptcha_settings_form', |
|
72 | - 'html_id' => 'recaptcha_settings_form', |
|
73 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
74 | - 'subsections' => apply_filters( |
|
75 | - 'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections', |
|
76 | - array( |
|
77 | - 'main_settings_hdr' => new EE_Form_Section_HTML( |
|
78 | - EEH_HTML::h2( |
|
79 | - esc_html__('reCAPTCHA Anti-spam Settings', 'event_espresso') |
|
80 | - . EEH_Template::get_help_tab_link('recaptcha_info') |
|
81 | - ) |
|
82 | - ), |
|
83 | - 'main_settings' => $this->mainSettings(), |
|
84 | - 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
|
85 | - EEH_HTML::h2(esc_html__('reCAPTCHA Appearance', 'event_espresso')) |
|
86 | - ), |
|
87 | - 'appearance_settings' => $this->appearanceSettings(), |
|
88 | - 'required_fields_note' => new EE_Form_Section_HTML( |
|
89 | - EEH_HTML::p( |
|
90 | - esc_html__('All fields marked with a * are required fields', 'event_espresso'), |
|
91 | - '', |
|
92 | - 'grey-text' |
|
93 | - ) |
|
94 | - ), |
|
95 | - ) |
|
96 | - ), |
|
97 | - ) |
|
98 | - ); |
|
99 | - } |
|
63 | + /** |
|
64 | + * @return EE_Form_Section_Proper |
|
65 | + * @throws EE_Error |
|
66 | + */ |
|
67 | + protected function settingsForm() |
|
68 | + { |
|
69 | + return new EE_Form_Section_Proper( |
|
70 | + array( |
|
71 | + 'name' => 'recaptcha_settings_form', |
|
72 | + 'html_id' => 'recaptcha_settings_form', |
|
73 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
74 | + 'subsections' => apply_filters( |
|
75 | + 'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections', |
|
76 | + array( |
|
77 | + 'main_settings_hdr' => new EE_Form_Section_HTML( |
|
78 | + EEH_HTML::h2( |
|
79 | + esc_html__('reCAPTCHA Anti-spam Settings', 'event_espresso') |
|
80 | + . EEH_Template::get_help_tab_link('recaptcha_info') |
|
81 | + ) |
|
82 | + ), |
|
83 | + 'main_settings' => $this->mainSettings(), |
|
84 | + 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
|
85 | + EEH_HTML::h2(esc_html__('reCAPTCHA Appearance', 'event_espresso')) |
|
86 | + ), |
|
87 | + 'appearance_settings' => $this->appearanceSettings(), |
|
88 | + 'required_fields_note' => new EE_Form_Section_HTML( |
|
89 | + EEH_HTML::p( |
|
90 | + esc_html__('All fields marked with a * are required fields', 'event_espresso'), |
|
91 | + '', |
|
92 | + 'grey-text' |
|
93 | + ) |
|
94 | + ), |
|
95 | + ) |
|
96 | + ), |
|
97 | + ) |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * @return EE_Form_Section_Proper |
|
104 | - * @throws EE_Error |
|
105 | - */ |
|
106 | - protected function mainSettings() |
|
107 | - { |
|
108 | - return new EE_Form_Section_Proper( |
|
109 | - array( |
|
110 | - 'name' => 'recaptcha_settings_tbl', |
|
111 | - 'html_id' => 'recaptcha_settings_tbl', |
|
112 | - 'html_class' => 'form-table', |
|
113 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
114 | - 'subsections' => apply_filters( |
|
115 | - 'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections', |
|
116 | - array( |
|
117 | - 'use_captcha' => new EE_Yes_No_Input( |
|
118 | - array( |
|
119 | - 'html_label_text' => esc_html__('Use reCAPTCHA', 'event_espresso'), |
|
120 | - 'html_help_text' => sprintf( |
|
121 | - esc_html__( |
|
122 | - 'reCAPTCHA is a free service that protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', |
|
123 | - 'event_espresso' |
|
124 | - ), |
|
125 | - '<a href="https://www.google.com/recaptcha/intro/index.html">', |
|
126 | - '</a>' |
|
127 | - ), |
|
128 | - 'default' => $this->config->use_captcha !== null |
|
129 | - ? $this->config->use_captcha : false, |
|
130 | - 'display_html_label_text' => false, |
|
131 | - ) |
|
132 | - ), |
|
133 | - 'recaptcha_publickey' => new EE_Text_Input( |
|
134 | - array( |
|
135 | - 'html_label_text' => esc_html__('Site Key', 'event_espresso'), |
|
136 | - 'html_help_text' => esc_html__( |
|
137 | - 'The site key is used to display the widget on your site.', |
|
138 | - 'event_espresso' |
|
139 | - ), |
|
140 | - 'default' => $this->config->recaptcha_publickey !== null |
|
141 | - ? stripslashes($this->config->recaptcha_publickey) : '', |
|
142 | - ) |
|
143 | - ), |
|
144 | - 'recaptcha_privatekey' => new EE_Text_Input( |
|
145 | - array( |
|
146 | - 'html_label_text' => esc_html__('Secret Key', 'event_espresso'), |
|
147 | - 'html_help_text' => esc_html__( |
|
148 | - 'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', |
|
149 | - 'event_espresso' |
|
150 | - ), |
|
151 | - 'default' => $this->config->recaptcha_privatekey !== null |
|
152 | - ? stripslashes($this->config->recaptcha_privatekey) |
|
153 | - : '', |
|
154 | - ) |
|
155 | - ), |
|
156 | - 'recaptcha_protected_forms' => new EE_Checkbox_Multi_Input( |
|
157 | - array( |
|
158 | - 'ticket_selector' => esc_html__('Ticket Selector', 'event_espresso'), |
|
159 | - 'registration_form' => esc_html__('Registration Form', 'event_espresso'), |
|
160 | - ), |
|
161 | - array( |
|
162 | - 'html_label_text' => esc_html__( |
|
163 | - 'Invisible reCAPTCHA Protection', |
|
164 | - 'event_espresso' |
|
165 | - ), |
|
166 | - 'html_help_text' => esc_html__( |
|
167 | - 'Select which Event Espresso forms you would like to enable Invisible reCAPTCHA on.', |
|
168 | - 'event_espresso' |
|
169 | - ), |
|
170 | - 'default' => is_array($this->config->recaptcha_protected_forms) |
|
171 | - ? $this->config->recaptcha_protected_forms |
|
172 | - : array(), |
|
173 | - 'display_html_label_text' => false, |
|
174 | - ) |
|
175 | - ), |
|
176 | - ) |
|
177 | - ), |
|
178 | - ) |
|
179 | - ); |
|
180 | - } |
|
102 | + /** |
|
103 | + * @return EE_Form_Section_Proper |
|
104 | + * @throws EE_Error |
|
105 | + */ |
|
106 | + protected function mainSettings() |
|
107 | + { |
|
108 | + return new EE_Form_Section_Proper( |
|
109 | + array( |
|
110 | + 'name' => 'recaptcha_settings_tbl', |
|
111 | + 'html_id' => 'recaptcha_settings_tbl', |
|
112 | + 'html_class' => 'form-table', |
|
113 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
114 | + 'subsections' => apply_filters( |
|
115 | + 'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections', |
|
116 | + array( |
|
117 | + 'use_captcha' => new EE_Yes_No_Input( |
|
118 | + array( |
|
119 | + 'html_label_text' => esc_html__('Use reCAPTCHA', 'event_espresso'), |
|
120 | + 'html_help_text' => sprintf( |
|
121 | + esc_html__( |
|
122 | + 'reCAPTCHA is a free service that protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', |
|
123 | + 'event_espresso' |
|
124 | + ), |
|
125 | + '<a href="https://www.google.com/recaptcha/intro/index.html">', |
|
126 | + '</a>' |
|
127 | + ), |
|
128 | + 'default' => $this->config->use_captcha !== null |
|
129 | + ? $this->config->use_captcha : false, |
|
130 | + 'display_html_label_text' => false, |
|
131 | + ) |
|
132 | + ), |
|
133 | + 'recaptcha_publickey' => new EE_Text_Input( |
|
134 | + array( |
|
135 | + 'html_label_text' => esc_html__('Site Key', 'event_espresso'), |
|
136 | + 'html_help_text' => esc_html__( |
|
137 | + 'The site key is used to display the widget on your site.', |
|
138 | + 'event_espresso' |
|
139 | + ), |
|
140 | + 'default' => $this->config->recaptcha_publickey !== null |
|
141 | + ? stripslashes($this->config->recaptcha_publickey) : '', |
|
142 | + ) |
|
143 | + ), |
|
144 | + 'recaptcha_privatekey' => new EE_Text_Input( |
|
145 | + array( |
|
146 | + 'html_label_text' => esc_html__('Secret Key', 'event_espresso'), |
|
147 | + 'html_help_text' => esc_html__( |
|
148 | + 'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', |
|
149 | + 'event_espresso' |
|
150 | + ), |
|
151 | + 'default' => $this->config->recaptcha_privatekey !== null |
|
152 | + ? stripslashes($this->config->recaptcha_privatekey) |
|
153 | + : '', |
|
154 | + ) |
|
155 | + ), |
|
156 | + 'recaptcha_protected_forms' => new EE_Checkbox_Multi_Input( |
|
157 | + array( |
|
158 | + 'ticket_selector' => esc_html__('Ticket Selector', 'event_espresso'), |
|
159 | + 'registration_form' => esc_html__('Registration Form', 'event_espresso'), |
|
160 | + ), |
|
161 | + array( |
|
162 | + 'html_label_text' => esc_html__( |
|
163 | + 'Invisible reCAPTCHA Protection', |
|
164 | + 'event_espresso' |
|
165 | + ), |
|
166 | + 'html_help_text' => esc_html__( |
|
167 | + 'Select which Event Espresso forms you would like to enable Invisible reCAPTCHA on.', |
|
168 | + 'event_espresso' |
|
169 | + ), |
|
170 | + 'default' => is_array($this->config->recaptcha_protected_forms) |
|
171 | + ? $this->config->recaptcha_protected_forms |
|
172 | + : array(), |
|
173 | + 'display_html_label_text' => false, |
|
174 | + ) |
|
175 | + ), |
|
176 | + ) |
|
177 | + ), |
|
178 | + ) |
|
179 | + ); |
|
180 | + } |
|
181 | 181 | |
182 | 182 | |
183 | - /** |
|
184 | - * @return EE_Form_Section_Proper |
|
185 | - * @throws EE_Error |
|
186 | - */ |
|
187 | - protected function appearanceSettings() |
|
188 | - { |
|
189 | - return new EE_Form_Section_Proper( |
|
190 | - array( |
|
191 | - 'name' => 'recaptcha_appearance_settings_tbl', |
|
192 | - 'html_id' => 'recaptcha_appearance_settings_tbl', |
|
193 | - 'html_class' => 'form-table', |
|
194 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
195 | - 'subsections' => apply_filters( |
|
196 | - 'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections', |
|
197 | - array( |
|
198 | - 'recaptcha_theme' => new EE_Radio_Button_Input( |
|
199 | - array( |
|
200 | - 'invisible' => esc_html__('Invisible', 'event_espresso'), |
|
201 | - 'light' => esc_html__('Light', 'event_espresso'), |
|
202 | - 'dark' => esc_html__('Dark', 'event_espresso'), |
|
203 | - ), |
|
204 | - array( |
|
205 | - 'html_label_text' => esc_html__('Theme', 'event_espresso'), |
|
206 | - 'html_help_text' => esc_html__( |
|
207 | - 'The color theme of the widget.', |
|
208 | - 'event_espresso' |
|
209 | - ), |
|
210 | - 'default' => $this->config->recaptcha_theme !== null |
|
211 | - ? $this->config->recaptcha_theme |
|
212 | - : 'invisible', |
|
213 | - 'display_html_label_text' => false, |
|
214 | - ) |
|
215 | - ), |
|
216 | - 'recaptcha_badge' => new EE_Radio_Button_Input( |
|
217 | - array( |
|
218 | - 'bottomleft' => esc_html__('Bottom Left', 'event_espresso'), |
|
219 | - 'bottomright' => esc_html__('Bottom Right', 'event_espresso'), |
|
220 | - 'inline' => esc_html__('Inline', 'event_espresso'), |
|
221 | - ), |
|
222 | - array( |
|
223 | - 'html_label_text' => esc_html__( |
|
224 | - 'Invisible reCAPTCHA Badge Position', |
|
225 | - 'event_espresso' |
|
226 | - ), |
|
227 | - 'html_help_text' => esc_html__( |
|
228 | - 'If using Invisible reCAPTCHA, then this determines the position of the reCAPTCHA badge. "Bottom Left" and "Bottom Right" both will float at the bottom of the screen. "Inline" appears beside the submit button but allows you to control the CSS.', |
|
229 | - 'event_espresso' |
|
230 | - ), |
|
231 | - 'default' => $this->config->recaptcha_badge !== null |
|
232 | - ? $this->config->recaptcha_badge |
|
233 | - : 'bottomleft', |
|
234 | - 'display_html_label_text' => false, |
|
235 | - ) |
|
236 | - ), |
|
237 | - 'recaptcha_type' => new EE_Radio_Button_Input( |
|
238 | - array( |
|
239 | - 'image' => esc_html__('Image', 'event_espresso'), |
|
240 | - 'audio' => esc_html__('Audio', 'event_espresso'), |
|
241 | - ), |
|
242 | - array( |
|
243 | - 'html_label_text' => esc_html__('Type', 'event_espresso'), |
|
244 | - 'html_help_text' => esc_html__( |
|
245 | - 'The type of CAPTCHA to serve.', |
|
246 | - 'event_espresso' |
|
247 | - ), |
|
248 | - 'default' => $this->config->recaptcha_type !== null |
|
249 | - ? $this->config->recaptcha_type |
|
250 | - : 'image', |
|
251 | - 'display_html_label_text' => false, |
|
252 | - ) |
|
253 | - ), |
|
254 | - 'recaptcha_language' => new EE_Select_Input( |
|
255 | - array( |
|
256 | - 'ar' => esc_html__('Arabic', 'event_espresso'), |
|
257 | - 'bg' => esc_html__('Bulgarian', 'event_espresso'), |
|
258 | - 'ca' => esc_html__('Catalan', 'event_espresso'), |
|
259 | - 'zh-CN' => esc_html__('Chinese (Simplified)', 'event_espresso'), |
|
260 | - 'zh-TW' => esc_html__('Chinese (Traditional) ', 'event_espresso'), |
|
261 | - 'hr' => esc_html__('Croatian', 'event_espresso'), |
|
262 | - 'cs' => esc_html__('Czech', 'event_espresso'), |
|
263 | - 'da' => esc_html__('Danish', 'event_espresso'), |
|
264 | - 'nl' => esc_html__('Dutch', 'event_espresso'), |
|
265 | - 'en-GB' => esc_html__('English (UK)', 'event_espresso'), |
|
266 | - 'en' => esc_html__('English (US)', 'event_espresso'), |
|
267 | - 'fil' => esc_html__('Filipino', 'event_espresso'), |
|
268 | - 'fi' => esc_html__('Finnish', 'event_espresso'), |
|
269 | - 'fr' => esc_html__('French', 'event_espresso'), |
|
270 | - 'fr-CA' => esc_html__('French (Canadian)', 'event_espresso'), |
|
271 | - 'de' => esc_html__('German', 'event_espresso'), |
|
272 | - 'de-AT' => esc_html__('German (Austria)', 'event_espresso'), |
|
273 | - 'de-CH' => esc_html__('German (Switzerland)', 'event_espresso'), |
|
274 | - 'el' => esc_html__('Greek', 'event_espresso'), |
|
275 | - 'iw' => esc_html__('Hebrew', 'event_espresso'), |
|
276 | - 'hi' => esc_html__('Hindi', 'event_espresso'), |
|
277 | - 'hu' => esc_html__('Hungarian', 'event_espresso'), |
|
278 | - 'id' => esc_html__('Indonesian', 'event_espresso'), |
|
279 | - 'it' => esc_html__('Italian', 'event_espresso'), |
|
280 | - 'ja' => esc_html__('Japanese', 'event_espresso'), |
|
281 | - 'ko' => esc_html__('Korean', 'event_espresso'), |
|
282 | - 'lv' => esc_html__('Latvian', 'event_espresso'), |
|
283 | - 'lt' => esc_html__('Lithuanian', 'event_espresso'), |
|
284 | - 'no' => esc_html__('Norwegian', 'event_espresso'), |
|
285 | - 'fa' => esc_html__('Persian', 'event_espresso'), |
|
286 | - 'pl' => esc_html__('Polish', 'event_espresso'), |
|
287 | - 'pt' => esc_html__('Portuguese', 'event_espresso'), |
|
288 | - 'pt-BR' => esc_html__('Portuguese (Brazil)', 'event_espresso'), |
|
289 | - 'pt-PT' => esc_html__('Portuguese (Portugal)', 'event_espresso'), |
|
290 | - 'ro' => esc_html__('Romanian', 'event_espresso'), |
|
291 | - 'ru' => esc_html__('Russian', 'event_espresso'), |
|
292 | - 'sr' => esc_html__('Serbian', 'event_espresso'), |
|
293 | - 'sk' => esc_html__('Slovak', 'event_espresso'), |
|
294 | - 'sl' => esc_html__('Slovenian', 'event_espresso'), |
|
295 | - 'es' => esc_html__('Spanish', 'event_espresso'), |
|
296 | - 'es-419' => esc_html__('Spanish (Latin America)', 'event_espresso'), |
|
297 | - 'sv' => esc_html__('Swedish', 'event_espresso'), |
|
298 | - 'th' => esc_html__('Thai', 'event_espresso'), |
|
299 | - 'tr' => esc_html__('Turkish', 'event_espresso'), |
|
300 | - 'uk' => esc_html__('Ukrainian', 'event_espresso'), |
|
301 | - 'vi' => esc_html__('Vietnamese', 'event_espresso'), |
|
302 | - ), |
|
303 | - array( |
|
304 | - 'html_label_text' => esc_html__('Language', 'event_espresso'), |
|
305 | - 'html_help_text' => esc_html__( |
|
306 | - 'Forces the widget to render in a specific language.', |
|
307 | - 'event_espresso' |
|
308 | - ), |
|
309 | - 'default' => $this->config->recaptcha_language !== null |
|
310 | - ? $this->config->recaptcha_language : 'en', |
|
311 | - ) |
|
312 | - ), |
|
313 | - ) |
|
314 | - ), |
|
315 | - ) |
|
316 | - ); |
|
317 | - } |
|
183 | + /** |
|
184 | + * @return EE_Form_Section_Proper |
|
185 | + * @throws EE_Error |
|
186 | + */ |
|
187 | + protected function appearanceSettings() |
|
188 | + { |
|
189 | + return new EE_Form_Section_Proper( |
|
190 | + array( |
|
191 | + 'name' => 'recaptcha_appearance_settings_tbl', |
|
192 | + 'html_id' => 'recaptcha_appearance_settings_tbl', |
|
193 | + 'html_class' => 'form-table', |
|
194 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
195 | + 'subsections' => apply_filters( |
|
196 | + 'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections', |
|
197 | + array( |
|
198 | + 'recaptcha_theme' => new EE_Radio_Button_Input( |
|
199 | + array( |
|
200 | + 'invisible' => esc_html__('Invisible', 'event_espresso'), |
|
201 | + 'light' => esc_html__('Light', 'event_espresso'), |
|
202 | + 'dark' => esc_html__('Dark', 'event_espresso'), |
|
203 | + ), |
|
204 | + array( |
|
205 | + 'html_label_text' => esc_html__('Theme', 'event_espresso'), |
|
206 | + 'html_help_text' => esc_html__( |
|
207 | + 'The color theme of the widget.', |
|
208 | + 'event_espresso' |
|
209 | + ), |
|
210 | + 'default' => $this->config->recaptcha_theme !== null |
|
211 | + ? $this->config->recaptcha_theme |
|
212 | + : 'invisible', |
|
213 | + 'display_html_label_text' => false, |
|
214 | + ) |
|
215 | + ), |
|
216 | + 'recaptcha_badge' => new EE_Radio_Button_Input( |
|
217 | + array( |
|
218 | + 'bottomleft' => esc_html__('Bottom Left', 'event_espresso'), |
|
219 | + 'bottomright' => esc_html__('Bottom Right', 'event_espresso'), |
|
220 | + 'inline' => esc_html__('Inline', 'event_espresso'), |
|
221 | + ), |
|
222 | + array( |
|
223 | + 'html_label_text' => esc_html__( |
|
224 | + 'Invisible reCAPTCHA Badge Position', |
|
225 | + 'event_espresso' |
|
226 | + ), |
|
227 | + 'html_help_text' => esc_html__( |
|
228 | + 'If using Invisible reCAPTCHA, then this determines the position of the reCAPTCHA badge. "Bottom Left" and "Bottom Right" both will float at the bottom of the screen. "Inline" appears beside the submit button but allows you to control the CSS.', |
|
229 | + 'event_espresso' |
|
230 | + ), |
|
231 | + 'default' => $this->config->recaptcha_badge !== null |
|
232 | + ? $this->config->recaptcha_badge |
|
233 | + : 'bottomleft', |
|
234 | + 'display_html_label_text' => false, |
|
235 | + ) |
|
236 | + ), |
|
237 | + 'recaptcha_type' => new EE_Radio_Button_Input( |
|
238 | + array( |
|
239 | + 'image' => esc_html__('Image', 'event_espresso'), |
|
240 | + 'audio' => esc_html__('Audio', 'event_espresso'), |
|
241 | + ), |
|
242 | + array( |
|
243 | + 'html_label_text' => esc_html__('Type', 'event_espresso'), |
|
244 | + 'html_help_text' => esc_html__( |
|
245 | + 'The type of CAPTCHA to serve.', |
|
246 | + 'event_espresso' |
|
247 | + ), |
|
248 | + 'default' => $this->config->recaptcha_type !== null |
|
249 | + ? $this->config->recaptcha_type |
|
250 | + : 'image', |
|
251 | + 'display_html_label_text' => false, |
|
252 | + ) |
|
253 | + ), |
|
254 | + 'recaptcha_language' => new EE_Select_Input( |
|
255 | + array( |
|
256 | + 'ar' => esc_html__('Arabic', 'event_espresso'), |
|
257 | + 'bg' => esc_html__('Bulgarian', 'event_espresso'), |
|
258 | + 'ca' => esc_html__('Catalan', 'event_espresso'), |
|
259 | + 'zh-CN' => esc_html__('Chinese (Simplified)', 'event_espresso'), |
|
260 | + 'zh-TW' => esc_html__('Chinese (Traditional) ', 'event_espresso'), |
|
261 | + 'hr' => esc_html__('Croatian', 'event_espresso'), |
|
262 | + 'cs' => esc_html__('Czech', 'event_espresso'), |
|
263 | + 'da' => esc_html__('Danish', 'event_espresso'), |
|
264 | + 'nl' => esc_html__('Dutch', 'event_espresso'), |
|
265 | + 'en-GB' => esc_html__('English (UK)', 'event_espresso'), |
|
266 | + 'en' => esc_html__('English (US)', 'event_espresso'), |
|
267 | + 'fil' => esc_html__('Filipino', 'event_espresso'), |
|
268 | + 'fi' => esc_html__('Finnish', 'event_espresso'), |
|
269 | + 'fr' => esc_html__('French', 'event_espresso'), |
|
270 | + 'fr-CA' => esc_html__('French (Canadian)', 'event_espresso'), |
|
271 | + 'de' => esc_html__('German', 'event_espresso'), |
|
272 | + 'de-AT' => esc_html__('German (Austria)', 'event_espresso'), |
|
273 | + 'de-CH' => esc_html__('German (Switzerland)', 'event_espresso'), |
|
274 | + 'el' => esc_html__('Greek', 'event_espresso'), |
|
275 | + 'iw' => esc_html__('Hebrew', 'event_espresso'), |
|
276 | + 'hi' => esc_html__('Hindi', 'event_espresso'), |
|
277 | + 'hu' => esc_html__('Hungarian', 'event_espresso'), |
|
278 | + 'id' => esc_html__('Indonesian', 'event_espresso'), |
|
279 | + 'it' => esc_html__('Italian', 'event_espresso'), |
|
280 | + 'ja' => esc_html__('Japanese', 'event_espresso'), |
|
281 | + 'ko' => esc_html__('Korean', 'event_espresso'), |
|
282 | + 'lv' => esc_html__('Latvian', 'event_espresso'), |
|
283 | + 'lt' => esc_html__('Lithuanian', 'event_espresso'), |
|
284 | + 'no' => esc_html__('Norwegian', 'event_espresso'), |
|
285 | + 'fa' => esc_html__('Persian', 'event_espresso'), |
|
286 | + 'pl' => esc_html__('Polish', 'event_espresso'), |
|
287 | + 'pt' => esc_html__('Portuguese', 'event_espresso'), |
|
288 | + 'pt-BR' => esc_html__('Portuguese (Brazil)', 'event_espresso'), |
|
289 | + 'pt-PT' => esc_html__('Portuguese (Portugal)', 'event_espresso'), |
|
290 | + 'ro' => esc_html__('Romanian', 'event_espresso'), |
|
291 | + 'ru' => esc_html__('Russian', 'event_espresso'), |
|
292 | + 'sr' => esc_html__('Serbian', 'event_espresso'), |
|
293 | + 'sk' => esc_html__('Slovak', 'event_espresso'), |
|
294 | + 'sl' => esc_html__('Slovenian', 'event_espresso'), |
|
295 | + 'es' => esc_html__('Spanish', 'event_espresso'), |
|
296 | + 'es-419' => esc_html__('Spanish (Latin America)', 'event_espresso'), |
|
297 | + 'sv' => esc_html__('Swedish', 'event_espresso'), |
|
298 | + 'th' => esc_html__('Thai', 'event_espresso'), |
|
299 | + 'tr' => esc_html__('Turkish', 'event_espresso'), |
|
300 | + 'uk' => esc_html__('Ukrainian', 'event_espresso'), |
|
301 | + 'vi' => esc_html__('Vietnamese', 'event_espresso'), |
|
302 | + ), |
|
303 | + array( |
|
304 | + 'html_label_text' => esc_html__('Language', 'event_espresso'), |
|
305 | + 'html_help_text' => esc_html__( |
|
306 | + 'Forces the widget to render in a specific language.', |
|
307 | + 'event_espresso' |
|
308 | + ), |
|
309 | + 'default' => $this->config->recaptcha_language !== null |
|
310 | + ? $this->config->recaptcha_language : 'en', |
|
311 | + ) |
|
312 | + ), |
|
313 | + ) |
|
314 | + ), |
|
315 | + ) |
|
316 | + ); |
|
317 | + } |
|
318 | 318 | |
319 | 319 | |
320 | - /** |
|
321 | - * @param EE_Registration_Config $EE_Registration_Config |
|
322 | - * @return EE_Registration_Config |
|
323 | - * @throws InvalidArgumentException |
|
324 | - * @throws InvalidInterfaceException |
|
325 | - * @throws InvalidDataTypeException |
|
326 | - * @throws EE_Error |
|
327 | - * @throws ReflectionException |
|
328 | - */ |
|
329 | - public function updateAdminSettings(EE_Registration_Config $EE_Registration_Config) |
|
330 | - { |
|
331 | - try { |
|
332 | - $recaptcha_settings_form = $this->settingsForm(); |
|
333 | - // if not displaying a form, then check for form submission |
|
334 | - if ($recaptcha_settings_form->was_submitted()) { |
|
335 | - // capture form data |
|
336 | - $recaptcha_settings_form->receive_form_submission(); |
|
337 | - // validate form data |
|
338 | - if ($recaptcha_settings_form->is_valid()) { |
|
339 | - // grab validated data from form |
|
340 | - $valid_data = $recaptcha_settings_form->valid_data(); |
|
341 | - // user proofing recaptcha: If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message. |
|
342 | - if ($valid_data['main_settings']['use_captcha'] |
|
343 | - && ( |
|
344 | - ! $EE_Registration_Config->use_captcha |
|
345 | - && ( |
|
346 | - empty($valid_data['main_settings']['recaptcha_publickey']) |
|
347 | - || empty($valid_data['main_settings']['recaptcha_privatekey']) |
|
348 | - ) |
|
349 | - ) |
|
350 | - && apply_filters( |
|
351 | - 'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', |
|
352 | - true, |
|
353 | - $EE_Registration_Config |
|
354 | - ) |
|
355 | - ) { |
|
356 | - $valid_data['main_settings']['use_captcha'] = false; |
|
357 | - EE_Error::add_error( |
|
358 | - esc_html__( |
|
359 | - 'The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', |
|
360 | - 'event_espresso' |
|
361 | - ), |
|
362 | - __FILE__, |
|
363 | - __FUNCTION__, |
|
364 | - __LINE__ |
|
365 | - ); |
|
366 | - } |
|
367 | - $EE_Registration_Config->use_captcha = $valid_data['main_settings']['use_captcha']; |
|
368 | - $EE_Registration_Config->recaptcha_publickey = $valid_data['main_settings']['recaptcha_publickey']; |
|
369 | - $EE_Registration_Config->recaptcha_protected_forms = $valid_data['main_settings']['recaptcha_protected_forms']; |
|
370 | - $EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey']; |
|
371 | - $EE_Registration_Config->recaptcha_type = $valid_data['appearance_settings']['recaptcha_type']; |
|
372 | - $EE_Registration_Config->recaptcha_theme = $valid_data['appearance_settings']['recaptcha_theme']; |
|
373 | - $EE_Registration_Config->recaptcha_badge = $valid_data['appearance_settings']['recaptcha_badge']; |
|
374 | - $EE_Registration_Config->recaptcha_language = $valid_data['appearance_settings']['recaptcha_language']; |
|
375 | - } else { |
|
376 | - if ($recaptcha_settings_form->submission_error_message() !== '') { |
|
377 | - EE_Error::add_error( |
|
378 | - $recaptcha_settings_form->submission_error_message(), |
|
379 | - __FILE__, |
|
380 | - __FUNCTION__, |
|
381 | - __LINE__ |
|
382 | - ); |
|
383 | - } |
|
384 | - } |
|
385 | - } |
|
386 | - } catch (EE_Error $e) { |
|
387 | - $e->get_error(); |
|
388 | - } |
|
389 | - return $EE_Registration_Config; |
|
390 | - } |
|
320 | + /** |
|
321 | + * @param EE_Registration_Config $EE_Registration_Config |
|
322 | + * @return EE_Registration_Config |
|
323 | + * @throws InvalidArgumentException |
|
324 | + * @throws InvalidInterfaceException |
|
325 | + * @throws InvalidDataTypeException |
|
326 | + * @throws EE_Error |
|
327 | + * @throws ReflectionException |
|
328 | + */ |
|
329 | + public function updateAdminSettings(EE_Registration_Config $EE_Registration_Config) |
|
330 | + { |
|
331 | + try { |
|
332 | + $recaptcha_settings_form = $this->settingsForm(); |
|
333 | + // if not displaying a form, then check for form submission |
|
334 | + if ($recaptcha_settings_form->was_submitted()) { |
|
335 | + // capture form data |
|
336 | + $recaptcha_settings_form->receive_form_submission(); |
|
337 | + // validate form data |
|
338 | + if ($recaptcha_settings_form->is_valid()) { |
|
339 | + // grab validated data from form |
|
340 | + $valid_data = $recaptcha_settings_form->valid_data(); |
|
341 | + // user proofing recaptcha: If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message. |
|
342 | + if ($valid_data['main_settings']['use_captcha'] |
|
343 | + && ( |
|
344 | + ! $EE_Registration_Config->use_captcha |
|
345 | + && ( |
|
346 | + empty($valid_data['main_settings']['recaptcha_publickey']) |
|
347 | + || empty($valid_data['main_settings']['recaptcha_privatekey']) |
|
348 | + ) |
|
349 | + ) |
|
350 | + && apply_filters( |
|
351 | + 'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', |
|
352 | + true, |
|
353 | + $EE_Registration_Config |
|
354 | + ) |
|
355 | + ) { |
|
356 | + $valid_data['main_settings']['use_captcha'] = false; |
|
357 | + EE_Error::add_error( |
|
358 | + esc_html__( |
|
359 | + 'The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', |
|
360 | + 'event_espresso' |
|
361 | + ), |
|
362 | + __FILE__, |
|
363 | + __FUNCTION__, |
|
364 | + __LINE__ |
|
365 | + ); |
|
366 | + } |
|
367 | + $EE_Registration_Config->use_captcha = $valid_data['main_settings']['use_captcha']; |
|
368 | + $EE_Registration_Config->recaptcha_publickey = $valid_data['main_settings']['recaptcha_publickey']; |
|
369 | + $EE_Registration_Config->recaptcha_protected_forms = $valid_data['main_settings']['recaptcha_protected_forms']; |
|
370 | + $EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey']; |
|
371 | + $EE_Registration_Config->recaptcha_type = $valid_data['appearance_settings']['recaptcha_type']; |
|
372 | + $EE_Registration_Config->recaptcha_theme = $valid_data['appearance_settings']['recaptcha_theme']; |
|
373 | + $EE_Registration_Config->recaptcha_badge = $valid_data['appearance_settings']['recaptcha_badge']; |
|
374 | + $EE_Registration_Config->recaptcha_language = $valid_data['appearance_settings']['recaptcha_language']; |
|
375 | + } else { |
|
376 | + if ($recaptcha_settings_form->submission_error_message() !== '') { |
|
377 | + EE_Error::add_error( |
|
378 | + $recaptcha_settings_form->submission_error_message(), |
|
379 | + __FILE__, |
|
380 | + __FUNCTION__, |
|
381 | + __LINE__ |
|
382 | + ); |
|
383 | + } |
|
384 | + } |
|
385 | + } |
|
386 | + } catch (EE_Error $e) { |
|
387 | + $e->get_error(); |
|
388 | + } |
|
389 | + return $EE_Registration_Config; |
|
390 | + } |
|
391 | 391 | } |
@@ -6,33 +6,33 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | spl_autoload_register(function ($class) { |
9 | - if (substr($class, 0, 10) !== 'ReCaptcha\\') { |
|
10 | - /* If the class does not lie under the "ReCaptcha" namespace, |
|
9 | + if (substr($class, 0, 10) !== 'ReCaptcha\\') { |
|
10 | + /* If the class does not lie under the "ReCaptcha" namespace, |
|
11 | 11 | * then we can exit immediately. |
12 | 12 | */ |
13 | - return; |
|
14 | - } |
|
13 | + return; |
|
14 | + } |
|
15 | 15 | |
16 | - /* All of the classes have names like "ReCaptcha\Foo", so we need |
|
16 | + /* All of the classes have names like "ReCaptcha\Foo", so we need |
|
17 | 17 | * to replace the backslashes with frontslashes if we want the |
18 | 18 | * name to map directly to a location in the filesystem. |
19 | 19 | */ |
20 | - $class = str_replace('\\', '/', $class); |
|
20 | + $class = str_replace('\\', '/', $class); |
|
21 | 21 | |
22 | - /* First, check under the current directory. It is important that |
|
22 | + /* First, check under the current directory. It is important that |
|
23 | 23 | * we look here first, so that we don't waste time searching for |
24 | 24 | * test classes in the common case. |
25 | 25 | */ |
26 | - $path = dirname(__FILE__).'/'.$class.'.php'; |
|
27 | - if (is_readable($path)) { |
|
28 | - require_once $path; |
|
29 | - } |
|
26 | + $path = dirname(__FILE__).'/'.$class.'.php'; |
|
27 | + if (is_readable($path)) { |
|
28 | + require_once $path; |
|
29 | + } |
|
30 | 30 | |
31 | - /* If we didn't find what we're looking for already, maybe it's |
|
31 | + /* If we didn't find what we're looking for already, maybe it's |
|
32 | 32 | * a test class? |
33 | 33 | */ |
34 | - $path = dirname(__FILE__).'/../tests/'.$class.'.php'; |
|
35 | - if (is_readable($path)) { |
|
36 | - require_once $path; |
|
37 | - } |
|
34 | + $path = dirname(__FILE__).'/../tests/'.$class.'.php'; |
|
35 | + if (is_readable($path)) { |
|
36 | + require_once $path; |
|
37 | + } |
|
38 | 38 | }); |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * classes. |
6 | 6 | */ |
7 | 7 | |
8 | -spl_autoload_register(function ($class) { |
|
8 | +spl_autoload_register(function($class) { |
|
9 | 9 | if (substr($class, 0, 10) !== 'ReCaptcha\\') { |
10 | 10 | /* If the class does not lie under the "ReCaptcha" namespace, |
11 | 11 | * then we can exit immediately. |
@@ -33,87 +33,87 @@ |
||
33 | 33 | */ |
34 | 34 | class SocketPost implements RequestMethod |
35 | 35 | { |
36 | - /** |
|
37 | - * reCAPTCHA service host. |
|
38 | - * |
|
39 | - * @const string |
|
40 | - */ |
|
41 | - const RECAPTCHA_HOST = 'www.google.com'; |
|
42 | - |
|
43 | - /** |
|
44 | - * @const string reCAPTCHA service path |
|
45 | - */ |
|
46 | - const SITE_VERIFY_PATH = '/recaptcha/api/siteverify'; |
|
47 | - |
|
48 | - /** |
|
49 | - * @const string Bad request error |
|
50 | - */ |
|
51 | - const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}'; |
|
52 | - |
|
53 | - /** |
|
54 | - * @const string Bad response error |
|
55 | - */ |
|
56 | - const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}'; |
|
57 | - |
|
58 | - /** |
|
59 | - * Socket to the reCAPTCHA service |
|
60 | - * |
|
61 | - * @var Socket |
|
62 | - */ |
|
63 | - private $socket; |
|
64 | - |
|
65 | - /** |
|
66 | - * Constructor |
|
67 | - * |
|
68 | - * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing |
|
69 | - */ |
|
70 | - public function __construct(Socket $socket = null) |
|
71 | - { |
|
72 | - if (! is_null($socket)) { |
|
73 | - $this->socket = $socket; |
|
74 | - } else { |
|
75 | - $this->socket = new Socket(); |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * Submit the POST request with the specified parameters. |
|
81 | - * |
|
82 | - * @param RequestParameters $params Request parameters |
|
83 | - * @return string Body of the reCAPTCHA response |
|
84 | - */ |
|
85 | - public function submit(RequestParameters $params) |
|
86 | - { |
|
87 | - $errno = 0; |
|
88 | - $errstr = ''; |
|
89 | - |
|
90 | - if ($this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30) !== false) { |
|
91 | - $content = $params->toQueryString(); |
|
92 | - |
|
93 | - $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; |
|
94 | - $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; |
|
95 | - $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
|
96 | - $request .= "Content-length: " . strlen($content) . "\r\n"; |
|
97 | - $request .= "Connection: close\r\n\r\n"; |
|
98 | - $request .= $content . "\r\n\r\n"; |
|
99 | - |
|
100 | - $this->socket->fwrite($request); |
|
101 | - $response = ''; |
|
102 | - |
|
103 | - while (! $this->socket->feof()) { |
|
104 | - $response .= $this->socket->fgets(4096); |
|
105 | - } |
|
106 | - |
|
107 | - $this->socket->fclose(); |
|
108 | - |
|
109 | - if (0 === strpos($response, 'HTTP/1.1 200 OK')) { |
|
110 | - $parts = preg_split("#\n\s*\n#Uis", $response); |
|
111 | - return $parts[1]; |
|
112 | - } |
|
113 | - |
|
114 | - return self::BAD_RESPONSE; |
|
115 | - } |
|
116 | - |
|
117 | - return self::BAD_REQUEST; |
|
118 | - } |
|
36 | + /** |
|
37 | + * reCAPTCHA service host. |
|
38 | + * |
|
39 | + * @const string |
|
40 | + */ |
|
41 | + const RECAPTCHA_HOST = 'www.google.com'; |
|
42 | + |
|
43 | + /** |
|
44 | + * @const string reCAPTCHA service path |
|
45 | + */ |
|
46 | + const SITE_VERIFY_PATH = '/recaptcha/api/siteverify'; |
|
47 | + |
|
48 | + /** |
|
49 | + * @const string Bad request error |
|
50 | + */ |
|
51 | + const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}'; |
|
52 | + |
|
53 | + /** |
|
54 | + * @const string Bad response error |
|
55 | + */ |
|
56 | + const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}'; |
|
57 | + |
|
58 | + /** |
|
59 | + * Socket to the reCAPTCHA service |
|
60 | + * |
|
61 | + * @var Socket |
|
62 | + */ |
|
63 | + private $socket; |
|
64 | + |
|
65 | + /** |
|
66 | + * Constructor |
|
67 | + * |
|
68 | + * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing |
|
69 | + */ |
|
70 | + public function __construct(Socket $socket = null) |
|
71 | + { |
|
72 | + if (! is_null($socket)) { |
|
73 | + $this->socket = $socket; |
|
74 | + } else { |
|
75 | + $this->socket = new Socket(); |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * Submit the POST request with the specified parameters. |
|
81 | + * |
|
82 | + * @param RequestParameters $params Request parameters |
|
83 | + * @return string Body of the reCAPTCHA response |
|
84 | + */ |
|
85 | + public function submit(RequestParameters $params) |
|
86 | + { |
|
87 | + $errno = 0; |
|
88 | + $errstr = ''; |
|
89 | + |
|
90 | + if ($this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30) !== false) { |
|
91 | + $content = $params->toQueryString(); |
|
92 | + |
|
93 | + $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; |
|
94 | + $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; |
|
95 | + $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
|
96 | + $request .= "Content-length: " . strlen($content) . "\r\n"; |
|
97 | + $request .= "Connection: close\r\n\r\n"; |
|
98 | + $request .= $content . "\r\n\r\n"; |
|
99 | + |
|
100 | + $this->socket->fwrite($request); |
|
101 | + $response = ''; |
|
102 | + |
|
103 | + while (! $this->socket->feof()) { |
|
104 | + $response .= $this->socket->fgets(4096); |
|
105 | + } |
|
106 | + |
|
107 | + $this->socket->fclose(); |
|
108 | + |
|
109 | + if (0 === strpos($response, 'HTTP/1.1 200 OK')) { |
|
110 | + $parts = preg_split("#\n\s*\n#Uis", $response); |
|
111 | + return $parts[1]; |
|
112 | + } |
|
113 | + |
|
114 | + return self::BAD_RESPONSE; |
|
115 | + } |
|
116 | + |
|
117 | + return self::BAD_REQUEST; |
|
118 | + } |
|
119 | 119 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function __construct(Socket $socket = null) |
71 | 71 | { |
72 | - if (! is_null($socket)) { |
|
72 | + if ( ! is_null($socket)) { |
|
73 | 73 | $this->socket = $socket; |
74 | 74 | } else { |
75 | 75 | $this->socket = new Socket(); |
@@ -87,20 +87,20 @@ discard block |
||
87 | 87 | $errno = 0; |
88 | 88 | $errstr = ''; |
89 | 89 | |
90 | - if ($this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30) !== false) { |
|
90 | + if ($this->socket->fsockopen('ssl://'.self::RECAPTCHA_HOST, 443, $errno, $errstr, 30) !== false) { |
|
91 | 91 | $content = $params->toQueryString(); |
92 | 92 | |
93 | - $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; |
|
94 | - $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; |
|
93 | + $request = "POST ".self::SITE_VERIFY_PATH." HTTP/1.1\r\n"; |
|
94 | + $request .= "Host: ".self::RECAPTCHA_HOST."\r\n"; |
|
95 | 95 | $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
96 | - $request .= "Content-length: " . strlen($content) . "\r\n"; |
|
96 | + $request .= "Content-length: ".strlen($content)."\r\n"; |
|
97 | 97 | $request .= "Connection: close\r\n\r\n"; |
98 | - $request .= $content . "\r\n\r\n"; |
|
98 | + $request .= $content."\r\n\r\n"; |
|
99 | 99 | |
100 | 100 | $this->socket->fwrite($request); |
101 | 101 | $response = ''; |
102 | 102 | |
103 | - while (! $this->socket->feof()) { |
|
103 | + while ( ! $this->socket->feof()) { |
|
104 | 104 | $response .= $this->socket->fgets(4096); |
105 | 105 | } |
106 | 106 |
@@ -29,79 +29,79 @@ |
||
29 | 29 | */ |
30 | 30 | class Socket |
31 | 31 | { |
32 | - private $handle = null; |
|
32 | + private $handle = null; |
|
33 | 33 | |
34 | - /** |
|
35 | - * fsockopen |
|
36 | - * |
|
37 | - * @see http://php.net/fsockopen |
|
38 | - * @param string $hostname |
|
39 | - * @param int $port |
|
40 | - * @param int $errno |
|
41 | - * @param string $errstr |
|
42 | - * @param float $timeout |
|
43 | - * @return resource |
|
44 | - */ |
|
45 | - public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null) |
|
46 | - { |
|
47 | - $this->handle = fsockopen( |
|
48 | - $hostname, |
|
49 | - $port, |
|
50 | - $errno, |
|
51 | - $errstr, |
|
52 | - (is_null($timeout) ? ini_get("default_socket_timeout") : $timeout) |
|
53 | - ); |
|
34 | + /** |
|
35 | + * fsockopen |
|
36 | + * |
|
37 | + * @see http://php.net/fsockopen |
|
38 | + * @param string $hostname |
|
39 | + * @param int $port |
|
40 | + * @param int $errno |
|
41 | + * @param string $errstr |
|
42 | + * @param float $timeout |
|
43 | + * @return resource |
|
44 | + */ |
|
45 | + public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null) |
|
46 | + { |
|
47 | + $this->handle = fsockopen( |
|
48 | + $hostname, |
|
49 | + $port, |
|
50 | + $errno, |
|
51 | + $errstr, |
|
52 | + (is_null($timeout) ? ini_get("default_socket_timeout") : $timeout) |
|
53 | + ); |
|
54 | 54 | |
55 | - if ($this->handle != false && $errno === 0 && $errstr === '') { |
|
56 | - return $this->handle; |
|
57 | - } else { |
|
58 | - return false; |
|
59 | - } |
|
60 | - } |
|
55 | + if ($this->handle != false && $errno === 0 && $errstr === '') { |
|
56 | + return $this->handle; |
|
57 | + } else { |
|
58 | + return false; |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * fwrite |
|
64 | - * |
|
65 | - * @see http://php.net/fwrite |
|
66 | - * @param string $string |
|
67 | - * @param int $length |
|
68 | - * @return int | bool |
|
69 | - */ |
|
70 | - public function fwrite($string, $length = null) |
|
71 | - { |
|
72 | - return fwrite($this->handle, $string, (is_null($length) ? strlen($string) : $length)); |
|
73 | - } |
|
62 | + /** |
|
63 | + * fwrite |
|
64 | + * |
|
65 | + * @see http://php.net/fwrite |
|
66 | + * @param string $string |
|
67 | + * @param int $length |
|
68 | + * @return int | bool |
|
69 | + */ |
|
70 | + public function fwrite($string, $length = null) |
|
71 | + { |
|
72 | + return fwrite($this->handle, $string, (is_null($length) ? strlen($string) : $length)); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * fgets |
|
77 | - * |
|
78 | - * @see http://php.net/fgets |
|
79 | - * @param int $length |
|
80 | - */ |
|
81 | - public function fgets($length = null) |
|
82 | - { |
|
83 | - return fgets($this->handle, $length); |
|
84 | - } |
|
75 | + /** |
|
76 | + * fgets |
|
77 | + * |
|
78 | + * @see http://php.net/fgets |
|
79 | + * @param int $length |
|
80 | + */ |
|
81 | + public function fgets($length = null) |
|
82 | + { |
|
83 | + return fgets($this->handle, $length); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * feof |
|
88 | - * |
|
89 | - * @see http://php.net/feof |
|
90 | - * @return bool |
|
91 | - */ |
|
92 | - public function feof() |
|
93 | - { |
|
94 | - return feof($this->handle); |
|
95 | - } |
|
86 | + /** |
|
87 | + * feof |
|
88 | + * |
|
89 | + * @see http://php.net/feof |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | + public function feof() |
|
93 | + { |
|
94 | + return feof($this->handle); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * fclose |
|
99 | - * |
|
100 | - * @see http://php.net/fclose |
|
101 | - * @return bool |
|
102 | - */ |
|
103 | - public function fclose() |
|
104 | - { |
|
105 | - return fclose($this->handle); |
|
106 | - } |
|
97 | + /** |
|
98 | + * fclose |
|
99 | + * |
|
100 | + * @see http://php.net/fclose |
|
101 | + * @return bool |
|
102 | + */ |
|
103 | + public function fclose() |
|
104 | + { |
|
105 | + return fclose($this->handle); |
|
106 | + } |
|
107 | 107 | } |