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