<commit_before><?php
/**
 * Created by PhpStorm.
 * User: dvienne
 * Date: 22/06/2017
 * Time: 10:25
 */

namespace Dominiquevienne\Honeypot;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;


class Honeypot {

  private $_minFormCompletionTime = 10;
  private $_maxFailureAttempts    = 3;
  private $_maxAttempts           = 10;
  private $_checks                = [
    'timeCheck',
    'honeypotCheck',
    'tokenCheck',
    'failureCheck',
    'quantityCheck',
  ];
  private $_availableChecks       = [
    'timeCheck',
    'honeypotCheck',
    'tokenCheck',
    'failureCheck',
    'quantityCheck',
  ];
  private $_logger;
  private $_logPath               = 'logs/honeypot.logs';



  public function __construct($config = [])
  {
    if(empty($_SESSION)) {
      session_start();
    }

    if(!empty($config['minFormCompletionTime']) AND is_int($config['minFormCompletionTime'])) {
      $this->setMinFormCompletionTime($config['minFormCompletionTime']);
    }

    if(!empty($config['maxFailureAttempts']) AND is_int($config['maxFailureAttempts'])) {
      $this->setMaxFailureAttempts($config['maxFailureAttempts']);
    }

    if(!empty($config['maxAttempts']) AND is_int($config['maxAttempts'])) {
      $this->setMaxAttempts($config['maxAttempts']);
    }

    if(!empty($config['checks'])) {
      $this->setChecks($config['checks']);
    }

    $this->_logger  = new Logger('honeypotLogger');
    $this->_logger->pushHandler(new StreamHandler($this->getLogPath()));
  }


  /**
   * Getter for minFormCompletionTime<commit_msg>Allow to set a custom log-path for the Honeypot class using the config array<commit_after><?php
/**
 * Created by PhpStorm.
 * User: dvienne
 * Date: 22/06/2017
 * Time: 10:25
 */

namespace Dominiquevienne\Honeypot;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;


class Honeypot {

  private $_minFormCompletionTime = 10;
  private $_maxFailureAttempts    = 3;
  private $_maxAttempts           = 10;
  private $_checks                = [
    'timeCheck',
    'honeypotCheck',
    'tokenCheck',
    'failureCheck',
    'quantityCheck',
  ];
  private $_availableChecks       = [
    'timeCheck',
    'honeypotCheck',
    'tokenCheck',
    'failureCheck',
    'quantityCheck',
  ];
  private $_logger;
  private $_logPath               = 'logs/honeypot.logs';



  public function __construct($config = [])
  {
    if(empty($_SESSION)) {
      session_start();
    }

    if(!empty($config['minFormCompletionTime']) AND is_int($config['minFormCompletionTime'])) {
      $this->setMinFormCompletionTime($config['minFormCompletionTime']);
    }

    if(!empty($config['maxFailureAttempts']) AND is_int($config['maxFailureAttempts'])) {
      $this->setMaxFailureAttempts($config['maxFailureAttempts']);
    }

    if(!empty($config['maxAttempts']) AND is_int($config['maxAttempts'])) {
      $this->setMaxAttempts($config['maxAttempts']);
    }

    if(!empty($config['checks'])) {
      $this->setChecks($config['checks']);
    }

    if(!empty($config['logPath'])) {
      $this->setLogPath($config['logPath']);
    }

    $this->_logger  = new Logger('honeypotLogger');
    $this->_logger->pushHandler(new StreamHandler($this->getLogPath()));
  }


  /**
   * Getter for minFormCompletionTime
{'fraction_non_alphanumeric': 0.1585740626920713, 'fraction_numerical': 0.010448678549477565, 'mean_word_length': 3.5271210013908205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6528488', 'n_tokens_mistral': 1093, 'n_tokens_neox': 991, 'n_words': 160}