https://bugs.cacert.org/view.php?id=827
authorMarkus Warg <markus@server12.mawa>
Tue, 19 Oct 2010 14:41:25 +0000 (16:41 +0200)
committerMichael Tänzer <neo@nhng.de>
Tue, 30 Nov 2010 21:36:26 +0000 (22:36 +0100)
changes submitted by Dirk Astrath on 10.10.2010 by email
(cherry picked from commit 066d7cbdcebe67345c61a958c5aa258eb5b14c18)

pages/wot/10.php
pages/wot/15.php [new file with mode: 0644]

index ccf8011..fefc84c 100644 (file)
@@ -16,6 +16,8 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */ ?>
 <?
+       $thawte = false;
+
 ?>
 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
   <tr>
   </tr>
   <tr>
 <?
-       $query = "SELECT COUNT(1) as `assurances` FROM `notary` WHERE `from`=".intval($_SESSION['profile']['id'])." AND `from` != `to`";
-       
+       $query = "SELECT `users`. *, count(*) AS `list` FROM `users`, `notary`
+                       WHERE `users`.`id` = `notary`.`from` AND `notary`.`from` != `notary`.`to`
+                       AND `from`='".intval($_SESSION['profile']['id'])."' GROUP BY `notary`.`from`";
        $res = mysql_query($query);
        $row = mysql_fetch_assoc($res);
-       $rc = intval($row['assurances']);
-
-       $query = "SELECT COUNT(1) FROM `notary` GROUP BY `from` HAVING COUNT(1) > {$rc}";
+       $rc = intval($row['list']);
+/*
+       $query = "SELECT `users`. *, count(*) AS `list` FROM `users`, `notary`
+                       WHERE `users`.`id` = `notary`.`from` AND `notary`.`from` != `notary`.`to`
+                       GROUP BY `notary`.`from` HAVING count(*) > '$rc' ORDER BY `notary`.`when` DESC";
+*/
+       $query = "SELECT count(*) AS `list` FROM `users` 
+                       inner join `notary` on `users`.`id` = `notary`.`from` 
+                       GROUP BY `notary`.`from` HAVING count(*) > '$rc'";
 
        $rank = mysql_num_rows(mysql_query($query)) + 1;
 ?>
     <td class="DataTD"><b><?=_("Method")?></b></td>
   </tr>
 <?
-        $points = 0;
-        $query = "select sum(points) as apoints from `notary` where `from`='".intval($_SESSION['profile']['id'])."' and `from`=`to` ";
-        $res = mysql_query($query);
-       $row = mysql_fetch_assoc($res);
-
-       $maxpoints=intval($_SESSION['profile']['points'])-$row['apoints'];
-
-       $points = 0;
-       $query = "SELECT n.`id`, n.`date`, n.`awarded`, n.`from` as `from_id`, u.`fname` AS `from_fname`, u.`lname` AS `from_lname`, n.`location`, n.`method` FROM `notary` n LEFT JOIN `users` u ON n.`from`=u.`id` WHERE n.`to`=".intval($_SESSION['profile']['id'])." ORDER BY n.`when` DESC, n.`id` DESC";
+       $query = "select * from `notary` where `to`='".intval($_SESSION['profile']['id'])."'";
        $res = mysql_query($query);
        while($row = mysql_fetch_assoc($res))
        {
-               $awarded = $row['awarded'];
-               if ($points+$awarded > $maxpoints)
-                       $awarded = $maxpoints-$points;
-               $points = $points + $awarded;
+               $fromuser = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".intval($row['from'])."'"));
 ?>
   <tr>
     <td class="DataTD"><?=$row['id']?></td>
     <td class="DataTD"><?=$row['date']?></td>
-    <td class="DataTD"><a href="wot.php?id=9&amp;userid=<?=intval($row['from_id'])?>"><?=$row['from_fname']." ".$row['from_lname']?></td>
-    <td class="DataTD"><?=$awarded?></td>
+    <td class="DataTD"><a href="wot.php?id=9&amp;userid=<?=intval($row['from'])?>"><?=$fromuser['fname']." ".$fromuser['lname']?></td>
+    <td class="DataTD"><?=$row['points']?></td>
     <td class="DataTD"><?=$row['location']?></td>
     <td class="DataTD"><?=_(sprintf("%s", $row['method']))?></td>
   </tr>
-<? } ?>
-  <tr>
+<?
+  $thawte = ($row['method'] == "Thawte Points Transfer") or $thawte;
+} ?>
     <td class="DataTD" colspan="3"><b><?=_("Total Points")?>:</b></td>
     <td class="DataTD"><?=intval($_SESSION['profile']['points'])?></td>
     <td class="DataTD" colspan="2">&nbsp;</td>
   </tr>
 </table>
+<?
+if ($thawte)
+        echo "<br><strong style='color: red'>Your Thawte-Points will be revoked as of November 16, 2010. Please check new calculation <a href='/wot.php?id=15'></strong>here</a>";
+?>
 <br>
 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
   <tr>
   </tr>
 <?
        $points = 0;
