cacert-webdb/scripts/gpgcerts.php

66 lines
2.8 KiB
PHP
Raw Normal View History

2004-11-18 23:21:15 +00:00
#!/usr/bin/php -q
<? /*
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.
*/
include_once("../includes/mysql.php");
$query = "select * from `gpg` where `crt`=''";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res))
{
$row['crt'] = "../crt/gpg-".$row['id'].".crt";
$do = `gpg --homedir /root/.gnupg --import $row[csr] 2>&1`;
$extras = "";
if($row['multiple'] == 1)
$extras .= " echo \"y\";";
if($row['expires'] == 1)
$extras .= " echo \"n\";";
2005-02-16 18:11:53 +00:00
$do = `( $extras echo "365"; echo "y"; echo "2"; echo "y")|gpg --default-key gpg@cacert.org --homedir /root/.gnupg --batch --no-tty --command-fd 0 \
2004-11-18 23:21:15 +00:00
--status-fd 1 --cert-policy-url http://www.cacert.org/index.php?id=10 \
--ask-cert-expire --sign-key $row[email] 2>&1`;
$do = `gpg --homedir /root/.gnupg --export --armor $row[email] > $row[crt]`;
$do = `gpg --homedir /root/.gnupg --batch --yes --delete-key $row[email] 2>&1`;
$user = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='$row[memid]'"));
if($user['language'] != "")
{
$userlang = $user['language'];
putenv("LANG=".$_SESSION['_config']['translations'][$userlang]);
setlocale(LC_ALL, $_SESSION['_config']['translations'][$userlang]);
} else {
putenv("LANG=en_AU");
setlocale(LC_ALL, "en_AU");
}
if(filesize($row['crt']) > 0)
2004-11-18 23:21:15 +00:00
{
$query = "update `gpg` set `crt`='$row[crt]', `issued`=NOW(), `expire`=FROM_UNIXTIME(UNIX_TIMESTAMP(NOW()) + 31536000) where `id`='".$row['id']."'";
mysql_query($query);
$body = _("Hi")." $user[fname],\n\n";
$body .= sprintf(_("Your CAcert signed key for %s is available online at:")."\n\n", $row['email']);
2004-11-18 23:21:15 +00:00
$body .= "https://www.cacert.org/gpg.php?id=3&cert=$row[id]\n\n";
$body .= _("To help improve the trust of CAcert in general, it's appreciated if you could also sign our key and upload it to a key server. Below is a copy of our primary key details:")."\n\n";
$body .= "pub 1024D/65D0FD58 2003-07-11 CA Cert Signing Authority (Root CA) <gpg@cacert.org>\n";
$body .= "Key fingerprint = A31D 4F81 EF4E BD07 B456 FA04 D2BB 0D01 65D0 FD58\n\n";
$body .= _("Best regards")."\n"._("CAcert.org Support!")."\n\n";
2004-12-09 01:48:16 +00:00
sendmail($user[email], "[CAcert.org] Your GPG/PGP Key", $body, "support@cacert.org", "returns@cacert.org", "", "CAcert Support");
2004-11-18 23:21:15 +00:00
} else {
$query = "delete from `gpg` where `id`='".$row['id']."'";
mysql_query($query);
}
}
?>