summaryrefslogtreecommitdiff
path: root/cacert/tverify
diff options
context:
space:
mode:
authorMarkus Warg <mw@it-sls.de>2010-03-11 15:17:02 +0100
committerMarkus Warg <mw@it-sls.de>2010-03-11 15:17:02 +0100
commit83b70a122092220d839d8a62c2b07913faa20fce (patch)
tree9b39a35e5183d9a36a3c3df38cf185f99de6708b /cacert/tverify
downloadcacert-devel-83b70a122092220d839d8a62c2b07913faa20fce.tar.gz
cacert-devel-83b70a122092220d839d8a62c2b07913faa20fce.tar.xz
cacert-devel-83b70a122092220d839d8a62c2b07913faa20fce.zip
source code taken from cacert-20090625.tar.bz2
Diffstat (limited to 'cacert/tverify')
-rw-r--r--cacert/tverify/.htaccess5
-rw-r--r--cacert/tverify/CVS/Entries4
-rw-r--r--cacert/tverify/CVS/Repository1
-rw-r--r--cacert/tverify/CVS/Root1
-rw-r--r--cacert/tverify/favicon.icobin0 -> 3638 bytes
-rw-r--r--cacert/tverify/index.php163
-rw-r--r--cacert/tverify/index/0.php149
-rw-r--r--cacert/tverify/index/1.php1
-rw-r--r--cacert/tverify/index/CVS/Entries3
-rw-r--r--cacert/tverify/index/CVS/Repository1
-rw-r--r--cacert/tverify/index/CVS/Root1
11 files changed, 329 insertions, 0 deletions
diff --git a/cacert/tverify/.htaccess b/cacert/tverify/.htaccess
new file mode 100644
index 0000000..bb5fe0e
--- /dev/null
+++ b/cacert/tverify/.htaccess
@@ -0,0 +1,5 @@
+php_value auto_prepend_file /www/includes/general.php
+php_value output_buffering 1
+errordocument 404 /error404.php
+errordocument 403 /error403.php
+errordocument 401 /error401.php
diff --git a/cacert/tverify/CVS/Entries b/cacert/tverify/CVS/Entries
new file mode 100644
index 0000000..14698f6
--- /dev/null
+++ b/cacert/tverify/CVS/Entries
@@ -0,0 +1,4 @@
+/.htaccess/1.1/Sat Mar 12 19:40:24 2005//
+/favicon.ico/1.1/Sat Mar 12 19:40:24 2005//
+D/index////
+/index.php/1.13/Sun Apr 5 00:44:05 2009//
diff --git a/cacert/tverify/CVS/Repository b/cacert/tverify/CVS/Repository
new file mode 100644
index 0000000..b25f81a
--- /dev/null
+++ b/cacert/tverify/CVS/Repository
@@ -0,0 +1 @@
+cacert/tverify
diff --git a/cacert/tverify/CVS/Root b/cacert/tverify/CVS/Root
new file mode 100644
index 0000000..a363882
--- /dev/null
+++ b/cacert/tverify/CVS/Root
@@ -0,0 +1 @@
+/var/lib/cvs
diff --git a/cacert/tverify/favicon.ico b/cacert/tverify/favicon.ico
new file mode 100644
index 0000000..3c9c9c2
--- /dev/null
+++ b/cacert/tverify/favicon.ico
Binary files differ
diff --git a/cacert/tverify/index.php b/cacert/tverify/index.php
new file mode 100644
index 0000000..8976341
--- /dev/null
+++ b/cacert/tverify/index.php
@@ -0,0 +1,163 @@
+<? /*
+ 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
+*/ ?>
+<?
+// phpinfo(); exit;
+ include_once("../includes/general.php");
+ loadem("tverify");
+
+ $id = intval($_GET['id']);
+ if(intval($_REQUEST['id']) > 0)
+ $id = intval($_REQUEST['id']);
+
+ if($id == 1)
+ {
+ $nofile = 1;
+ $filename = "";
+ $photoid = $_FILES['photoid'];
+ if($photoid['error'] == 0 && $_REQUEST["notaryURL"] != "")
+ {
+ $filename = $photoid['tmp_name'];
+ $do = trim(`file -b -i $filename`);
+ $type = strtolower($do);
+ switch($type)
+ {
+ case 'image/gif': $ext = "gif"; $nofile = 0; break;
+ case 'image/jpeg': $ext = "jpg"; $nofile = 0; break;
+ case 'image/jpg': $ext = "jpg"; $nofile = 0; break;
+ case 'image/png': $ext = "png"; $nofile = 0; break;
+ default:
+ $id = 0;
+ $_SESSION['_config']['errmsg'] = _("Only jpg, gif and png file types are acceptable, your browser sent a file of type: ").$type;
+ }
+ }
+ }
+
+ if($id == 1)
+ {
+ $email = mysql_escape_string(trim($_REQUEST["email"]));
+ $password = mysql_escape_string(stripslashes(trim($_REQUEST["pword"])));
+ $URL = mysql_escape_string(trim($_REQUEST["notaryURL"]));
+ $CN = mysql_escape_string($_SESSION['_config']['CN']);
+ $memid = intval($_SESSION['_config']['uid']);
+ $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'"));
+
+ if($URL != "" && $nofile == 0)
+ $max = 150;
+ else if($URL != "")
+ $max = 90;
+ else
+ $max = 50;
+
+ if($URL != "")
+ if(!preg_match("/^https:\/\/www\.thawte\.com\/cgi\/personal\/wot\/directory\.exe\?(.*?&)?node=\d+(&.*)?$/",$URL))
+ {
+ showheader(_("Thawte Points Transfer"));
+ echo _("You failed to enter a valid Thawte Notary URL.");
+ showfooter();
+ exit;
+ }
+
+ if($tmp['points'] >= $max)
+ {
+ showheader(_("Thawte Points Transfer"));
+ echo _("Your request would not gain you any more points and will not be taken any further.").
+ sprintf(_("You have %s points already and you would have been issued up to %s points."), $tmp['points'], $max);
+ showfooter();
+ exit;
+ }
+
+ }
+
+ if($id == 1)
+ {
+ $query = "select * from `users`,`email` where `email`.`memid`='$memid' and `email`.`email`='$email' and `users`.`id`=`email`.`memid` and
+ (`password`=old_password('$password') or `password`=sha1('$password') or `password`=password('$password'))";
+ if(mysql_num_rows(mysql_query($query)) <= 0)
+ {
+ $_SESSION['_config']['errmsg'] = _("I'm sorry, I couldn't match your login details (password) to your certificate to an account on this system.");
+ $id = 0;
+ } else {
+ $query = "insert into `tverify` set `memid`='$memid', `URL`='$URL', `CN`='$CN', `created`=NOW()";
+ mysql_query($query);
+ $tverify = mysql_insert_id();
+ if($nofile == 0)
+ {
+ $filename = $photoid['tmp_name'];
+ $newfile = mysql_escape_string('/www/photoid/'.$tverify.".".$ext);
+ move_uploaded_file($filename, $newfile);
+ $query = "update `tverify` set `photoid`='$newfile' where `id`='$tverify'";
+ mysql_query($query);
+ }
+ }
+ }
+
+ if($id == 1)
+ {
+ $points = 0;
+ if($URL != "" && $newfile != "")
+ $points = 150 - intval($tmp['points']);
+ else if($URL != "")
+ $points = 90 - intval($tmp['points']);
+ else
+ $points = 50 - intval($tmp['points']);
+
+ if($points < 0)
+ $points = 0;
+ }
+
+ if($id == 1 && $max == 50)
+ {
+ if($points > 0)
+ {
+ mysql_query("insert into `notary` set `from`='0', `to`='$memid', `points`='$points',
+ `method`='Thawte Points Transfer', `when`=NOW()");
+ fix_assurer_flag($memid);
+ }
+ $totalpoints = intval($tmp['points']) + $points;
+ mysql_query("update `tverify` set `modified`=NOW() where `id`='$tverify'");
+
+ $body = _("Your request to have points transfered was sucessful. You were issued $points points as a result, and you now have $totalpoints in total")."\n\n";
+
+ $body .= _("Best regards")."\n";
+ $body .= _("CAcert Support Team");
+ sendmail($user['email'], "[CAcert.org] Thawte Notary Points Transfer", $body, "website-form@cacert.org", "returns@cacert.org", "", "CAcert Tverify");
+ } else if($id == 1) {
+ $body = "There is a new valid request for thawte points tranfer, details as follows:\n\n";
+ $body .= "To vote on this application, go to: https://www.cacert.org/account.php?id=52&uid=$tverify\n\n";
+ $body .= "Or use the certificate login: https://secure.cacert.org/account.php?id=52&uid=$tverify\n\n";
+
+ $body .= "We know that by signing into https://tverify.cacert.org that\n";
+ $body .= "1. they have possession of a cert issued from Thawte\n";
+ $body .= "2. the person named in the cert has been verified by Thawte's Web of Trust\n";
+ $body .= "3. at least 1 of the emails listed as valid in that cert belongs to a\n";
+ $body .= "CAcert.org user\n\n";
+ $body .= "It's up to us as voting members to verify the details that can't be\n";
+ $body .= "programatically handled, that means checking the ID, and signing into\n";
+ $body .= "the Thawte site and validating their name is listed as a notary.\n\n";
+
+ $body .= "Best regards"."\n";
+ $body .= "CAcert Support Team";
+
+ sendmail("cacert-tverify@lists.cacert.org", "[CAcert.org] Thawte Notary Points Transfer", $body, "website-form@cacert.org", "returns@cacert.org", "", "CAcert Tverify");
+ }
+
+ showheader(_("Thawte Points Transfer"));
+ includeit($id, "tverify");
+ showfooter();
+?>
diff --git a/cacert/tverify/index/0.php b/cacert/tverify/index/0.php
new file mode 100644
index 0000000..2264bab
--- /dev/null
+++ b/cacert/tverify/index/0.php
@@ -0,0 +1,149 @@
+<? /*
+ 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
+*/
+ $continue = 1;
+ //Checking for Thawte Freemail members, who aren´t notaries
+ if($_SERVER['SSL_CLIENT_S_DN_CN'] == 'Thawte Freemail Member')
+ {
+ $continue = 0;
+ echo _("I wasn't able to locate your name on your certificate, as such you can't continue with this process.");
+ }
+
+ //Extracting the Email address from the certificate that is presented, looking up the email in the database to find the user that has registered it.
+ if($continue == 1)
+ {
+ $addy = array();
+ $emails = explode("/", trim($_SERVER['SSL_CLIENT_S_DN']));
+ foreach($emails as $email)
+ {
+ $bits = explode("=", $email);
+ if($bits['0'] == "emailAddress")
+ {
+ $query = "select * from `email` where `email`='".$bits['1']."' and `deleted`=0 and hash=''";
+ $account = mysql_query($query);
+ if(mysql_num_rows($account))
+ $addy[] = $bits['1'];
+ }
+ }
+ }
+
+ //Verifying that we found a record with that email address
+ if(count($addy) <= 0 && $continue == 1)
+ {
+ $continue = 0;
+ echo _("I wasn't able to match any email accounts on your certificate to any accounts in our database, as such I can't continue with this process.");
+ }
+
+ //If we found one, we extract the member-id from the sql result of the query we did above, and fetch the name of that user
+ if($continue == 1)
+ {
+ $row = mysql_fetch_assoc($account);
+ $memid = $row['memid'];
+
+
+ //Fetching the name of the user we have in the database:
+ $query = "select `fname`, `mname`, `lname`, `suffix` from `users` where `id`='$memid' and `deleted`=0";
+ $res = mysql_query($query);
+ $row = mysql_fetch_assoc($res);
+
+ //Building the user´s name, and ignoring punctuation
+ $cacert_name=$row['fname']." ".$row['mname']." ".$row['lname']." ".$row['suffix'];
+ $cacert_name=strtr($cacert_name,",.","");
+ $cacert_name=trim(str_replace(" ", " ", $cacert_name));
+
+ //Generate a short name form without the middle name
+ $cacert_short_name=$row['fname']." ".$row['lname']." ".$row['suffix'];
+ $cacert_short_name=strtr($cacert_short_name,",.","");
+ $cacert_short_name=trim(str_replace(" ", " ", $cacert_short_name));
+
+
+ $tverifybits = explode(" ", trim($_SERVER['SSL_CLIENT_S_DN_G']), 2);
+ $firstname = trim($tverifybits['0']);
+ $givenname = trim($_SERVER['SSL_CLIENT_S_DN_G']);
+ $lastname = trim($_SERVER['SSL_CLIENT_S_DN_S']);
+ $tverify_name=strtr("$givenname $lastname",",.","");
+ $tverify_short_name=strtr("$firstname $lastname",",.","");
+
+ if(($cacert_name != $tverify_name) and ($cacert_short_name == $tverify_name))
+ {
+ $continue = 0;
+ printf(_("Your CAcert account contains a middle name (%s), but we cannot verify this middle name with the certificate."),$row['mname']);
+
+ }
+
+ if($continue and ($cacert_name != $tverify_name) and ($cacert_name == $tverify_short_name))
+ {
+ printf(_("Your certificate containes a middle name (%s) which isn´t listed in your CAcert account. In case you might want to get certificates with your middle name included in the future, you should add the middle name to your CAcert account before continueing."));
+ }
+
+ if($continue and ($cacert_name != $tverify_name) and ($cacert_name != $tverify_short_name) and ($cacert_short_name == $tverify_short_name))
+ {
+ printf(_("There is a problem with your middle name. You could remove the middle name in your CAcert account, which should help to continue with the TVerify process, but then you can´t use it in your certificates."));
+ }
+
+ if($continue and ($cacert_name != $tverify_name) and ($cacert_name != $tverify_short_name))
+ {
+ $continue = 0;
+ printf(_("The name and email address on your certificate (%s) could not be exactly matched to any stored in our database (%s), as such I'm not able to continue with this process."),$tverify_name,$cacert_name);
+ }
+ }
+
+ if($_SERVER['SSL_CLIENT_VERIFY'] == "SUCCESS" && $continue == 1)
+ {
+ $_SESSION['_config']['uid'] = $memid;
+ $_SESSION['_config']['CN'] = trim($_SERVER['SSL_CLIENT_S_DN']);
+?>
+<p style="border:dotted 1px #900;padding:0.3em;background-color:#ffe;">
+<?=_("By just submitting your Thawte certificate you can be issued 50 points automatically to any matching account in the system that you operate.")?><br>
+<?=_("To receive an additional 40 points you must also include a valid link to your notary listing on the Thawte website.")?><br>
+<?=_("If you meet the above criteria you are also elligible to receive an additional 60 points by submitting a legible government issued copy of your photo ID. If details on your photo ID aren't legible you may be excluded from receiving these points.")?></p>
+<? if($_SESSION['_config']['errmsg'] != "") { ?><p>&nbsp;</p><p style="border:dotted 1px #900;padding:0.3em;background-color:#ffe;"><?
+ echo $_SESSION['_config']['errmsg']."</p>";
+ unset($_SESSION['_config']['errmsg']);
+} ?>
+<form method="post" action="index.php" enctype="multipart/form-data">
+<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
+ <tr>
+ <td colspan="2" class="title"><?=_("Points Transfer and Verification")?></td>
+ </tr>
+ <tr>
+ <td class="DataTD" width="125"><?=_("Email Address")?>: </td>
+ <td class="DataTD" width="125"><input type="text" name="email" value="<?=$row['email']?>"></td>
+ </tr>
+ <tr>
+ <td class="DataTD" width="125"><?=_("Notary URL")?>: </td>
+ <td class="DataTD" width="125"><input type="text" name="notaryURL" value="<?=htmlentities($_POST['notaryURL'])?>"></td>
+ </tr>
+ <tr>
+ <td class="DataTD" width="125"><?=_("Photo ID")?>: </td>
+ <td class="DataTD" width="125"><input type="file" name="photoid"></td>
+ </tr>
+ <tr>
+ <td class="DataTD"><?=_("Pass Phrase")?>: </td>
+ <td class="DataTD"><input type="password" name="pword"></td>
+ </tr>
+ <tr>
+ <td class="DataTD" colspan="2"><input type="submit" name="process" value="<?=_("Submit Application for Points Transfer")?>"></td>
+ </tr>
+
+</table>
+<input type="hidden" name="id" value="1">
+</form>
+<? } else if($continue == 1) {
+ echo _("1I'm sorry, I couldn't verify your certificate");
+ }
+?>
diff --git a/cacert/tverify/index/1.php b/cacert/tverify/index/1.php
new file mode 100644
index 0000000..ad9875a
--- /dev/null
+++ b/cacert/tverify/index/1.php
@@ -0,0 +1 @@
+<p><?=_("Your request is now queued for processing, you will be notified by an automated email when your request has been verified by the points transfer team.");?></p>
diff --git a/cacert/tverify/index/CVS/Entries b/cacert/tverify/index/CVS/Entries
new file mode 100644
index 0000000..23d69d7
--- /dev/null
+++ b/cacert/tverify/index/CVS/Entries
@@ -0,0 +1,3 @@
+/1.php/1.1/Sat Mar 12 19:40:24 2005//
+/0.php/1.10/Sun Apr 6 19:45:25 2008//
+D
diff --git a/cacert/tverify/index/CVS/Repository b/cacert/tverify/index/CVS/Repository
new file mode 100644
index 0000000..985f83a
--- /dev/null
+++ b/cacert/tverify/index/CVS/Repository
@@ -0,0 +1 @@
+cacert/tverify/index
diff --git a/cacert/tverify/index/CVS/Root b/cacert/tverify/index/CVS/Root
new file mode 100644
index 0000000..a363882
--- /dev/null
+++ b/cacert/tverify/index/CVS/Root
@@ -0,0 +1 @@
+/var/lib/cvs