CMS
Version 3.9
admin_page_proxy_view.inc
Go to the documentation of this file.
1
<?php
7
/**************************************************************
8
9
Copyright (c) 2010 Sonjara, Inc
10
11
Permission is hereby granted, free of charge, to any person
12
obtaining a copy of this software and associated documentation
13
files (the "Software"), to deal in the Software without
14
restriction, including without limitation the rights to use,
15
copy, modify, merge, publish, distribute, sublicense, and/or sell
16
copies of the Software, and to permit persons to whom the
17
Software is furnished to do so, subject to the following
18
conditions:
19
20
The above copyright notice and this permission notice shall be
21
included in all copies or substantial portions of the Software.
22
23
Except as contained in this notice, the name(s) of the above
24
copyright holders shall not be used in advertising or otherwise
25
to promote the sale, use or other dealings in this Software
26
without prior written authorization.
27
28
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35
OTHER DEALINGS IN THE SOFTWARE.
36
37
*****************************************************************/
38
39
class
AdminPageProxyView
40
{
41
var
$adminPage
=
null
;
42
43
function
__construct
()
44
{
45
global
$isAction
;
46
global
$isResource
;
47
global $isAdmin;
48
49
global
$identifier
;
50
global
$page
;
51
global
$section
;
52
global
$config
;
53
54
// Security rules for AdminPageProxies
55
56
// #0 - AdminPageProxyView can only be instantiated in a ComponentPage script - not inside an action handler, resource or admin page
57
// #1 - admin page may only be exposed by a component page that has the same identifier (i.e. script has same name)
58
// #2 - admin page must be in the same component as the component page creating the proxy
59
// #3 - page must be served under SSL
60
// #4 - user must have one of the privileged access roles (i.e. role must be able to access the admin section)
61
62
try
63
{
64
$this->adminPage =
AdminPage::fromIdentifier
(
$identifier
);
65
}
66
catch
(DataNotFoundException $e)
67
{
68
throw
new
FakoliException
(
"No matching admin page"
);
69
}
70
71
$adminComponent = $this->adminPage->Component();
72
$hostComponent =
$page
->Component();
73
74
$https =
Fakoli::checkSSL
();
75
76
// #0
77
if
(
$isAction
||
$isResource
|| $isAdmin)
78
{
79
throw
new
FakoliException
(
"Incorrect execution context for proxy view"
);
80
}
81
82
// #1
83
if
(
$page
->identifier != $this->adminPage->identifier)
84
{
85
throw
new
FakoliException
(
"Proxy identifier mismatch"
);
86
}
87
88
// #2
89
if
($adminComponent->component_id != $hostComponent->component_id)
90
{
91
throw
new
FakoliException
(
"Proxy component mismatch"
);
92
}
93
94
// #3
95
96
if
(!$https)
97
{
98
throw
new
FakoliException
(
"Connection not secured by SSL"
);
99
}
100
101
// #4
102
103
$adminAccess
=
$config
[
"admin_access_roles"
];
104
if
(!
$adminAccess
)
$adminAccess
=
"admin"
;
105
106
if
(!checkRole(
$adminAccess
))
107
{
108
throw
new
FakoliException
(
"Insufficiently privileged"
);
109
}
110
111
$shim =
AdminManager::getAdminProxyShim
();
112
if
(is_callable($shim)) $shim();
113
}
114
115
function
drawView
()
116
{
117
global
$config
;
118
global
$method
;
119
global
$user
;
120
global
$script
;
121
global
$styles
;
122
global $dialogs;
123
global
$page
;
124
global
$menu_item
;
125
global $isAdmin;
126
127
require_once $this->adminPage->server_path;
128
}
129
}?>
$menu_item
$menu_item
Definition:
activity_report.inc:8
$script
$script
Definition:
activity_report.inc:37
$section
$section
Definition:
event_form.inc:44
$page
$page
Definition:
help.inc:39
$adminAccess
if(! $class||! $itemID) $adminAccess
Definition:
approve.inc:12
AdminManager\getAdminProxyShim
static getAdminProxyShim()
Definition:
admin_manager.inc:20
AdminPage\fromIdentifier
static fromIdentifier($identifier)
Definition:
admin_page.inc:60
AdminPageProxyView
Definition:
admin_page_proxy_view.inc:40
AdminPageProxyView\__construct
__construct()
Definition:
admin_page_proxy_view.inc:43
AdminPageProxyView\drawView
drawView()
Definition:
admin_page_proxy_view.inc:115
AdminPageProxyView\$adminPage
$adminPage
Definition:
admin_page_proxy_view.inc:41
FakoliException
FakoliException is the base exception class for all Fakoli errors.
Definition:
core.inc:53
Fakoli\checkSSL
static checkSSL()
Checks if SSL is enabled on the current request.
Definition:
core.inc:958
$user
global $user
Definition:
comment_form.inc:16
$method
$method
Pull out a simple reference to the request method.
Definition:
core.inc:1573
$isResource
$isResource
Definition:
core.inc:1585
$isAction
if($config["default_content_type"]) $isAction
Definition:
core.inc:1584
$config
global $config
Definition:
import.inc:4
$styles
$styles
Definition:
blog_article_form.inc:85
$identifier
$identifier
Definition:
rss.inc:37
code
cms.sonjara.com
cms
components
admin
admin_page_proxy_view.inc
Generated on Tue Mar 23 2021 15:36:11 for CMS by
1.9.1