class Helper in Anti Spam by CleanTalk 9.1.x
Same name in this branch
- 9.1.x src/lib/Cleantalk/Common/Helper.php \Cleantalk\Common\Helper
 - 9.1.x src/lib/Cleantalk/ApbctDrupal/Helper.php \Cleantalk\ApbctDrupal\Helper
 
Same name and namespace in other branches
- 8.4 src/lib/Cleantalk/ApbctDrupal/Helper.php \Cleantalk\ApbctDrupal\Helper
 
Hierarchy
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\ApbctDrupalView 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
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            Helper:: | 
                  public static | property | * | |
| 
            Helper:: | 
                  public static | property | * | |
| 
            Helper:: | 
                  constant | * Default user agent for HTTP requests | ||
| 
            Helper:: | 
                  public static | function | Universal method to adding cookies | |
| 
            Helper:: | 
                  public static | function | * Merging arrays without reseting numeric keys * * | |
| 
            Helper:: | 
                  public static | function | * Merging arrays without reseting numeric keys recursive * * | |
| 
            Helper:: | 
                  public static | function | * Pops line from the csv buffer and fromat it by map to array * * | |
| 
            Helper:: | 
                  public static | function | * Pops line from buffer without formatting * * | |
| 
            Helper:: | 
                  public static | function | * Pops line from the csv buffer and fromat it by map to array * * | |
| 
            Helper:: | 
                  static | function | ||
| 
            Helper:: | 
                  static | function | ||
| 
            Helper:: | 
                  public static | function | Validate CIDR | |
| 
            Helper:: | 
                  public static | function | Escapes MySQL params | |
| 
            Helper:: | 
                  public static | function | * Resolve DNS to IP * * | |
| 
            Helper:: | 
                  public static | function | * Function convert from UTF8 * * | |
| 
            Helper:: | 
                  public static | function | 
            Get fw stats from the storage. Overrides Helper:: | 
                  |
| 
            Helper:: | 
                  private static | function | Get site url for remote calls. | |
| 
            Helper:: | 
                  public static | function | ||
| 
            Helper:: | 
                  static | function | * Get mime type from file or data * * | |
| 
            Helper:: | 
                  public static | function | Gets every HTTP_ headers from $_SERVER | |
| 
            Helper:: | 
                  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:: | 
                  public static | function | Wrapper for http_request Requesting data via HTTP request with GET method | |
| 
            Helper:: | 
                  public static | function | Wrapper for http_request Requesting HTTP response code for $url | |
| 
            Helper:: | 
                  public static | function | Do the remote call to the host. | |
| 
            Helper:: | 
                  public static | function | Getting arrays of IP (REMOTE_ADDR, X-Forwarded-For, X-Real-Ip, Cf_Connecting_Ip) | |
| 
            Helper:: | 
                  public static | function | * Get URL form IP. Check if it's belong to cleantalk. * * | |
| 
            Helper:: | 
                  static | function | * Checks if the IP is in private range * * | |
| 
            Helper:: | 
                  public static | function | Its own implementation of the native method long2ip() | |
| 
            Helper:: | 
                  public static | function | * Check if the IP belong to mask. Recursive. * Octet by octet for IPv4 * Hextet by hextet for IPv6 * * | |
| 
            Helper:: | 
                  static | function | * Converts long mask like 4294967295 to number like 32 * * | |
| 
            Helper:: | 
                  public static | function | * Get URL form IP * * | |
| 
            Helper:: | 
                  public static | function | * Get URL form IP. Check if it's belong to cleantalk. * * | |
| 
            Helper:: | 
                  public static | function | * Expand IPv6 * * | |
| 
            Helper:: | 
                  public static | function | * Reduce IPv6 * * | |
| 
            Helper:: | 
                  public static | function | * Validating IPv4, IPv6 * * | |
| 
            Helper:: | 
                  public static | function | * Checks if the string is JSON type * * | |
| 
            Helper:: | 
                  public static | function | ||
| 
            Helper:: | 
                  public static | function | * Masks a value with asterisks (*) Needed by the getFieldsAny() * | |
| 
            Helper:: | 
                  public static | function | * Print html form for external forms() * | |
| 
            Helper:: | 
                  public static | function | * Function removing non UTF8 characters from array|string|object * * | |
| 
            Helper:: | 
                  public static | function | 
            Save fw stats on the storage. Overrides Helper:: | 
                  |
| 
            Helper:: | 
                  public static | function | 
            Implement here any actions after SFW updating finished. Overrides Helper:: | 
                  |
| 
            Helper:: | 
                  public static | function | ||
| 
            Helper:: | 
                  public static | function | * Function convert anything to UTF8 and removes non UTF8 characters * * |