PHP Classes

File: vault/rules_softlayer.php

Recommend this page to a friend!
  Classes of Caleb   CIDRAM   vault/rules_softlayer.php   Download  
File: vault/rules_softlayer.php
Role: Example script
Content type: text/plain
Description: Example script
Class: CIDRAM
Check if an IP address is a bad source of traffic
Author: By
Last change: Update of vault/rules_softlayer.php
Date: 4 years ago
Size: 2,702 bytes
 

Contents

Class file image Download
<?php
/**
 * This file is a part of the CIDRAM package.
 * Homepage: https://cidram.github.io/
 *
 * CIDRAM COPYRIGHT 2016 and beyond by Caleb Mazalevskis (Maikuolan).
 *
 * License: GNU/GPLv2
 * @see LICENSE.txt
 *
 * This file: Extended rules for Soft Layer CIDRs (last modified: 2019.05.17).
 */

/** Prevents execution from outside of CIDRAM. */
if (!defined('CIDRAM')) {
    die(
'[CIDRAM] This should not be accessed directly.');
}

/** Prevents execution from outside of the CheckFactors closure. */
if (!isset($Factors[$FactorIndex])) {
    die(
'[CIDRAM] This should not be accessed directly.');
}

/** Safety. */
if (!isset($CIDRAM['RunParamResCache'])) {
   
$CIDRAM['RunParamResCache'] = [];
}

/**
 * Define object for these rules for later recall (all parameters inherited from CheckFactors).
 *
 * @param array $Factors All CIDR factors of the IP being checked.
 * @param int $FactorIndex The index of the CIDR factor of the triggered rule.
 * @param string $LN The line information generated by CheckFactors.
 * @param string $Tag The triggered rule's section's name (if there's any).
 */
$CIDRAM['RunParamResCache']['rules_softlayer.php'] = function (array $Factors = [], int $FactorIndex = 0, string $LN = '', string $Tag = '') use (&$CIDRAM) {

   
/** Skip further processing if the "block_cloud" directive is false. */
   
if (!$CIDRAM['Config']['signatures']['block_cloud']) {
        return;
    }

   
/** ShowyouBot bypass. */
   
if (strpos($CIDRAM['BlockInfo']['UALC'], 'showyoubot') !== false) {
        return;
    }

   
/** Disqus bypass. */
   
if (strpos($CIDRAM['BlockInfo']['UALC'], 'disqus') !== false) {
        return;
    }

   
/** Feedspot bypass. */
   
if (strpos($CIDRAM['BlockInfo']['UA'], 'Feedspot http://www.feedspot.com') !== false) {
        return;
    }

   
/** Superfeedr bypass. */
   
if (strpos($CIDRAM['BlockInfo']['UA'], 'Superfeedr bot/2.0') !== false) {
        return;
    }

   
/** Feedbot bypass. */
   
if (strpos($CIDRAM['BlockInfo']['UA'], 'Feedbot') !== false) {
        return;
    }

   
$CIDRAM['BlockInfo']['ReasonMessage'] = $CIDRAM['L10N']->getString('ReasonMessage_Cloud');
    if (!empty(
$CIDRAM['BlockInfo']['WhyReason'])) {
       
$CIDRAM['BlockInfo']['WhyReason'] .= ', ';
    }
   
$CIDRAM['BlockInfo']['WhyReason'] .= $CIDRAM['L10N']->getString('Short_Cloud') . $LN;
    if (!empty(
$CIDRAM['BlockInfo']['Signatures'])) {
       
$CIDRAM['BlockInfo']['Signatures'] .= ', ';
    }
   
$CIDRAM['BlockInfo']['Signatures'] .= $Factors[$FactorIndex];
   
$CIDRAM['BlockInfo']['SignatureCount']++;

};

/** Execute object. */
$RunExitCode = $CIDRAM['RunParamResCache']['rules_softlayer.php']($Factors, $FactorIndex, $LN, $Tag);