1701 |
ddelon |
1 |
<?php
|
|
|
2 |
ob_start("ob_gzhandler");
|
|
|
3 |
require_once(realpath(dirname(__FILE__) . '/') . '/secret/wp-hashcash.lib');
|
|
|
4 |
|
|
|
5 |
$field_id = hashcash_random_string(rand(6,18));
|
|
|
6 |
$fn_enable_name = hashcash_random_string(rand(6,18));
|
|
|
7 |
?>
|
|
|
8 |
|
|
|
9 |
addLoadEvent(<?php echo $fn_enable_name; ?>);
|
|
|
10 |
|
|
|
11 |
function createHiddenField(){
|
|
|
12 |
var inp = document.createElement('input');
|
|
|
13 |
inp.setAttribute('type', 'hidden');
|
|
|
14 |
inp.setAttribute('id', '<?php echo $field_id; ?>');
|
|
|
15 |
inp.setAttribute('name', 'hashcash_value');
|
|
|
16 |
inp.setAttribute('value', '-1');
|
|
|
17 |
|
|
|
18 |
var e = document.getElementById('<?php echo HASHCASH_FORM_ID; ?>');
|
|
|
19 |
e.appendChild(inp);
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
function addVerbage(){
|
1704 |
ddelon |
23 |
var e = document.getElementById('<?php echo HASHCASH_FORM_CLASS; ?>');
|
1701 |
ddelon |
24 |
var p = document.createElement('p');
|
|
|
25 |
p.innerHTML = '<?php echo str_replace("'", "\'", hashcash_verbage()); ?>';
|
1704 |
ddelon |
26 |
e.appendChild(p);
|
1701 |
ddelon |
27 |
}
|
|
|
28 |
|
|
|
29 |
function <?php echo $fn_enable_name;?>(){
|
|
|
30 |
createHiddenField();
|
|
|
31 |
addVerbage();
|
|
|
32 |
loadHashCashKey('<?php
|
|
|
33 |
echo $_GET['siteurl']; ?>/client/integrateur_wikini/bibliotheque/hashcash/wp-hashcash-getkey.php', '<?php echo $field_id; ?>');
|
|
|
34 |
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
function loadHashCashKey(fragment_url, e_id) {
|
|
|
38 |
var xmlhttp=createXMLHttp();
|
|
|
39 |
var element = document.getElementById(e_id);
|
|
|
40 |
|
|
|
41 |
xmlhttp.open("GET", fragment_url, true);
|
|
|
42 |
xmlhttp.onreadystatechange = function() {
|
|
|
43 |
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
|
|
44 |
element.value = eval(xmlhttp.responseText);
|
|
|
45 |
}
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
xmlhttp.send(null);
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
function getElementsByClass(searchClass,node,tag) {
|
|
|
52 |
var classElements = new Array();
|
|
|
53 |
if ( node == null )
|
|
|
54 |
node = document;
|
|
|
55 |
if ( tag == null )
|
|
|
56 |
tag = '*';
|
|
|
57 |
var els = node.getElementsByTagName(tag);
|
|
|
58 |
var elsLen = els.length;
|
|
|
59 |
var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
|
|
|
60 |
for (i = 0, j = 0; i < elsLen; i++) {
|
|
|
61 |
if ( pattern.test(els[i].className) ) {
|
|
|
62 |
classElements[j] = els[i];
|
|
|
63 |
j++;
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
return classElements;
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
function createXMLHttp() {
|
|
|
70 |
if (typeof XMLHttpRequest != "undefined")
|
|
|
71 |
return new XMLHttpRequest();
|
|
|
72 |
|
|
|
73 |
var xhrVersion = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp","Microsoft.XMLHttp" ];
|
|
|
74 |
|
|
|
75 |
for (var i = 0; i < xhrVersion.length; i++) {
|
|
|
76 |
try {
|
|
|
77 |
var xhrObj = new ActiveXObject(xhrVersion[i]);
|
|
|
78 |
return xhrObj;
|
|
|
79 |
} catch (e) { }
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
return null;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
function addLoadEvent(func) {
|
|
|
86 |
var oldonload = window.onload;
|
|
|
87 |
if (typeof window.onload != 'function') {
|
|
|
88 |
window.onload = func;
|
|
|
89 |
} else {
|
|
|
90 |
window.onload = function() {
|
|
|
91 |
func();
|
|
|
92 |
oldonload();
|
|
|
93 |
}
|
|
|
94 |
}
|
|
|
95 |
}
|