summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/account.php9
-rw-r--r--includes/general.php14
-rw-r--r--includes/lib/account.php51
-rw-r--r--includes/lib/general.php50
-rw-r--r--includes/loggedin.php16
-rw-r--r--includes/wot.inc.php51
-rw-r--r--[-rwxr-xr-x]password.dat.sample0
-rw-r--r--[-rwxr-xr-x]scripts/DumpWeakCerts.pl0
-rw-r--r--scripts/assurer.php2
-rw-r--r--[-rwxr-xr-x]scripts/mail-weak-keys.php0
-rw-r--r--[-rwxr-xr-x]scripts/mass-revoke.php0
-rw-r--r--www/cats/cats_import.php5
-rw-r--r--www/index.php15
13 files changed, 157 insertions, 56 deletions
diff --git a/includes/account.php b/includes/account.php
index 14702b9..24c61d8 100644
--- a/includes/account.php
+++ b/includes/account.php
@@ -1290,6 +1290,8 @@
showheader(_("My CAcert.org Account!"));
if($_SESSION['_config']['user']['pword1'] == "" || $_SESSION['_config']['user']['pword1'] != $_SESSION['_config']['user']['pword2'])
{
+ echo '<h3 style="color:red">', _("Failure: Pass Phrase not Changed"),
+ '</h3>', "\n";
echo _("New Pass Phrases specified don't match or were blank.");
} else {
$score = checkpw($_SESSION['_config']['user']['pword1'], $_SESSION['profile']['email'], $_SESSION['profile']['fname'],
@@ -1306,14 +1308,21 @@
}
if(strlen($_SESSION['_config']['user']['pword1']) < 6) {
+ echo '<h3 style="color:red">',
+ _("Failure: Pass Phrase not Changed"), '</h3>', "\n";
echo _("The Pass Phrase you submitted was too short.");
} else if($score < 3) {
+ echo '<h3 style="color:red">',
+ _("Failure: Pass Phrase not Changed"), '</h3>', "\n";
printf(_("The Pass Phrase you submitted failed to contain enough differing characters and/or contained words from your name and/or email address. Only scored %s points out of 6."), $score);
} else if($rc <= 0) {
+ echo '<h3 style="color:red">',
+ _("Failure: Pass Phrase not Changed"), '</h3>', "\n";
echo _("You failed to correctly enter your current Pass Phrase.");
} else {
mysql_query("update `users` set `password`=sha1('".$_SESSION['_config']['user']['pword1']."')
where `id`='".$_SESSION['profile']['id']."'");
+ echo '<h3>', _("Pass Phrase Changed Successfully"), '</h3>', "\n";
echo _("Your Pass Phrase has been updated and your primary email account has been notified of the change.");
$body = sprintf(_("Hi %s,"),$_SESSION['profile']['fname'])."\n";
$body .= _("You are receiving this email because you or someone else")."\n";
diff --git a/includes/general.php b/includes/general.php
index cb17e63..ebdf20e 100644
--- a/includes/general.php
+++ b/includes/general.php
@@ -38,6 +38,7 @@
$_SESSION['_config']['filepath'] = "/www";
require_once($_SESSION['_config']['filepath']."/includes/mysql.php");
+ require_once($_SESSION['_config']['filepath'].'/includes/lib/account.php');
if(array_key_exists('HTTP_HOST',$_SERVER) &&
$_SERVER['HTTP_HOST'] != $_SESSION['_config']['normalhostname'] &&
@@ -847,19 +848,6 @@
$text=preg_replace("/[^\w-.@]/","",$text);
return($text);
}
-
- function fix_assurer_flag($userID)
- {
- // Update Assurer-Flag on users table if 100 points. Should the number of points be SUM(points) or SUM(awarded)?
- $query = mysql_query('UPDATE `users` AS `u` SET `assurer` = 1 WHERE `u`.`id` = \''.(int)intval($userID).
- '\' AND EXISTS(SELECT 1 FROM `cats_passed` AS `tp`, `cats_variant` AS `cv` WHERE `tp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND `tp`.`user_id` = `u`.`id`)'.
- ' AND (SELECT SUM(`points`) FROM `notary` AS `n` WHERE `n`.`to` = `u`.`id` AND `expire` < now()) >= 100'); // Challenge has been passed and non-expired points >= 100
-
- // Reset flag if requirements are not met
- $query = mysql_query('UPDATE `users` AS `u` SET `assurer` = 0 WHERE `u`.`id` = \''.(int)intval($userID).
- '\' AND (NOT EXISTS(SELECT 1 FROM `cats_passed` AS `tp`, `cats_variant` AS `cv` WHERE `tp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND `tp`.`user_id` = `u`.`id`)'.
- ' OR (SELECT SUM(`points`) FROM `notary` AS `n` WHERE `n`.`to` = `u`.`id` AND `n`.`expire` < now()) < 100)');
- }
// returns 0 if $userID is an Assurer
// Otherwise :
diff --git a/includes/lib/account.php b/includes/lib/account.php
new file mode 100644
index 0000000..f7a24fa
--- /dev/null
+++ b/includes/lib/account.php
@@ -0,0 +1,51 @@
+<?php
+/*
+ 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
+*/
+
+function fix_assurer_flag($userID)
+{
+ // Update Assurer-Flag on users table if 100 points.
+ // Should the number of points be SUM(points) or SUM(awarded)?
+ $query = mysql_query('UPDATE `users` AS `u` SET `assurer` = 1 WHERE '.
+ '`u`.`id` = \''.(int)intval($userID).'\' AND '.
+ 'EXISTS(SELECT 1 FROM `cats_passed` AS `cp`, `cats_variant` AS `cv` '.
+ 'WHERE `cp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND '.
+ '`cp`.`user_id` = `u`.`id`) AND '.
+ '(SELECT SUM(`points`) FROM `notary` AS `n` WHERE `n`.`to` = `u`.`id` '.
+ 'AND (`n`.`expire` > now() OR `n`.`expire` IS NULL)) >= 100');
+ // Challenge has been passed and non-expired points >= 100
+
+ if (!$query) {
+ return false;
+ }
+
+ // Reset flag if requirements are not met
+ $query = mysql_query('UPDATE `users` AS `u` SET `assurer` = 0 WHERE '.
+ '`u`.`id` = \''.(int)intval($userID).'\' AND '.
+ '(NOT EXISTS(SELECT 1 FROM `cats_passed` AS `cp`, `cats_variant` AS '.
+ '`cv` WHERE `cp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 '.
+ 'AND `cp`.`user_id` = `u`.`id`) OR '.
+ '(SELECT SUM(`points`) FROM `notary` AS `n` WHERE `n`.`to` = `u`.`id` '.
+ 'AND (`n`.`expire` > now() OR `n`.`expire` IS NULL)) < 100)');
+
+ if (!$query) {
+ return false;
+ }
+
+ return true;
+} \ No newline at end of file
diff --git a/includes/lib/general.php b/includes/lib/general.php
new file mode 100644
index 0000000..25d2561
--- /dev/null
+++ b/includes/lib/general.php
@@ -0,0 +1,50 @@
+<? /*
+ LibreSSL - CAcert web application
+ Copyright (C) 2004-2011 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
+*/
+
+/**
+ * Checks if the user may log in and retrieve the user id
+ *
+ * Usually called with $_SERVER['SSL_CLIENT_M_SERIAL'] and
+ * $_SERVER['SSL_CLIENT_I_DN_CN']
+ *
+ * @param $serial string
+ * usually $_SERVER['SSL_CLIENT_M_SERIAL']
+ * @param $issuer_cn string
+ * usually $_SERVER['SSL_CLIENT_I_DN_CN']
+ * @return int
+ * the user id, -1 in case of error
+ */
+function get_user_id_from_cert($serial, $issuer_cn)
+{
+ $query = "select `memid` from `emailcerts` where
+ `serial`='".mysql_escape_string($serial)."' and
+ `rootcert`= (select `id` from `root_certs` where
+ `Cert_Text`='".mysql_escape_string($issuer_cn)."') and
+ `revoked`=0 and disablelogin=0 and
+ UNIX_TIMESTAMP(`expire`) - UNIX_TIMESTAMP() > 0";
+ $res = mysql_query($query);
+ if(mysql_num_rows($res) > 0)
+ {
+ $row = mysql_fetch_assoc($res);
+ return intval($row['memid']);
+ }
+
+ return -1;
+}
+
+?>
diff --git a/includes/loggedin.php b/includes/loggedin.php
index 355527f..bf6b455 100644
--- a/includes/loggedin.php
+++ b/includes/loggedin.php
@@ -16,6 +16,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+ include_once("../includes/lib/general.php");
if($_SERVER['HTTP_HOST'] == $_SESSION['_config']['securehostname'] && $_SESSION['profile']['id'] > 0 && $_SESSION['profile']['loggedin'] != 0)
{
@@ -41,14 +42,11 @@
if($_SERVER['HTTP_HOST'] == $_SESSION['_config']['securehostname'] && ($_SESSION['profile']['id'] == 0 || $_SESSION['profile']['loggedin'] == 0))
{
- $query = "select * from `emailcerts` where `serial`='${_SERVER['SSL_CLIENT_M_SERIAL']}' and `revoked`=0 and disablelogin=0 and
- UNIX_TIMESTAMP(`expire`) - UNIX_TIMESTAMP() > 0";
- $res = mysql_query($query);
+ $user_id = get_user_id_from_cert($_SERVER['SSL_CLIENT_M_SERIAL'],
+ $_SERVER['SSL_CLIENT_I_DN_CN']);
- if(mysql_num_rows($res) > 0)
+ if($user_id >= 0)
{
- $row = mysql_fetch_assoc($res);
-
$_SESSION['profile']['loggedin'] = 0;
$_SESSION['profile'] = "";
foreach($_SESSION as $key)
@@ -61,7 +59,8 @@
session_unregister($key);
}
- $_SESSION['profile'] = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".$row['memid']."'"));
+ $_SESSION['profile'] = mysql_fetch_assoc(mysql_query(
+ "select * from `users` where `id`='".$user_id."'"));
if($_SESSION['profile']['locked'] == 0)
$_SESSION['profile']['loggedin'] = 1;
else
@@ -131,13 +130,12 @@
$normalhost=$_SESSION['_config']['normalhostname'];
$_SESSION['profile']['loggedin'] = 0;
$_SESSION['profile'] = "";
- foreach($_SESSION as $key)
+ foreach($_SESSION as $key => $value)
{
unset($_SESSION[$key]);
unset($$key);
session_unregister($key);
}
- unset($_SESSION);
header("location: https://".$normalhost."/index.php");
exit;
diff --git a/includes/wot.inc.php b/includes/wot.inc.php
index ce35ed6..05ce449 100644
--- a/includes/wot.inc.php
+++ b/includes/wot.inc.php
@@ -14,7 +14,7 @@
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
-*/
+*/
function query_init ($query)
{
@@ -35,7 +35,7 @@
function get_number_of_assurances ($userid)
{
$res = query_init ("SELECT count(*) AS `list` FROM `notary`
- WHERE `notary`.`from` != `notary`.`to` AND `notary`.`from`='".intval($userid)."'");
+ WHERE `method` = 'Face to Face Meeting' AND `from`='".intval($userid)."' ");
$row = query_getnextrow($res);
return intval($row['list']);
@@ -44,7 +44,7 @@
function get_number_of_assurees ($userid)
{
$res = query_init ("SELECT count(*) AS `list` FROM `notary`
- WHERE `notary`.`from` != `notary`.`to` AND `notary`.`to`='".intval($userid)."'");
+ WHERE `method` = 'Face to Face Meeting' AND `to`='".intval($userid)."' ");
$row = query_getnextrow($res);
return intval($row['list']);
@@ -52,39 +52,41 @@
function get_top_assurer_position ($no_of_assurances)
{
- $res = query_init ("SELECT count(*) AS `list` FROM `notary`
- GROUP BY `notary`.`from` HAVING count(*) > '".intval($no_of_assurances)."'");
+ $res = query_init ("SELECT count(*) AS `list` FROM `notary`
+ WHERE `method` = 'Face to Face Meeting'
+ GROUP BY `from` HAVING count(*) > '".intval($no_of_assurances)."'");
return intval(query_get_number_of_rows($res)+1);
}
function get_top_assuree_position ($no_of_assurees)
{
$res = query_init ("SELECT count(*) AS `list` FROM `notary`
- GROUP BY `notary`.`to` HAVING count(*) > '".intval($no_of_assurees)."'");
+ WHERE `method` = 'Face to Face Meeting'
+ GROUP BY `to` HAVING count(*) > '".intval($no_of_assurees)."'");
return intval(query_get_number_of_rows($res)+1);
}
function get_given_assurances ($userid)
{
- $res = query_init ("select * from `notary` where `notary`.`from`='".intval($userid)."' and `notary`.`from` != `to` order by `notary`.`id` asc");
+ $res = query_init ("select * from `notary` where `from`='".intval($userid)."' and `from` != `to` order by `id` asc");
return $res;
}
function get_received_assurances ($userid)
{
- $res = query_init ("select * from `notary` where `notary`.`to`='".intval($userid)."' and `notary`.`from` != `notary`.`to` order by `notary`.`id` asc ");
+ $res = query_init ("select * from `notary` where `to`='".intval($userid)."' and `from` != `to` order by `id` asc ");
return $res;
}
function get_given_assurances_summary ($userid)
{
- $res = query_init ("select count(*) as number,points,awarded,method from notary where `notary`.`from`='".intval($userid)."' group by points,awarded,method");
+ $res = query_init ("select count(*) as number,points,awarded,method from notary where `from`='".intval($userid)."' group by points,awarded,method");
return $res;
}
-
+
function get_received_assurances_summary ($userid)
{
- $res = query_init ("select count(*) as number,points,awarded,method from notary where `notary`.`to`='".intval($userid)."' group by points,awarded,method");
+ $res = query_init ("select count(*) as number,points,awarded,method from notary where `to`='".intval($userid)."' group by points,awarded,method");
return $res;
}
@@ -124,7 +126,7 @@
$awarded = 100;
}
else
- $experience = 0;
+ $experience = 0;
switch ($row['method'])
{
@@ -272,15 +274,6 @@
<?
}
- function output_cats_needed()
- {
-?>
- <tr>
- <td class="DataTD" colspan=4><strong style='color: red'><?=_("You have to pass the CAcert Assurer Challenge (CATS-Test) to be an Assurer")?></strong></td>
- </tr>
-<?
- }
-
// ************* output given assurances ******************
@@ -291,7 +284,7 @@
$res = get_given_assurances(intval($userid));
while($row = mysql_fetch_assoc($res))
{
- $fromuser = get_user (intval($row['to']));
+ $fromuser = get_user (intval($row['to']));
calc_experience ($row,$points,$experience,$sum_experience);
$name = show_user_link ($fromuser['fname']." ".$fromuser['lname'],intval($row['to']));
output_assurances_row (intval($row['id']),$row['date'],$name,intval($row['awarded']),$row['location'],$row['method']==""?"":_(sprintf("%s", $row['method'])),$experience);
@@ -309,7 +302,7 @@
{
$fromuser = get_user (intval($row['from']));
calc_assurances ($row,$points,$experience,$sum_experience,$awarded);
- $name = show_user_link ($fromuser['fname']." ".$fromuser['lname'],intval($row['to']));
+ $name = show_user_link ($fromuser['fname']." ".$fromuser['lname'],intval($row['from']));
output_assurances_row (intval($row['id']),$row['date'],$name,$awarded,$row['location'],$row['method']==""?"":_(sprintf("%s", $row['method'])),$experience);
}
}
@@ -412,7 +405,7 @@
else
{
$sum_points_countable = $sum_points;
- $remark_points = "&nbsp";
+ $remark_points = "&nbsp;";
}
if ($sum_experience > $max_experience)
{
@@ -439,7 +432,7 @@
if ($sum_points_countable < $max_points)
{
if ($sum_experience_countable != 0)
- $remark_experience = $points_on_hold_txt;_("Points on hold due to less assurance points");
+ $remark_experience = _("Points on hold due to less assurance points");
$sum_experience_countable = 0;
if ($sum_experience_other_countable != 0)
$remark_experience_other = _("Points on hold due to less assurance points");
@@ -449,7 +442,15 @@
$issue_points = 0;
$cats_test_passed = get_cats_state ($userid);
if ($cats_test_passed == 0)
+ {
$issue_points_txt = "<strong style='color: red'>"._("You have to pass the CAcert Assurer Challenge (CATS-Test) to be an Assurer")."</strong>";
+ if ($sum_points_countable < $max_points)
+ {
+ $issue_points_txt = "<strong style='color: red'>";
+ $issue_points_txt .= sprintf(_("You need %s assurance points and the passed CATS-Test to be an Assurer"), intval($max_points));
+ $issue_points_txt .= "</strong>";
+ }
+ }
else
{
$experience_total = $sum_experience_countable+$sum_experience_other_countable;
diff --git a/password.dat.sample b/password.dat.sample
index f9bbb55..f9bbb55 100755..100644
--- a/password.dat.sample
+++ b/password.dat.sample
diff --git a/scripts/DumpWeakCerts.pl b/scripts/DumpWeakCerts.pl
index 580390e..580390e 100755..100644
--- a/scripts/DumpWeakCerts.pl
+++ b/scripts/DumpWeakCerts.pl
diff --git a/scripts/assurer.php b/scripts/assurer.php
index c649fbf..d85a2a6 100644
--- a/scripts/assurer.php
+++ b/scripts/assurer.php
@@ -30,7 +30,7 @@
$query = "
select u.email, fname, lname, sum(n.points) from users u, notary n
where n.to=u.id
- and not exists(select 1 from cats_passed cp where cp.user_id=u.id)
+ and not EXISTS(SELECT 1 FROM `cats_passed` AS `tp`, `cats_variant` AS `cv` WHERE `tp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND `tp`.`user_id` = `u`.`id`)
and exists(select 1 from notary n2 where n2.from=u.id and year(n2.`when`)>2007)
and (select count(*) from notary n3 where n3.from=u.id) > 1
group by email, fname, lname
diff --git a/scripts/mail-weak-keys.php b/scripts/mail-weak-keys.php
index 95c0e4f..95c0e4f 100755..100644
--- a/scripts/mail-weak-keys.php
+++ b/scripts/mail-weak-keys.php
diff --git a/scripts/mass-revoke.php b/scripts/mass-revoke.php
index 18c036b..18c036b 100755..100644
--- a/scripts/mass-revoke.php
+++ b/scripts/mass-revoke.php
diff --git a/www/cats/cats_import.php b/www/cats/cats_import.php
index 6d77a75..56dd0cf 100644
--- a/www/cats/cats_import.php
+++ b/www/cats/cats_import.php
@@ -24,6 +24,8 @@
API for CATS to import passed tests into main CAcert database.
*/
+require_once('../../includes/lib/account.php');
+
function sanitize_string($buffer) {
return htmlentities(utf8_decode($buffer), (int)ENQ_QUOTES);
}
@@ -154,8 +156,7 @@ if (!$query) {
}
// Update Assurer-Flag on users table if 100 points. Should the number of points be SUM(points) or SUM(awarded)?
-$query = mysql_query('UPDATE `users` AS `u` SET `assurer` = 1 WHERE `u`.`id` = \''.(int)intval($userID).'\' AND EXISTS(SELECT 1 FROM `cats_passed` AS `tp` WHERE `tp`.`user_id` = `u`.`id`) AND (SELECT SUM(`points`) FROM `notary` AS `n` WHERE `n`.`to` = `u`.`id` AND `expire` < now()) >= 100;'); // Challenge has been passed and non-expired points >= 100
-if (!$query) {
+if (!fix_assurer_flag($userID)) {
echo 'Invalid query'."\r\n";
trigger_error('Invalid query', E_USER_ERROR);
exit();
diff --git a/www/index.php b/www/index.php
index 7330877..a4c50fc 100644
--- a/www/index.php
+++ b/www/index.php
@@ -148,13 +148,16 @@
if($id == 4 && $_SERVER['HTTP_HOST'] == $_SESSION['_config']['securehostname'])
{
- $query = "select * from `emailcerts` where `serial`='$_SERVER[SSL_CLIENT_M_SERIAL]' and `revoked`=0 and disablelogin=0 and
- UNIX_TIMESTAMP(`expire`) - UNIX_TIMESTAMP() > 0";
- $res = mysql_query($query);
- if(mysql_num_rows($res) > 0)
+ include_once("../includes/lib/general.php");
+ $user_id = get_user_id_from_cert($_SERVER['SSL_CLIENT_M_SERIAL'],
+ $_SERVER['SSL_CLIENT_I_DN_CN']);
+
+ if($user_id >= 0)
{
- $row = mysql_fetch_assoc($res);
- $_SESSION['profile'] = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='$row[memid]' and `deleted`=0 and `locked`=0"));
+ $_SESSION['profile'] = mysql_fetch_assoc(mysql_query(
+ "select * from `users` where
+ `id`='$user_id' and `deleted`=0 and `locked`=0"));
+
if($_SESSION['profile']['id'] != 0)
{
$_SESSION['profile']['loggedin'] = 1;