mirror of
				https://github.com/Mibew/java.git
				synced 2025-10-31 18:41:09 +03:00 
			
		
		
		
	git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@620 c66351dc-e62f-0410-b875-e3a5c0b9693f
		
			
				
	
	
		
			104 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			104 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /*
 | |
|  * This file is part of Mibew Messenger project.
 | |
|  * 
 | |
|  * Copyright (c) 2005-2009 Mibew Messenger Community
 | |
|  * 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
 | |
|  * 
 | |
|  * 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.
 | |
|  * 
 | |
|  * Contributors:
 | |
|  *    Evgeny Gryaznov - initial API and implementation
 | |
|  */
 | |
| 
 | |
| require_once('libs/common.php');
 | |
| require_once('libs/chat.php');
 | |
| require_once('libs/expand.php');
 | |
| require_once('libs/captcha.php');
 | |
| 
 | |
| $errors = array();
 | |
| $page = array();
 | |
| 
 | |
| function store_message($name, $email, $info, $message) {
 | |
| 	global $state_left, $current_locale, $kind_for_agent, $kind_user;
 | |
| 	$groupid = 0;
 | |
| 	$remoteHost = get_remote_host();
 | |
| 	$userbrowser = $_SERVER['HTTP_USER_AGENT'];
 | |
| 	$visitor = visitor_from_request();
 | |
| 	$link = connect();
 | |
| 	$thread = create_thread($groupid,$name,$remoteHost,"",$current_locale,$visitor['id'], $userbrowser,$state_left,$link);
 | |
| 	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);
 | |
| }
 | |
| 
 | |
| $email = getparam('email');
 | |
| $visitor_name = getparam('name');
 | |
| $message = getparam('message');
 | |
| $info = getparam('info');
 | |
| 
 | |
| 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");
 | |
| 	}
 | |
| }
 | |
| 
 | |
| loadsettings();
 | |
| if($settings["enablecaptcha"] == "1" && can_show_captcha()) {
 | |
| 	$captcha = getparam('captcha');
 | |
| 	$original = $_SESSION['captcha'];
 | |
| 	if(empty($original) || empty($captcha) || $captcha != $original) {
 | |
| 	  $errors[] = getlocal('errors.captcha');
 | |
| 	}
 | |
| 	unset($_SESSION['captcha']);
 | |
| }
 | |
| 
 | |
| if( count($errors) > 0 ) {
 | |
| 	$page['formname'] = topage($visitor_name);
 | |
| 	$page['formemail'] = $email;
 | |
| 	$page['formmessage'] = topage($message);
 | |
| 	$page['showcaptcha'] = $settings["enablecaptcha"] == "1" && can_show_captcha() ? "1" : "";
 | |
| 	$page['info'] = topage($info);
 | |
| 	setup_logo();
 | |
| 	expand("styles", getchatstyle(), "leavemessage.tpl");
 | |
| 	exit;
 | |
| }
 | |
| 
 | |
| $message_locale = $settings['left_messages_locale'];
 | |
| if(!locale_exists($message_locale)) {
 | |
| 	$message_locale = $home_locale;
 | |
| }
 | |
| 
 | |
| store_message($visitor_name, $email, $info, $message);
 | |
| 
 | |
| $subject = getstring2_("leavemail.subject", array($visitor_name), $message_locale);
 | |
| $body = getstring2_("leavemail.body", array($visitor_name,$email,$message,$info ? "$info\n" : ""), $message_locale);
 | |
| 
 | |
| $inbox_mail = $settings['email'];
 | |
| 
 | |
| if($inbox_mail) {
 | |
| 	webim_mail($inbox_mail, $email, $subject, $body);
 | |
| }
 | |
| 
 | |
| setup_logo();
 | |
| expand("styles", getchatstyle(), "leavemessagesent.tpl");
 | |
| ?>
 |