bug 1221: added `deleted` = 0
authorBenny Baumann <BenBE@geshi.org>
Tue, 19 Nov 2013 22:02:00 +0000 (23:02 +0100)
committerBenny Baumann <BenBE@geshi.org>
Tue, 19 Nov 2013 22:24:09 +0000 (23:24 +0100)
13 files changed:
includes/account.php
includes/lib/account.php
includes/lib/general.php
includes/loggedin.php
pages/account/52.php
pages/account/55.php
pages/wot/1.php
pages/wot/9.php
stamp/common.php
www/api/ccsr.php
www/api/cemails.php
www/index.php
www/stats.php

index 2addca1..1c9db57 100644 (file)
 
        if($oldid == 13 && $process != "")
        {
-               $ddquery = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['profile']['id']."' group by `to`";
+               $ddquery = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['profile']['id']."' and `deleted` = 0 group by `to`";
                $ddres = mysql_query($ddquery);
                $ddrow = mysql_fetch_assoc($ddres);
                $_SESSION['profile']['points'] = $ddrow['total'];
                $_SESSION['profile'] = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".$_SESSION['profile']['id']."'"));
                $_SESSION['profile']['loggedin'] = 1;
 
-               $ddquery = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['profile']['id']."' group by `to`";
+               $ddquery = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['profile']['id']."' and `deleted` = 0 group by `to`";
                $ddres = mysql_query($ddquery);
                $ddrow = mysql_fetch_assoc($ddres);
                $_SESSION['profile']['points'] = $ddrow['total'];
                        $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'"));
+                       $tmp = mysql_fetch_assoc(mysql_query("select sum(`points`) as `points` from `notary` where `to`='$memid' and `deleted` = 0"));
 
                        $points = 0;
                        if($tverify['URL'] != "" && $tverify['photoid'] != "")
index e311668..46bbcee 100644 (file)
@@ -51,7 +51,7 @@ function fix_assurer_flag($userID = NULL)
                                SELECT SUM(`points`) FROM `notary` AS `n`
                                WHERE `n`.`to` = `u`.`id`
                                        AND (`n`.`expire` > now()
-                                       OR `n`.`expire` IS NULL)
+                                       OR `n`.`expire` IS NULL) and `n`.`deleted` = 0
                        ) >= 100';
        
        $query = mysql_query($sql);
@@ -85,7 +85,7 @@ function fix_assurer_flag($userID = NULL)
                                                AND (
                                                        `n`.`expire` > now()
                                                        OR `n`.`expire` IS NULL
-                                               )
+                                               ) and `n`.`deleted` = 0
                                ) < 100
                        )';
        
index 85b132d..cb73c51 100644 (file)
@@ -146,7 +146,7 @@ function runCommand($command, $input = "", &$output = null, &$errors = true) {
                        $Result |= 5;
                }
                
