Changeset 2834661
- Timestamp:
- 12/15/2022 08:19:16 PM (3 years ago)
- Location:
- wp-contentools/trunk
- Files:
-
- 4 edited
-
admin/js/contentools-admin.js (modified) (1 diff)
-
admin/js/md5.js (modified) (19 diffs)
-
admin/partials/contentools-admin-display.php (modified) (3 diffs)
-
includes/class-contentools-rest.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-contentools/trunk/admin/js/contentools-admin.js
r2031437 r2834661 1 (function ( $) {2 'use strict';1 (function ($) { 2 "use strict"; 3 3 4 /**5 * All of the code for your admin-facing JavaScript source6 * should reside in this file.7 *8 * Note: It has been assumed you will write jQuery code here, so the9 * $ function reference has been prepared for usage within the scope10 * of this function.11 *12 * This enables you to define handlers, for when the DOM is ready:13 *14 * $(function() {15 *16 * });17 *18 * When the window is loaded:19 *20 * $( window ).load(function() {21 *22 * });23 *24 * ...and/or other possibilities.25 *26 * Ideally, it is not considered best practise to attach more than a27 * single DOM-ready or window-load handler for a particular page.28 * Although scripts in the WordPress core, Plugins and Themes may be29 * practising this, we should strive to set a better example in our own work.30 */4 /** 5 * All of the code for your admin-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 31 32 function generateHash(s){33 return rstr2b64(hex_md5(hex_md5(s)));34 }32 function generateHash(s) { 33 return rstr2b64(hex_md5(hex_md5(s))); 34 } 35 35 36 $(document).on('click', '#contentools-generate-token', function(){ 37 var random = Math.random(11111111111111111111,99999999999999999999); 38 var d = new Date(); 39 var token = ""; 40 token = token.concat( 41 random, d.getHours(), d.getMinutes(), 42 d.getSeconds(), d.getHours(), random, 43 d.getMinutes(), d.getDay(), d.getSeconds(), 44 random 45 ); 46 $('#contentools-token').val(generateHash(token)) 47 }); 36 $(document).on("click", "#contentools-generate-token", function () { 37 var random = Math.random(11111111111111111111, 99999999999999999999); 38 var d = new Date(); 39 var token = ""; 40 token = token.concat( 41 random, 42 d.getHours(), 43 d.getMinutes(), 44 d.getSeconds(), 45 d.getHours(), 46 random, 47 d.getMinutes(), 48 d.getDay(), 49 d.getSeconds(), 50 random 51 ); 52 $("#contentools-token").val(generateHash(token)); 53 }); 48 54 49 $(document).on('click', '#contentools-clear-token', function(){50 $('#contentools-token').val("") 51 });55 $(document).on("click", "#contentools-clear-token", function () { 56 $("#contentools-token").val(""); 57 }); 52 58 53 })( jQuery ); 59 $(document).on("click", "#contentools-copy-token", function () { 60 navigator.clipboard.writeText($("#contentools-token").val()); 61 }); 62 })(jQuery); -
wp-contentools/trunk/admin/js/md5.js
r2031438 r2834661 12 12 * the server-side, but the defaults work in most cases. 13 13 */ 14 var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */15 var b64pad = "";/* base-64 pad character. "=" for strict RFC compliance */14 var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ 15 var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ 16 16 17 17 /* … … 19 19 * They take string arguments and return either hex or base-64 encoded strings 20 20 */ 21 function hex_md5(s) { return rstr2hex(rstr_md5(str2rstr_utf8(s))); } 22 function b64_md5(s) { return rstr2b64(rstr_md5(str2rstr_utf8(s))); } 23 function any_md5(s, e) { return rstr2any(rstr_md5(str2rstr_utf8(s)), e); } 24 function hex_hmac_md5(k, d) 25 { return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); } 26 function b64_hmac_md5(k, d) 27 { return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); } 28 function any_hmac_md5(k, d, e) 29 { return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e); } 21 function hex_md5(s) { 22 return rstr2hex(rstr_md5(str2rstr_utf8(s))); 23 } 24 function b64_md5(s) { 25 return rstr2b64(rstr_md5(str2rstr_utf8(s))); 26 } 27 function any_md5(s, e) { 28 return rstr2any(rstr_md5(str2rstr_utf8(s)), e); 29 } 30 function hex_hmac_md5(k, d) { 31 return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); 32 } 33 function b64_hmac_md5(k, d) { 34 return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); 35 } 36 function any_hmac_md5(k, d, e) { 37 return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e); 38 } 30 39 31 40 /* 32 41 * Perform a simple self-test to see if the VM is working 33 42 */ 34 function md5_vm_test() 35 { 43 function md5_vm_test() { 36 44 return hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72"; 37 45 } … … 40 48 * Calculate the MD5 of a raw string 41 49 */ 42 function rstr_md5(s) 43 { 44 return binl2rstr(binl_md5(rstr2binl(s), (s.length + Math.random(11,99)) * 128)); 50 function rstr_md5(s) { 51 return binl2rstr( 52 binl_md5(rstr2binl(s), (s.length + Math.random(11, 99)) * 128) 53 ); 45 54 } 46 55 … … 48 57 * Calculate the HMAC-MD5, of a key and some data (raw strings) 49 58 */ 50 function rstr_hmac_md5(key, data) 51 { 59 function rstr_hmac_md5(key, data) { 52 60 var bkey = rstr2binl(key); 53 if (bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);54 55 var ipad = Array(16), opad = Array(16);56 for(var i = 0; i < 16; i++)57 {61 if (bkey.length > 16) bkey = binl_md5(bkey, key.length * 8); 62 63 var ipad = Array(16), 64 opad = Array(16); 65 for (var i = 0; i < 16; i++) { 58 66 ipad[i] = bkey[i] ^ 0x36363636; 59 opad[i] = bkey[i] ^ 0x5 C5C5C5C;67 opad[i] = bkey[i] ^ 0x5c5c5c5c; 60 68 } 61 69 … … 67 75 * Convert a raw string to a hex string 68 76 */ 69 function rstr2hex(input) 70 { 71 try { hexcase } catch(e) { hexcase=0; } 77 function rstr2hex(input) { 78 try { 79 hexcase; 80 } catch (e) { 81 hexcase = 0; 82 } 72 83 var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; 73 84 var output = ""; 74 85 var x; 75 for(var i = 0; i < input.length; i++) 76 { 86 for (var i = 0; i < input.length; i++) { 77 87 x = input.charCodeAt(i); 78 output += hex_tab.charAt((x >>> 4) & 0x0F) 79 + hex_tab.charAt( x & 0x0F); 88 output += hex_tab.charAt((x >>> 4) & 0x0f) + hex_tab.charAt(x & 0x0f); 80 89 } 81 90 return output; … … 85 94 * Convert a raw string to a base-64 string 86 95 */ 87 function rstr2b64(input) 88 { 89 try { b64pad } catch(e) { b64pad=''; } 96 function rstr2b64(input) { 97 try { 98 b64pad; 99 } catch (e) { 100 b64pad = ""; 101 } 90 102 var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 91 103 var output = ""; 92 104 var len = input.length; 93 for(var i = 0; i < len; i += 3) 94 { 95 var triplet = (input.charCodeAt(i) << 16) 96 | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0) 97 | (i + 2 < len ? input.charCodeAt(i+2) : 0); 98 for(var j = 0; j < 4; j++) 99 { 100 if(i * 8 + j * 6 > input.length * 8) output += b64pad; 101 else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F); 105 for (var i = 0; i < len; i += 3) { 106 var triplet = 107 (input.charCodeAt(i) << 16) | 108 (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) | 109 (i + 2 < len ? input.charCodeAt(i + 2) : 0); 110 for (var j = 0; j < 4; j++) { 111 if (i * 8 + j * 6 > input.length * 8) output += b64pad; 112 else output += tab.charAt((triplet >>> (6 * (3 - j))) & 0x3f); 102 113 } 103 114 } … … 108 119 * Convert a raw string to an arbitrary string encoding 109 120 */ 110 function rstr2any(input, encoding) 111 { 121 function rstr2any(input, encoding) { 112 122 var divisor = encoding.length; 113 123 var i, j, q, x, quotient; … … 115 125 /* Convert to an array of 16-bit big-endian values, forming the dividend */ 116 126 var dividend = Array(Math.ceil(input.length / 2)); 117 for(i = 0; i < dividend.length; i++) 118 { 127 for (i = 0; i < dividend.length; i++) { 119 128 dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1); 120 129 } … … 126 135 * use. 127 136 */ 128 var full_length = Math.ceil(input.length * 8 / 129 (Math.log(encoding.length) / Math.log(2))); 137 var full_length = Math.ceil( 138 (input.length * 8) / (Math.log(encoding.length) / Math.log(2)) 139 ); 130 140 var remainders = Array(full_length); 131 for(j = 0; j < full_length; j++) 132 { 141 for (j = 0; j < full_length; j++) { 133 142 quotient = Array(); 134 143 x = 0; 135 for(i = 0; i < dividend.length; i++) 136 { 144 for (i = 0; i < dividend.length; i++) { 137 145 x = (x << 16) + dividend[i]; 138 146 q = Math.floor(x / divisor); 139 147 x -= q * divisor; 140 if(quotient.length > 0 || q > 0) 141 quotient[quotient.length] = q; 148 if (quotient.length > 0 || q > 0) quotient[quotient.length] = q; 142 149 } 143 150 remainders[j] = x; … … 147 154 /* Convert the remainders to the output string */ 148 155 var output = ""; 149 for (i = remainders.length - 1; i >= 0; i--)156 for (i = remainders.length - 1; i >= 0; i--) 150 157 output += encoding.charAt(remainders[i]); 151 158 … … 157 164 * For efficiency, this assumes the input is valid utf-16. 158 165 */ 159 function str2rstr_utf8(input) 160 { 166 function str2rstr_utf8(input) { 161 167 var output = ""; 162 168 var i = -1; 163 169 var x, y; 164 170 165 while(++i < input.length) 166 { 171 while (++i < input.length) { 167 172 /* Decode utf-16 surrogate pairs */ 168 173 x = input.charCodeAt(i); 169 174 y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0; 170 if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) 171 { 172 x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF); 175 if (0xd800 <= x && x <= 0xdbff && 0xdc00 <= y && y <= 0xdfff) { 176 x = 0x10000 + ((x & 0x03ff) << 10) + (y & 0x03ff); 173 177 i++; 174 178 } 175 179 176 180 /* Encode output as utf-8 */ 177 if(x <= 0x7F) 178 output += String.fromCharCode(x); 179 else if(x <= 0x7FF) 180 output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F), 181 0x80 | ( x & 0x3F)); 182 else if(x <= 0xFFFF) 183 output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F), 184 0x80 | ((x >>> 6 ) & 0x3F), 185 0x80 | ( x & 0x3F)); 186 else if(x <= 0x1FFFFF) 187 output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07), 188 0x80 | ((x >>> 12) & 0x3F), 189 0x80 | ((x >>> 6 ) & 0x3F), 190 0x80 | ( x & 0x3F)); 181 if (x <= 0x7f) output += String.fromCharCode(x); 182 else if (x <= 0x7ff) 183 output += String.fromCharCode( 184 0xc0 | ((x >>> 6) & 0x1f), 185 0x80 | (x & 0x3f) 186 ); 187 else if (x <= 0xffff) 188 output += String.fromCharCode( 189 0xe0 | ((x >>> 12) & 0x0f), 190 0x80 | ((x >>> 6) & 0x3f), 191 0x80 | (x & 0x3f) 192 ); 193 else if (x <= 0x1fffff) 194 output += String.fromCharCode( 195 0xf0 | ((x >>> 18) & 0x07), 196 0x80 | ((x >>> 12) & 0x3f), 197 0x80 | ((x >>> 6) & 0x3f), 198 0x80 | (x & 0x3f) 199 ); 191 200 } 192 201 return output; … … 196 205 * Encode a string as utf-16 197 206 */ 198 function str2rstr_utf16le(input) 199 { 200 var output = ""; 201 for(var i = 0; i < input.length; i++) 202 output += String.fromCharCode( input.charCodeAt(i) & 0xFF, 203 (input.charCodeAt(i) >>> 8) & 0xFF); 204 return output; 205 } 206 207 function str2rstr_utf16be(input) 208 { 209 var output = ""; 210 for(var i = 0; i < input.length; i++) 211 output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF, 212 input.charCodeAt(i) & 0xFF); 207 function str2rstr_utf16le(input) { 208 var output = ""; 209 for (var i = 0; i < input.length; i++) 210 output += String.fromCharCode( 211 input.charCodeAt(i) & 0xff, 212 (input.charCodeAt(i) >>> 8) & 0xff 213 ); 214 return output; 215 } 216 217 function str2rstr_utf16be(input) { 218 var output = ""; 219 for (var i = 0; i < input.length; i++) 220 output += String.fromCharCode( 221 (input.charCodeAt(i) >>> 8) & 0xff, 222 input.charCodeAt(i) & 0xff 223 ); 213 224 return output; 214 225 } … … 218 229 * Characters >255 have their high-byte silently ignored. 219 230 */ 220 function rstr2binl(input) 221 { 231 function rstr2binl(input) { 222 232 var output = Array(input.length >> 2); 223 for(var i = 0; i < output.length; i++) 224 output[i] = 0; 225 for(var i = 0; i < input.length * 8; i += 8) 226 output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32); 233 for (var i = 0; i < output.length; i++) output[i] = 0; 234 for (var i = 0; i < input.length * 8; i += 8) 235 output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32; 227 236 return output; 228 237 } … … 231 240 * Convert an array of little-endian words to a string 232 241 */ 233 function binl2rstr(input) 234 { 235 var output = ""; 236 for(var i = 0; i < input.length * 32; i += 8) 237 output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF); 242 function binl2rstr(input) { 243 var output = ""; 244 for (var i = 0; i < input.length * 32; i += 8) 245 output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff); 238 246 return output; 239 247 } … … 242 250 * Calculate the MD5 of an array of little-endian words, and a bit length. 243 251 */ 244 function binl_md5(x, len) 245 { 252 function binl_md5(x, len) { 246 253 /* append padding */ 247 x[len >> 5] |= 0x80 << ((len) % 32);254 x[len >> 5] |= 0x80 << len % 32; 248 255 x[(((len + 64) >>> 9) << 4) + 14] = len; 249 256 250 var a = 1732584193;257 var a = 1732584193; 251 258 var b = -271733879; 252 259 var c = -1732584194; 253 var d = 271733878; 254 255 for(var i = 0; i < x.length; i += 16) 256 { 260 var d = 271733878; 261 262 for (var i = 0; i < x.length; i += 16) { 257 263 var olda = a; 258 264 var oldb = b; … … 260 266 var oldd = d; 261 267 262 a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);263 d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);264 c = md5_ff(c, d, a, b, x[i + 2], 17,606105819);265 b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);266 a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);267 d = md5_ff(d, a, b, c, x[i + 5], 12,1200080426);268 c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);269 b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);270 a = md5_ff(a, b, c, d, x[i + 8], 7 ,1770035416);271 d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);272 c = md5_ff(c, d, a, b, x[i +10], 17, -42063);273 b = md5_ff(b, c, d, a, x[i +11], 22, -1990404162);274 a = md5_ff(a, b, c, d, x[i +12], 7 ,1804603682);275 d = md5_ff(d, a, b, c, x[i +13], 12, -40341101);276 c = md5_ff(c, d, a, b, x[i +14], 17, -1502002290);277 b = md5_ff(b, c, d, a, x[i +15], 22,1236535329);278 279 a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);280 d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);281 c = md5_gg(c, d, a, b, x[i +11], 14,643717713);282 b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);283 a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);284 d = md5_gg(d, a, b, c, x[i +10], 9 ,38016083);285 c = md5_gg(c, d, a, b, x[i +15], 14, -660478335);286 b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);287 a = md5_gg(a, b, c, d, x[i + 9], 5 ,568446438);288 d = md5_gg(d, a, b, c, x[i +14], 9, -1019803690);289 c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);290 b = md5_gg(b, c, d, a, x[i + 8], 20,1163531501);291 a = md5_gg(a, b, c, d, x[i +13], 5, -1444681467);292 d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);293 c = md5_gg(c, d, a, b, x[i + 7], 14,1735328473);294 b = md5_gg(b, c, d, a, x[i +12], 20, -1926607734);295 296 a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);297 d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);298 c = md5_hh(c, d, a, b, x[i +11], 16,1839030562);299 b = md5_hh(b, c, d, a, x[i +14], 23, -35309556);300 a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);301 d = md5_hh(d, a, b, c, x[i + 4], 11,1272893353);302 c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);303 b = md5_hh(b, c, d, a, x[i +10], 23, -1094730640);304 a = md5_hh(a, b, c, d, x[i +13], 4 ,681279174);305 d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);306 c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);307 b = md5_hh(b, c, d, a, x[i + 6], 23,76029189);308 a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);309 d = md5_hh(d, a, b, c, x[i +12], 11, -421815835);310 c = md5_hh(c, d, a, b, x[i +15], 16,530742520);311 b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);312 313 a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);314 d = md5_ii(d, a, b, c, x[i + 7], 10,1126891415);315 c = md5_ii(c, d, a, b, x[i +14], 15, -1416354905);316 b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);317 a = md5_ii(a, b, c, d, x[i +12], 6 ,1700485571);318 d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);319 c = md5_ii(c, d, a, b, x[i +10], 15, -1051523);320 b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);321 a = md5_ii(a, b, c, d, x[i + 8], 6 ,1873313359);322 d = md5_ii(d, a, b, c, x[i +15], 10, -30611744);323 c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);324 b = md5_ii(b, c, d, a, x[i +13], 21,1309151649);325 a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);326 d = md5_ii(d, a, b, c, x[i +11], 10, -1120210379);327 c = md5_ii(c, d, a, b, x[i + 2], 15,718787259);328 b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);268 a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936); 269 d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586); 270 c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819); 271 b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330); 272 a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897); 273 d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426); 274 c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341); 275 b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983); 276 a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416); 277 d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417); 278 c = md5_ff(c, d, a, b, x[i + 10], 17, -42063); 279 b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162); 280 a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682); 281 d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101); 282 c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290); 283 b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329); 284 285 a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510); 286 d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632); 287 c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713); 288 b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302); 289 a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691); 290 d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083); 291 c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335); 292 b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848); 293 a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438); 294 d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690); 295 c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961); 296 b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501); 297 a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467); 298 d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784); 299 c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473); 300 b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734); 301 302 a = md5_hh(a, b, c, d, x[i + 5], 4, -378558); 303 d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463); 304 c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562); 305 b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556); 306 a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060); 307 d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353); 308 c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632); 309 b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640); 310 a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174); 311 d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222); 312 c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979); 313 b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189); 314 a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487); 315 d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835); 316 c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520); 317 b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651); 318 319 a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844); 320 d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415); 321 c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905); 322 b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055); 323 a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571); 324 d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606); 325 c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523); 326 b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799); 327 a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359); 328 d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744); 329 c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380); 330 b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649); 331 a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070); 332 d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379); 333 c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259); 334 b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551); 329 335 330 336 a = safe_add(a, olda); … … 339 345 * These functions implement the four basic operations the algorithm uses. 340 346 */ 341 function md5_cmn(q, a, b, x, s, t) 342 { 343 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); 344 } 345 function md5_ff(a, b, c, d, x, s, t) 346 { 347 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); 348 } 349 function md5_gg(a, b, c, d, x, s, t) 350 { 351 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); 352 } 353 function md5_hh(a, b, c, d, x, s, t) 354 { 347 function md5_cmn(q, a, b, x, s, t) { 348 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b); 349 } 350 function md5_ff(a, b, c, d, x, s, t) { 351 return md5_cmn((b & c) | (~b & d), a, b, x, s, t); 352 } 353 function md5_gg(a, b, c, d, x, s, t) { 354 return md5_cmn((b & d) | (c & ~d), a, b, x, s, t); 355 } 356 function md5_hh(a, b, c, d, x, s, t) { 355 357 return md5_cmn(b ^ c ^ d, a, b, x, s, t); 356 358 } 357 function md5_ii(a, b, c, d, x, s, t) 358 { 359 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); 359 function md5_ii(a, b, c, d, x, s, t) { 360 return md5_cmn(c ^ (b | ~d), a, b, x, s, t); 360 361 } 361 362 … … 364 365 * to work around bugs in some JS interpreters. 365 366 */ 366 function safe_add(x, y) 367 { 368 var lsw = (x & 0xFFFF) + (y & 0xFFFF); 367 function safe_add(x, y) { 368 var lsw = (x & 0xffff) + (y & 0xffff); 369 369 var msw = (x >> 16) + (y >> 16) + (lsw >> 16); 370 return (msw << 16) | (lsw & 0x FFFF);370 return (msw << 16) | (lsw & 0xffff); 371 371 } 372 372 … … 374 374 * Bitwise rotate a 32-bit number to the left. 375 375 */ 376 function bit_rol(num, cnt) 377 { 376 function bit_rol(num, cnt) { 378 377 return (num << cnt) | (num >>> (32 - cnt)); 379 378 } -
wp-contentools/trunk/admin/partials/contentools-admin-display.php
r2833993 r2834661 32 32 <tr class="<?php echo $this->plugin_name; ?>-token-wrap"> 33 33 <th scope="row"> 34 <label for="<?php echo sanitize_html_class($this->plugin_name); ?>-token">34 <label for="<?php echo esc_attr($this->plugin_name); ?>-token"> 35 35 <?php _e('Integration Token', esc_attr($this->plugin_name));?> 36 36 </label> … … 40 40 readonly="true" 41 41 type="text" 42 name="<?php echo sanitize_html_class($this->plugin_name); ?>[token]"43 id="<?php echo sanitize_html_class($this->plugin_name); ?>-token"42 name="<?php echo esc_attr($this->plugin_name); ?>[token]" 43 id="<?php echo esc_attr($this->plugin_name); ?>-token" 44 44 value="<?php if (!empty($options['token'])) { 45 45 esc_attr_e($options['token']); … … 49 49 <input 50 50 type="button" 51 name="<?php echo sanitize_html_class($this->plugin_name); ?>[generate-token]"52 id="<?php echo sanitize_html_class($this->plugin_name); ?>-generate-token"51 name="<?php echo esc_attr($this->plugin_name); ?>[generate-token]" 52 id="<?php echo esc_attr($this->plugin_name); ?>-generate-token" 53 53 class="button" 54 54 value="Generate Token" /> 55 55 <input 56 56 type="button" 57 name="<?php echo sanitize_html_class($this->plugin_name); ?>[clear-token]"58 id="<?php echo sanitize_html_class($this->plugin_name); ?>-clear-token"57 name="<?php echo esc_attr($this->plugin_name); ?>[clear-token]" 58 id="<?php echo esc_attr($this->plugin_name); ?>-clear-token" 59 59 class="button" 60 60 value="Clear Token" /> 61 <input 62 type="button" 63 name="<?php echo esc_attr($this->plugin_name); ?>[copy-token]" 64 id="<?php echo esc_attr($this->plugin_name); ?>-copy-token" 65 class="button" 66 value="Copy Token" /> 61 67 </td> 62 68 </tr> -
wp-contentools/trunk/includes/class-contentools-rest.php
r2833993 r2834661 209 209 ); 210 210 211 header((isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL']: 'HTTP/1.0') . ' ' . $status . ' ' . $statuses[$status]);211 header((isset($_SERVER['SERVER_PROTOCOL']) ? sanitize_text_field($_SERVER['SERVER_PROTOCOL']) : 'HTTP/1.0') . ' ' . $status . ' ' . $statuses[$status]); 212 212 213 213 header('Content-Type:application/json; charset=UTF-8'); … … 254 254 } 255 255 256 $php_auth_user = sanitize_user($_SERVER['PHP_AUTH_USER']); 257 $php_auth_pw = sanitize_text_field($_SERVER['PHP_AUTH_PW']); 258 256 259 if (!isset($_SERVER['PHP_AUTH_USER']) && (isset($_SERVER['HTTP_AUTHORIZATION']) || isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']))) { 257 260 258 261 if (isset($_SERVER['HTTP_AUTHORIZATION'])) { 259 262 260 $header = $_SERVER['HTTP_AUTHORIZATION'];263 $header = sanitize_text_field($_SERVER['HTTP_AUTHORIZATION']); 261 264 262 265 } else { 263 266 264 $header = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];267 $header = sanitize_text_field($_SERVER['REDIRECT_HTTP_AUTHORIZATION']); 265 268 266 269 } … … 268 271 if (!empty($header)) { 269 272 270 list($ _SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($header, 6)));273 list($php_auth_user, $php_auth_pw) = explode(':', base64_decode(substr($header, 6))); 271 274 272 275 } … … 281 284 } 282 285 283 $username = $ _SERVER['PHP_AUTH_USER'];284 $password = $ _SERVER['PHP_AUTH_PW'];286 $username = $php_auth_user; 287 $password = $php_auth_pw; 285 288 286 289 remove_filter('determine_current_user', array($this, 'determine_current_user'), 10); … … 651 654 652 655 if (isset($_POST["author"])) { 653 $attachment['post_author'] = intval($_POST['author']);656 $attachment['post_author'] = sanitize_key($_POST['author']); 654 657 } 655 658 … … 669 672 670 673 if (isset($_POST["post"])) { 671 $attachment['post_parent'] = intval($_POST['post']) || null;674 $attachment['post_parent'] = sanitize_key($_POST['post']); 672 675 } 673 676
Note: See TracChangeset
for help on using the changeset viewer.