-       $query = "SELECT n.`id`, n.`date`, n.`awarded`, n.`location`, n.`method`, n.`to` AS `to_id`, u.`fname` AS `to_fname`, u.`lname` AS `to_lname` FROM `notary` n LEFT JOIN `users` u ON n.`to`=u.`id` WHERE n.`from`=".intval($_SESSION['profile']['id'])." AND n.`to`!=".intval($_SESSION['profile']['id'])." ORDER BY n.`when` DESC, n.`id` DESC";
+       $query = "select * from `notary` where `from`='".intval($_SESSION['profile']['id'])."' and `to`!='".intval($_SESSION['profile']['id'])."'";
        $res = mysql_query($query);
        while($row = mysql_fetch_assoc($res))
        {
-               $points += $row['awarded'];
-               $name = trim($row['to_fname']." ".$row['to_lname']);
+               $fromuser = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".intval($row['to'])."'"));
+               $points += $row['points'];
+               $name = trim($fromuser['fname']." ".$fromuser['lname']);
                if($name == "")
-                       $name = '<i>'._("Deleted before Verification").'</i>';
+                       $name = _("Deleted before Verification");
                else
-                       $name = "<a href='wot.php?id=9&amp;userid=".intval($row['to_id'])."'>$name</a>";
+                       $name = "<a href='wot.php?id=9&amp;userid=".intval($row['to'])."'>$name</a>";
 ?>
   <tr>
     <td class="DataTD"><?=intval($row['id'])?></td>
     <td class="DataTD"><?=$row['date']?></td>
     <td class="DataTD"><?=$name?></td>
-    <td class="DataTD"><?=intval($row['awarded'])?></td>
+    <td class="DataTD"><?=intval($row['points'])?></td>
     <td class="DataTD"><?=$row['location']?></td>
     <td class="DataTD"><?=$row['method']==""?"":_(sprintf("%s", $row['method']))?></td>
   </tr>
diff --git a/pages/wot/15.php b/pages/wot/15.php
new file mode 100644 (file)
index 0000000..fa1ca50
--- /dev/null
@@ -0,0 +1,185 @@
+<? /*
+    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
+*/ ?>
+<?
+?>
+<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
+  <tr>
+    <td colspan="5" class="title"><?=_("Assurer Ranking")?></td>
+  </tr>
+  <tr>
+<?
+       $query = "SELECT `users`. *, count(*) AS `list` FROM `users`, `notary`
+                       WHERE `users`.`id` = `notary`.`from` AND `notary`.`from` != `notary`.`to`
+                       AND `from`='".intval($_SESSION['profile']['id'])."' GROUP BY `notary`.`from`";
+       $res = mysql_query($query);
+       $row = mysql_fetch_assoc($res);
+       $rc = intval($row['list']);
+/*
+       $query = "SELECT `users`. *, count(*) AS `list` FROM `users`, `notary`
+                       WHERE `users`.`id` = `notary`.`from` AND `notary`.`from` != `notary`.`to`
+                       GROUP BY `notary`.`from` HAVING count(*) > '$rc' ORDER BY `notary`.`when` DESC";
+*/
+       $query = "SELECT count(*) AS `list` FROM `users` 
+                       inner join `notary` on `users`.`id` = `notary`.`from` 
+                       GROUP BY `notary`.`from` HAVING count(*) > '$rc'";
+
+       $rank = mysql_num_rows(mysql_query($query)) + 1;
+?>
+    <td class="DataTD"><?=sprintf(_("You have made %s assurances which ranks you as the #%s top assurer."), intval($rc), intval($rank))?></td>
+  </tr>
+</table>
+<br>
+<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
+  <tr>
+    <td colspan="6" class="title"><?=_("Your Experience Points")?></td>
+  </tr>
+  <tr>
+    <td class="DataTD"><b><?=_("ID")?></b></td>
+    <td class="DataTD"><b><?=_("Date")?></b></td>
+    <td class="DataTD"><b><?=_("Who")?></b></td>
+    <td class="DataTD"><b><?=_("Points")?></b></td>
+    <td class="DataTD"><b><?=_("Location")?></b></td>
+    <td class="DataTD"><b><?=_("Method")?></b></td>
+  </tr>
+<?
+       $maxpoints=50;
+       $points = 0;
+
+       $query = "select * from `notary` where `to`='".intval($_SESSION['profile']['id'])."' and `from` = `to` order by `id` desc ";
+       $res = mysql_query($query);
+       while($row = mysql_fetch_assoc($res))
+       {
+               $awarded = $row['awarded'];
+               if ($points+$awarded > $maxpoints)
+                       $awarded = $maxpoints-$points;
+               $points = $points + $awarded;
+               $fromuser = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".intval($row['from'])."'"));
+?>
+  <tr>
+    <td class="DataTD"><?=$row['id']?></td>
+    <td class="DataTD"><?=$row['date']?></td>
+    <td class="DataTD"><a href="wot.php?id=9&amp;userid=<?=intval($row['from'])?>"><?=$fromuser['fname']." ".$fromuser['lname']?></td>
+    <td class="DataTD"><?=$awarded?></td>
+    <td class="DataTD"><?=$row['location']?></td>
+    <td class="DataTD"><?=_(sprintf("%s", $row['method']))?></td>
+  </tr>
+<? } ?>
+  <tr>
+    <td class="DataTD" colspan="3"><b><?=_("Total Points")?>:</b></td>
+    <td class="DataTD"><?=$points?></td>
+    <td class="DataTD" colspan="2">&nbsp;</td>
+  </tr>
+</table>
+<br>
+<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
+  <tr>
+    <td colspan="6" class="title"><?=_("Your Assurance Points")?></td>
+  </tr>
+  <tr>
+    <td class="DataTD"><b><?=_("ID")?></b></td>
+    <td class="DataTD"><b><?=_("Date")?></b></td>
+    <td class="DataTD"><b><?=_("Who")?></b></td>
+    <td class="DataTD"><b><?=_("Points")?></b></td>
+    <td class="DataTD"><b><?=_("Location")?></b></td>
+    <td class="DataTD"><b><?=_("Method")?></b></td>
+  </tr>
+<?
+        $points = 0;
+       $maxpoints = 100;
+//        $query = "select sum(points) as apoints from `notary` where `from`='".intval($_SESSION['profile']['id'])."' and `from`=`to` ";
+//        $res = mysql_query($query);
+//     $row = mysql_fetch_assoc($res);
+//     $maxpoints=intval($_SESSION['profile']['points'])-$row['apoints'];
+
+       $points = 0;
+       $query = "select * from `notary` where `to`='".intval($_SESSION['profile']['id'])."' and `from` != `to` order by `id` desc ";
+       $res = mysql_query($query);
+       while($row = mysql_fetch_assoc($res))
+       {
+               $awarded = $row['awarded'];
+               if ($row['method'] == "Thawte Points Transfer")
+                       {
+                       $points=0;
+                       $awarded="<strong style='color: red'>Revoked</strong>";
+                       } else
+                       {
+                       if ($points+$awarded > $maxpoints)
+                               $awarded = $maxpoints-$points;
+                       $points = $points + $awarded;
+                       }
+               $fromuser = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".intval($row['from'])."'"));
+?>
+  <tr>
+    <td class="DataTD"><?=$row['id']?></td>
+    <td class="DataTD"><?=$row['date']?></td>
+    <td class="DataTD"><a href="wot.php?id=9&amp;userid=<?=intval($row['from'])?>"><?=$fromuser['fname']." ".$fromuser['lname']?></td>
+    <td class="DataTD"><?=$awarded?></td>
+    <td class="DataTD"><?=$row['location']?></td>
+    <td class="DataTD"><?=_(sprintf("%s", $row['method']))?></td>
+  </tr>
+<? } ?>
+  <tr>
+    <td class="DataTD" colspan="3"><b><?=_("Total Points")?>:</b></td>
+    <td class="DataTD"><?=$points?></td>
+    <td class="DataTD" colspan="2">&nbsp;</td>
+  </tr>
+</table>
+<br>
+<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
+  <tr>
+    <td colspan="6" class="title"><?=_("Assurance Points You Issued")?></td>
+  </tr>
+  <tr>
+    <td class="DataTD"><b><?=_("ID")?></b></td>
+    <td class="DataTD"><b><?=_("Date")?></b></td>
+    <td class="DataTD"><b><?=_("Who")?></b></td>
+    <td class="DataTD"><b><?=_("Points")?></b></td>
+    <td class="DataTD"><b><?=_("Location")?></b></td>
+    <td class="DataTD"><b><?=_("Method")?></b></td>
+  </tr>
+<?
+       $points = 0;
+       $query = "select * from `notary` where `from`='".intval($_SESSION['profile']['id'])."' and `to`!='".intval($_SESSION['profile']['id'])."' order by `id` desc";
+       $res = mysql_query($query);
+       while($row = mysql_fetch_assoc($res))
+       {
+               $fromuser = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".intval($row['to'])."'"));
+               $points += $row['awarded'];
+               $name = trim($fromuser['fname']." ".$fromuser['lname']);
+               if($name == "")
+                       $name = _("Deleted before Verification");
+               else
+                       $name = "<a href='wot.php?id=9&amp;userid=".intval($row['to'])."'>$name</a>";
+?>
+  <tr>
+    <td class="DataTD"><?=intval($row['id'])?></td>
+    <td class="DataTD"><?=$row['date']?></td>
+    <td class="DataTD"><?=$name?></td>
+    <td class="DataTD"><?=intval($row['awarded'])?></td>
+    <td class="DataTD"><?=$row['location']?></td>
+    <td class="DataTD"><?=$row['method']==""?"":_(sprintf("%s", $row['method']))?></td>
+  </tr>
+<? } ?>
+  <tr>
+    <td class="DataTD" colspan="3"><b><?=_("Total Points Issued")?>:</b></td>
+    <td class="DataTD"><?=$points?></td>
+    <td class="DataTD" colspan="2">&nbsp;</td>
+  </tr>
+</table>
+<p>[ <a href='javascript:history.go(-1)'><?=_("Go Back")?></a> ]</p>
+