english/components/com_aicontactsafe/models/message.php
// function to ban and IP and notify the administrator
function to ban and IP and notify the administrator
function to ban and IP and notify the administrator
function ban_ip( $ips_list = '' ) {
		$ips_to_ban = explode(';',$ips_list);
		$ips_banned = explode(';',$this->_config_values['ban_ips']);
		$ips_banned = array_merge($ips_banned, $ips_to_ban);
		$ips_banned = array_unique($ips_banned);
		asort($ips_banned);
		$ban_ips = implode(';',$ips_banned);
		if (substr($ban_ips,0,1) == ';') {
			$ban_ips = substr($ban_ips,1);
		}
		$db = & JFactory::getDBO();
		$query = 'update `#__aicontactsafe_config` set config_value = \'' . $ban_ips . '\' where config_key = \'ban_ips\'';
		$db->setQuery( $query );
		$isOK = $db->query();
		if ($isOK) {
			$from = $this->_app->getCfg('mailfrom');
			$fromname = $this->_app->getCfg('fromname');
			$email_recipient = $this->_app->getCfg('mailfrom');
			$subject = JText::_('COM_AICONTACTSAFE_IP_AUTOMATICALLY_BLOCKED');
			$body = JText::_('COM_AICONTACTSAFE_IP_AUTOMATICALLY_BLOCKED') . '<br />' . $ips_list . '<br />';
			$mode = true;
			$isOK = JUtility::sendMail($from, $fromname, $email_recipient, $subject, $body, $mode);
		} else {
			$this->_app->_session->set( 'isOK:' . $this->_sTask, false );
			JError::raiseError( 500, $db->getErrorMsg() );
			return false;
		}
		return true;
	}
function ban_ip ( $ ips_list = '' ) { $ ips_to_ban = explode ( ';' , $ ips_list ) ; $ ips_banned = explode ( ';' , $ this -> _config_values [ 'ban_ips' ] ) ; $ ips_banned = array_merge ( $ ips_banned , $ ips_to_ban ) ; $ ips_banned = array_unique ( $ ips_banned ) ; asort ( $ ips_banned ) ; $ ban_ips = implode ( ';' , $ ips_banned ) ; if ( substr ( $ ban_ips , 0 , 1 ) == ';' ) { $ ban_ips = substr ( $ ban_ips , 1 ) ; } $ db = & JFactory :: getDBO ( ) ; $ query = 'update `#__aicontactsafe_config` set config_value = \'' . $ ban_ips . '\' where config_key = \'ban_ips\'' ; $ db -> setQuery ( $ query ) ; $ isOK = $ db -> query ( ) ; if ( $ isOK ) { $ from = $ this -> _app -> getCfg ( 'mailfrom' ) ; $ fromname = $ this -> _app -> getCfg ( 'fromname' ) ; $ email_recipient = $ this -> _app -> getCfg ( 'mailfrom' ) ; $ subject = JText :: _ ( 'COM_AICONTACTSAFE_IP_AUTOMATICALLY_BLOCKED' ) ; $ body = JText :: _ ( 'COM_AICONTACTSAFE_IP_AUTOMATICALLY_BLOCKED' ) . '<br />' . $ ips_list . '<br />' ; $ mode = true ; $ isOK = JUtility :: sendMail ( $ from , $ fromname , $ email_recipient , $ subject , $ body , $ mode ) ; } else { $ this -> _app -> _session -> set ( 'isOK:' . $ this -> _sTask , false ) ; JError :: raiseError ( 500 , $ db -> getErrorMsg ( ) ) ; return false ; } return true ; }
function to ban and IP and notify the administrator
function to ban and IP and notify the administrator
// initialize different variables // send a notification to the administrator