PHP有时会出现错误

发布于 2024-12-11 12:58:08 字数 3517 浏览 0 评论 0原文

我有一个脚本,它使用一些 PhpBB 函数向所有论坛成员发送 emial。我制作了一个 php 页面,一个包含主题和消息的表单,并添加了可以执行此操作的 phpBB 函数。 问题是,有时我会收到此错误:

Fatal error: Cannot redeclare smtpmail() (previously declared in /home/**/domains/**.ca/public_html/zonemembres/includes/functions_messenger.php:896) in /home/**/domains/**.ca/public_html/zonemembres/includes/functions_messenger.php on line 1103

在这里您可以看到代码:

 if (!function_exists('send')) {
                        include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
                    }
                for ($i = 0, $size = sizeof($contact_users); $i < $size; $i++) {

                    $messenger = new messenger(true);

                    // Email headers
                    $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
                    $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
                    $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
                    $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
                    if (!empty($contact_data['contact_reason'])) {
                        $messenger->template('contact', $contact_users[$i]['user_lang']);
                    } else {
                        $messenger->template('contact_no_reason_custom', $contact_users[$i]['user_lang']);
                    }
                    $messenger->to($contact_users[$i]['user_email'], $contact_users[$i]['username']);
                    //$messenger->to('[email protected]', $contact_users[$i]['username']);
                    $messenger->im($contact_users[$i]['user_jabber'], $contact_users[$i]['username']);
                    $messenger->from($contact_data['email']);
                    $messenger->replyto($contact_data['email']);
                    $link = 'http://www.adgmrcq.ca/zonemembres/viewtopic.php?f=' . $config_contact["contact_bot_forum"] . '&t=' . $last_topic_id[0]["topic_id"];
                    $messenger->assign_vars(array(
                        'ADM_USERNAME' => htmlspecialchars_decode($user->data['username']),
                        'ADM_EMAIL' => htmlspecialchars_decode($user->data['user_email']),
                        'SITENAME' => htmlspecialchars_decode($config['sitename']),
                        'USER_IP' => $user->ip,
                        'USERNAME' => $contact_users[$i]['username'],
                        'USER_EMAIL' => htmlspecialchars_decode($contact_data['email']),
                        'DATE' => $date,
                        'REASON' => htmlspecialchars_decode($contact_data['contact_reason']),
                        'SUBJECT' => htmlspecialchars_decode($subject),
                        'MESSAGE' => $message,
                        'LINK' => $link,
                    ));
                    $contact_users[$i]['user_notify_type'] = NOTIFY_EMAIL;
                    $messenger->send($contact_users[$i]['user_notify_type']);
                    $messenger->save_queue();
                    unset($messenger);
                }

这是我感兴趣的部分。 $messenger 变量在 functions_messenger.php< 中声明/code>,该文件似乎声明了两次函数。奇怪的是我有时会收到此错误。我没能找到它如何出现的规则。

有人有一些想法吗?谢谢你!!

I have a script that uses some PhpBB functions to send an emial to all forum members. I made a php page, a form with subject and message and added the phpBB functions that would do this.
The problem is that JUST SOMETIMES I get this error:

Fatal error: Cannot redeclare smtpmail() (previously declared in /home/**/domains/**.ca/public_html/zonemembres/includes/functions_messenger.php:896) in /home/**/domains/**.ca/public_html/zonemembres/includes/functions_messenger.php on line 1103

here you can see the code:

 if (!function_exists('send')) {
                        include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
                    }
                for ($i = 0, $size = sizeof($contact_users); $i < $size; $i++) {

                    $messenger = new messenger(true);

                    // Email headers
                    $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
                    $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
                    $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
                    $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
                    if (!empty($contact_data['contact_reason'])) {
                        $messenger->template('contact', $contact_users[$i]['user_lang']);
                    } else {
                        $messenger->template('contact_no_reason_custom', $contact_users[$i]['user_lang']);
                    }
                    $messenger->to($contact_users[$i]['user_email'], $contact_users[$i]['username']);
                    //$messenger->to('[email protected]', $contact_users[$i]['username']);
                    $messenger->im($contact_users[$i]['user_jabber'], $contact_users[$i]['username']);
                    $messenger->from($contact_data['email']);
                    $messenger->replyto($contact_data['email']);
                    $link = 'http://www.adgmrcq.ca/zonemembres/viewtopic.php?f=' . $config_contact["contact_bot_forum"] . '&t=' . $last_topic_id[0]["topic_id"];
                    $messenger->assign_vars(array(
                        'ADM_USERNAME' => htmlspecialchars_decode($user->data['username']),
                        'ADM_EMAIL' => htmlspecialchars_decode($user->data['user_email']),
                        'SITENAME' => htmlspecialchars_decode($config['sitename']),
                        'USER_IP' => $user->ip,
                        'USERNAME' => $contact_users[$i]['username'],
                        'USER_EMAIL' => htmlspecialchars_decode($contact_data['email']),
                        'DATE' => $date,
                        'REASON' => htmlspecialchars_decode($contact_data['contact_reason']),
                        'SUBJECT' => htmlspecialchars_decode($subject),
                        'MESSAGE' => $message,
                        'LINK' => $link,
                    ));
                    $contact_users[$i]['user_notify_type'] = NOTIFY_EMAIL;
                    $messenger->send($contact_users[$i]['user_notify_type']);
                    $messenger->save_queue();
                    unset($messenger);
                }

This is the part that I'm interested in. The $messenger variable is declared in functions_messenger.php, the file that seems to declare a function twice. The strange thing is that I get this error just sometimes. I didn't manage to find a rule of how this could appear.

Does anyone have some ideas? Thank you!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两人的回忆 2024-12-18 12:58:08

转到文件 /home//domains/.ca/public_html/zonemembres/includes/functions_messenger.php,找到函数 smtpmail() 并将其包装到 if 语句中,如下所示:

if(!function_exists('smtpmail'))
{
    function smtpmail()
    {
        // Function decleration here
    }
}

Go to file /home//domains/.ca/public_html/zonemembres/includes/functions_messenger.php, find the function smtpmail() and wrap it into an if statement like that:

if(!function_exists('smtpmail'))
{
    function smtpmail()
    {
        // Function decleration here
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文