-               $query = mysql_query('SELECT SUM(`points`) AS `points` FROM `notary` AS `n` WHERE `n`.`to` = \''.(int)intval($userID).'\' AND `n`.`expire` < now()');
+               $query = mysql_query('SELECT SUM(`points`) AS `points` FROM `notary` AS `n` WHERE `n`.`to` = \''.(int)intval($userID).'\' AND `n`.`expire` < now() and `deleted` = 0');
                $row = mysql_fetch_assoc($query);
                if ($row['points'] < 100) {
                        $Result |= 3;
index 4f9b8e8..de61ee1 100644 (file)
 
        if($_SERVER['HTTP_HOST'] == $_SESSION['_config']['securehostname'] && $_SESSION['profile']['id'] > 0 && $_SESSION['profile']['loggedin'] > 0)
        {
-               $query = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['profile']['id']."' group by `to`";
+               $query = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['profile']['id']."' and `deleted` = 0 group by `to`";
                $res = mysql_query($query);
                $row = mysql_fetch_assoc($res);
                $_SESSION['profile']['points'] = $row['total'];
index 77a3bae..73a8bae 100644 (file)
@@ -35,7 +35,7 @@
                        exit;
                }
 
-               $query = "select sum(`points`) as `points` from `notary` where `to`='$memid'";
+               $query = "select sum(`points`) as `points` from `notary` where `to`='$memid' and `deleted` = 0";
                $notary = mysql_fetch_assoc(mysql_query($query));
                $query = "select * from `users` where `id`='$memid'";
                $user = mysql_fetch_assoc(mysql_query($query));
index ec401a0..402b7a8 100644 (file)
@@ -87,7 +87,7 @@
     <tr><td colspan="3" class="DataTD"><a href="account.php?id=43&amp;userid=<?=$user_id ?>">back</a></td></tr>\r
 <?    } else {\r
         $query = 'SELECT `u`.id, `u`.`assurer`, SUM(`points`) FROM `users` AS `u`, `notary` AS `n` '.\r
-                 '  WHERE `u`.`id` = \''.(int)intval($_SESSION['profile']['id']).'\' AND `n`.`to` = `u`.`id` AND `expire` < now() '.\r
+                 '  WHERE `u`.`id` = \''.(int)intval($_SESSION['profile']['id']).'\' AND `n`.`to` = `u`.`id` AND `expire` < now() and  and `n`.`deleted` = 0'.
                  '  GROUP BY `u`.id, `u`.`assurer`';\r
         $res = mysql_query($query);\r
         if (!$res) {\r
index a45b5df..9e5d0f5 100644 (file)
@@ -91,7 +91,7 @@
        {
        $query = "select *, `users`.`id` as `id` from `users`,`notary` where `listme`='1' and
                        `ccid`='".$ccid."' and `regid`='".$regid."' and
-                       `locid`='".$locid."' and `users`.`id`=`notary`.`to`
+                       `locid`='".$locid."' and `users`.`id`=`notary`.`to` and `notary`.`deleted`=0
                        group by `notary`.`to` HAVING SUM(`points`) >= 100 order by `points` desc";
        $list = mysql_query($query);
        if(mysql_num_rows($list) > 0)
index bfa7a98..0d9b22d 100644 (file)
@@ -28,7 +28,7 @@
                $user = mysql_fetch_array($res);
                $userlang = $user['language'];
                $points = mysql_num_rows(mysql_query("select sum(`points`) as `total` from `notary`
-                               where `to`='".$user['id']."' group by `to` HAVING SUM(`points`) > 0"));
+                               where `to`='".$user['id']."' and `deleted`=0 group by `to` HAVING SUM(`points`) > 0"));
                if($points <= 0)
                {
                        echo _("Sorry, I was unable to locate that user.");
index ff814dd..d0a71f4 100644 (file)
                        if($org == 0)
                        {
                                $query = "SELECT *, sum(`points`) AS `total` FROM `users`, `notary` WHERE `users`.`id` = '$cert[memid]' AND
-                                               `notary`.`to` = `users`.`id` and `notary`.`when` <= '$cert[issued]' GROUP BY `notary`.`to`";
+                                               `notary`.`to` = `users`.`id` and `notary`.`when` <= '$cert[issued]' and `notary`.`deleted`=0 GROUP BY `notary`.`to`";
                                $user = mysql_fetch_assoc(mysql_query($query));
                        } else {
                                $query = "select * from `orginfo` where `id`='$cert[orgid]'";
index 7efdf8d..a0f36e2 100644 (file)
@@ -42,7 +42,7 @@ require_once '../../includes/lib/check_weak_key.php';
        }
        if(count($emails) <= 0)
                die("404,Wasn't able to match any emails sent against your account");
-       $query = "select sum(`points`) as `points` from `notary` where `to`='$memid' group by `to`";
+       $query = "select sum(`points`) as `points` from `notary` where `to`='$memid' and `notary`.`deleted`=0 group by `to`";
        $row = mysql_fetch_assoc(mysql_query($query));
        $points = $row['points'];
 
index 0d067ea..260ca4f 100644 (file)
@@ -25,7 +25,7 @@
        echo "200,Authentication Ok\n";
        $user = mysql_fetch_assoc($res);
        $memid = $user['id'];
-       $query = "select sum(`points`) as `points` from `notary` where `to`='$memid' group by `to`";
+       $query = "select sum(`points`) as `points` from `notary` where `to`='$memid' and `notary`.`deleted`=0 group by `to`";
        $row = mysql_fetch_assoc(mysql_query($query));
        $points = $row['points'];
        echo "CS=".intval($user['codesign'])."\n";
index c7cc03e..d680f38 100644 (file)
@@ -319,7 +319,7 @@ require_once('../includes/lib/l10n.php');
                                L10n::set_translation($_SESSION['profile']['language']);
                                L10n::init_gettext();
                        }
-                       $query = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['profile']['id']."' group by `to`";
+                       $query = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['profile']['id']."' and `notary`.`deleted`=0 group by `to`";
                        $res = mysql_query($query);
                        $row = mysql_fetch_assoc($res);
                        $_SESSION['profile']['points'] = $row['total'];
index 93f693e..b119c07 100644 (file)
                $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts` where `revoked`=0 and `expire`>NOW()"));\r
                $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts` where `revoked`=0 and `expire`>NOW()"));\r
                $stats['valid_certificates'] = number_format($certs);\r
-               $stats['assurances_made'] = number_format(tc(mysql_query("select count(`id`) as `count` from `notary`")));\r
-               $stats['users_1to49'] = number_format(mysql_num_rows(mysql_query("select `to` from `notary` group by `to` having sum(`points`) > 0 and sum(`points`) < 50")));\r
-               $stats['users_50to99'] = number_format(mysql_num_rows(mysql_query("select `to` from `notary` group by `to` having sum(`points`) >= 50 and sum(`points`) < 100")));\r
+               $stats['assurances_made'] = number_format(tc(mysql_query("select count(`id`) as `count` from `notary` where `notary`.`deleted`=0")));
+               $stats['users_1to49'] = number_format(mysql_num_rows(mysql_query("select `to` from `notary`  where `notary`.`deleted`=0 group by `to` having sum(`points`) > 0 and sum(`points`) < 50")));
+               $stats['users_50to99'] = number_format(mysql_num_rows(mysql_query("select `to` from `notary`  where `notary`.`deleted`=0 group by `to` having sum(`points`) >= 50 and sum(`points`) < 100")));
                $stats['assurer_candidates'] = number_format(tc(mysql_query("select count(*) as `count` from `users` where ".\r
                                     "not exists(select 1 from `cats_passed` as `cp`, `cats_variant` as `cv` where `cp`.`user_id`=`users`.`id` and `cp`.`variant_id`=`cv`.`id` and `cv`.`type_id`=1) and ".\r
-                                    "(select sum(`points`) from `notary` where `to`=`users`.`id`) >= 100")));\r
+                                    "(select sum(`points`) from `notary` where `to`=`users`.`id` and `notary`.`deleted`=0) >= 100 ")));
                $stats['aussurers_with_test'] = number_format(tc(mysql_query("select count(*) as `count` from `users` where ".\r
                                     "exists(select 1 from `cats_passed` as `cp`, `cats_variant` as `cv` where `cp`.`user_id`=`users`.`id` and `cp`.`variant_id`=`cv`.`id` and `cv`.`type_id`=1) and ".\r
-                                    "(select sum(`points`) from `notary` where `to`=`users`.`id`) >= 100")));\r
-               $stats['points_issued'] = number_format(tc(mysql_query("select sum(`points`) as `count` from `notary`")));\r
+                                    "(select sum(`points`) from `notary` where `to`=`users`.`id` and where `notary`.`deleted`=0) >= 100")));
+               $stats['points_issued'] = number_format(tc(mysql_query("select sum(`points`) as `count` from `notary` where `notary`.`deleted`=0")));
 \r
                $totalusers=0;\r
                $totassurers=0;\r
                        $tmp_arr['date'] = date("Y-m", mktime(0,0,0,date("m") - $i,1,date("Y")));\r
                        $date = date("Y-m", mktime(0,0,0,date("m") - $i,1,date("Y")));\r
                        $totalusers += $users = tc(mysql_query("select count(`id`) as `count` from `users` where `created` like '$date%' and `verified`=1"));\r
