1<?php
2
3verifyCsrfGetToken();
4
5$access = accessLevel('listbounces');
6
7$listid = empty($_GET['id']) ? 0 : sprintf('%d', $_GET['id']);
8$download = isset($_GET['type']) && $_GET['type'] == 'dl';
9$isowner_and = '';
10$isowner_where = '';
11$status = '';
12
13switch ($access) {
14    case 'owner':
15        if ($listid) {
16            $req = Sql_Query(sprintf('select id from '.$tables['list'].' where owner = %d and id = %d',
17                $_SESSION['logindetails']['id'], $listid));
18            if (!Sql_Affected_Rows()) {
19                Fatal_Error(s('You do not have enough privileges to view this page'));
20
21                return;
22            }
23        }
24        $isowner_and = sprintf(' list.owner = %d and ', $_SESSION['logindetails']['id']);
25        $isowner_where = sprintf(' where list.owner = %d ', $_SESSION['logindetails']['id']);
26        break;
27    case 'all':
28    case 'view':
29        break;
30    case 'none':
31    default:
32        if ($listid) {
33            Fatal_Error(s('You do not have enough privileges to view this page'));
34            $isowner_and = sprintf(' list.owner = 0 and ');
35            $isowner_where = sprintf(' where list.owner = 0 ');
36
37            return;
38        }
39        break;
40}
41if (!empty($_SESSION['LoadDelay'])) {
42    sleep($_SESSION['LoadDelay']);
43}
44$req = Sql_Query(sprintf('select listuser.listid,count(distinct userid) as numusers from %s list, %s listuser,
45    %s umb, %s lm where %s list.id = listuser.listid and listuser.listid = lm.listid and listuser.userid = umb.user group by listuser.listid
46    order by listuser.listid limit 250', $GLOBALS['tables']['list'], $GLOBALS['tables']['listuser'],
47    $GLOBALS['tables']['user_message_bounce'], $GLOBALS['tables']['listmessage'], $isowner_and));
48$ls = new WebblerListing(s('Choose a list'));
49$ls->setElementHeading('List name');
50$some = 0;
51while ($row = Sql_Fetch_Array($req)) {
52    $some = 1;
53    $element = '<!--'.s('list').' '.$row['listid'].'-->'.listName($row['listid']);
54    $ls->addElement($element, PageUrl2('listbounces&amp;id='.$row['listid']));
55    //  $ls->addColumn($element,$GLOBALS['I18N']->get('name'),listName($row['listid']),PageUrl2('editlist&amp;id='.$row['listid']));
56    $ls->addColumn($element, s('Total bounces'), number_format($row['numusers']));
57}
58if ($some) {
59    $status = $ls->display();
60} else {
61    $status = '<p>'.s('None found').'</p>';
62}
63