some gpg code added + bug fixes etc
parent
21cc988c40
commit
2e0fce259e
@ -0,0 +1,91 @@
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
/**
|
||||
* check site seal
|
||||
*
|
||||
* @package org.cacert.framework
|
||||
* @author Duane Groth <duane@groth.net>
|
||||
* @copyright Copyright (C) 2003, {@link http://www.cacert.org/ CAcert Inc.}
|
||||
* @version $Id: siteseal.cgi,v 1.1 2004/11/10 06:12:43 root Exp $
|
||||
*/
|
||||
|
||||
if($_SERVER["HTTPS"] == "on")
|
||||
$http = "https";
|
||||
else
|
||||
$http = "http";
|
||||
|
||||
/* obfuscate var names */
|
||||
srand((double)microtime()*1000000);
|
||||
$var1 = "ca".md5(rand(0,9999999));
|
||||
$var2 = "ca".md5(rand(0,9999999));
|
||||
$var3 = "ca".md5(rand(0,9999999));
|
||||
$var4 = "ca".md5(rand(0,9999999));
|
||||
$var5 = "ca".md5(rand(0,9999999));
|
||||
$var6 = "ca".md5(rand(0,9999999));
|
||||
$var7 = "ca".md5(rand(0,9999999));
|
||||
$var8 = "ca".md5(rand(0,9999999));
|
||||
$var9 = "ca".md5(rand(0,9999999));
|
||||
$var10 = "ca".md5(rand(0,9999999));
|
||||
$var11 = "ca".md5(rand(0,9999999));
|
||||
|
||||
header("Content-Type: text/javascript");
|
||||
header("Content-Disposition: inline; filename=\"siteseal.js\"");
|
||||
|
||||
?>
|
||||
|
||||
var <?=$var1?> = window.location.href;
|
||||
<? // var <?=$var2?> = '<?=$http?>://www.cacert.org/certdetails.php?referer=' + <?=$var1?>; ?>
|
||||
var <?=$var2?> = '<?=$http?>://www.cacert.org';
|
||||
var <?=$var3?> = (new Date()).getTimezoneOffset();
|
||||
|
||||
var <?=$var4?> = navigator.userAgent.toLowerCase();
|
||||
var <?=$var5?> = false;
|
||||
if (<?=$var4?>.indexOf("msid") != 1) {
|
||||
<?=$var5?> = (<?=$var4?>.indexOf("msie 5") == -1 && <?=$var4?>.indexOf("msie 6") == -1);
|
||||
}
|
||||
|
||||
function <?=$var6?>(e) {
|
||||
if (document.addEventListener) {
|
||||
if (e.target.name == '<?=$var7?>') {
|
||||
<?=$var8?>();
|
||||
return false;
|
||||
}
|
||||
} else if (document.captureEvents) {
|
||||
if (e.target.toString().indexOf('certdetails') != -1) {
|
||||
<?=$var8?>();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function <?=$var9?>() {
|
||||
if (event.button == 1) {
|
||||
if (<?=$var5?>) {
|
||||
return true;
|
||||
} else {
|
||||
<?=$var8?>();
|
||||
return false;
|
||||
}
|
||||
} else if (event.button == 2) {
|
||||
<?=$var8?>();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function <?=$var8?>() {
|
||||
cacertWindow = window.open(<?=$var2?>, '<?=$var10?>', config='height=420,width=523,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=yes');
|
||||
cacertWindow.focus();
|
||||
}
|
||||
|
||||
if (document.addEventListener) {
|
||||
document.addEventListener('mouseup', <?=$var6?>, true);
|
||||
} else {
|
||||
if (document.layers) {
|
||||
document.captureEvents(Event.MOUSEDOWN);
|
||||
document.onmousedown=<?=$var6?>;
|
||||
}
|
||||
}
|
||||
|
||||
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>"); ?>
|
||||
|
@ -0,0 +1,101 @@
|
||||
<? /*
|
||||
Copyright (C) 2004 by Duane Groth <duane_at_CAcert_dot_org>
|
||||
|
||||
This file is part of CAcert.
|
||||
|
||||
CAcert has been released under a CAcert Source license
|
||||
which can be found included with these source files or can
|
||||
be downloaded from the internet from the following address:
|
||||
http://www.cacert.org/src-lic.php
|
||||
|
||||
CAcert is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the License for more details.
|
||||
*/
|
||||
|
||||
if($_SERVER['HTTP_HOST'] == "secure.cacert.org")
|
||||
{
|
||||
$query = "select * from `emailcerts` where `serial`='$_SERVER[SSL_CLIENT_M_SERIAL]' and `revoked`=0 and
|
||||
UNIX_TIMESTAMP(`expire`) - UNIX_TIMESTAMP() > 0";
|
||||
$res = mysql_query($query);
|
||||
if(mysql_num_rows($res) > 0)
|
||||
{
|
||||
$row = mysql_fetch_assoc($res);
|
||||
|
||||
$_SESSION['profile'] = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".$row['memid']."'"));
|
||||
$_SESSION['profile']['loggedin'] = 1;
|
||||
} else {
|
||||
$_SESSION['profile']['loggedin'] = 0;
|
||||
|
||||
unset($_SESSION['_config']['oldlocation']);
|
||||
|
||||
foreach($_GET as $key => $val)
|
||||
{
|
||||
if($_SESSION['_config']['oldlocation'])
|
||||
$_SESSION['_config']['oldlocation'] .= "&";
|
||||
|
||||
$_SESSION['_config']['oldlocation'] .= "$key=$val";
|
||||
}
|
||||
$_SESSION['_config']['oldlocation'] = "account.php?".$_SESSION['_config']['oldlocation'];
|
||||
|
||||
header("location: https://".$_SERVER['HTTP_HOST']."/index.php?id=4");
|
||||
exit;
|
||||
}
|
||||
} else if($_SERVER['HTTP_HOST'] == "secure.cacert.org" && $_SESSION['profile']['id'] > 0) {
|
||||
$_SESSION['profile'] = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".$_SESSION['profile']['id']."'"));
|
||||
}
|
||||
|
||||
if($_SERVER['HTTP_HOST'] == "secure.cacert.org" && ($_SESSION['profile']['id'] <= 0 || $_SESSION['profile']['loggedin'] == 0))
|
||||
{
|
||||
header("location: https://www.cacert.org");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($_SERVER['HTTP_HOST'] == "secure.cacert.org" && $_SESSION['profile']['id'] > 0)
|
||||
{
|
||||
$query = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['profile']['id']."' group by `to`";
|
||||
$res = mysql_query($query);
|
||||
$row = mysql_fetch_assoc($res);
|
||||
$_SESSION['profile']['points'] = $row['total'];
|
||||
|
||||
if($_SESSION['profile']['language'] == "")
|
||||
{
|
||||
$query = "update `users` set `language`='".$_SESSION['_config']['language']."'
|
||||
where `id`='".$_SESSION['profile']['id']."'";
|
||||
mysql_query($query);
|
||||
} else {
|
||||
$_SESSION['_config']['language'] = $_SESSION['profile']['language'];
|
||||
|
||||
putenv("LANG=".$_SESSION['_config']['language']);
|
||||
setlocale(LC_ALL, $_SESSION['_config']['language']);
|
||||
|
||||
$domain = 'messages';
|
||||
bindtextdomain("$domain", "/home/cacert/locale");
|
||||
textdomain("$domain");
|
||||
}
|
||||
}
|
||||
|
||||
if($id == "logout")
|
||||
{
|
||||
$_SESSION['profile']['loggedin'] = 0;
|
||||
header("location: https://".$_SERVER['HTTP_HOST']."/index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($_SESSION['profile']['loggedin'] < 1)
|
||||
{
|
||||
unset($_SESSION['_config']['oldlocation']);
|
||||
|
||||
foreach($_GET as $key => $val)
|
||||
{
|
||||
if($_SESSION['_config']['oldlocation'])
|
||||
$_SESSION['_config']['oldlocation'] .= "&";
|
||||
|
||||
$_SESSION['_config']['oldlocation'] .= "$key=$val";
|
||||
}
|
||||
$_SESSION['_config']['oldlocation'] = "account.php?".$_SESSION['_config']['oldlocation'];
|
||||
|
||||
header("location: https://".$_SERVER['HTTP_HOST']."/index.php?id=4");
|
||||
exit;
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,9 @@
|
||||
all: runserver.c runclient.c
|
||||
gcc -O2 -o runserver runserver.c
|
||||
gcc -O2 -o runclient runclient.c
|
||||
chown root:www-data runserver runclient
|
||||
chmod 4710 runserver runclient
|
||||
gcc -O2 -o rungpg rungpg.c
|
||||
chown root:www-data runserver runclient rungpg
|
||||
chmod 4710 runserver runclient rungpg
|
||||
|
||||
clean:
|
||||
rm -f runserver runclient
|
||||
rm -f runserver runclient rungpg
|
||||
|
@ -0,0 +1,161 @@
|
||||
<? /*
|
||||
Copyright (C) 2004 by Duane Groth <duane_at_CAcert_dot_org>
|
||||
|
||||
This file is part of CAcert.
|
||||
|
||||
CAcert has been released under the CAcert Source License
|
||||
which can be found included with these source files or can
|
||||
be downloaded from the internet from the following address:
|
||||
http://www.cacert.org/src-lic.php
|
||||
|
||||
CAcert is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the License for more details.
|
||||
*/ ?>
|
||||
<?
|
||||
require_once("../includes/loggedin.php");
|
||||
|
||||
loadem("account");
|
||||
|
||||
$oldid = intval($_POST['oldid']);
|
||||
$id = intval($id);
|
||||
|
||||
if($oldid == "1")
|
||||
{
|
||||
if($_POST['process'] != _("Submit") || $_POST['level'] == "" || $_POST['CSR'] == "" || intval($_POST['level']) < 0 || intval($_POST['level']) > 1)
|
||||
{
|
||||
$_SESSON['_config']['errmsg'] = _("You failed to paste a valid GPG/PGP key.");
|
||||
$id = $oldid;
|
||||
unset($oldid);
|
||||
}
|
||||
}
|
||||
|
||||
if($oldid == "1")
|
||||
{
|
||||
$gpgkey = $_POST['CSR'];
|
||||
$gpg = `echo "$gpgkey"|gpg --with-colons --homedir /tmp 2>&1`;
|
||||
$lines = "";
|
||||
foreach(explode("\n", $gpg) as $line)
|
||||
{
|
||||
if(substr($line, 0, 3) == "pub" || substr($line, 0, 3) == "uid")
|
||||
{
|
||||
if($lines != "")
|
||||
$lines .= "\n";
|
||||
$lines .= $line;
|
||||
}
|
||||
}
|
||||
$gpg = $lines;
|
||||
|
||||
foreach(explode("\n", $gpg) as $line)
|
||||
{
|
||||
$name = $comment = "";
|
||||
$bits = explode(":", $line);
|
||||
if($bits[0] == "pub" && (!$keyid || !$when))
|
||||
{
|
||||
$keyid = $bits[4];
|
||||
$when = $bits[5];
|
||||
}
|
||||
if(!strstr($line, "@")) continue;
|
||||
|
||||
$pos = strpos($bits[9], "(") - 1;
|
||||
$nocomment = 0;
|
||||
if($pos < 0)
|
||||
{
|
||||
$nocomment = 1;
|
||||
$pos = strpos($bits[9], "<") - 1;
|
||||
}
|
||||
$name = trim(hex2bin(trim(substr($bits[9], 0, $pos))));
|
||||
if($name != "")
|
||||
$names[] = $name;
|
||||
if($nocomment == 0)
|
||||
{
|
||||
$pos += 2;
|
||||
$pos2 = strpos($bits[9], ")");
|
||||
$comm = trim(hex2bin(trim(substr($bits[9], $pos, $pos2 - $pos))));
|
||||
if($comm != "")
|
||||
$comment[] = $comm;
|
||||
$pos = $pos2 + 3;
|
||||
} else {
|
||||
$pos = strpos($bits[9], "<") + 1;
|
||||
}
|
||||
$pos2 = strpos($bits[9], ">", $pos);
|
||||
$mail = trim(hex2bin(trim(substr($bits[9], $pos, $pos2 - $pos))));
|
||||
if($mail != "")
|
||||
$emailaddies[] = $mail;
|
||||
}
|
||||
|
||||
if($_SESSION['profile']['points'] < 50 && $_POST['level'] == 1)
|
||||
{
|
||||
$_SESSON['_config']['errmsg'] = _("You don't have enough assurance points to be issued a high level trust gpg signature.");
|
||||
unset($_POST['process']);
|
||||
$id = $oldid;
|
||||
unset($oldid);
|
||||
}
|
||||
|
||||
foreach($names as $name)
|
||||
{
|
||||
if($name == $_SESSION['profile']['fname']." ".$_SESSION['profile']['lname'])
|
||||
continue;
|
||||
if($name == $_SESSION['profile']['fname']." ".$_SESSION['profile']['mname']." ".$_SESSION['profile']['lname'])
|
||||
continue;
|
||||
if($name == $_SESSION['profile']['fname']." ".$_SESSION['profile']['lname']." ".$_SESSION['profile']['suffix'])
|
||||
continue;
|
||||
if($name == $_SESSION['profile']['fname']." ".$_SESSION['profile']['mname']." ".$_SESSION['profile']['lname']." ".$_SESSION['profile']['suffix'])
|
||||
continue;
|
||||
$_SESSON['_config']['errmsg'] = _("No suitable name combination could be matched from your PGP/GPG keys to what we have in the database");
|
||||
unset($_POST['process']);
|
||||
$id = $oldid;
|
||||
unset($oldid);
|
||||
}
|
||||
|
||||
foreach($emailaddies as $email)
|
||||
{
|
||||
if(mysql_num_rows(mysql_query("select * from `email` where `memid`='".$_SESSION['profile']['id']."' and
|
||||
`email`='$email' and `deleted`=0 and `hash`=''")) > 0)
|
||||
continue;
|
||||
$_SESSON['_config']['errmsg'] = _("No suitable emails could be matched from your PGP/GPG keys to what we have in the database");
|
||||
unset($_POST['process']);
|
||||
$id = $oldid;
|
||||
unset($oldid);
|
||||
}
|
||||
}
|
||||
|
||||
if($oldid == "1")
|
||||
{
|
||||
$_POST['level'] = intval($_POST['level']);
|
||||
if($_POST['level'] < 0 || $_POST['level'] > 1)
|
||||
$_POST['level'] = 0;
|
||||
|
||||
$query = "insert into `gpg` set `memid`='".$_SESSION['profile']['id']."', `email`='".$emailaddies['0']."',`level`='".$_POST['level']."'";
|
||||
mysql_query($query);
|
||||
$id = mysql_insert_id();
|
||||
|
||||
$fp = fopen("../csr/gpg-$id.csr", "w");
|
||||
fputs($fp, $csr);
|
||||
fclose($fp);
|
||||
|
||||
mysql_query("update `gpg` set `csr`='../csr/gpg-$id.csr' where `id`='$id'");
|
||||
|
||||
$do = `../scripts/rungpg`;
|
||||
|
||||
showheader(_("Welcome to CAcert.org"));
|
||||
$query = "select * from `gpg` where `id`='$id' and `crt`!=''";
|
||||
$res = mysql_query($query);
|
||||
if(mysql_num_rows($res) <= 0)
|
||||
{
|
||||
echo _("Your certificate request has failed to be processed correctly, please try submitting it again.");
|
||||
} else {
|
||||
echo "<pre>";
|
||||
readfile("../crt/gpg-$id.crt");
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
showfooter();
|
||||
exit;
|
||||
}
|
||||
|
||||
showheader(_("Welcome to CAcert.org"));
|
||||
includeit($id, "gpg");
|
||||
showfooter();
|
||||
|
||||
?>
|
Loading…
Reference in New Issue