-                       $totassurers += $assurers = mysql_num_rows(mysql_query("select `to` from `notary` where `when` like '$date%' and `method`!='Administrative Increase' group by `to` having sum(`points`) >= 100"));\r
+                       $totassurers += $assurers = mysql_num_rows(mysql_query("select `to` from `notary` where `when` like '$date%' and `method`!='Administrative Increase' and `notary`.`deleted`=0 group by `to` having sum(`points`) >= 100"));
                        $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `created` like '$date%'"));\r
                        $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `created` like '$date%'"));\r
                        $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `issued` like '$date%'"));\r
                        $tmp_arr = array();\r
                        $tmp_arr['date'] = $i;\r
                        $totalusers += $users = tc(mysql_query("select count(`id`) as `count` from `users` where `created` like '$i%' and `verified`=1"));\r
-                       $totassurers += $assurers = mysql_num_rows(mysql_query("select `to` from `notary` where `when` like '$i%' and `method`!='Administrative Increase' group by `to` having sum(`points`) >= 100"));\r
+                       $totassurers += $assurers = mysql_num_rows(mysql_query("select `to` from `notary` where `when` like '$i%' and `method`!='Administrative Increase' and `notary`.`deleted`=0 group by `to` having sum(`points`) >= 100"));
                        $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `created` like '$i%'"));\r
                        $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `created` like '$i%'"));\r
                        $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `issued` like '$i%'"));\r