69 lines
2.8 KiB
PHP
Executable file
69 lines
2.8 KiB
PHP
Executable file
#!/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`;
|
|
|
|
$extra = "";
|
|
if(intval($row['level']) != 1)
|
|
$extra = " --default-key lowgpg@cacert.org";
|
|
|
|
$extras = "";
|
|
if($row['multiple'] == 1)
|
|
$extras .= " echo \"y\";";
|
|
if($row['expires'] == 1)
|
|
$extras .= " echo \"n\";";
|
|
|
|
$do = `( $extras echo "365"; echo "y"; echo "3"; echo "y")|gpg$extra --homedir /root/.gnupg --batch --no-tty --command-fd 0 \
|
|
--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)
|
|
{
|
|
$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']);
|
|
$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";
|
|
mail($user[email], "[CAcert.org] Your GPG/PGP Key", $body, "From: CAcert-Support <duane@cacert.org>");
|
|
} else {
|
|
$query = "delete from `gpg` where `id`='".$row['id']."'";
|
|
mysql_query($query);
|
|
}
|
|
}
|
|
?>
|