Merge branch 'bug-1273' into release
[cacert-devel.git] / cgi-bin / siteseal.cgi
1 #!/usr/bin/php -q
2 <?
3 /**
4 * check site seal
5 *
6 * @package org.cacert.framework
7 * @author Duane Groth <duane@groth.net>
8 * @copyright Copyright (C) 2003-2008, {@link http://www.cacert.org/ CAcert Inc.}
9 * @license GPL Version 2
10 * @version $Id: siteseal.cgi,v 1.4 2008-04-06 19:44:25 root Exp $
11 */
12
13 if($_SERVER["HTTPS"] == "on")
14 $http = "https";
15 else
16 $http = "http";
17
18 /* obfuscate var names */
19 srand((double)microtime()*1000000);
20 $var1 = "ca1-".md5(rand(0,9999999));
21 $var2 = "ca2-".md5(rand(0,9999999));
22 $var3 = "ca3-".md5(rand(0,9999999));
23 $var4 = "ca4-".md5(rand(0,9999999));
24 $var5 = "ca5-".md5(rand(0,9999999));
25 $var6 = "ca6-".md5(rand(0,9999999));
26 $var7 = "ca7-".md5(rand(0,9999999));
27 $var8 = "ca8-".md5(rand(0,9999999));
28 $var9 = "ca9-".md5(rand(0,9999999));
29 $var10 = "caa-".md5(rand(0,9999999));
30 $var11 = "cab-".md5(rand(0,9999999));
31
32 header("Content-Type: text/javascript");
33 header("Content-Disposition: inline; filename=\"siteseal.js\"");
34
35 ?>
36
37 var <?=$var1?> = window.location.href;
38 <? // var <?=$var2?> = '<?=$http?>://www.cacert.org/certdetails.php?referer=' + <?=$var1?>; ?>
39 var <?=$var2?> = '<?=$http?>://www.cacert.org';
40 var <?=$var3?> = (new Date()).getTimezoneOffset();
41
42 var <?=$var4?> = navigator.userAgent.toLowerCase();
43 var <?=$var5?> = false;
44 if (<?=$var4?>.indexOf("msid") != 1) {
45 <?=$var5?> = (<?=$var4?>.indexOf("msie 5") == -1 && <?=$var4?>.indexOf("msie 6") == -1);
46 }
47
48 function <?=$var6?>(e) {
49 if (document.addEventListener) {
50 if (e.target.name == '<?=$var7?>') {
51 <?=$var8?>();
52 return false;
53 }
54 } else if (document.captureEvents) {
55 if (e.target.toString().indexOf('certdetails') != -1) {
56 <?=$var8?>();
57 return false;
58 }
59 }
60 return true;
61 }
62
63 function <?=$var9?>() {
64 if (event.button == 1) {
65 if (<?=$var5?>) {
66 return true;
67 } else {
68 <?=$var8?>();
69 return false;
70 }
71 } else if (event.button == 2) {
72 <?=$var8?>();
73 return false;
74 }
75 }
76
77 function <?=$var8?>() {
78 cacertWindow = window.open(<?=$var2?>, '<?=$var10?>', config='height=420,width=523,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=yes');
79 cacertWindow.focus();
80 }
81
82 if (document.addEventListener) {
83 document.addEventListener('mouseup', <?=$var6?>, true);
84 } else {
85 if (document.layers) {
86 document.captureEvents(Event.MOUSEDOWN);
87 document.onmousedown=<?=$var6?>;
88 }
89 }
90
91 document.write("<a href='" + <?=$var2?> + "' target='<?=$var10?>' tabindex='-1' onmousedown='<?=$var9?>(); return false;'><img name='<?=$var7?>' border='0' src='<?=$http?>://www.cacert.org/sealgen.php?cert=<?=$cert?>&referer=" + <?=$var1?> + "' alt='Click to verify' oncontextmenu='return false;' /></a>"); ?>
92