Subversion Repositories Applications.papyrus

Rev

Rev 1694 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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