diff --git a/includes/account.php b/includes/account.php index 2ebb2a1..8d8e34b 100644 --- a/includes/account.php +++ b/includes/account.php @@ -16,7 +16,7 @@ loadem("account"); - if($process == _("Add") && $oldid == 1) + if($process != "" && $oldid == 1) { $id = 1; if(trim(mysql_escape_string(stripslashes($newemail))) == "") @@ -48,7 +48,7 @@ $body .= "http://$hostname/verify.php?type=email&emailid=$emailid&hash=$hash\n\n"; $body .= _("Best regards")."\n"._("CAcert.org Support!"); - mail($email, "[CAcert.org] "._("Email Probe"), $body, "From: CAcacert-Support "); + mail($email, "[CAcert.org] "._("Email Probe"), $body, "From: CAcacert-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."), $email); @@ -56,7 +56,7 @@ exit; } - if($process == _("Make Default") && $oldid == 2) + if($makedefault != "" && $oldid == 2) { $id = 2; $emailid = intval($emailid); @@ -79,7 +79,7 @@ exit; } - if($process == _("Delete") && $oldid == 2) + if($process != "" && $oldid == 2) { $id = 2; showheader(_("My CAcert.org Account!")); @@ -112,7 +112,7 @@ exit; } - if($process == _("Next") && $oldid == 3) + if($process != "" && $oldid == 3) { if(!is_array($addid)) { @@ -335,7 +335,7 @@ $_SESSION['_config']['domain'] = $newdomain; } - if($process == _("Probe") && $oldid == 8) + if($process != "" && $oldid == 8) { unset($oldid); $id = 8; @@ -373,7 +373,7 @@ $body .= "http://$hostname/verify.php?type=domain&domainid=$domainid&hash=$hash\n\n"; $body .= _("Best regards")."\n"._("CAcert.org Support!"); - mail($authaddy, "[CAcert.org] "._("Email Probe"), $body, "From: CAcert-Support "); + mail($authaddy, "[CAcert.org] "._("Email Probe"), $body, "From: 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']); @@ -381,7 +381,7 @@ exit; } - if($process == _("Delete") && $oldid == 9) + if($process != "" && $oldid == 9) { $id = 9; showheader(_("My CAcert.org Account!")); @@ -412,7 +412,7 @@ exit; } - if($process == _("Submit") && $oldid == 10) + if($process != "" && $oldid == 10) { $CSR = trim($CSR); $_SESSION['_config']['CSR'] = $CSR; @@ -432,7 +432,7 @@ } } - if($process == _("Submit") && $oldid == 11) + if($process != "" && $oldid == 11) { $CSR = $_SESSION['_config']['CSR']; $_SESSION['_config']['subject'] = trim(`echo "$CSR"|/usr/bin/openssl req -text|grep Subject:`); @@ -482,7 +482,7 @@ } } - if($oldid == 12 && $process == _("Renew")) + if($oldid == 12 && $renew != "") { $id = 12; showheader(_("My CAcert.org Account!")); @@ -534,7 +534,7 @@ exit; } - if($oldid == 12 && $process == _("Revoke/Delete")) + if($oldid == 12 && $revoke != "") { $id = 12; showheader(_("My CAcert.org Account!")); @@ -598,7 +598,7 @@ exit; } - if($oldid == 5 && $process == _("Renew")) + if($oldid == 5 && $renew != "") { showheader(_("My CAcert.org Account!")); if(is_array($revokeid)) @@ -652,7 +652,7 @@ exit; } - if($oldid == 5 && $process == _("Revoke/Delete")) + if($oldid == 5 && $revoke != "") { $id = 5; showheader(_("My CAcert.org Account!")); @@ -718,7 +718,7 @@ $_SESSION['_config']['user']['set'] = 1; } - if($oldid == 13 && $process == _("Update")) + if($oldid == 13 && $process != "") { $_SESSION['_config']['user']['fname'] = trim(mysql_escape_string(stripslashes($fname))); $_SESSION['_config']['user']['mname'] = trim(mysql_escape_string(stripslashes($mname))); @@ -756,7 +756,7 @@ } } - if($oldid == 13 && $process == _("Update")) + if($oldid == 13 && $process != "") { if($_SESSION['profile']['points'] < 100) { @@ -792,7 +792,7 @@ exit; } - if($oldid == 14 && $process == _("Update Pass Phrase")) + if($oldid == 14 && $process != "") { $_SESSION['_config']['user']['oldpass'] = trim(mysql_escape_string(stripslashes($oldpassword))); $_SESSION['_config']['user']['pword1'] = trim(mysql_escape_string(stripslashes($pword1))); @@ -862,7 +862,7 @@ exit; } - if($oldid == 16 && $process == _("Next")) + if($oldid == 16 && $process != "") { if(@count($_SESSION['_config']['emails']) > 0) $id = 17; @@ -999,7 +999,7 @@ } } - if($oldid == 18 && $process == _("Renew")) + if($oldid == 18 && $renew != "") { showheader(_("My CAcert.org Account!")); if(is_array($revokeid)) @@ -1049,7 +1049,7 @@ exit; } - if($oldid == 18 && $process == _("Revoke/Delete")) + if($oldid == 18 && $revoke != "") { $id = 18; showheader(_("My CAcert.org Account!")); @@ -1111,7 +1111,7 @@ exit; } - if($process == _("Submit") && $oldid == 20) + if($process != "" && $oldid == 20) { $CSR = trim($CSR); $_SESSION['_config']['CSR'] = $CSR; @@ -1139,7 +1139,7 @@ } } - if($process == _("Submit") && $oldid == 21) + if($process != "" && $oldid == 21) { $CSR = $_SESSION['_config']['CSR']; $_SESSION['_config']['subject'] = trim(`echo "$CSR"|/usr/bin/openssl req -text|grep Subject:`); @@ -1212,7 +1212,7 @@ } } - if($oldid == 22 && $process == _("Renew")) + if($oldid == 22 && $renew != "") { showheader(_("My CAcert.org Account!")); if(is_array($revokeid)) @@ -1267,7 +1267,7 @@ exit; } - if($oldid == 22 && $process == _("Revoke/Delete")) + if($oldid == 22 && $revoke != "") { showheader(_("My CAcert.org Account!")); if(is_array($revokeid)) @@ -1343,7 +1343,7 @@ exit; } - if($oldid == 24 && $process == _("Next")) + if($oldid == 24 && $process != "") { $id = intval($oldid); $_SESSION['_config']['O'] = trim(mysql_escape_string(stripslashes($O))); @@ -1370,7 +1370,7 @@ } } - if($oldid == 27 && $process == _("Update")) + if($oldid == 27 && $process != "") { $id = intval($oldid); $_SESSION['_config']['O'] = trim(mysql_escape_string(stripslashes($O))); @@ -1398,12 +1398,11 @@ } } - if($oldid == 28 && $process == _("Add")) + if($oldid == 28 && $process != "") { $domain = $_SESSION['_config']['domain'] = trim(mysql_escape_string(stripslashes($domainname))); $res1 = mysql_query("select * from `orgdomains` where `domain`='$domain'"); - $res2 = mysql_query("select * from `domains` where `domain`='$domain' and `deleted`=0"); - if(mysql_num_rows($res1) > 0 || mysql_num_rows($res2) > 0) + 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; @@ -1417,7 +1416,7 @@ $id = 25; } - if($oldid == 28 && $process == _("Add")) + if($oldid == 28 && $process != "") { mysql_query("insert into `orgdomains` set `orgid`='".$_SESSION['_config']['orgid']."', `domain`='$domain'"); showheader(_("My CAcert.org Account!")); @@ -1427,7 +1426,7 @@ exit; } - if($oldid == 29 && $process == _("Update")) + if($oldid == 29 && $process != "") { $domain = mysql_escape_string(stripslashes(trim($domainname))); @@ -1463,7 +1462,7 @@ $do = `../scripts/runclient`; } - if($oldid == 29 && $process == _("Update")) + if($oldid == 29 && $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']."'"); @@ -1474,7 +1473,7 @@ exit; } - if($oldid == 30 && $process == _("Delete")) + if($oldid == 30 && $process != "") { $row = mysql_fetch_assoc(mysql_query("select * from `orgdomains` where `id`='".$_SESSION['_config']['domid']."'")); $domain = $row['domain']; @@ -1572,7 +1571,7 @@ } } - if($oldid == 33 && $process == _("Add")) + if($oldid == 33 && $process != "") { if($_SESSION['profile']['admin'] == 1) $masteracc = $_SESSION['_config'][masteracc] = intval($masteracc); @@ -1594,7 +1593,7 @@ } } - if($oldid == 34 && $process == _("Delete")) + if($oldid == 34 && $process != "") { mysql_query("delete from `org` where `memid`='".$_SESSION['_config']['memid']."'"); } @@ -1704,6 +1703,76 @@ exit; } + if($process != "" && $oldid == 45) + { + $CSR = trim($CSR); + $_SESSION['_config']['CSR'] = $CSR; + $_SESSION['_config']['subject'] = trim(`echo "$CSR"|/usr/bin/openssl req -text|grep Subject:`); + $id = 46; + + extractit(); + getcn(); + getalt(); + + if($_SESSION['_config']["0.CN"] == "") + { + showheader(_("My CAcert.org Account!")); + echo _("CommonName field was blank. Can't continue."); + showfooter(); + exit; + } + } + + if($process != "" && $oldid == 46) + { + $CSR = $_SESSION['_config']['CSR']; + $_SESSION['_config']['subject'] = trim(`echo "$CSR"|/usr/bin/openssl req -text|grep Subject:`); + $id = 11; + + extractit(); + getcn(); + getalt(); + + if($_SESSION['_config']["0.CN"] == "") + { + showheader(_("My CAcert.org Account!")); + echo _("CommonName field was blank. 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'"); + $do = `../scripts/runserver`; + $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!")); + echo _("Your certificate request has failed to be processed correctly, please try submitting it again."); + showfooter(); + exit; + } else { + $id = 47; + $cert = $CSRid; + } + } + if(intval($cert) > 0) $_SESSION['_config']['cert'] = intval($cert); if(intval($orgid) > 0) diff --git a/includes/account_stuff.php b/includes/account_stuff.php index 914a3d9..e7e2c7d 100644 --- a/includes/account_stuff.php +++ b/includes/account_stuff.php @@ -175,12 +175,10 @@ function hideall() {

+

- -