Completed
Pull Request — master (#27)
by Michael
01:42
created

admin/bmh_callback_database.php (3 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/* This is a sample callback function for PHPMailer-BMH (Bounce Mail Handler).
4
 * This callback function will echo the results of the BMH processing.
5
 */
6
7
/* Callback (action) function
8
 * @param int     $msgnum        the message number returned by Bounce Mail Handler
9
 * @param string  $bounce_type   the bounce type: 'antispam','autoreply','concurrent','content_reject','command_reject','internal_error','defer','delayed'        => array('remove'=>0,'bounce_type'=>'temporary'),'dns_loop','dns_unknown','full','inactive','latin_only','other','oversize','outofoffice','unknown','unrecognized','user_reject','warning'
10
 * @param string  $email         the target email address
11
 * @param string  $subject       the subject, ignore now
12
 * @param string  $xheader       the XBounceHeader from the mail
13
 * @param boolean $remove        remove status, 1 means removed, 0 means not removed
14
 * @param string  $rule_no       Bounce Mail Handler detect rule no.
15
 * @param string  $rule_cat      Bounce Mail Handler detect rule category.
16
 * @param int     $totalFetched  total number of messages in the mailbox
17
 * @return boolean
18
 */
19
20
use XoopsModules\Xnewsletter;
21
22
require_once __DIR__ . '/admin_header.php';
23
24
/**
25
 * @param      $msgnum
26
 * @param      $bounce_type
27
 * @param      $email
28
 * @param      $subject
29
 * @param      $xheader
30
 * @param      $remove
31
 * @param bool $rule_no
32
 * @param bool $rule_cat
33
 * @param int  $totalFetched
34
 *
35
 * @return bool
36
 */
37
function callbackAction(
38
    $msgnum,
0 ignored issues
show
The parameter $msgnum is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
    $bounce_type,
40
    $email,
41
    $subject,
42
    $xheader,
0 ignored issues
show
The parameter $xheader is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
    $remove,
44
    $rule_no = false,
45
    $rule_cat = false,
46
    $totalFetched = 0)
0 ignored issues
show
The parameter $totalFetched is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
{
48
    global $xoopsUser;
49
    $helper = Xnewsletter\Helper::getInstance();
50
51
    if ('0000' != $rule_no) {
52
        $bmhObj = $helper->getHandler('Bmh')->create();
53
        $bmhObj->setVar('bmh_rule_no', $rule_no);
54
        $bmhObj->setVar('bmh_rule_cat', $rule_cat);
55
        $bmhObj->setVar('bmh_bouncetype', $bounce_type);
56
        //$verif_bmh_remove = ($remove === true || $remove == '1') ? '1' : '0';
57
        $bmhObj->setVar('bmh_remove', $remove);
58
        $bmhObj->setVar('bmh_email', $email);
59
        $bmhObj->setVar('bmh_subject', $subject);
60
        $bmhObj->setVar('bmh_measure', '0');
61
        $bmhObj->setVar('bmh_submitter', $xoopsUser->uid());
62
        $bmhObj->setVar('bmh_created', time());
63
64
        if (!$helper->getHandler('Bmh')->insert($bmhObj)) {
65
            echo $bmhObj->getHtmlErrors();
66
67
            return false;
68
        }
69
        //echo $msgnum . ': '  . $rule_no . ' | '  . $rule_cat . ' | '  . $bounce_type . ' | '  . $remove . ' | ' . $email . ' | '  . $subject . ' | '  . $xheader . "<br>\n";
70
    }
71
72
    return true;
73
}
74