www-apps/pmwiki - cookbook - aescrypt
[anomen-overlay.git] / www-apps / pmwiki / cookbook / AesCrypt / aescrypt.php
blobc9a758091921defd7f28216e15c3dbb0d1684e9f
1 <?php if (!defined('PmWiki')) exit();
3 /*
4 AesCrypt
6 Copyright 2011 Anomen (ludek_h@seznam.cz)
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
13 $RecipeInfo['AesCrypt']['Version'] = '2012-04-23';
15 SDV($AesCryptKDF, 'sha256_dup');
16 SDV($AesCryptCipherToken, '(:aes ');
17 SDV($AesCryptEndToken, ':)');
18 SDV($AesCryptPadding, 6);
20 SDV($HTMLStylesFmt['aescrypt'], "
21 #aescrypt_m {
22 position: absolute;
23 z-index: 200;
24 top: 0px;
25 left: 0px;
26 width: 100%;
27 height: 100%;
28 opacity: .4;
29 filter: alpha(opacity=40);
30 /* this hack is so it works in IE
31 * I find setting the color in the css gives me more flexibility
32 * than the PNG solution.
34 background-color:transparent !important;
35 background-color: #333333;
36 /* this hack is for opera support
37 * you can uncomment the background-image if you don't care about opera.
38 * this gives you the flexibility to use any bg color that you want, instead of the png
40 background-image/**/: url('$PubDirUrl/aescrypt/maskbg.png') !important; // For browsers Moz, Opera, etc.
41 background-image:none;
42 background-color:#cccccc;
43 background-repeat: repeat;
44 /*display:none; */
45 visibility: hidden;
48 .aescrypt_overlay {
49 visibility: hidden;
50 position: absolute;
51 left: 0px;
52 top: 0px;
53 width:100%;
54 height:100%;
55 text-align:center;
56 z-index: 1000;
59 .aescrypt_overlay div {
60 width:300px;
61 margin: 100px auto;
62 background-color: #ffffff;
63 border:1px solid #000000;
64 padding:15px;
65 text-align:center;
68 #aescrypt_i {
69 float:right;
72 ");
75 $HTMLHeaderFmt['aescrypt_common'] = "
76 <script type=\"text/javascript\" src=\"\$PubDirUrl/aescrypt/aescrypt.js\"></script>
77 <script type=\"text/javascript\" src=\"\$PubDirUrl/aescrypt/main.js\"></script>
78 <script type=\"text/javascript\">
79 // <![CDATA[
81 /**
82 * Key derivation function selected by AesCryptKDF variable.
84 AesCtr.kdf = function(password, nBits, nonce) {
85 return AesCtr.kdf_$AesCryptKDF (password, nBits, nonce);
88 AesCrypt.AesCryptCipherToken = '$AesCryptCipherToken';
89 AesCrypt.AesCryptEndToken = '$AesCryptEndToken';
90 AesCrypt.AesCryptPadding = $AesCryptPadding;
91 AesCrypt.PubDirUrl = '$PubDirUrl/aescrypt';
93 // ]]>
94 </script>
97 /* generate decryption code */
98 function aescryptMarkup($ciphertext)
100 static $id = 0;
101 $id++;
102 $res = "\n";
103 $res .= "<div id=\"aescrypt_c_$id\" style=\"white-space:pre;display:none;\">$ciphertext</div>";
104 $res .= "<div id=\"aescrypt_d_$id\">";
105 $res .= "<a id=\"aescrypt_a_$id\" href=\"javascript:void (0);\" onClick=\"AesCrypt.decPopup($id);\">";
106 $res .= "[Decrypt]";
107 $res .= "</a>";
108 $res .= "</div>";
109 return $res;
112 Markup('aescrypt',
113 'directives',
114 "/\\Q$AesCryptCipherToken\\E\\s*(.*?)\\s*\\Q$AesCryptEndToken\\E/se",
115 "aescryptMarkup('$1')");
117 if ($action == 'edit') {
119 if (IsEnabled($EnableGUIButtons)) {
120 $GUIButtons['aescrypt'] = array(750, '', '', '',
121 "<a href='#' onclick='AesCrypt.encPopup();'><img src='\$GUIButtonDirUrlFmt/aescrypt.png' title='Encrypt' /></a>");
122 } else {
123 $MessagesFmt[] = "<input type='button' name='aesButton' value='Encrypt' onClick='AesCrypt.encPopup();'/>";