有时会出现PHP错误

时间:2011-10-24 07:01:39

标签: php web-services oop phpbb

我有一个脚本,它使用一些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('silvian.iosub@gmail.com', $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中声明,该文件似乎声明了一个函数两次。奇怪的是,我有时会得到这个错误。我没有设法找到这样的规则。

有没有人有想法?谢谢!!

1 个答案:

答案 0 :(得分:1)

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

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