-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSpecialEncrypt.php
More file actions
76 lines (73 loc) · 2.76 KB
/
SpecialEncrypt.php
File metadata and controls
76 lines (73 loc) · 2.76 KB
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
<?php
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is a MediaWiki extension. It is not a valid entry point' );
}
class SpecialEncrypt extends SpecialPage {
function __construct( ) {
parent::__construct( 'Encrypt', 'encrypt' );
}
public function userCanExecute( User $user ) {
return true;
}
function execute( $par ) {
$user = $this->getUser();
if ( !$user->isAllowed( 'encrypt' ) ) {
throw new PermissionsError( null, array( array(
'encrypt-notallowed' ) ) );
}
$this->setHeaders();
$output = $this->getOutput();
global $wgScript, $wgROT13DefaultKey;
$request = $this->getRequest();
$content = $request->getVal( 'page' );
$parVal = $request->getVal( 'par' );
if ( $parVal ) {
$par = $parVal;
}
if ( !$par || strlen( $par ) != 52 ) {
$par = $wgROT13DefaultKey;
}
$this->getOutput()->addHTML(
Xml::textarea( 'page', $content, 40, 5, array( 'form' => 'viewwikitext-form1' ) ) . ' ' .
Html::closeElement( 'textarea' ) . "\n" .
Html::openElement( 'form', array( 'method' => 'post', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'viewwikitext-form1' ) ) .
Xml::submitButton( $this->msg( 'htmlform-submit' )->text() ) .
Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
Html::hidden( 'par', $par ) .
Html::closeElement( 'form' ) . "\n"
);
$keys = str_split ( $par, strlen ( $par ) / 2 );
$text = '';
$newOutput = '';
if ( $content ) {
$array = str_split ( $content );
foreach ( $array as $element ) {
if ( strpos ( $keys[0], strtolower ( $element ) ) !== FALSE ) {
$newChar = substr ( $keys[1], strpos ( $keys[0],
strtolower ( $element ) ), 1 );
if ( ctype_upper ( $element ) ) {
$newChar = strtoupper( $newChar );
} else {
$newChar = strtolower( $newChar );
}
$newOutput .= $newChar;
} else {
$newOutput .= $element;
}
}
}
$text = $newOutput;
#$pageLang = $title->getPageLanguage();
$params = array(
'id' => 'wpTextbox1',
'name' => 'wpTextbox1',
'cols' => $this->getUser()->getOption( 'cols' ),
'rows' => $this->getUser()->getOption( 'rows' ),
'readonly' => 'readonly',
#'lang' => $pageLang->getHtmlCode(),
#'dir' => $pageLang->getDir(),
);
$output->addHTML( Html::element( 'textarea', $params, $text ) );
return;
}
}