/** * 添加/编辑客服信息的提交 */ function action_insert_update() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; $user_id = intval($_POST['user_id']); /* 取得客服id */ $cus_id = intval($_POST['cus_id']); $customer = array('supp_id' => -1, 'user_id' => $_POST['user_id'], 'of_username' => $_POST['of_username'], 'cus_name' => $_POST['cus_name'], 'cus_password' => $_POST['cus_password'], 'cus_type' => $_POST['cus_type'], 'cus_enable' => $_POST['cus_enable'], 'cus_desc' => $_POST['cus_desc']); // 判断密码是否为空 if (empty($customer['of_username'])) { sys_msg($_LANG['error_of_username_empty']); } // 判断客服名称是否为空 if (empty($customer['cus_name'])) { sys_msg($_LANG['error_cus_name_empty']); } // 检查聊天系统用户名是否已经绑定了其他管理员账户 if (check_of_username_binding($customer['of_username'], $customer['user_id'])) { sys_msg($_LANG['error_of_username_binding']); } else { // 用户不存在则需要判断密码是否为空 if (!check_of_username_exist($customer['of_username'])) { // 判断密码是否为空 if (empty($customer['cus_password'])) { sys_msg($_LANG['error_password_empty']); } } // 创建活更新聊天系统用户 $create_success = create_of_user($customer['of_username'], $customer['cus_password'], $customer['cus_name'], null, 10, -1); if (!$create_success) { sys_msg($_LANG['error_create_of_user']); } } if (empty($_POST['cus_id'])) { // 检查管理员账户是否存在 if (check_user_id_exist($user_id)) { sys_msg($_LANG['error_user_id_exist']); } $customer['add_time'] = gmtime(); /* insert */ $db->autoExecute($ecs->table('chat_customer'), $customer, 'INSERT'); /* log */ admin_log(addslashes($customer['of_username']), 'add', 'chat_customer'); /* 提示信息 */ $links = array(array('href' => 'customer.php?act=add', 'text' => $_LANG['continue_add']), array('href' => 'customer.php?act=list', 'text' => $_LANG['back_list'])); sys_msg($_LANG['add_success'], 0, $links); } else { // 检查管理员账户是否存在 if (check_user_id_exist($user_id, $cus_id)) { sys_msg($_LANG['error_user_id_exist']); } /* update */ $db->autoExecute($ecs->table('chat_customer'), $customer, 'UPDATE', "cus_id = '{$cus_id}'"); /* log */ admin_log(addslashes($customer['of_username']) . '[' . $cus_id . ']', 'edit', 'chat_customer'); /* 提示信息 */ $links = array(array('href' => 'customer.php?act=list&' . list_link_postfix(), 'text' => $_LANG['back_list'])); sys_msg($_LANG['edit_success'], 0, $links); } /* 显示客服列表页面 */ assign_query_info(); $smarty->display('customer_info.htm'); }
function action_authfail() { $user_id = $_SESSION['user_id']; $sql = "select user_name, password, email from " . $GLOBALS['ecs']->table('users') . " where user_id = '{$user_id}'"; $row = $db->getRow($sql); $success = create_of_user($user_id, $row['password'], $row['user_name'], $row['email'], 10, -1); if ($success) { $result = array('error' => 1, 'message' => '可能由于网络原因,发生错误!请点击 <a href="chat.php?act=chat"><strong>重试</strong></a> ,重新连接...', 'content' => ''); } else { $result = array('error' => 1, 'message' => '由于网络原因,发生错误!请点击 <a href="chat.php?act=chat"><strong>重试</strong></a> ,重新连接...', 'content' => ''); } $result = json_encode($result); exit($result); }