-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProtectTag.php
137 lines (122 loc) · 3.19 KB
/
ProtectTag.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* ProtectTag allows to do the following operations:
* - modify protect-tags
* - set attributes (parameters) for protect tags
*
* PHP version 5
*
* @category Encryption
* @package PageProtectionPlus
* @author Fabian Schmitt <[email protected]>, Pawel Wilk <[email protected]>
* @copyright 2006, 2007 Fabian Schmitt
* @license http://www.gnu.org/licenses/gpl.html General Public License version 2 or higher
* @version 2.3b
* @link http://www.mediawiki.org/wiki/Extension:PPP
*/
require_once("AccessList.php");
require_once("CipherSuite.php");
/**
* Helper for modifying protect-tags.
* Initialise with setters and then call getStart() and getEnd().
* @todo Add getters and fromString-method.
*/
class ProtectTag
{
public $mAccess = null;
public $mShow = "";
public $mErrorPage = "";
public $mCipher = "";
private $mValidShow = array("warning", "crypt", "page", "none", "text");
private $mCipherSuite = null;
/**
* Constructor. Creates default-tag.
*/
function ProtectTag()
{
$this->setShow("warning");
$this->setAccessList(new AccessList());
$this->setCipherSuite(new CipherSuite());
}
/**
* Set access list for current tag
* @param access AccessList-Object
*/
public function setAccessList($access)
{
$this->mAccess = $access;
$this->mAccess->AccessListDefaults();
}
/**
* Set ciphersuite for current tag.
* @param ciphersuite-object
*/
public function setCipherSuite($ciphersuite)
{
$this->mCipherSuite = $ciphersuite;
}
/**
* Sets parameter "cipher" for current tag.
* @param cipher name
*/
public function setCipher($cipher)
{
$cipher = $this->mCipherSuite->correct_cipher_name($cipher);
if ($cipher === false) {
$cipher = "";
}
$this->mCipher = $cipher;
}
/**
* Sets parameter "show" and checks for allowed values.
* @param show "show"-parameter
*/
public function setShow($show)
{
if (in_array($show, $this->mValidShow)) {
$this->mShow = $show;
}
}
/**
* Sets parameter "errorpage".
* @param page "errorpage"
*/
public function setErrorPage($page)
{
$this->mErrorPage = $page;
}
/**
* Gets formatted start-tag of this object. It contains only the
* needed parameters.
* @return String with start-tag
*/
public function getStart()
{
$tag = "<".PROTECT_TAG." ";
if ($this->mShow != "") {
$tag = $tag."show=\"".$this->mShow."\"";
}
if ($this->mErrorPage != "") {
$tag = $tag." errorpage=\"".$this->mErrorPage."\"";
}
if ($this->mCipher != "") {
$tag = $tag." cipher=\"".$this->mCipher."\"";
}
$tag = $tag
." "
.$this->mAccess->getUsersParam()
." "
.$this->mAccess->getGroupsParam()
.">";
return $tag;
}
/**
* Gets the end-tag of this protect-tag.
* @return String with end-tag
*/
public function getEnd()
{
return "</".PROTECT_TAG.">";
}
}
?>