2007-10-10 19:15:47 +04:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* This file is part of Web Instant Messenger project.
|
|
|
|
*
|
2009-01-14 01:19:12 +03:00
|
|
|
* Copyright (c) 2005-2009 Web Messenger Community
|
2007-10-10 19:15:47 +04:00
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2008-06-05 01:36:54 +04:00
|
|
|
require_once('../libs/common.php');
|
|
|
|
require_once('../libs/operator.php');
|
2009-03-23 00:22:51 +03:00
|
|
|
require_once('../libs/operator_settings.php');
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
$operator = check_login();
|
|
|
|
|
2008-10-06 04:45:25 +04:00
|
|
|
$page = array('opid' => '');
|
2007-10-10 19:15:47 +04:00
|
|
|
$errors = array();
|
2008-10-06 04:45:25 +04:00
|
|
|
$opId = '';
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
if( isset($_POST['login']) && isset($_POST['password']) ) {
|
2008-10-06 04:45:25 +04:00
|
|
|
$opId = verifyparam( "opid", "/^(\d{1,9})?$/", "");
|
2007-10-10 19:15:47 +04:00
|
|
|
$login = getparam('login');
|
|
|
|
$password = getparam('password');
|
|
|
|
$passwordConfirm = getparam('passwordConfirm');
|
2008-05-06 01:08:57 +04:00
|
|
|
$localname = getparam('name');
|
2007-10-10 19:15:47 +04:00
|
|
|
$commonname = getparam('commonname');
|
|
|
|
|
2008-05-06 01:08:57 +04:00
|
|
|
if( !$localname )
|
2007-10-10 19:15:47 +04:00
|
|
|
$errors[] = no_field("form.field.agent_name");
|
|
|
|
|
|
|
|
if( !$commonname )
|
|
|
|
$errors[] = no_field("form.field.agent_commonname");
|
|
|
|
|
2008-05-07 01:30:15 +04:00
|
|
|
if( !$login ) {
|
2007-10-10 19:15:47 +04:00
|
|
|
$errors[] = no_field("form.field.login");
|
2008-05-07 01:30:15 +04:00
|
|
|
} else if( !preg_match( "/^[\w_]+$/",$login) ) {
|
|
|
|
$errors[] = getlocal("page_agent.error.wrong_login");
|
|
|
|
}
|
2007-10-10 19:15:47 +04:00
|
|
|
|
2008-10-06 04:45:25 +04:00
|
|
|
if( !$opId && !$password )
|
2007-10-10 19:15:47 +04:00
|
|
|
$errors[] = no_field("form.field.password");
|
|
|
|
|
|
|
|
if( $password != $passwordConfirm )
|
2008-05-06 15:14:48 +04:00
|
|
|
$errors[] = getlocal("my_settings.error.password_match");
|
2007-10-10 19:15:47 +04:00
|
|
|
|
2008-05-06 01:08:57 +04:00
|
|
|
$existing_operator = operator_by_login($login);
|
2008-10-06 04:45:25 +04:00
|
|
|
if( (!$opId && $existing_operator) ||
|
|
|
|
( $opId && $existing_operator && $opId != $existing_operator['operatorid']) )
|
2008-05-06 15:14:48 +04:00
|
|
|
$errors[] = getlocal("page_agent.error.duplicate_login");
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
if( count($errors) == 0 ) {
|
2008-10-06 04:45:25 +04:00
|
|
|
if (!$opId) {
|
2008-12-09 02:47:40 +03:00
|
|
|
$newop = create_operator($login,$password,$localname,$commonname,"");
|
|
|
|
header("Location: $webimroot/operator/avatar.php?op=".$newop['operatorid']);
|
|
|
|
exit;
|
2007-10-10 19:15:47 +04:00
|
|
|
} else {
|
2008-10-06 04:45:25 +04:00
|
|
|
update_operator($opId,$login,$password,$localname,$commonname);
|
2008-12-09 02:47:40 +03:00
|
|
|
header("Location: $webimroot/operator/operators.php");
|
|
|
|
exit;
|
2007-10-10 19:15:47 +04:00
|
|
|
}
|
|
|
|
} else {
|
2008-05-06 15:14:48 +04:00
|
|
|
$page['formlogin'] = topage($login);
|
|
|
|
$page['formname'] = topage($localname);
|
|
|
|
$page['formcommonname'] = topage($commonname);
|
2008-10-06 04:45:25 +04:00
|
|
|
$page['opid'] = topage($opId);
|
2007-10-10 19:15:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if( isset($_GET['op']) ) {
|
2008-10-06 04:45:25 +04:00
|
|
|
$opId = verifyparam( 'op', "/^\d{1,9}$/");
|
|
|
|
$op = operator_by_id($opId);
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
if( !$op ) {
|
2008-05-06 15:14:48 +04:00
|
|
|
$errors[] = getlocal("no_such_operator");
|
2008-10-06 04:45:25 +04:00
|
|
|
$page['opid'] = topage($opId);
|
2007-10-10 19:15:47 +04:00
|
|
|
} else {
|
2008-05-06 15:14:48 +04:00
|
|
|
$page['formlogin'] = topage($op['vclogin']);
|
|
|
|
$page['formname'] = topage($op['vclocalename']);
|
|
|
|
$page['formcommonname'] = topage($op['vccommonname']);
|
2008-10-06 04:45:25 +04:00
|
|
|
$page['opid'] = topage($op['operatorid']);
|
2007-10-10 19:15:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 04:20:04 +03:00
|
|
|
prepare_menu($operator);
|
2009-03-23 00:22:51 +03:00
|
|
|
setup_operator_settings_tabs($opId,0);
|
2007-10-10 19:15:47 +04:00
|
|
|
start_html_output();
|
|
|
|
require('../view/agent.php');
|
2007-05-10 21:31:10 +04:00
|
|
|
?>
|