diff options
Diffstat (limited to 'phpBB/includes/acp/acp_bots.php')
| -rw-r--r-- | phpBB/includes/acp/acp_bots.php | 51 | 
1 files changed, 28 insertions, 23 deletions
| diff --git a/phpBB/includes/acp/acp_bots.php b/phpBB/includes/acp/acp_bots.php index d08cabb062..1ea320e674 100644 --- a/phpBB/includes/acp/acp_bots.php +++ b/phpBB/includes/acp/acp_bots.php @@ -1,10 +1,13 @@  <?php  /**  * -* @package acp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -16,16 +19,13 @@ if (!defined('IN_PHPBB'))  	exit;  } -/** -* @package acp -*/  class acp_bots  {  	var $u_action;  	function main($id, $mode)  	{ -		global $config, $db, $user, $auth, $template, $cache; +		global $config, $db, $user, $auth, $template, $cache, $request;  		global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;  		$action = request_var('action', ''); @@ -158,7 +158,7 @@ class acp_bots  					{  						$error[] = $user->lang['ERR_BOT_NO_MATCHES'];  					} -			 +  					if ($bot_row['bot_ip'] && !preg_match('#^[\d\.,:]+$#', $bot_row['bot_ip']))  					{  						if (!$ip_list = gethostbynamel($bot_row['bot_ip'])) @@ -177,7 +177,7 @@ class acp_bots  					{  						$error[] = $user->lang['ERR_BOT_AGENT_MATCHES_UA'];  					} -					 +  					$bot_name = false;  					if ($bot_id)  					{ @@ -202,7 +202,7 @@ class acp_bots  					{  						$error[] = $user->lang['BOT_NAME_TAKEN'];  					} -					 +  					if (!sizeof($error))  					{  						// New bot? Create a new user and group entry @@ -220,7 +220,6 @@ class acp_bots  							{  								trigger_error($user->lang['NO_BOT_GROUP'] . adm_back_link($this->u_action . "&id=$bot_id&action=$action"), E_USER_WARNING);  							} -						  							$user_id = user_add(array(  								'user_type'				=> (int) USER_IGNORE, @@ -234,7 +233,7 @@ class acp_bots  								'user_style'			=> (int) $bot_row['bot_style'],  								'user_allow_massemail'	=> 0,  							)); -	 +  							$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(  								'user_id'		=> (int) $user_id,  								'bot_name'		=> (string) $bot_row['bot_name'], @@ -243,7 +242,7 @@ class acp_bots  								'bot_ip'		=> (string) $bot_row['bot_ip'])  							);  							$db->sql_query($sql); -	 +  							$log = 'ADDED';  						}  						else if ($bot_id) @@ -290,12 +289,12 @@ class acp_bots  							$log = 'UPDATED';  						} -						 +  						$cache->destroy('_bots'); -						 +  						add_log('admin', 'LOG_BOT_' . $log, $bot_row['bot_name']);  						trigger_error($user->lang['BOT_' . $log] . adm_back_link($this->u_action)); -					 +  					}  				}  				else if ($bot_id) @@ -336,11 +335,11 @@ class acp_bots  					'U_ACTION'		=> $this->u_action . "&id=$bot_id&action=$action",  					'U_BACK'		=> $this->u_action,  					'ERROR_MSG'		=> (sizeof($error)) ? implode('<br />', $error) : '', -					 +  					'BOT_NAME'		=> $bot_row['bot_name'],  					'BOT_IP'		=> $bot_row['bot_ip'],  					'BOT_AGENT'		=> $bot_row['bot_agent'], -					 +  					'S_EDIT_BOT'		=> true,  					'S_ACTIVE_OPTIONS'	=> $s_active_options,  					'S_STYLE_OPTIONS'	=> $style_select, @@ -354,6 +353,14 @@ class acp_bots  			break;  		} +		if ($request->is_ajax() && ($action == 'activate' || $action == 'deactivate')) +		{ +			$json_response = new \phpbb\json_response; +			$json_response->send(array( +				'text'	=> $user->lang['BOT_' . (($action == 'activate') ? 'DE' : '') . 'ACTIVATE'], +			)); +		} +  		$s_options = '';  		$_options = array('activate' => 'BOT_ACTIVATE', 'deactivate' => 'BOT_DEACTIVATE', 'delete' => 'DELETE');  		foreach ($_options as $value => $lang) @@ -390,7 +397,7 @@ class acp_bots  		}  		$db->sql_freeresult($result);  	} -	 +  	/**  	* Validate bot name against username table  	*/ @@ -410,9 +417,7 @@ class acp_bots  		$result = $db->sql_query($sql);  		$row = $db->sql_fetchrow($result);  		$db->sql_freeresult($result); -		 +  		return ($row) ? false : true;  	}  } - -?>
\ No newline at end of file | 
