1<?php
2/**
3 *
4 *
5 */
6
7
8verifyCsrfGetToken();
9
10$access = accessLevel('msgbounces');
11
12if (isset($_GET['id'])) {
13    $id = sprintf('%d', $_GET['id']);
14} else {
15    $id = 0;
16}
17if (isset($_GET['start'])) {
18    $start = sprintf('%d', $_GET['start']);
19} else {
20    $start = 0;
21}
22
23switch ($access) {
24    case 'owner':
25        $subselect = ' and owner = '.$_SESSION['logindetails']['id'];
26        if ($id) {
27            $allow = Sql_Fetch_Row_query(sprintf('select owner from %s where id = %d %s', $GLOBALS['tables']['message'],
28                $id, $subselect));
29            if ($allow[0] != $_SESSION['logindetails']['id']) {
30                echo $GLOBALS['I18N']->get('You do not have access to this page');
31
32                return;
33            }
34        }
35
36        break;
37    case 'all':
38        $subselect = '';
39        break;
40    case 'none':
41    default:
42        $subselect = ' where id = 0';
43        echo $GLOBALS['I18N']->get('You do not have access to this page');
44
45        return;
46        break;
47}
48
49$status = '';
50$req = Sql_Query(sprintf('select msg.id as messageid, msg.subject, count(msgbounce.bounce) as totalbounces from %s msg,%s msgbounce
51    where msg.id = msgbounce.message %s
52    group by msg.id order by messageid', $GLOBALS['tables']['message'],
53    $GLOBALS['tables']['user_message_bounce'], $subselect));
54if (!Sql_Affected_Rows()) {
55    $status .= '<p class="information">'.s('There are currently no data to view').'</p>';
56}
57
58$ls = new WebblerListing(s('Choose a campaign'));
59$ls->setElementHeading('Campaign name');
60$some = 0;
61while ($row = Sql_Fetch_Array($req)) {
62
63    $messagedata = loadMessageData($row['messageid']);
64    if (empty($download)) {
65        if ($messagedata['subject'] != $messagedata['campaigntitle']) {
66            $element = '<!--'.$row['messageid'].'-->'.stripslashes($messagedata['campaigntitle']).'<br/><strong>'.shortenTextDisplay($messagedata['subject'],
67                    30).'</strong>';
68        } else {
69            $element = '<!--'.$row['messageid'].'-->'.shortenTextDisplay($messagedata['subject'], 30);
70        }
71    } else {
72        $element = $messagedata['subject'];
73    }
74    $some = 1;
75    $ls->addElement($element, PageUrl2('msgbounces&amp;id='.$row['messageid']));
76    $ls->addColumn($element, s('Total bounces'), number_format($row['totalbounces']));
77}
78if ($some) {
79    $status = $ls->display();
80} else {
81    $status = '<p>'.s('None found').'</p>';
82}
83