-
Notifications
You must be signed in to change notification settings - Fork 0
/
ext.moxie_code_auth.php
103 lines (88 loc) · 2.19 KB
/
ext.moxie_code_auth.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
<?php
if (!defined('EXT'))
{
exit('Invalid file request');
}
class Moxie_code_auth
{
var $settings = array();
var $name = 'Moxiecode Authentication';
var $version = '0.1.0';
var $description = 'Restricts Access to TinyMCE File Manager and Image Manager';
var $settings_exist = 'n';
var $docs_url = '';
var $_sess_name = 'isLoggedIn';
function Moxie_code_auth($settings = '')
{
}
function create_moxiecode_session()
{
$this->_start_session();
$_SESSION[$this->_sess_name] = true;
}
function destroy_moxiecode_session()
{
$this->_start_session();
if (isset($_SESSION[$this->_sess_name]))
{
unset($_SESSION[$this->_sess_name]);
if (empty($_SESSION))
{
session_destroy();
}
}
}
function activate_extension()
{
global $DB;
$DB->query($DB->insert_string('exp_extensions',
array(
'extension_id' => '',
'class' => __CLASS__,
'method' => 'create_moxiecode_session',
'hook' => 'cp_member_login',
'settings' => '',
'priority' => 10,
'version' => $this->version,
'enabled' => 'y'
)
)
);
$DB->query($DB->insert_string('exp_extensions',
array(
'extension_id' => '',
'class' => __CLASS__,
'method' => 'destroy_moxiecode_session',
'hook' => 'cp_member_logout',
'settings' => '',
'priority' => 10,
'version' => $this->version,
'enabled' => 'y'
)
)
);
}
function update_extension($current='')
{
global $DB;
if ($current == '' OR $current == $this->version)
{
return FALSE;
}
$DB->query("UPDATE exp_extensions
SET version = '".$DB->escape_str($this->version)."'
WHERE class = '" . __CLASS__ . "'");
}
function disable_extension()
{
global $DB;
$DB->query("DELETE FROM exp_extensions WHERE class = '" . __CLASS__ . "'");
}
function _start_session()
{
if (!isset($_SESSION))
{
session_start();
}
}
}