2007-12-03 00:32:47 +03:00
|
|
|
<?php
|
|
|
|
/*
|
2009-06-04 02:44:32 +04:00
|
|
|
* This file is part of Mibew Messenger project.
|
2009-08-04 20:30:39 +04:00
|
|
|
*
|
2011-02-16 03:22:22 +03:00
|
|
|
* Copyright (c) 2005-2011 Mibew Messenger Community
|
2009-08-04 19:03:27 +04:00
|
|
|
* All rights reserved. The contents of this file are subject to the terms of
|
|
|
|
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
|
|
|
* is available at http://www.eclipse.org/legal/epl-v10.html
|
2009-08-04 20:30:39 +04:00
|
|
|
*
|
2009-08-04 17:38:37 +04:00
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
|
|
|
* the provisions of the GPL are applicable instead of those above. If you wish
|
|
|
|
* to allow use of your version of this file only under the terms of the GPL, and
|
|
|
|
* not to allow others to use your version of this file under the terms of the
|
|
|
|
* EPL, indicate your decision by deleting the provisions above and replace them
|
|
|
|
* with the notice and other provisions required by the GPL.
|
2009-08-04 20:30:39 +04:00
|
|
|
*
|
2007-12-03 00:32:47 +03:00
|
|
|
* Contributors:
|
|
|
|
* Evgeny Gryaznov - initial API and implementation
|
|
|
|
*/
|
|
|
|
|
2008-06-05 01:36:54 +04:00
|
|
|
require_once('libs/common.php');
|
|
|
|
require_once('libs/chat.php');
|
2008-10-11 01:40:57 +04:00
|
|
|
require_once('libs/expand.php');
|
2009-08-11 19:06:46 +04:00
|
|
|
require_once('libs/groups.php');
|
2009-08-11 14:09:44 +04:00
|
|
|
require_once('libs/captcha.php');
|
2007-12-03 00:32:47 +03:00
|
|
|
|
|
|
|
$errors = array();
|
|
|
|
$page = array();
|
|
|
|
|
2009-08-11 19:06:46 +04:00
|
|
|
function store_message($name, $email, $info, $message,$groupid,$referrer) {
|
2009-08-08 02:49:11 +04:00
|
|
|
global $state_left, $current_locale, $kind_for_agent, $kind_user;
|
|
|
|
$remoteHost = get_remote_host();
|
|
|
|
$userbrowser = $_SERVER['HTTP_USER_AGENT'];
|
|
|
|
$visitor = visitor_from_request();
|
|
|
|
$link = connect();
|
2009-08-11 19:06:46 +04:00
|
|
|
$thread = create_thread($groupid,$name,$remoteHost,$referrer,$current_locale,$visitor['id'], $userbrowser,$state_left,$link);
|
|
|
|
if( $referrer ) {
|
|
|
|
post_message_($thread['threadid'],$kind_for_agent,getstring2('chat.came.from',array($referrer)),$link);
|
|
|
|
}
|
2009-08-08 02:49:11 +04:00
|
|
|
if($email) {
|
|
|
|
post_message_($thread['threadid'],$kind_for_agent,getstring2('chat.visitor.email',array($email)),$link);
|
|
|
|
}
|
|
|
|
if($info) {
|
|
|
|
post_message_($thread['threadid'],$kind_for_agent,getstring2('chat.visitor.info',array($info)),$link);
|
|
|
|
}
|
|
|
|
post_message_($thread['threadid'],$kind_user,$message,$link,$name);
|
|
|
|
mysql_close($link);
|
|
|
|
}
|
|
|
|
|
2009-08-11 19:06:46 +04:00
|
|
|
$groupid = "";
|
|
|
|
$groupname = "";
|
|
|
|
loadsettings();
|
|
|
|
if($settings['enablegroups'] == '1') {
|
|
|
|
$groupid = verifyparam( "group", "/^\d{1,8}$/", "");
|
|
|
|
if($groupid) {
|
|
|
|
$group = group_by_id($groupid);
|
|
|
|
if(!$group) {
|
|
|
|
$groupid = "";
|
|
|
|
} else {
|
|
|
|
$groupname = get_group_name($group);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-06 01:08:57 +04:00
|
|
|
$email = getparam('email');
|
|
|
|
$visitor_name = getparam('name');
|
2007-12-03 00:32:47 +03:00
|
|
|
$message = getparam('message');
|
2009-02-08 03:28:33 +03:00
|
|
|
$info = getparam('info');
|
2009-08-11 19:06:46 +04:00
|
|
|
$referrer = urldecode(getparam("referrer"));
|
2007-12-03 00:32:47 +03:00
|
|
|
|
2008-05-06 01:08:57 +04:00
|
|
|
if( !$email ) {
|
2007-12-03 00:32:47 +03:00
|
|
|
$errors[] = no_field("form.field.email");
|
2008-05-06 01:08:57 +04:00
|
|
|
} else if( !$visitor_name ) {
|
2007-12-03 00:32:47 +03:00
|
|
|
$errors[] = no_field("form.field.name");
|
|
|
|
} else if( !$message ) {
|
|
|
|
$errors[] = no_field("form.field.message");
|
|
|
|
} else {
|
2008-05-06 01:08:57 +04:00
|
|
|
if( !is_valid_email($email)) {
|
2007-12-03 00:32:47 +03:00
|
|
|
$errors[] = wrong_field("form.field.email");
|
|
|
|
}
|
|
|
|
}
|
2009-07-18 17:54:45 +04:00
|
|
|
|
2009-08-11 14:09:44 +04:00
|
|
|
if($settings["enablecaptcha"] == "1" && can_show_captcha()) {
|
2009-07-18 17:54:45 +04:00
|
|
|
$captcha = getparam('captcha');
|
2011-02-16 03:40:39 +03:00
|
|
|
$original = isset($_SESSION["mibew_captcha"]) ? $_SESSION["mibew_captcha"] : "";
|
2009-07-18 17:54:45 +04:00
|
|
|
if(empty($original) || empty($captcha) || $captcha != $original) {
|
|
|
|
$errors[] = getlocal('errors.captcha');
|
|
|
|
}
|
2011-02-16 03:40:39 +03:00
|
|
|
unset($_SESSION['mibew_captcha']);
|
2009-07-02 18:59:52 +04:00
|
|
|
}
|
2007-12-03 00:32:47 +03:00
|
|
|
|
|
|
|
if( count($errors) > 0 ) {
|
2009-08-11 19:06:46 +04:00
|
|
|
setup_leavemessage($visitor_name,$email,$message,$groupid,$groupname,$info,$referrer,can_show_captcha());
|
2008-11-08 02:24:45 +03:00
|
|
|
setup_logo();
|
2008-10-15 00:21:25 +04:00
|
|
|
expand("styles", getchatstyle(), "leavemessage.tpl");
|
2007-12-03 00:32:47 +03:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2009-03-08 23:53:16 +03:00
|
|
|
$message_locale = $settings['left_messages_locale'];
|
|
|
|
if(!locale_exists($message_locale)) {
|
|
|
|
$message_locale = $home_locale;
|
|
|
|
}
|
|
|
|
|
2009-08-11 19:06:46 +04:00
|
|
|
store_message($visitor_name, $email, $info, $message, $groupid, $referrer);
|
2009-08-08 02:49:11 +04:00
|
|
|
|
2009-03-08 23:53:16 +03:00
|
|
|
$subject = getstring2_("leavemail.subject", array($visitor_name), $message_locale);
|
|
|
|
$body = getstring2_("leavemail.body", array($visitor_name,$email,$message,$info ? "$info\n" : ""), $message_locale);
|
|
|
|
|
2008-09-30 03:10:03 +04:00
|
|
|
$inbox_mail = $settings['email'];
|
2007-12-03 00:32:47 +03:00
|
|
|
|
2008-09-30 03:10:03 +04:00
|
|
|
if($inbox_mail) {
|
|
|
|
webim_mail($inbox_mail, $email, $subject, $body);
|
|
|
|
}
|
2007-12-03 00:32:47 +03:00
|
|
|
|
2008-11-08 02:24:45 +03:00
|
|
|
setup_logo();
|
2008-10-15 00:21:25 +04:00
|
|
|
expand("styles", getchatstyle(), "leavemessagesent.tpl");
|
2007-12-03 00:32:47 +03:00
|
|
|
?>
|