mirror of
				https://github.com/Mibew/design.git
				synced 2025-11-04 04:15:14 +03:00 
			
		
		
		
	git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@159 c66351dc-e62f-0410-b875-e3a5c0b9693f
		
			
				
	
	
		
			94 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			94 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/*
 | 
						|
 * This file is part of Web Instant Messenger project.
 | 
						|
 *
 | 
						|
 * Copyright (c) 2005-2008 Web Messenger Community
 | 
						|
 * All rights reserved. This program and the accompanying materials
 | 
						|
 * are made available under 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
 | 
						|
 *
 | 
						|
 * Contributors:
 | 
						|
 *    Evgeny Gryaznov - initial API and implementation
 | 
						|
 */
 | 
						|
 | 
						|
require_once('../libs/common.php');
 | 
						|
require_once('../libs/operator.php');
 | 
						|
 | 
						|
$operator = check_login();
 | 
						|
 | 
						|
$page = array('opid' => '');
 | 
						|
$errors = array();
 | 
						|
$opId = '';
 | 
						|
 | 
						|
if( isset($_POST['login']) && isset($_POST['password']) ) {
 | 
						|
	$opId = verifyparam( "opid", "/^(\d{1,9})?$/", "");
 | 
						|
	$login = getparam('login');
 | 
						|
	$password = getparam('password');
 | 
						|
	$passwordConfirm = getparam('passwordConfirm');
 | 
						|
	$localname = getparam('name');
 | 
						|
	$commonname = getparam('commonname');
 | 
						|
 | 
						|
	if( !$localname )
 | 
						|
		$errors[] = no_field("form.field.agent_name");
 | 
						|
 | 
						|
	if( !$commonname )
 | 
						|
		$errors[] = no_field("form.field.agent_commonname");
 | 
						|
 | 
						|
	if( !$login ) {
 | 
						|
		$errors[] = no_field("form.field.login");
 | 
						|
	} else if( !preg_match( "/^[\w_]+$/",$login) ) {
 | 
						|
		$errors[] = getlocal("page_agent.error.wrong_login");
 | 
						|
	}
 | 
						|
 | 
						|
	if( !$opId && !$password )
 | 
						|
		$errors[] = no_field("form.field.password");
 | 
						|
 | 
						|
	if( $password != $passwordConfirm )
 | 
						|
		$errors[] = getlocal("my_settings.error.password_match");
 | 
						|
 | 
						|
	$existing_operator = operator_by_login($login);
 | 
						|
	if( (!$opId && $existing_operator) ||
 | 
						|
		( $opId && $existing_operator && $opId != $existing_operator['operatorid']) )
 | 
						|
		$errors[] = getlocal("page_agent.error.duplicate_login");
 | 
						|
 | 
						|
	if( count($errors) == 0 ) {
 | 
						|
		if (!$opId) {
 | 
						|
			create_operator($login,$password,$localname,$commonname,"");
 | 
						|
		} else {
 | 
						|
			update_operator($opId,$login,$password,$localname,$commonname);
 | 
						|
		}
 | 
						|
		header("Location: $webimroot/operator/operators.php");
 | 
						|
		exit;
 | 
						|
	} else {
 | 
						|
		$page['formlogin'] = topage($login);
 | 
						|
		$page['formname'] = topage($localname);
 | 
						|
		$page['formcommonname'] = topage($commonname);
 | 
						|
		$page['opid'] = topage($opId);
 | 
						|
	}
 | 
						|
 | 
						|
} else if( isset($_GET['op']) ) {
 | 
						|
	$opId = verifyparam( 'op', "/^\d{1,9}$/");
 | 
						|
	$op = operator_by_id($opId);
 | 
						|
 | 
						|
	if( !$op ) {
 | 
						|
		$errors[] = getlocal("no_such_operator");
 | 
						|
		$page['opid'] = topage($opId);
 | 
						|
	} else {
 | 
						|
		$page['formlogin'] = topage($op['vclogin']);
 | 
						|
		$page['formname'] = topage($op['vclocalename']);
 | 
						|
		$page['formcommonname'] = topage($op['vccommonname']);
 | 
						|
		$page['opid'] = topage($op['operatorid']);
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
$page['operator'] = topage(get_operator_name($operator));
 | 
						|
 | 
						|
$page['tabs'] = $opId ? array(
 | 
						|
	getlocal("page_agent.tab.main") => "",
 | 
						|
	getlocal("page_agent.tab.avatar") => "$webimroot/operator/avatar.php?op=$opId"
 | 
						|
) : array();
 | 
						|
 | 
						|
start_html_output();
 | 
						|
require('../view/agent.php');
 | 
						|
?>
 |