forked from beck24/elgg_recaptcha
/
start.php
108 lines (81 loc) · 2.09 KB
/
start.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
namespace Beck24\ReCaptcha;
const PLUGIN_ID = 'elgg_recaptcha';
const PLUGIN_VERSION = 20150919;
require_once __DIR__ . '/lib/functions.php';
require_once __DIR__ . '/lib/hooks.php';
elgg_register_event_handler('init', 'system', __NAMESPACE__ . '\\init');
function init() {
elgg_extend_view('css/elgg', 'css/elgg_recaptcha');
elgg_register_plugin_hook_handler('view', 'all', __NAMESPACE__ . '\\view_hook');
elgg_register_plugin_hook_handler('action', 'all', __NAMESPACE__ . '\\action_hook');
elgg_define_js('google_recaptcha', array(
'src' => 'https://www.google.com/recaptcha/api.js?render=explicit&onload=elgg_recaptcha_render&hl=' . get_language()
));
}
/**
*
* @staticvar type $browsers
* @return typeget an array of browsers we can identify
*/
function get_browsers() {
static $browsers;
if ($browsers) {
return $browsers;
}
$refl = new \ReflectionClass('BrowserDetection');
$constants = $refl->getConstants();
$browsers = array();
foreach ($constants as $name => $value) {
if (strpos($name, 'BROWSER_') === 0) {
$browsers[$name] = $value;
}
}
asort($browsers);
return $browsers;
}
/**
* get an array of platforms we can identify
*/
function get_platforms() {
static $platforms;
if ($platforms) {
return $platforms;
}
$refl = new \ReflectionClass('BrowserDetection');
$constants = $refl->getConstants();
$platforms = array();
foreach ($constants as $name => $value) {
if (strpos($name, 'PLATFORM_') === 0) {
$platforms[$name] = $value;
}
}
asort($platforms);
return $platforms;
}
/**
* get the current users platform
*/
function get_platform($label = true) {
$browser = new \BrowserDetection();
$l = $browser->getPlatform();
if ($label) {
return $l;
}
// return the machine name
$platforms = get_platforms();
return array_search($l, $platforms);
}
/**
* get the current users browser
*/
function get_browser($label = true) {
$browser = new \BrowserDetection();
$l = $browser->getBrowser();
if ($label) {
return $l;
}
// return the machine name
$browsers = get_browsers();
return array_search($l, $browsers);
}