You are here

class Helper in Anti Spam by CleanTalk 9.1.x

Same name in this branch
  1. 9.1.x src/lib/Cleantalk/Common/Helper.php \Cleantalk\Common\Helper
  2. 9.1.x src/lib/Cleantalk/ApbctDrupal/Helper.php \Cleantalk\ApbctDrupal\Helper
Same name and namespace in other branches
  1. 8.4 src/lib/Cleantalk/ApbctDrupal/Helper.php \Cleantalk\ApbctDrupal\Helper

Hierarchy

  • class \Cleantalk\Common\Helper
    • class \Cleantalk\ApbctDrupal\Helper

Expanded class hierarchy of Helper

4 files declare their use of Helper
BootSubscriber.php in src/EventSubscriber/BootSubscriber.php
cleantalk.module in ./cleantalk.module
CleantalkFuncs.php in src/CleantalkFuncs.php
CleantalkSettingsForm.php in src/Form/CleantalkSettingsForm.php

File

src/lib/Cleantalk/ApbctDrupal/Helper.php, line 5

Namespace

Cleantalk\ApbctDrupal
View source
class Helper extends \Cleantalk\Common\Helper {

  /**
   * Get fw stats from the storage.
   *
   * @return array
   * @example array( 'firewall_updating' => false, 'firewall_updating_id' => md5(), 'firewall_update_percent' => 0, 'firewall_updating_last_start' => 0 )
   * @important This method must be overloaded in the CMS-based Helper class.
   */
  public static function getFwStats() {
    return array(
      'firewall_updating_id' => \Drupal::state()
        ->get('firewall_updating_id') ? \Drupal::state()
        ->get('firewall_updating_id') : null,
      'firewall_updating_last_start' => \Drupal::state()
        ->get('firewall_updating_last_start') ? \Drupal::state()
        ->get('firewall_updating_last_start') : 0,
      'firewall_update_percent' => \Drupal::state()
        ->get('firewall_update_percent') ? \Drupal::state()
        ->get('firewall_update_percent') : null,
    );
  }

  /**
   * Save fw stats on the storage.
   *
   * @param array $fw_stats
   * @return bool
   * @important This method must be overloaded in the CMS-based Helper class.
   */
  public static function setFwStats($fw_stats) {
    \Drupal::state()
      ->set('firewall_updating_id', isset($fw_stats['firewall_updating_id']) ? $fw_stats['firewall_updating_id'] : null);
    \Drupal::state()
      ->set('firewall_updating_last_start', isset($fw_stats['firewall_updating_last_start']) ? $fw_stats['firewall_updating_last_start'] : 0);
    \Drupal::state()
      ->set('firewall_update_percent', isset($fw_stats['firewall_update_percent']) ? $fw_stats['firewall_update_percent'] : 0);
  }

  /**
   * Implement here any actions after SFW updating finished.
   *
   * @return void
   */
  public static function SfwUpdate_DoFinisnAction() {
    \Drupal::state()
      ->set('cleantalk_sfw_last_check', time());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Helper::$cleantalks_servers public static property *
Helper::$private_networks public static property *
Helper::AGENT constant * Default user agent for HTTP requests
Helper::apbct_cookie__set public static function Universal method to adding cookies
Helper::array_merge__save_numeric_keys public static function * Merging arrays without reseting numeric keys * *
Helper::array_merge__save_numeric_keys__recursive public static function * Merging arrays without reseting numeric keys recursive * *
Helper::buffer__csv__get_map public static function * Pops line from the csv buffer and fromat it by map to array * *
Helper::buffer__csv__pop_line public static function * Pops line from buffer without formatting * *
Helper::buffer__csv__pop_line_to_array public static function * Pops line from the csv buffer and fromat it by map to array * *
Helper::buffer__parse__csv static function
Helper::buffer__trim_and_clear_from_empty_lines static function
Helper::cidr__validate public static function Validate CIDR
Helper::db__prepare_param public static function Escapes MySQL params
Helper::dns__resolve public static function * Resolve DNS to IP * *
Helper::fromUTF8 public static function * Function convert from UTF8 * *
Helper::getFwStats public static function Get fw stats from the storage. Overrides Helper::getFwStats
Helper::getSiteUrl private static function Get site url for remote calls.
Helper::get_fields_any public static function
Helper::get_mime_type static function * Get mime type from file or data * *
Helper::http__get_headers public static function Gets every HTTP_ headers from $_SERVER
Helper::http__request public static function * Function sends raw http request * * May use 4 presets(combining possible): * get_code - getting only HTTP response code * async - async requests * get - GET-request * ssl - use SSL * * @todo Have to replace this method…
Helper::http__request__get_content public static function Wrapper for http_request Requesting data via HTTP request with GET method
Helper::http__request__get_response_code public static function Wrapper for http_request Requesting HTTP response code for $url
Helper::http__request__rc_to_host public static function Do the remote call to the host.
Helper::ip__get public static function Getting arrays of IP (REMOTE_ADDR, X-Forwarded-For, X-Real-Ip, Cf_Connecting_Ip)
Helper::ip__is_cleantalks public static function * Get URL form IP. Check if it's belong to cleantalk. * *
Helper::ip__is_private_network static function * Checks if the IP is in private range * *
Helper::ip__long2ip public static function Its own implementation of the native method long2ip()
Helper::ip__mask_match public static function * Check if the IP belong to mask. Recursive. * Octet by octet for IPv4 * Hextet by hextet for IPv6 * *
Helper::ip__mask__long_to_number static function * Converts long mask like 4294967295 to number like 32 * *
Helper::ip__resolve public static function * Get URL form IP * *
Helper::ip__resolve__cleantalks public static function * Get URL form IP. Check if it's belong to cleantalk. * *
Helper::ip__v6_normalize public static function * Expand IPv6 * *
Helper::ip__v6_reduce public static function * Reduce IPv6 * *
Helper::ip__validate public static function * Validating IPv4, IPv6 * *
Helper::is_json public static function * Checks if the string is JSON type * *
Helper::key_is_correct public static function
Helper::obfuscate_param public static function * Masks a value with asterisks (*) Needed by the getFieldsAny() *
Helper::print_form public static function * Print html form for external forms() *
Helper::removeNonUTF8 public static function * Function removing non UTF8 characters from array|string|object * *
Helper::setFwStats public static function Save fw stats on the storage. Overrides Helper::setFwStats
Helper::SfwUpdate_DoFinisnAction public static function Implement here any actions after SFW updating finished. Overrides Helper::SfwUpdate_DoFinisnAction
Helper::time__get_interval_start public static function
Helper::toUTF8 public static function * Function convert anything to UTF8 and removes non UTF8 characters * *