groupId = $groupid; $thread->userName = $name; $thread->remote = $remoteHost; $thread->referer = $referrer; $thread->locale = $current_locale; $thread->userId = $visitor['id']; $thread->userAgent = $userbrowser; $thread->state = Thread::STATE_LEFT; $thread->save(); if( $referrer ) { $thread->postMessage(Thread::KIND_FOR_AGENT,getstring2('chat.came.from',array($referrer))); } if($email) { $thread->postMessage(Thread::KIND_FOR_AGENT, getstring2('chat.visitor.email',array($email))); } if($info) { $thread->postMessage(Thread::KIND_FOR_AGENT, getstring2('chat.visitor.info',array($info))); } $thread->postMessage(Thread::KIND_USER, $message, $name); } $groupid = ""; $groupname = ""; $group = NULL; if(Settings::get('enablegroups') == '1') { $groupid = verifyparam( "group", "/^\d{1,8}$/", ""); if($groupid) { $group = group_by_id($groupid); if(!$group) { $groupid = ""; } else { $groupname = get_group_name($group); } } } $email = getparam('email'); $visitor_name = getparam('name'); $message = getparam('message'); $info = getparam('info'); $referrer = urldecode(getparam("referrer")); if( !$email ) { $errors[] = no_field("form.field.email"); } else if( !$visitor_name ) { $errors[] = no_field("form.field.name"); } else if( !$message ) { $errors[] = no_field("form.field.message"); } else { if( !is_valid_email($email)) { $errors[] = wrong_field("form.field.email"); } } if(Settings::get("enablecaptcha") == "1" && can_show_captcha()) { $captcha = getparam('captcha'); $original = isset($_SESSION["mibew_captcha"]) ? $_SESSION["mibew_captcha"] : ""; if(empty($original) || empty($captcha) || $captcha != $original) { $errors[] = getlocal('errors.captcha'); } unset($_SESSION['mibew_captcha']); } if( count($errors) > 0 ) { setup_leavemessage($visitor_name,$email,$message,$groupid,$groupname,$info,$referrer,can_show_captcha()); setup_logo($group); expand("styles/dialogs", getchatstyle(), "leavemessage.tpl"); exit; } $message_locale = Settings::get('left_messages_locale'); if(!locale_exists($message_locale)) { $message_locale = $home_locale; } store_message($visitor_name, $email, $info, $message, $groupid, $referrer); $subject = getstring2_("leavemail.subject", array($visitor_name), $message_locale); $body = getstring2_("leavemail.body", array($visitor_name,$email,$message,$info ? "$info\n" : ""), $message_locale); if (isset($group) && !empty($group['vcemail'])) { $inbox_mail = $group['vcemail']; } else { if (! is_null($group['parent'])) { $parentgroup = group_by_id($group['parent']); if ($parentgroup && !empty($parentgroup['vcemail'])) { $inbox_mail = $parentgroup['vcemail']; } } } if (empty($inbox_mail)) { $inbox_mail = Settings::get('email'); } if($inbox_mail) { webim_mail($inbox_mail, $email, $subject, $body); } setup_logo($group); expand("styles/dialogs", getchatstyle(), "leavemessagesent.tpl"); ?>