/* LibreSSL - CAcert web application Copyright (C) 2004-2008 CAcert Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ require_once("../includes/loggedin.php"); loadem("account"); $id = intval($_REQUEST['id']); $oldid = intval($_REQUEST['oldid']); if($id == 45 || $id == 46 || $oldid == 45 || $oldid == 46) { $id = 1; unset($oldid); } if($_REQUEST['process'] != "" && $oldid == 1) { $id = 1; if(strstr($_REQUEST['newemail'], "xn--") && $_SESSION['profile']['codesign'] <= 0) { showheader(_("My CAcert.org Account!")); echo _("Due to the possibility for punycode domain exploits we currently do not allow any certificates to sign punycode domains or email addresses."); showfooter(); exit; } if(trim(mysql_real_escape_string(stripslashes($_REQUEST['newemail']))) == "") { showheader(_("My CAcert.org Account!")); printf(_("Not a valid email address. Can't continue."), $_REQUEST['email']); showfooter(); exit; } unset($oldid); $_REQUEST['email'] = trim(mysql_real_escape_string(stripslashes($_REQUEST['newemail']))); $query = "select * from `email` where `email`='".$_REQUEST['email']."' and `deleted`=0"; $res = mysql_query($query); if(mysql_num_rows($res) > 0) { showheader(_("My CAcert.org Account!")); printf(_("The email address '%s' is already in the system. Can't continue."), $_REQUEST['email']); showfooter(); exit; } $checkemail = checkEmail($_REQUEST['newemail']); if($checkemail != "OK") { showheader(_("My CAcert.org Account!")); if (substr($checkemail, 0, 1) == "4") { echo "
"._("The mail server responsible for your domain indicated a temporary failure. This may be due to anti-SPAM measures, such as greylisting. Please try again in a few minutes.")."
\n"; } else { echo ""._("Email Address given was invalid, or a test connection couldn't be made to your server, or the server rejected the email address as invalid")."
\n"; } echo "$checkemail
\n"; showfooter(); exit; } $hash = make_hash(); $query = "insert into `email` set `email`='".$_REQUEST['email']."',`memid`='".$_SESSION['profile']['id']."',`created`=NOW(),`hash`='$hash'"; mysql_query($query); $emailid = mysql_insert_id(); $body = _("Below is the link you need to open to verify your email address. Once your address is verified you will be able to start issuing certificates to your heart's content!")."\n\n"; $body .= "http://".$_SESSION['_config']['normalhostname']."/verify.php?type=email&emailid=$emailid&hash=$hash\n\n"; $body .= _("Best regards")."\n"._("CAcert.org Support!"); sendmail($_REQUEST['email'], "[CAcert.org] "._("Email Probe"), $body, "support@cacert.org", "", "", "CAcert Support"); showheader(_("My CAcert.org Account!")); printf(_("The email address '%s' has been added to the system, however before any certificates for this can be issued you need to open the link in a browser that has been sent to your email address."), sanitizeHTML($_REQUEST['email'])); showfooter(); exit; } if($_REQUEST['makedefault'] != "" && $oldid == 2) { $id = 2; $emailid = intval($emailid); $query = "select * from `email` where `id`='$emailid' and `memid`='".$_SESSION['profile']['id']."' and `hash` = '' and `deleted`=0"; $res = mysql_query($query); if(mysql_num_rows($res) <= 0) { showheader(_("Error!")); echo _("You currently don't have access to the email address you selected, or you haven't verified it yet."); showfooter(); exit; } $row = mysql_fetch_assoc($res); $body = sprintf(_("Hi %s,"),$_SESSION['_config']['user']['fname'])."\n"; $body .= _("You are receiving this email because you or someone else")."\n"; $body .= _("has changed the default email on your account.")."\n\n"; $body .= _("Best regards")."\n"._("CAcert.org Support!"); sendmail($_SESSION['_config']['user']['email'], "[CAcert.org] "._("Default Account Changed"), $body, "support@cacert.org", "", "", "CAcert Support"); $_SESSION['profile']['email'] = $row['email']; $query = "update `users` set `email`='".$row['email']."' where `id`='".$_SESSION['profile']['id']."'"; mysql_query($query); showheader(_("My CAcert.org Account!")); printf(_("Your default email address has been updated to '%s'."), $row['email']); showfooter(); exit; } if($_REQUEST['process'] != "" && $oldid == 2) { $id = 2; showheader(_("My CAcert.org Account!")); $delcount = 0; if(is_array($delid)) { foreach($delid as $id) { $id = intval($id); $query = "select * from `email` where `id`='$id' and `memid`='".$_SESSION['profile']['id']."' and `email`!='".$_SESSION['profile']['email']."'"; $res = mysql_query($query); if(mysql_num_rows($res) > 0) { $row = mysql_fetch_assoc($res); echo $row['email'].""._("Email Address given was invalid, or a test connection couldn't be made to your server, or the server rejected the email address as invalid")."
\n"; if (substr($checkemail, 0, 1) == "4") { echo ""._("The mail server responsible for your domain indicated a temporary failure. This may be due to anti-SPAM measures, such as greylisting. Please try again in a few minutes.")."
\n"; } else { echo ""._("Email Address given was invalid, or a test connection couldn't be made to your server, or the server rejected the email address as invalid")."
\n"; } echo "$checkemail
\n"; showfooter(); exit; } $hash = make_hash(); $query = "insert into `domains` set `domain`='".mysql_real_escape_string($_SESSION['_config']['domain'])."', `memid`='".$_SESSION['profile']['id']."',`created`=NOW(),`hash`='$hash'"; mysql_query($query); $domainid = mysql_insert_id(); $body = sprintf(_("Below is the link you need to open to verify your domain '%s'. Once your address is verified you will be able to start issuing certificates to your heart's content!"),$_SESSION['_config']['domain'])."\n\n"; $body .= "http://".$_SESSION['_config']['normalhostname']."/verify.php?type=domain&domainid=$domainid&hash=$hash\n\n"; $body .= _("Best regards")."\n"._("CAcert.org Support!"); sendmail($authaddy, "[CAcert.org] "._("Email Probe"), $body, "support@cacert.org", "", "", "CAcert Support"); showheader(_("My CAcert.org Account!")); printf(_("The domain '%s' has been added to the system, however before any certificates for this can be issued you need to open the link in a browser that has been sent to your email address."), $_SESSION['_config']['domain']); showfooter(); exit; } if($_REQUEST['process'] != "" && $oldid == 9) { $id = 9; showheader(_("My CAcert.org Account!")); if(is_array($delid)) { echo _("The following domains have been removed:")."\n$cert\n\n"; } } } else { echo _("You did not select any certificates for renewal."); } showfooter(); exit; } if($oldid == 12 && $revoke != "") { $id = 12; showheader(_("My CAcert.org Account!")); if(is_array($revokeid)) { echo _("Now revoking the following certificates:")."
"; print_r($_SESSION['_config']); die; if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { $id = 20; showheader(_("My CAcert.org Account!")); echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue."); showfooter(); exit; } $_SESSION['_config']['rootcert'] = intval($_REQUEST['rootcert']); if($_SESSION['_config']['rootcert'] < 1 || $_SESSION['_config']['rootcert'] > 2) $_SESSION['_config']['rootcert'] = 1; } if($_REQUEST['process'] != "" && $oldid == 21) { $id = 21; if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { showheader(_("My CAcert.org Account!")); echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue."); showfooter(); exit; } if($_SESSION['_config']['rowid']['0'] > 0) { $query = "select * from `org`,`orginfo` where `orginfo`.`id`='".$_SESSION['_config']['rowid']['0']."' and `orginfo`.`id`=`org`.`orgid` and `org`.`memid`='".$_SESSION['profile']['id']."'"; } else { $query = "select * from `org`,`orginfo` where `orginfo`.`id`='".$_SESSION['_config']['altid']['0']."' and `orginfo`.`id`=`org`.`orgid` and `org`.`memid`='".$_SESSION['profile']['id']."'"; } $org = mysql_fetch_assoc(mysql_query($query)); $csrsubject = ""; if($_SESSION['_config']['OU']) $csrsubject .= "/organizationalUnitName=".$_SESSION['_config']['OU']; if($org['O']) $csrsubject .= "/organizationName=".$org['O']; if($org['L']) $csrsubject .= "/localityName=".$org['L']; if($org['ST']) $csrsubject .= "/stateOrProvinceName=".$org['ST']; if($org['C']) $csrsubject .= "/countryName=".$org['C']; //if($org['contact']) // $csrsubject .= "/emailAddress=".trim($org['contact']); if(is_array($_SESSION['_config']['rows'])) foreach($_SESSION['_config']['rows'] as $row) $csrsubject .= "/commonName=$row"; if(is_array($_SESSION['_config']['altrows'])) foreach($_SESSION['_config']['altrows'] as $subalt) { if($SAN != "") $SAN .= ","; $SAN .= "$subalt"; } if($SAN != "") $csrsubject .= "/subjectAltName=".$SAN; $type=""; if($_REQUEST["ocspcert"]!="") $type="8"; if($_SESSION['_config']['rowid']['0'] > 0) { $query = "insert into `orgdomaincerts` set `CN`='".$_SESSION['_config']['rows']['0']."', `orgid`='".$org['id']."', `created`=NOW(), `subject`='$csrsubject', `rootcert`='".$_SESSION['_config']['rootcert']."', `type`='$type'"; } else { $query = "insert into `orgdomaincerts` set `CN`='".$_SESSION['_config']['altrows']['0']."', `orgid`='".$org['id']."', `created`=NOW(), `subject`='$csrsubject', `rootcert`='".$_SESSION['_config']['rootcert']."', `type`='$type'"; } mysql_query($query); $CSRid = mysql_insert_id(); $CSRname = $_SESSION['_config']['filepath']."/csr/orgserver-$CSRid.csr"; rename($_SESSION['_config']['tmpfname'], $CSRname); mysql_query("update `orgdomaincerts` set `CSR_name`='$CSRname' where `id`='$CSRid'"); if(is_array($_SESSION['_config']['rowid'])) foreach($_SESSION['_config']['rowid'] as $id) mysql_query("insert into `orgdomlink` set `orgdomid`='$id', `orgcertid`='$CSRid'"); if(is_array($_SESSION['_config']['altid'])) foreach($_SESSION['_config']['altid'] as $id) mysql_query("insert into `orgdomlink` set `orgdomid`='$id', `orgcertid`='$CSRid'"); waitForResult("orgdomaincerts", $CSRid,$oldid); $query = "select * from `orgdomaincerts` where `id`='$CSRid' and `crt_name` != ''"; $res = mysql_query($query); if(mysql_num_rows($res) <= 0) { showheader(_("My CAcert.org Account!")); printf(_("Your certificate request has failed to be processed correctly, see %sthe WIKI page%s for reasons and solutions.")." CSRid: $CSRid", "", ""); showfooter(); exit; } else { $id = 23; $cert = $CSRid; } } if($oldid == 22 && $renew != "") { showheader(_("My CAcert.org Account!")); if(is_array($revokeid)) { echo _("Now renewing the following certificates:")."
\n"; foreach($revokeid as $id) { $id = intval($id); $query = "select *,UNIX_TIMESTAMP(`orgdomaincerts`.`revoked`) as `revoke` from `orgdomaincerts`,`org` where `orgdomaincerts`.`id`='$id' and `orgdomaincerts`.`orgid`=`org`.`orgid` and `org`.`memid`='".$_SESSION['profile']['id']."'"; $res = mysql_query($query); if(mysql_num_rows($res) <= 0) { printf(_("Invalid ID '%s' presented, can't do anything with it.")."
\n", $id); continue; } mysql_query("update `orgdomaincerts` set `renewed`='1' where `id`='$id'"); $row = mysql_fetch_assoc($res); if($row[revoke] > 0) { printf(_("It would seem '%s' has already been revoked. I'll skip this for now.")."
\n", $row['CN']); continue; } $query = "insert into `orgdomaincerts` set `orgid`='".$row['orgid']."', `CN`='".$row['CN']."', `subject`='".$row['subject']."', `csr_name`='".$row['csr_name']."', `created`='".$row['created']."', `modified`=NOW(), `subject`='".$row['subject']."', `rootcert`='".$row['rootcert']."'"; mysql_query($query); $newid = mysql_insert_id(); $newfile = $_SESSION['_config']['filepath']."/csr/orgserver-$newid.csr"; copy($row['csr_name'], $newfile); mysql_query("update `orgdomaincerts` set `csr_name`='$newfile' where `id`='$newid'"); echo _("Renewing").": ".$row['CN']."
\n"; $res = mysql_query("select * from `orgdomlink` where `orgcertid`='".$row['id']."'"); while($r2 = mysql_fetch_assoc($res)) mysql_query("insert into `orgdomlink` set `orgdomid`='".$r2['id']."', `orgcertid`='$newid'"); waitForResult("orgdomaincerts", $newid,$oldid,0); $query = "select * from `orgdomaincerts` where `id`='$newid' and `crt_name` != ''"; $res = mysql_query($query); if(mysql_num_rows($res) <= 0) { printf(_("Your certificate request has failed to be processed correctly, see %sthe WIKI page%s for reasons and solutions.")." newid: $newid", "", ""); } else { $drow = mysql_fetch_assoc($res); $cert = `/usr/bin/openssl x509 -in $drow[crt_name]`; echo "\n$cert\n\n"; } } } else { echo _("You did not select any certificates for renewal."); } showfooter(); exit; } if($oldid == 22 && $revoke != "") { showheader(_("My CAcert.org Account!")); if(is_array($revokeid)) { echo _("Now revoking the following certificates:")."
\n"; foreach($revokeid as $id) { $id = intval($id); $query = "select *,UNIX_TIMESTAMP(`orgdomaincerts`.`revoked`) as `revoke` from `orgdomaincerts`,`org` where `orgdomaincerts`.`id`='$id' and `orgdomaincerts`.`orgid`=`org`.`orgid` and `org`.`memid`='".$_SESSION['profile']['id']."'"; $res = mysql_query($query); if(mysql_num_rows($res) <= 0) { printf(_("Invalid ID '%s' presented, can't do anything with it.")."
\n", $id); continue; } $row = mysql_fetch_assoc($res); if($row[revoke] > 0) { printf(_("It would seem '%s' has already been revoked. I'll skip this for now.")."
\n", $row['CN']); continue; } mysql_query("update `orgdomaincerts` set `revoked`='1970-01-01 10:00:01' where `id`='$id'"); printf(_("Certificate for '%s' has been revoked.")."
\n", $row['CN']); } } else { echo _("You did not select any certificates for revocation."); } if(is_array($delid)) { echo _("Now deleting the following pending requests:")."
\n"; foreach($delid as $id) { $id = intval($id); $query = "select *,UNIX_TIMESTAMP(`orgdomaincerts`.`expire`) as `expired` from `orgdomaincerts`,`org` where `orgdomaincerts`.`id`='$id' and `orgdomaincerts`.`orgid`=`org`.`orgid` and `org`.`memid`='".$_SESSION['profile']['id']."'"; $res = mysql_query($query); if(mysql_num_rows($res) <= 0) { printf(_("Invalid ID '%s' presented, can't do anything with it.")."
\n", $id); continue; } $row = mysql_fetch_assoc($res); if($row['expired'] > 0) { printf(_("Couldn't remove the request for `%s`, request had already been processed.")."
\n", $row['CN']); continue; } mysql_query("delete from `orgdomaincerts` where `id`='$id'"); @unlink($row['csr_name']); @unlink($row['crt_name']); printf(_("Removed a pending request for '%s'")."
\n", $row['CN']); } } showfooter(); exit; } if(($id == 24 || $oldid == 24 || $id == 25 || $oldid == 25 || $id == 26 || $oldid == 26 || $id == 27 || $oldid == 27 || $id == 28 || $oldid == 28 || $id == 29 || $oldid == 29 || $id == 30 || $oldid == 30 || $id == 31 || $oldid == 31) && $_SESSION['profile']['orgadmin'] != 1) { showheader(_("My CAcert.org Account!")); echo _("You don't have access to this area."); showfooter(); exit; } if($oldid == 24 && $_REQUEST['process'] != "") { $id = intval($oldid); $_SESSION['_config']['O'] = trim(mysql_real_escape_string(stripslashes($O))); $_SESSION['_config']['contact'] = trim(mysql_real_escape_string(stripslashes($contact))); $_SESSION['_config']['L'] = trim(mysql_real_escape_string(stripslashes($L))); $_SESSION['_config']['ST'] = trim(mysql_real_escape_string(stripslashes($ST))); $_SESSION['_config']['C'] = trim(mysql_real_escape_string(stripslashes($C))); $_SESSION['_config']['comments'] = trim(mysql_real_escape_string(stripslashes($comments))); if($_SESSION['_config']['O'] == "" || $_SESSION['_config']['contact'] == "") { $_SESSION['_config']['errmsg'] = _("Organisation Name and Contact Email are required fields."); } else { mysql_query("insert into `orginfo` set `O`='".$_SESSION['_config']['O']."', `contact`='".$_SESSION['_config']['contact']."', `L`='".$_SESSION['_config']['L']."', `ST`='".$_SESSION['_config']['ST']."', `C`='".$_SESSION['_config']['C']."', `comments`='".$_SESSION['_config']['comments']."'"); showheader(_("My CAcert.org Account!")); printf(_("'%s' has just been successfully added as an organisation to the database."), $_SESSION['_config']['O']); showfooter(); exit; } } if($oldid == 27 && $_REQUEST['process'] != "") { $id = intval($oldid); $_SESSION['_config']['O'] = trim(mysql_real_escape_string(stripslashes($O))); $_SESSION['_config']['contact'] = trim(mysql_real_escape_string(stripslashes($contact))); $_SESSION['_config']['L'] = trim(mysql_real_escape_string(stripslashes($L))); $_SESSION['_config']['ST'] = trim(mysql_real_escape_string(stripslashes($ST))); $_SESSION['_config']['C'] = trim(mysql_real_escape_string(stripslashes($C))); $_SESSION['_config']['comments'] = trim(mysql_real_escape_string(stripslashes($comments))); if($_SESSION['_config']['O'] == "" || $_SESSION['_config']['contact'] == "") { $_SESSION['_config']['errmsg'] = _("Organisation Name and Contact Email are required fields."); } else { mysql_query("update `orginfo` set `O`='".$_SESSION['_config']['O']."', `contact`='".$_SESSION['_config']['contact']."', `L`='".$_SESSION['_config']['L']."', `ST`='".$_SESSION['_config']['ST']."', `C`='".$_SESSION['_config']['C']."', `comments`='".$_SESSION['_config']['comments']."' where `id`='".$_SESSION['_config']['orgid']."'"); showheader(_("My CAcert.org Account!")); printf(_("'%s' has just been successfully updated in the database."), $_SESSION['_config']['O']); showfooter(); exit; } } if($oldid == 28 && $_REQUEST['process'] != "") { $domain = $_SESSION['_config']['domain'] = trim(mysql_real_escape_string(stripslashes($domainname))); $res1 = mysql_query("select * from `orgdomains` where `domain`='$domain'"); if(mysql_num_rows($res1) > 0) { $_SESSION['_config']['errmsg'] = sprintf(_("The domain '%s' is already in the system and is listed as valid. Can't continue."), $domain); $id = $oldid; unset($oldid); } } if($_SESSION['_config']['orgid'] <= 0 && $oldid == 28) { unset($oldid); $id = 25; } if($oldid == 28 && $_REQUEST['process'] != "") { mysql_query("insert into `orgdomains` set `orgid`='".$_SESSION['_config']['orgid']."', `domain`='$domain'"); showheader(_("My CAcert.org Account!")); printf(_("'%s' has just been successfully added to the database."), $domain); echo "
"._("Click here")." "._("to continue."); showfooter(); exit; } if($oldid == 29 && $_REQUEST['process'] != "") { $domain = mysql_real_escape_string(stripslashes(trim($domainname))); $res1 = mysql_query("select * from `orgdomains` where `domain` like '$domain' and `id`!='".$_SESSION['_config']['domid']."'"); $res2 = mysql_query("select * from `domains` where `domain` like '$domain' and `deleted`=0"); if(mysql_num_rows($res1) > 0 || mysql_num_rows($res2) > 0) { $_SESSION['_config']['errmsg'] = sprintf(_("The domain '%s' is already in the system and is listed as valid. Can't continue."), $domain); $id = $oldid; unset($oldid); } } if(($oldid == 29 || $oldid == 30) && $_REQUEST['process'] != _("Cancel")) { $query = "select `orgdomaincerts`.`id` as `id` from `orgdomlink`, `orgdomaincerts`, `orgdomains` where `orgdomlink`.`orgdomid`=`orgdomains`.`id` and `orgdomaincerts`.`id`=`orgdomlink`.`orgcertid` and `orgdomains`.`id`='".$_SESSION['_config']['domid']."'"; $res = mysql_query($query); while($row = mysql_fetch_assoc($res)) mysql_query("update `orgdomaincerts` set `revoked`='1970-01-01 10:00:01' where `id`='".$row['id']."'"); $query = "select `orgemailcerts`.`id` as `id` from `orgemailcerts`, `orgemaillink`, `orgdomains` where `orgemaillink`.`domid`=`orgdomains`.`id` and `orgemailcerts`.`id`=`orgemaillink`.`emailcertsid` and `orgdomains`.`id`='".$_SESSION['_config']['domid']."'"; $res = mysql_query($query); while($row = mysql_fetch_assoc($res)) mysql_query("update `orgemailcerts` set `revoked`='1970-01-01 10:00:01' where `id`='".$row['id']."'"); } if($oldid == 29 && $_REQUEST['process'] != "") { $row = mysql_fetch_assoc(mysql_query("select * from `orgdomains` where `id`='".$_SESSION['_config']['domid']."'")); mysql_query("update `orgdomains` set `domain`='$domain' where `id`='".$_SESSION['_config']['domid']."'"); showheader(_("My CAcert.org Account!")); printf(_("'%s' has just been successfully updated in the database."), $domain); echo "
"._("Click here")." "._("to continue."); showfooter(); exit; } if($oldid == 30 && $_REQUEST['process'] != "") { $row = mysql_fetch_assoc(mysql_query("select * from `orgdomains` where `id`='".$_SESSION['_config']['domid']."'")); $domain = $row['domain']; mysql_query("delete from `orgdomains` where `id`='".$_SESSION['_config']['domid']."'"); showheader(_("My CAcert.org Account!")); printf(_("'%s' has just been successfully deleted from the database."), $domain); echo "
"._("Click here")." "._("to continue."); showfooter(); exit; } if($oldid == 30) { $id = 26; $orgid = 0; } if($oldid == 31 && $_REQUEST['process'] != _("Cancel")) { $query = "select * from `orgdomains` where `orgid`='".$_SESSION['_config']['orgid']."'"; $dres = mysql_query($query); while($drow = mysql_fetch_assoc($dres)) { $query = "select `orgdomaincerts`.`id` as `id` from `orgdomlink`, `orgdomaincerts`, `orgdomains` where `orgdomlink`.`orgdomid`=`orgdomains`.`id` and `orgdomaincerts`.`id`=`orgdomlink`.`orgcertid` and `orgdomains`.`id`='".$drow['id']."'"; $res = mysql_query($query); while($row = mysql_fetch_assoc($res)) { mysql_query("update `orgdomaincerts` set `revoked`='1970-01-01 10:00:01' where `id`='".$row['id']."'"); mysql_query("delete from `orgdomaincerts` where `orgid`='".$row['id']."'"); mysql_query("delete from `orgdomlink` where `domid`='".$row['id']."'"); } $query = "select `orgemailcerts`.`id` as `id` from `orgemailcerts`, `orgemaillink`, `orgdomains` where `orgemaillink`.`domid`=`orgdomains`.`id` and `orgemailcerts`.`id`=`orgemaillink`.`emailcertsid` and `orgdomains`.`id`='".$drow['id']."'"; $res = mysql_query($query); while($row = mysql_fetch_assoc($res)) { mysql_query("update `orgemailcerts` set `revoked`='1970-01-01 10:00:01' where `id`='".$row['id']."'"); mysql_query("delete from `orgemailcerts` where `id`='".$row['id']."'"); mysql_query("delete from `orgemaillink` where `domid`='".$row['id']."'"); } } mysql_query("delete from `org` where `orgid`='".$_SESSION['_config']['orgid']."'"); mysql_query("delete from `orgdomains` where `orgid`='".$_SESSION['_config']['orgid']."'"); mysql_query("delete from `orginfo` where `id`='".$_SESSION['_config']['orgid']."'"); } if($oldid == 31) { $id = 25; $orgid = 0; } if($id == 32 || $oldid == 32 || $id == 33 || $oldid == 33 || $id == 34 || $oldid == 34 || $id == 35 || $oldid == 35) { $query = "select * from `org` where `memid`='".$_SESSION['profile']['id']."' and `masteracc`='1'"; $_macc = mysql_num_rows(mysql_query($query)); if($_SESSION['profile']['orgadmin'] != 1 && $_macc <= 0) { showheader(_("My CAcert.org Account!")); echo _("You don't have access to this area."); showfooter(); exit; } } if($id == 33 && $_SESSION['profile']['orgadmin'] != 1) { $orgid = intval($_SESSION['_config']['orgid']); $query = "select * from `org` where `orgid`='$orgid' and `memid`='".$_SESSION['profile']['id']."' and `masteracc`='1'"; $res = mysql_query($query); if(mysql_num_rows($res) <= 0) { $id = 35; } } if($oldid == 33 && $_REQUEST['process'] != "") { if($_SESSION['profile']['orgadmin'] == 1) $masteracc = $_SESSION['_config'][masteracc] = intval($masteracc); else $masteracc = $_SESSION['_config'][masteracc] = 0; $_REQUEST['email'] = $_SESSION['_config']['email'] = mysql_real_escape_string(stripslashes(trim($_REQUEST['email']))); $OU = $_SESSION['_config']['OU'] = mysql_real_escape_string(stripslashes(trim($OU))); $comments = $_SESSION['_config']['comments'] = mysql_real_escape_string(stripslashes(trim($comments))); $res = mysql_query("select * from `users` where `email`='".$_REQUEST['email']."' and `deleted`=0"); if(mysql_num_rows($res) <= 0) { $id = $oldid; unset($oldid); $_SESSION['_config']['errmsg'] = sprintf(_("Wasn't able to match '%s' against any user in the system"), $_REQUEST['email']); } else { $row = mysql_fetch_assoc($res); mysql_query("insert into `org` set `memid`='".$row['id']."', `orgid`='".intval($_SESSION['_config']['orgid'])."', `masteracc`='$masteracc', `OU`='$OU', `comments`='$comments'"); } } if(($oldid == 34 || $id == 34) && $_SESSION['profile']['orgadmin'] != 1) { $orgid = intval($_SESSION['_config']['orgid']); $res = mysql_query("select * from `org` where `orgid`='$orgid' and `memid`='".$_SESSION['profile']['id']."' and `masteracc`='1'"); if(mysql_num_rows($res) <= 0) $id = 32; } if($oldid == 34 && $_REQUEST['process'] != "") { $orgid = intval($_SESSION['_config']['orgid']); $memid = intval($_REQUEST['memid']); $query = "delete from `org` where `orgid`='$orgid' and `memid`='$memid'"; mysql_query($query); } if($oldid == 34 || $oldid == 33) { unset($oldid); $id = 32; $orgid = 0; } if($id == 36) { $row = mysql_fetch_assoc(mysql_query("select * from `alerts` where `memid`='".$_SESSION['profile']['id']."'")); $_REQUEST['general'] = $row['general']; $_REQUEST['country'] = $row['country']; $_REQUEST['regional'] = $row['regional']; $_REQUEST['radius'] = $row['radius']; } if($oldid == 36) { $rc = mysql_num_rows(mysql_query("select * from `alerts` where `memid`='".$_SESSION['profile']['id']."'")); if($rc > 0) { $query = "update `alerts` set `general`='".intval($_REQUEST['general'])."', `country`='".intval($_REQUEST['country'])."', `regional`='".intval($_REQUEST['regional'])."', `radius`='".intval($_REQUEST['radius'])."' where `memid`='".$_SESSION['profile']['id']."'"; } else { $query = "insert into `alerts` set `general`='".intval($_REQUEST['general'])."', `country`='".intval($_REQUEST['country'])."', `regional`='".intval($_REQUEST['regional'])."', `radius`='".intval($_REQUEST['radius'])."', `memid`='".$_SESSION['profile']['id']."'"; } mysql_query($query); $id = $oldid; unset($oldid); } if($oldid == 41 && $_REQUEST['action'] == 'default') { $lang = mysql_real_escape_string($_REQUEST['lang']); foreach($_SESSION['_config']['translations'] as $key => $val) { if($key == $lang) { mysql_query("update `users` set `language`='$lang' where `id`='".$_SESSION['profile']['id']."'"); $_SESSION['profile']['language'] = $lang; showheader(_("My CAcert.org Account!")); echo _("Your language setting has been updated."); showfooter(); exit; } } showheader(_("My CAcert.org Account!")); echo _("You tried to use an invalid language."); showfooter(); exit; } if($oldid == 41 && $_REQUEST['action'] == 'addsec') { $addlang = mysql_real_escape_string($_REQUEST['addlang']); mysql_query("insert into `addlang` set `userid`='".$_SESSION['profile']['id']."', `lang`='$addlang'"); showheader(_("My CAcert.org Account!")); echo _("Your language setting has been updated."); showfooter(); exit; } if($oldid == 41 && $_REQUEST['action'] == 'dellang') { $remove = mysql_real_escape_string($_REQUEST['remove']); mysql_query("delete from `addlang` where `userid`='".$_SESSION['profile']['id']."' and `lang`='$remove'"); showheader(_("My CAcert.org Account!")); echo _("Your language setting has been updated."); showfooter(); exit; } if(($id == 42 || $id == 43 || $id == 44 || $id == 48 || $id == 49 || $id == 50 || $oldid == 42 || $oldid == 43 || $oldid == 44 || $oldid == 48 || $oldid == 49 || $oldid == 50) && $_SESSION['profile']['admin'] != 1) { showheader(_("My CAcert.org Account!")); echo _("You don't have access to this area."); showfooter(); exit; } if(($id == 53 || $id == 54 || $oldid == 53 || $oldid == 54) && $_SESSION['profile']['locadmin'] != 1) { showheader(_("My CAcert.org Account!")); echo _("You don't have access to this area."); showfooter(); exit; } if($oldid == 54 || ($id == 53 && $_REQUEST['action'] != "") || ($id == 54 && $_REQUEST['action'] != "" && $_REQUEST['action'] != "aliases" && $_REQUEST['action'] != "edit" && $_REQUEST['action'] != "add")) { $id = 53; $ccid = intval($_REQUEST['ccid']); $regid = intval($_REQUEST['regid']); $newreg = intval($_REQUEST['newreg']); $locid = intval($_REQUEST['locid']); $name = mysql_real_escape_string($_REQUEST['name']); $long = mysql_real_escape_string($_REQUEST['longitude']); $lat = mysql_real_escape_string($_REQUEST['latitude']); if($locid > 0 && $_REQUEST['action'] == "edit" && $name == htmlentities($name)) { $query = "update `locations` set `name`='$name', `lat`='$lat', `long`='$long' where `id`='$locid'"; mysql_query($query); $row = mysql_fetch_assoc(mysql_query("select * from `locations` where `id`='$locid'")); $_REQUEST['regid'] = $row['regid']; unset($_REQUEST['ccid']); unset($_REQUEST['locid']); unset($_REQUEST['action']); } else if($regid > 0 && $_REQUEST['action'] == "edit" && $name == htmlentities($name)) { $query = "update `regions` set `name`='$name' where `id`='$regid'"; mysql_query($query); $row = mysql_fetch_assoc(mysql_query("select * from `regions` where `id`='$regid'")); $_REQUEST['ccid'] = $row['ccid']; unset($_REQUEST['regid']); unset($_REQUEST['locid']); unset($_REQUEST['action']); } else if($regid > 0 && $_REQUEST['action'] == "add" && $name == htmlentities($name)) { $row = mysql_fetch_assoc(mysql_query("select `ccid` from `regions` where `id`='$regid'")); $ccid = $row['ccid']; $query = "insert into `locations` set `ccid`='$ccid', `regid`='$regid', `name`='$name', `lat`='$lat', `long`='$long'"; mysql_query($query); unset($_REQUEST['ccid']); unset($_REQUEST['locid']); unset($_REQUEST['action']); } else if($ccid > 0 && $_REQUEST['action'] == "add" && $name == htmlentities($name) && $name != "") { $query = "insert into `regions` set `ccid`='$ccid', `name`='$name'"; mysql_query($query); $row = mysql_fetch_assoc(mysql_query("select * from `locations` where `id`='$locid'")); unset($_REQUEST['regid']); unset($_REQUEST['locid']); unset($_REQUEST['action']); } else if($locid > 0 && $_REQUEST['action'] == "delete") { $row = mysql_fetch_assoc(mysql_query("select * from `locations` where `id`='$locid'")); $_REQUEST['regid'] = $row['regid']; mysql_query("delete from `localias` where `locid`='$locid'"); mysql_query("delete from `locations` where `id`='$locid'"); unset($_REQUEST['ccid']); unset($_REQUEST['locid']); unset($_REQUEST['action']); } else if($locid > 0 && $_REQUEST['action'] == "move") { $row = mysql_fetch_assoc(mysql_query("select * from `locations` where `id`='$locid'")); $oldregid = $row['regid']; mysql_query("update `locations` set `regid`='$newreg' where `id`='$locid'"); mysql_query("update `users` set `regid`='$newreg' where `regid`='$oldregid'"); $row = mysql_fetch_assoc(mysql_query("select * from `locations` where `id`='$locid'")); $_REQUEST['regid'] = $row['regid']; unset($_REQUEST['ccid']); unset($_REQUEST['locid']); unset($_REQUEST['action']); } else if($regid > 0 && $_REQUEST['action'] == "delete") { $row = mysql_fetch_assoc(mysql_query("select * from `regions` where `id`='$regid'")); $_REQUEST['ccid'] = $row['ccid']; mysql_query("delete from `locations` where `regid`='$regid'"); mysql_query("delete from `regions` where `id`='$regid'"); unset($_REQUEST['regid']); unset($_REQUEST['locid']); unset($_REQUEST['action']); } else if($locid > 0 && $_REQUEST['action'] == "alias") { $id = 54; $_REQUEST['action'] = "aliases"; $_REQUEST['locid'] = $locid; $name = htmlentities($name); $row = mysql_query("insert into `localias` set `locid`='$locid',`name`='$name'"); } else if($locid > 0 && $_REQUEST['action'] == "delalias") { $id = 54; $_REQUEST['action'] = "aliases"; $_REQUEST['locid'] = $locid; $row = mysql_query("delete from `localias` where `locid`='$locid' and `name`='$name'"); } } if($oldid == 42 && $_REQUEST['email'] == "") { $id = $oldid; unset($oldid); } if($oldid == 42) { $id = 43; unset($oldid); } if($oldid == 43 && $_REQUEST['action'] == "updatedob") { $id = 43; unset($oldid); $lname = mysql_real_escape_string($_REQUEST['lname']); $day = intval($_REQUEST['day']); $month = intval($_REQUEST['month']); $year = intval($_REQUEST['year']); $userid = intval($_REQUEST['userid']); $query = "select `lname`,`dob` from `users` where `id`='$userid'"; $details = mysql_fetch_assoc(mysql_query($query)); $query = "insert into `adminlog` set `when`=NOW(),`old-lname`='${details['lname']}',`old-dob`='${details['dob']}', `new-lname`='$lname',`new-dob`='$year-$month-$day',`uid`='$userid',`adminid`='".$_SESSION['profile']['id']."'"; mysql_query($query); $query = "update `users` set `lname`='$lname',`dob`='$year-$month-$day' where `id`='$userid'"; mysql_query($query); } if($oldid == 48 && $_REQUEST['domain'] == "") { $id = $oldid; unset($oldid); } if($oldid == 48) { $id = 49; unset($oldid); } if($id == 44) { if($_REQUEST['userid'] != "") $_REQUEST['userid'] = intval($_REQUEST['userid']); $row = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".$_REQUEST['userid']."'")); if($row['email'] == "") $id = 42; else $_REQUEST['email'] = $row['email']; } if($oldid == 44) { showheader(_("My CAcert.org Account!")); if(intval($_REQUEST['userid']) <= 0) { echo _("No such user found."); } else { mysql_query("update `users` set `password`=sha1('".mysql_real_escape_string(stripslashes($_REQUEST['newpass']))."') where `id`='".intval($_REQUEST['userid'])."'"); $row = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".$_REQUEST['userid']."'")); printf(_("The password for %s has been updated successfully in the system."), $row['email']); $body = sprintf(_("Hi %s,"),$row['fname'])."\n"; $body .= _("You are receiving this email because a CAcert administrator")."\n"; $body .= _("has changed the password on your account.")."\n"; $body .= _("Best regards")."\n"._("CAcert.org Support!"); sendmail($row['email'], "[CAcert.org] "._("Password Update Notification"), $body, "support@cacert.org", "", "", "CAcert Support"); } showfooter(); exit; } if($_REQUEST['process'] != "" && $oldid == 45) { $CSR = trim($CSR); $_SESSION['_config']['CSR'] = $CSR; $_SESSION['_config']['subject'] = trim(`echo "$CSR"|/usr/bin/openssl req -text -noout|tr -d "\\0"|grep "Subject:"`); $bits = explode(",", trim(`echo "$CSR"|/usr/bin/openssl req -text -noout|tr -d "\\0"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`)); foreach($bits as $val) { $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val); } $id = 46; $_SESSION['_config']['0.CN'] = $_SESSION['_config']['0.subjectAltName'] = ""; extractit(); getcn(); getalt(); if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { showheader(_("My CAcert.org Account!")); echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue."); showfooter(); exit; } } if($_REQUEST['process'] != "" && $oldid == 46) { $CSR = $_SESSION['_config']['CSR']; $_SESSION['_config']['subject'] = trim(`echo "$CSR"|/usr/bin/openssl req -text -noout|tr -d "\\0"|grep "Subject:"`); $bits = explode(",", trim(`echo "$CSR"|/usr/bin/openssl req -text -noout|tr -d "\\0"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`)); foreach($bits as $val) { $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val); } $id = 11; $_SESSION['_config']['0.CN'] = $_SESSION['_config']['0.subjectAltName'] = ""; extractit(); getcn(); getalt(); if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { showheader(_("My CAcert.org Account!")); echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue."); showfooter(); exit; } $query = "insert into `domaincerts` set `CN`='".$_SESSION['_config']['0.CN']."', `domid`='".$_SESSION['_config']['row']['id']."', `created`=NOW()"; mysql_query($query); $CSRid = mysql_insert_id(); foreach($_SESSION['_config']['rowid'] as $dom) mysql_query("insert into `domlink` set `certid`='$CSRid', `domid`='$dom'"); if(is_array($_SESSION['_config']['altid'])) foreach($_SESSION['_config']['altid'] as $dom) mysql_query("insert into `domlink` set `certid`='$CSRid', `domid`='$dom'"); $CSRname = $_SESSION['_config']['filepath']."/csr/server-$CSRid.csr"; $fp = fopen($CSRname, "w"); fputs($fp, $_SESSION['_config']['CSR']); fclose($fp); mysql_query("update `domaincerts` set `CSR_name`='$CSRname' where `id`='$CSRid'"); waitForResult("domaincerts", $CSRid,$oldid); $query = "select * from `domaincerts` where `id`='$CSRid' and `crt_name` != ''"; $res = mysql_query($query); if(mysql_num_rows($res) <= 0) { showheader(_("My CAcert.org Account!")); printf(_("Your certificate request has failed to be processed correctly, see %sthe WIKI page%s for reasons and solutions."), "", ""); showfooter(); exit; } else { $id = 47; $cert = $CSRid; } } if($id == 43 && $_REQUEST['tverify'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['tverify']); $query = "select * from `users` where `id`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['tverify']; mysql_query("update `users` set `tverify`='$ver' where `id`='$memid'"); } if($id == 43 && $_REQUEST['assurer'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['assurer']); $query = "select * from `users` where `id`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['assurer']; mysql_query("update `users` set `assurer`='$ver' where `id`='$memid'"); } if($id == 43 && $_REQUEST['assurer_blocked'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['assurer_blocked']); $query = "select * from `users` where `id`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['assurer_blocked']; mysql_query("update `users` set `assurer_blocked`='$ver' where `id`='$memid'"); } if($id == 43 && $_REQUEST['locked'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['locked']); $query = "select * from `users` where `id`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['locked']; mysql_query("update `users` set `locked`='$ver' where `id`='$memid'"); } if($id == 43 && $_REQUEST['codesign'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['codesign']); $query = "select * from `users` where `id`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['codesign']; mysql_query("update `users` set `codesign`='$ver' where `id`='$memid'"); } if($id == 43 && $_REQUEST['orgadmin'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['orgadmin']); $query = "select * from `users` where `id`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['orgadmin']; mysql_query("update `users` set `orgadmin`='$ver' where `id`='$memid'"); } if($id == 43 && $_REQUEST['ttpadmin'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['ttpadmin']); $query = "select * from `users` where `id`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['ttpadmin']; mysql_query("update `users` set `ttpadmin`='$ver' where `id`='$memid'"); } if($id == 43 && $_REQUEST['adadmin'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['adadmin']); $query = "select * from `users` where `id`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = $row['adadmin'] + 1; if($ver > 2) $ver = 0; mysql_query("update `users` set `adadmin`='$ver' where `id`='$memid'"); } if($id == 43 && $_REQUEST['locadmin'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['locadmin']); $query = "select * from `users` where `id`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['locadmin']; mysql_query("update `users` set `locadmin`='$ver' where `id`='$memid'"); } if($id == 43 && $_REQUEST['admin'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['admin']); $query = "select * from `users` where `id`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['admin']; mysql_query("update `users` set `admin`='$ver' where `id`='$memid'"); } if($id == 43 && $_REQUEST['general'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['general']); $query = "select * from `alerts` where `memid`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['general']; mysql_query("update `alerts` set `general`='$ver' where `memid`='$memid'"); } if($id == 43 && $_REQUEST['country'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['country']); $query = "select * from `alerts` where `memid`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['country']; mysql_query("update `alerts` set `country`='$ver' where `memid`='$memid'"); } if($id == 43 && $_REQUEST['regional'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['regional']); $query = "select * from `alerts` where `memid`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['regional']; mysql_query("update `alerts` set `regional`='$ver' where `memid`='$memid'"); } if($id == 43 && $_REQUEST['radius'] > 0) { $memid = $_REQUEST['userid'] = intval($_REQUEST['radius']); $query = "select * from `alerts` where `memid`='$memid'"; $row = mysql_fetch_assoc(mysql_query($query)); $ver = !$row['radius']; mysql_query("update `alerts` set `radius`='$ver' where `memid`='$memid'"); } if($id == 50) { if($_REQUEST['userid'] != "") $_REQUEST['userid'] = intval($_REQUEST['userid']); $row = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".$_REQUEST['userid']."'")); if($row['email'] == "") $id = 42; else $_REQUEST['email'] = $row['email']; } if($oldid == 50) { $id = 43; $_REQUEST['userid'] = intval($_REQUEST['userid']); } if($oldid == 50 && $_REQUEST['process'] != "") { $_REQUEST['userid'] = intval($_REQUEST['userid']); $res = mysql_query("select * from `users` where `id`='".$_REQUEST['userid']."'"); if(mysql_num_rows($res) > 0) { $query = "update `domaincerts`,`domains` SET `domaincerts`.`revoked`='1970-01-01 10:00:01' WHERE `domaincerts`.`domid` = `domains`.`id` AND `domains`.`memid`='".$_REQUEST['userid']."'"; mysql_query($query); $query = "update `domains` SET `deleted`=NOW() WHERE `domains`.`memid`='".$_REQUEST['userid']."'"; mysql_query($query); $query = "update `emailcerts` SET `revoked`='1970-01-01 10:00:01' WHERE `memid`='".$_REQUEST['userid']."'"; mysql_query($query); $query = "update `email` SET `deleted`=NOW() WHERE `memid`='".$_REQUEST['userid']."'"; mysql_query($query); $query = "delete from `org` WHERE `memid`='".$_REQUEST['userid']."'"; mysql_query($query); $query = "update `users` SET `deleted`=NOW() WHERE `id`='".$_REQUEST['userid']."'"; mysql_query($query); } } if(($id == 51 || $id == 52 || $oldid == 52) && $_SESSION['profile']['tverify'] <= 0) { showheader(_("My CAcert.org Account!")); echo _("You don't have access to this area."); showfooter(); exit; } if($oldid == 52) { $uid = intval($_REQUEST['uid']); $query = "select * from `tverify` where `id`='$uid' and `modified`=0"; $rc = mysql_num_rows(mysql_query($query)); if($rc <= 0) { showheader(_("My CAcert.org Account!")); echo _("Unable to find a valid tverify request for this ID."); showfooter(); exit; } } if($oldid == 52) { $query = "select * from `tverify-vote` where `tverify`='$uid' and `memid`='".$_SESSION['profile']['id']."'"; $rc = mysql_num_rows(mysql_query($query)); if($rc > 0) { showheader(_("My CAcert.org Account!")); echo _("You have already voted on this request."); showfooter(); exit; } } if($oldid == 52 && ($_REQUEST['agree'] != "" || $_REQUEST['disagree'] != "")) { $vote = -1; if($_REQUEST['agree'] != "") $vote = 1; $query = "insert into `tverify-vote` set `tverify`='$uid', `memid`='".$_SESSION['profile']['id']."', `when`=NOW(), `vote`='$vote', `comment`='".mysql_real_escape_string($_REQUEST['comment'])."'"; mysql_query($query); $rc = mysql_num_rows(mysql_query("select * from `tverify-vote` where `tverify`='$uid' and `vote`='1'")); if($rc >= 8) { mysql_query("update `tverify` set `modified`=NOW() where `id`='$uid'"); $tverify = mysql_fetch_assoc(mysql_query("select * from `tverify` where `id`='$uid'")); $memid = $tverify['memid']; $user = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='$memid'")); $tmp = mysql_fetch_assoc(mysql_query("select sum(`points`) as `points` from `notary` where `to`='$memid'")); $points = 0; if($tverify['URL'] != "" && $tverify['photoid'] != "") $points = 150 - intval($tmp['points']); if($tverify['URL'] != "" && $tverify['photoid'] == "") $points = 90 - intval($tmp['points']); if($tverify['URL'] == "" && $tverify['photoid'] == "") $points = 50 - intval($tmp['points']); if($points < 0) $points = 0; if($points > 0) { mysql_query("insert into `notary` set `from`='0', `to`='$memid', `points`='$points', `method`='Thawte Points Transfer', `when`=NOW()"); } $totalpoints = intval($tmp['points']) + $points; $body = _("Your request to have points transfered was successful. You were issued $points points as a result, and you now have $totalpoints in total")."\n\n"._("The following comments were made by reviewers")."\n\n"; $res = mysql_query("select * from `tverify-vote` where `tverify`='$uid' and `vote`='1'"); while($row = mysql_fetch_assoc($res)) $body .= $row['comment']."\n"; $body .= "\n"; $body .= _("Best regards")."\n"; $body .= _("CAcert Support Team"); sendmail($user['email'], "[CAcert.org] Thawte Notary Points Transfer", $body, "website-form@cacert.org", "support@cacert.org", "", "CAcert Tverify"); } $rc = mysql_num_rows(mysql_query("select * from `tverify-vote` where `tverify`='$uid' and `vote`='-1'")); if($rc >= 4) { mysql_query("update `tverify` set `modified`=NOW() where `id`='$uid'"); $tverify = mysql_fetch_assoc(mysql_query("select * from `tverify` where `id`='$uid'")); $memid = $tverify['memid']; $user = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='$memid'")); $body = _("Unfortunately your request for a points increase has been denied, below is the comments from people that reviewed your request as to why they rejected your application.")."\n\n"; $res = mysql_query("select * from `tverify-vote` where `tverify`='$uid' and `vote`='-1'"); while($row = mysql_fetch_assoc($res)) $body .= $row['comment']."\n"; $body .= "\n"; $body .= _("You are welcome to try submitting another request at any time in the future, please make sure you take the reviewer comments into consideration or you risk having your application rejected again.")."\n\n"; $body .= _("Best regards")."\n"; $body .= _("CAcert Support Team"); sendmail($user['email'], "[CAcert.org] Thawte Notary Points Transfer", $body, "website-form@cacert.org", "support@cacert.org", "", "CAcert Tverify"); } showheader(_("My CAcert.org Account!")); echo _("Your vote has been accepted."); showfooter(); exit; } if(intval($cert) > 0) $_SESSION['_config']['cert'] = intval($cert); if(intval($orgid) > 0) $_SESSION['_config']['orgid'] = intval($orgid); if(intval($memid) > 0) $_SESSION['_config']['memid'] = intval($memid); if(intval($domid) > 0) $_SESSION['_config']['domid'] = intval($domid); $_SESSION['_config']['agent'] = $HTTP_USER_AGENT; ?>