Ejemplo n.º 1
0
/**
* Sends a reply made from reply form
*/
function cm_send_reply()
{
    global $xoopsSecurity, $xoopsModuleConfig, $xoopsConfig;
    $id = rmc_server_var($_POST, 'id', 0);
    $page = rmc_server_var($_POST, 'page', 1);
    if ($id <= 0) {
        redirectMsg('index.php?page=' . $page, __('You must specify a message ID', 'contact'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('index.php?page=' . $page, __('Session token expired!', 'contact'), 1);
        die;
    }
    $msg = new CTMessage($id);
    if ($msg->isNew()) {
        redirectMsg('index.php?page=' . $page, __('Sorry, specified message does not exists!', 'contact'), 1);
        die;
    }
    $subject = rmc_server_var($_POST, 'subject', '');
    $message = rmc_server_var($_POST, 'message', 1);
    if ($subject == '' || $message == '') {
        redirectMsg('index.php?action=reply&id=' . $id . '&page=' . $page, __('Please fill al required fields!', 'contact'), 1);
        die;
    }
    $xoopsMailer =& getMailer();
    $xoopsMailer->useMail();
    $xoopsMailer->setBody($message . '\\n--------------\\n' . __('Message sent with ContactMe!', 'contact') . '\\nFrom ' . $xoopsModuleConfig['url']);
    $xoopsMailer->setToEmails($msg->getVar('email'));
    $xoopsMailer->setFromEmail($xoopsConfig['from']);
    $xoopsMailer->setFromName($xoopsConfig['fromname']);
    $xoopsMailer->setSubject($subject);
    if (!$xoopsMailer->send(true)) {
        redirectMsg('index.php?action=reply&id=' . $id . '&page=' . $page, __('Message could not be delivered. Please try again.', 'contact') . '<br />' . $xoopsMailer->getErrors(), 1);
        die;
    }
    redirectMsg('index.php?page=' . $page, __('Message sent successfully!', 'contact'), 0);
}
Ejemplo n.º 2
0
function send_message()
{
    global $xoopsModule, $xoopsModuleConfig, $xoopsUser;
    $name = rmc_server_var($_POST, 'name', '');
    $email = rmc_server_var($_POST, 'email', '');
    $company = rmc_server_var($_POST, 'company', '');
    $phone = rmc_server_var($_POST, 'phone', '');
    $subject = rmc_server_var($_POST, 'subject', '');
    $message = rmc_server_var($_POST, 'message', '');
    if ($name == '' || $email == '' || !checkEmail($email) || $subject == '' || $message == '') {
        redirect_header($xoopsModuleConfig['url'], 1, __('Please fill all required fileds before to send this message!', 'contact'));
        die;
    }
    // Recaptcha check
    if (!RMEvents::get()->run_event('rmcommon.captcha.check', true)) {
        redirect_header($xoopsModuleConfig['url'], 1, __('Please check the security words and write it correctly!', 'contact'));
        die;
    }
    $xoopsMailer =& getMailer();
    $xoopsMailer->useMail();
    $xoopsMailer->setBody($message . "\n--------------\n" . __('Message sent with ContactMe!', 'contact') . "\n" . $xoopsModuleConfig['url']);
    $xoopsMailer->setToEmails($xoopsModuleConfig['mail']);
    $xoopsMailer->setFromEmail($email);
    $xoopsMailer->setFromName($name);
    $xoopsMailer->setSubject($subject);
    if (!$xoopsMailer->send(true)) {
        redirect_header($xoopsModuleConfig['url'], 1, __('Message could not be delivered. Please try again.', 'contact'));
        die;
    }
    // Save message on database for further use
    $msg = new CTMessage();
    $msg->setVar('subject', $subject);
    $msg->setVar('ip', $_SERVER['REMOTE_ADDR']);
    $msg->setVar('email', $email);
    $msg->setVar('name', $name);
    $msg->setVar('org', $company);
    $msg->setVar('body', $message);
    $msg->setVar('phone', $phone);
    $msg->setVar('register', $xoopsUser ? 1 : 0);
    if ($xoopsUser) {
        $msg->setVar('xuid', $xoopsUser->uid());
    }
    $msg->setVar('date', time());
    $msg->save();
    redirect_header(XOOPS_URL, 1, __('Your message has been sent successfully!', 'contact'));
}