67 lines
2.5 KiB
PHP
67 lines
2.5 KiB
PHP
|
#!/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(_("You can collect your certificate for %s by going to the following location:")."\n\n", $row['email']);
|
||
|
$body .= "https://www.cacert.org/gpg.php?id=3&cert=$row[id]\n\n";
|
||
|
$body .= _("Best regards")."\n"._("CAcert.org Support!");
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
?>
|