@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | require_once(BB2_CORE . "/functions.inc.php"); |
| 11 | 11 | |
| 12 | 12 | // Kill 'em all! |
| 13 | -function bb2_banned($settings, $package, $key, $previous_key=false) |
|
| 13 | +function bb2_banned($settings, $package, $key, $previous_key = false) |
|
| 14 | 14 | { |
| 15 | 15 | // Some spambots hit too hard. Slow them down a bit. |
| 16 | 16 | sleep(2); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | $unpacked = array(); |
| 74 | 74 | foreach ($value as $k => $v) { |
| 75 | - $i = $key. '[' . $k . ']'; |
|
| 75 | + $i = $key . '[' . $k . ']'; |
|
| 76 | 76 | if (is_array($v)) |
| 77 | 77 | $v = bb2_unpack_php_post_array($i, $v); |
| 78 | 78 | $unpacked[$i] = $v; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $request_uri = $_SERVER["REQUEST_URI"]; |
| 111 | - if (!$request_uri) $request_uri = $_SERVER['SCRIPT_NAME']; # IIS |
|
| 111 | + if (!$request_uri) $request_uri = $_SERVER['SCRIPT_NAME']; # IIS |
|
| 112 | 112 | |
| 113 | 113 | if ($settings['reverse_proxy'] && $ip = bb2_reverse_proxy($settings, $headers_mixed)) { |
| 114 | 114 | $headers['X-Bad-Behavior-Remote-Address'] = $_SERVER['REMOTE_ADDR']; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | // Check the http:BL |
| 148 | 148 | require_once(BB2_CORE . "/blackhole.inc.php"); |
| 149 | 149 | if ($r = bb2_httpbl($settings, $package)) { |
| 150 | - if ($r == 1) return false; # whitelisted |
|
| 150 | + if ($r == 1) return false; # whitelisted |
|
| 151 | 151 | return $r; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -163,28 +163,28 @@ discard block |
||
| 163 | 163 | if (stripos($ua, "bingbot") !== FALSE || stripos($ua, "msnbot") !== FALSE || stripos($ua, "MS Search") !== FALSE) { |
| 164 | 164 | require_once(BB2_CORE . "/searchengine.inc.php"); |
| 165 | 165 | if ($r = bb2_msnbot($package)) { |
| 166 | - if ($r == 1) return false; # whitelisted |
|
| 166 | + if ($r == 1) return false; # whitelisted |
|
| 167 | 167 | return $r; |
| 168 | 168 | } |
| 169 | 169 | return false; |
| 170 | 170 | } elseif (stripos($ua, "Googlebot") !== FALSE || stripos($ua, "Mediapartners-Google") !== FALSE || stripos($ua, "Google Web Preview") !== FALSE) { |
| 171 | 171 | require_once(BB2_CORE . "/searchengine.inc.php"); |
| 172 | 172 | if ($r = bb2_google($package)) { |
| 173 | - if ($r == 1) return false; # whitelisted |
|
| 173 | + if ($r == 1) return false; # whitelisted |
|
| 174 | 174 | return $r; |
| 175 | 175 | } |
| 176 | 176 | return false; |
| 177 | 177 | } elseif (stripos($ua, "Yahoo! Slurp") !== FALSE || stripos($ua, "Yahoo! SearchMonkey") !== FALSE) { |
| 178 | 178 | require_once(BB2_CORE . "/searchengine.inc.php"); |
| 179 | 179 | if ($r = bb2_yahoo($package)) { |
| 180 | - if ($r == 1) return false; # whitelisted |
|
| 180 | + if ($r == 1) return false; # whitelisted |
|
| 181 | 181 | return $r; |
| 182 | 182 | } |
| 183 | 183 | return false; |
| 184 | 184 | } elseif (stripos($ua, "Baidu") !== FALSE) { |
| 185 | 185 | require_once(BB2_CORE . "/searchengine.inc.php"); |
| 186 | 186 | if ($r = bb2_baidu($package)) { |
| 187 | - if ($r == 1) return false; # whitelisted |
|
| 187 | + if ($r == 1) return false; # whitelisted |
|
| 188 | 188 | return $r; |
| 189 | 189 | } |
| 190 | 190 | return false; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | bb2_db_query($query); |
| 15 | 15 | |
| 16 | 16 | // Waste a bunch more of the spammer's time, sometimes. |
| 17 | - if (rand(1,1000) == 1) { |
|
| 17 | + if (rand(1, 1000) == 1) { |
|
| 18 | 18 | $query = "OPTIMIZE TABLE `" . $settings['log_table'] . "`"; |
| 19 | 19 | bb2_db_query($query); |
| 20 | 20 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | function bb2_display_denial($settings, $package, $key, $previous_key = false) |
| 24 | 24 | { |
| 25 | - define('DONOTCACHEPAGE', true); // WP Super Cache |
|
| 25 | + define('DONOTCACHEPAGE', true); // WP Super Cache |
|
| 26 | 26 | if (!$previous_key) $previous_key = $key; |
| 27 | 27 | if ($key == "e87553e1") { |
| 28 | 28 | // FIXME: lookup the real key |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | header("HTTP/1.1 " . $response['response'] . " Bad Behavior"); |
| 41 | 41 | header("Status: " . $response['response'] . " Bad Behavior"); |
| 42 | 42 | $request_uri = $_SERVER["REQUEST_URI"]; |
| 43 | - if (!$request_uri) $request_uri = $_SERVER['SCRIPT_NAME']; # IIS |
|
| 43 | + if (!$request_uri) $request_uri = $_SERVER['SCRIPT_NAME']; # IIS |
|
| 44 | 44 | ?> |
| 45 | 45 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 46 | 46 | <!--< html xmlns="http://www.w3.org/1999/xhtml">--> |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | <?php |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | -function bb2_log_denial($settings, $package, $key, $previous_key=false) |
|
| 61 | +function bb2_log_denial($settings, $package, $key, $previous_key = false) |
|
| 62 | 62 | { |
| 63 | 63 | if (!$settings['logging']) return; |
| 64 | 64 | bb2_db_query(bb2_insert($settings, $package, $key)); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // Only conservative lists |
| 14 | 14 | $bb2_blackhole_lists = array( |
| 15 | - "sbl-xbl.spamhaus.org", // All around nasties |
|
| 15 | + "sbl-xbl.spamhaus.org", // All around nasties |
|
| 16 | 16 | // "dnsbl.sorbs.net", // Old useless data. |
| 17 | 17 | // "list.dsbl.org", // Old useless data. |
| 18 | 18 | // "dnsbl.ioerror.us", // Bad Behavior Blackhole |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | // Things that shouldn't be blocked, from aggregate lists |
| 22 | 22 | $bb2_blackhole_exceptions = array( |
| 23 | - "sbl-xbl.spamhaus.org" => array("127.0.0.4"), // CBL is problematic |
|
| 24 | - "dnsbl.sorbs.net" => array("127.0.0.10",), // Dynamic IPs only |
|
| 23 | + "sbl-xbl.spamhaus.org" => array("127.0.0.4"), // CBL is problematic |
|
| 24 | + "dnsbl.sorbs.net" => array("127.0.0.10",), // Dynamic IPs only |
|
| 25 | 25 | "list.dsbl.org" => array(), |
| 26 | 26 | "dnsbl.ioerror.us" => array(), |
| 27 | 27 | ); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | bb2_db_query("SET @@session.wait_timeout = 90"); |
| 53 | 53 | |
| 54 | 54 | $find = implode('.', array_reverse(explode('.', $package['ip']))); |
| 55 | - $result = gethostbynamel($settings['httpbl_key'].".${find}.dnsbl.httpbl.org."); |
|
| 55 | + $result = gethostbynamel($settings['httpbl_key'] . ".${find}.dnsbl.httpbl.org."); |
|
| 56 | 56 | if (!empty($result)) { |
| 57 | 57 | $ip = explode('.', $result[0]); |
| 58 | 58 | if ($ip[0] == 127 && ($ip[3] & 7) && $ip[2] >= $settings['httpbl_threat'] && $ip[1] <= $settings['httpbl_maxage']) { |
@@ -9,20 +9,20 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | // stripos() needed because stripos is only present on PHP 5 |
| 11 | 11 | if (!function_exists('stripos')) { |
| 12 | - function stripos($haystack,$needle,$offset = 0) { |
|
| 13 | - return(strpos(strtolower($haystack),strtolower($needle),$offset)); |
|
| 12 | + function stripos($haystack, $needle, $offset = 0) { |
|
| 13 | + return(strpos(strtolower($haystack), strtolower($needle), $offset)); |
|
| 14 | 14 | } |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // str_split() needed because str_split is only present on PHP 5 |
| 18 | 18 | if (!function_exists('str_split')) { |
| 19 | - function str_split($string, $split_length=1) |
|
| 19 | + function str_split($string, $split_length = 1) |
|
| 20 | 20 | { |
| 21 | 21 | if ($split_length < 1) { |
| 22 | 22 | return false; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - for ($pos=0, $chunks = array(); $pos < strlen($string); $pos+=$split_length) { |
|
| 25 | + for ($pos = 0, $chunks = array(); $pos < strlen($string); $pos += $split_length) { |
|
| 26 | 26 | $chunks[] = substr($string, $pos, $split_length); |
| 27 | 27 | } |
| 28 | 28 | return $chunks; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | foreach ($temp as $key=>$word) { |
| 36 | 36 | $temp[$key] = ucfirst(strtolower($word)); |
| 37 | 37 | } |
| 38 | - return join ('', $temp); |
|
| 38 | + return join('', $temp); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // Determine if an IP address resides in a CIDR netblock or netblocks. |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } else { |
| 53 | 53 | @list($ip, $mask) = explode('/', $cidr); |
| 54 | 54 | if (!$mask) $mask = 32; |
| 55 | - $mask = pow(2,32) - pow(2, (32 - $mask)); |
|
| 55 | + $mask = pow(2, 32) - pow(2, (32 - $mask)); |
|
| 56 | 56 | $output = ((ip2long($addr) & $mask) == (ip2long($ip) & $mask)); |
| 57 | 57 | } |
| 58 | 58 | return $output; |
@@ -5,160 +5,160 @@ |
||
| 5 | 5 | // Blacklisted user agents |
| 6 | 6 | // These user agent strings occur at the beginning of the line. |
| 7 | 7 | $bb2_spambots_0 = array( |
| 8 | - "-", // brute force password attempts, malicious botnet |
|
| 9 | - "8484 Boston Project", // video poker/porn spam |
|
| 10 | - "ArchiveTeam", // ignores robots.txt and hammers server |
|
| 11 | - "adwords", // referrer spam |
|
| 12 | - "autoemailspider", // spam harvester |
|
| 13 | - "blogsearchbot-martin", // from honeypot |
|
| 14 | - "BrowserEmulator/", // open proxy software |
|
| 15 | - "CherryPicker", // spam harvester |
|
| 16 | - "core-project/", // FrontPage extension exploits |
|
| 17 | - "Diamond", // delivers spyware/adware |
|
| 18 | - "Digger", // spam harvester |
|
| 19 | - "ecollector", // spam harvester |
|
| 20 | - "EmailCollector", // spam harvester |
|
| 21 | - "Email Siphon", // spam harvester |
|
| 22 | - "EmailSiphon", // spam harvester |
|
| 23 | - "Forum Poster", // forum spambot |
|
| 24 | - "grub crawler", // misc comment/email spam |
|
| 25 | - "HttpProxy", // misc comment/email spam |
|
| 26 | - "Internet Explorer", // XMLRPC exploits seen |
|
| 27 | - "ISC Systems iRc", // spam harvester |
|
| 28 | - "Jakarta Commons", // customised spambots |
|
| 29 | - "Java 1.", // unidentified robots |
|
| 30 | - "Java/1.", // unidentified robots |
|
| 31 | - "libwww-perl", // unidentified robots |
|
| 32 | - "LWP", // unidentified robots |
|
| 33 | - "lwp", // unidentified robots |
|
| 34 | - "Microsoft Internet Explorer/", // too old; assumed robot |
|
| 35 | - "Microsoft URL", // unidentified robots |
|
| 36 | - "Missigua", // spam harvester |
|
| 37 | - "MJ12bot/v1.0.8", // malicious botnet |
|
| 38 | - "Morfeus", // vulnerability scanner |
|
| 39 | - "Movable Type", // customised spambots |
|
| 8 | + "-", // brute force password attempts, malicious botnet |
|
| 9 | + "8484 Boston Project", // video poker/porn spam |
|
| 10 | + "ArchiveTeam", // ignores robots.txt and hammers server |
|
| 11 | + "adwords", // referrer spam |
|
| 12 | + "autoemailspider", // spam harvester |
|
| 13 | + "blogsearchbot-martin", // from honeypot |
|
| 14 | + "BrowserEmulator/", // open proxy software |
|
| 15 | + "CherryPicker", // spam harvester |
|
| 16 | + "core-project/", // FrontPage extension exploits |
|
| 17 | + "Diamond", // delivers spyware/adware |
|
| 18 | + "Digger", // spam harvester |
|
| 19 | + "ecollector", // spam harvester |
|
| 20 | + "EmailCollector", // spam harvester |
|
| 21 | + "Email Siphon", // spam harvester |
|
| 22 | + "EmailSiphon", // spam harvester |
|
| 23 | + "Forum Poster", // forum spambot |
|
| 24 | + "grub crawler", // misc comment/email spam |
|
| 25 | + "HttpProxy", // misc comment/email spam |
|
| 26 | + "Internet Explorer", // XMLRPC exploits seen |
|
| 27 | + "ISC Systems iRc", // spam harvester |
|
| 28 | + "Jakarta Commons", // customised spambots |
|
| 29 | + "Java 1.", // unidentified robots |
|
| 30 | + "Java/1.", // unidentified robots |
|
| 31 | + "libwww-perl", // unidentified robots |
|
| 32 | + "LWP", // unidentified robots |
|
| 33 | + "lwp", // unidentified robots |
|
| 34 | + "Microsoft Internet Explorer/", // too old; assumed robot |
|
| 35 | + "Microsoft URL", // unidentified robots |
|
| 36 | + "Missigua", // spam harvester |
|
| 37 | + "MJ12bot/v1.0.8", // malicious botnet |
|
| 38 | + "Morfeus", // vulnerability scanner |
|
| 39 | + "Movable Type", // customised spambots |
|
| 40 | 40 | // msnbot is using this fake user agent string now |
| 41 | 41 | //"Mozilla ", // malicious software |
| 42 | - "Mozilla/0", // malicious software |
|
| 43 | - "Mozilla/1", // malicious software |
|
| 44 | - "Mozilla/2", // malicious software |
|
| 45 | - "Mozilla/3", // malicious software |
|
| 46 | - "Mozilla/4.0(", // from honeypot |
|
| 47 | - "Mozilla/4.0+(compatible;+", // suspicious harvester |
|
| 48 | - "Mozilla/4.0 (Hydra)", // brute force tool |
|
| 49 | - "MSIE", // malicious software |
|
| 50 | - "MVAClient", // automated hacking attempts |
|
| 51 | - "Nessus", // vulnerability scanner |
|
| 52 | - "NutchCVS", // unidentified robots |
|
| 53 | - "Nutscrape/", // misc comment spam |
|
| 54 | - "OmniExplorer", // spam harvester |
|
| 55 | - "Opera/9.64(", // comment spam bot |
|
| 56 | - "PMAFind", // vulnerability scanner |
|
| 57 | - "psycheclone", // spam harvester |
|
| 58 | - "PussyCat ", // misc comment spam |
|
| 59 | - "PycURL", // misc comment spam |
|
| 60 | - "Python-urllib", // commonly abused |
|
| 61 | - "revolt", // vulnerability scanner |
|
| 42 | + "Mozilla/0", // malicious software |
|
| 43 | + "Mozilla/1", // malicious software |
|
| 44 | + "Mozilla/2", // malicious software |
|
| 45 | + "Mozilla/3", // malicious software |
|
| 46 | + "Mozilla/4.0(", // from honeypot |
|
| 47 | + "Mozilla/4.0+(compatible;+", // suspicious harvester |
|
| 48 | + "Mozilla/4.0 (Hydra)", // brute force tool |
|
| 49 | + "MSIE", // malicious software |
|
| 50 | + "MVAClient", // automated hacking attempts |
|
| 51 | + "Nessus", // vulnerability scanner |
|
| 52 | + "NutchCVS", // unidentified robots |
|
| 53 | + "Nutscrape/", // misc comment spam |
|
| 54 | + "OmniExplorer", // spam harvester |
|
| 55 | + "Opera/9.64(", // comment spam bot |
|
| 56 | + "PMAFind", // vulnerability scanner |
|
| 57 | + "psycheclone", // spam harvester |
|
| 58 | + "PussyCat ", // misc comment spam |
|
| 59 | + "PycURL", // misc comment spam |
|
| 60 | + "Python-urllib", // commonly abused |
|
| 61 | + "revolt", // vulnerability scanner |
|
| 62 | 62 | // WP 2.5 now has Flash; FIXME |
| 63 | 63 | // "Shockwave Flash", // spam harvester |
| 64 | - "sqlmap/", // SQL injection |
|
| 65 | - "Super Happy Fun ", // spam harvester |
|
| 66 | - "TrackBack/", // trackback spam |
|
| 67 | - "user", // suspicious harvester |
|
| 68 | - "User Agent: ", // spam harvester |
|
| 69 | - "User-Agent: ", // spam harvester |
|
| 70 | - "w3af", // vulnerability scanner |
|
| 71 | - "WebSite-X Suite", // misc comment spam |
|
| 72 | - "Winnie Poh", // Automated Coppermine hacks |
|
| 73 | - "Wordpress", // malicious software |
|
| 74 | - "\"", // malicious software |
|
| 64 | + "sqlmap/", // SQL injection |
|
| 65 | + "Super Happy Fun ", // spam harvester |
|
| 66 | + "TrackBack/", // trackback spam |
|
| 67 | + "user", // suspicious harvester |
|
| 68 | + "User Agent: ", // spam harvester |
|
| 69 | + "User-Agent: ", // spam harvester |
|
| 70 | + "w3af", // vulnerability scanner |
|
| 71 | + "WebSite-X Suite", // misc comment spam |
|
| 72 | + "Winnie Poh", // Automated Coppermine hacks |
|
| 73 | + "Wordpress", // malicious software |
|
| 74 | + "\"", // malicious software |
|
| 75 | 75 | ); |
| 76 | 76 | |
| 77 | 77 | // These user agent strings occur anywhere within the line. |
| 78 | 78 | $bb2_spambots = array( |
| 79 | - "\r", // A really dumb bot |
|
| 80 | - "<sc", // XSS exploit attempts |
|
| 81 | - "; Widows ", // misc comment/email spam |
|
| 82 | - ": ;", // shellshock |
|
| 83 | - ":;", // shellshock |
|
| 84 | - "a href=", // referrer spam |
|
| 85 | - "ArchiveBot", // ignores robots.txt and hammers server |
|
| 86 | - "Bad Behavior Test", // Add this to your user-agent to test BB |
|
| 87 | - "compatible ; MSIE", // misc comment/email spam |
|
| 88 | - "compatible-", // misc comment/email spam |
|
| 89 | - "DTS Agent", // misc comment/email spam |
|
| 90 | - "Email Extractor", // spam harvester |
|
| 91 | - "Firebird/", // too old; assumed robot |
|
| 92 | - "Gecko/2525", // revisit this in 500 years |
|
| 93 | - "grub-client", // search engine ignores robots.txt |
|
| 94 | - "hanzoweb", // very badly behaved crawler |
|
| 95 | - "Havij", // SQL injection tool |
|
| 96 | - "Indy Library", // misc comment/email spam |
|
| 97 | - "Ming Mong", // brute force tool |
|
| 98 | - "MSIE 7.0; Windows NT 5.2", // Cyveillance |
|
| 99 | - "Murzillo compatible", // comment spam bot |
|
| 100 | - ".NET CLR 1)", // free poker, etc. |
|
| 101 | - ".NET CLR1", // spam harvester |
|
| 102 | - "Netsparker", // vulnerability scanner |
|
| 103 | - "Nikto/", // vulnerability scanner |
|
| 104 | - "Perman Surfer", // old and very broken harvester |
|
| 105 | - "POE-Component-Client", // free poker, etc. |
|
| 106 | - "Teh Forest Lobster", // brute force tool |
|
| 107 | - "Turing Machine", // www.anonymizer.com abuse |
|
| 108 | - "Ubuntu/9.25", // comment spam bot |
|
| 109 | - "unspecified.mail", // stealth harvesters |
|
| 110 | - "User-agent: ", // spam harvester/splogger |
|
| 111 | - "WebaltBot", // spam harvester |
|
| 112 | - "WISEbot", // spam harvester |
|
| 113 | - "WISEnutbot", // spam harvester |
|
| 114 | - "Win95", // too old; assumed robot |
|
| 115 | - "Win98", // too old; assumed robot |
|
| 116 | - "WinME", // too old; assumed robot |
|
| 117 | - "Win 9x 4.90", // too old; assumed robot |
|
| 118 | - "Windows 3", // too old; assumed robot |
|
| 119 | - "Windows 95", // too old; assumed robot |
|
| 120 | - "Windows 98", // too old; assumed robot |
|
| 121 | - "Windows NT 4", // too old; assumed robot |
|
| 122 | - "Windows NT;", // too old; assumed robot |
|
| 79 | + "\r", // A really dumb bot |
|
| 80 | + "<sc", // XSS exploit attempts |
|
| 81 | + "; Widows ", // misc comment/email spam |
|
| 82 | + ": ;", // shellshock |
|
| 83 | + ":;", // shellshock |
|
| 84 | + "a href=", // referrer spam |
|
| 85 | + "ArchiveBot", // ignores robots.txt and hammers server |
|
| 86 | + "Bad Behavior Test", // Add this to your user-agent to test BB |
|
| 87 | + "compatible ; MSIE", // misc comment/email spam |
|
| 88 | + "compatible-", // misc comment/email spam |
|
| 89 | + "DTS Agent", // misc comment/email spam |
|
| 90 | + "Email Extractor", // spam harvester |
|
| 91 | + "Firebird/", // too old; assumed robot |
|
| 92 | + "Gecko/2525", // revisit this in 500 years |
|
| 93 | + "grub-client", // search engine ignores robots.txt |
|
| 94 | + "hanzoweb", // very badly behaved crawler |
|
| 95 | + "Havij", // SQL injection tool |
|
| 96 | + "Indy Library", // misc comment/email spam |
|
| 97 | + "Ming Mong", // brute force tool |
|
| 98 | + "MSIE 7.0; Windows NT 5.2", // Cyveillance |
|
| 99 | + "Murzillo compatible", // comment spam bot |
|
| 100 | + ".NET CLR 1)", // free poker, etc. |
|
| 101 | + ".NET CLR1", // spam harvester |
|
| 102 | + "Netsparker", // vulnerability scanner |
|
| 103 | + "Nikto/", // vulnerability scanner |
|
| 104 | + "Perman Surfer", // old and very broken harvester |
|
| 105 | + "POE-Component-Client", // free poker, etc. |
|
| 106 | + "Teh Forest Lobster", // brute force tool |
|
| 107 | + "Turing Machine", // www.anonymizer.com abuse |
|
| 108 | + "Ubuntu/9.25", // comment spam bot |
|
| 109 | + "unspecified.mail", // stealth harvesters |
|
| 110 | + "User-agent: ", // spam harvester/splogger |
|
| 111 | + "WebaltBot", // spam harvester |
|
| 112 | + "WISEbot", // spam harvester |
|
| 113 | + "WISEnutbot", // spam harvester |
|
| 114 | + "Win95", // too old; assumed robot |
|
| 115 | + "Win98", // too old; assumed robot |
|
| 116 | + "WinME", // too old; assumed robot |
|
| 117 | + "Win 9x 4.90", // too old; assumed robot |
|
| 118 | + "Windows 3", // too old; assumed robot |
|
| 119 | + "Windows 95", // too old; assumed robot |
|
| 120 | + "Windows 98", // too old; assumed robot |
|
| 121 | + "Windows NT 4", // too old; assumed robot |
|
| 122 | + "Windows NT;", // too old; assumed robot |
|
| 123 | 123 | #"Windows NT 4.0;)", // wikispam bot |
| 124 | - "Windows NT 5.0;)", // wikispam bot |
|
| 125 | - "Windows NT 5.1;)", // wikispam bot |
|
| 126 | - "Windows XP 5", // spam harvester |
|
| 127 | - "WordPress/4.01", // pingback spam |
|
| 128 | - "Xedant Human Emulator",// spammer script engine |
|
| 129 | - "ZmEu", // exploit scanner |
|
| 130 | - "\\\\)", // spam harvester |
|
| 124 | + "Windows NT 5.0;)", // wikispam bot |
|
| 125 | + "Windows NT 5.1;)", // wikispam bot |
|
| 126 | + "Windows XP 5", // spam harvester |
|
| 127 | + "WordPress/4.01", // pingback spam |
|
| 128 | + "Xedant Human Emulator", // spammer script engine |
|
| 129 | + "ZmEu", // exploit scanner |
|
| 130 | + "\\\\)", // spam harvester |
|
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | 133 | // These are regular expression matches. |
| 134 | 134 | $bb2_spambots_regex = array( |
| 135 | - "/^[A-Z]{10}$/", // misc email spam |
|
| 135 | + "/^[A-Z]{10}$/", // misc email spam |
|
| 136 | 136 | "/[bcdfghjklmnpqrstvwxz ]{8,}/", |
| 137 | 137 | // "/(;\){1,2}$/", // misc spammers/harvesters |
| 138 | - "/MSIE.*Windows XP/", // misc comment spam |
|
| 139 | - "/MSIE [2345]/", // too old; assumed robot |
|
| 138 | + "/MSIE.*Windows XP/", // misc comment spam |
|
| 139 | + "/MSIE [2345]/", // too old; assumed robot |
|
| 140 | 140 | ); |
| 141 | 141 | |
| 142 | 142 | // Blacklisted URL strings |
| 143 | 143 | // These strings are considered case-insensitive. |
| 144 | 144 | $bb2_spambots_url = array( |
| 145 | - "0x31303235343830303536", // Havij |
|
| 146 | - "../", // path traversal |
|
| 147 | - "..\\", // path traversal |
|
| 148 | - "%60information_schema%60", // SQL injection probe |
|
| 149 | - "+%2F*%21", // SQL injection probe |
|
| 150 | - "%27--", // SQL injection |
|
| 151 | - "%27 --", // SQL injection |
|
| 152 | - "%27%23", // SQL injection |
|
| 153 | - "%27 %23", // SQL injection |
|
| 154 | - "benchmark%28", // SQL injection probe |
|
| 155 | - "insert+into+", // SQL injection |
|
| 156 | - "r3dm0v3", // SQL injection probe |
|
| 157 | - "select+1+from", // SQL injection probe |
|
| 158 | - "union+all+select", // SQL injection probe |
|
| 159 | - "union+select", // SQL injection probe |
|
| 160 | - "waitfor+delay+", // SQL injection probe |
|
| 161 | - "w00tw00t", // vulnerability scanner |
|
| 145 | + "0x31303235343830303536", // Havij |
|
| 146 | + "../", // path traversal |
|
| 147 | + "..\\", // path traversal |
|
| 148 | + "%60information_schema%60", // SQL injection probe |
|
| 149 | + "+%2F*%21", // SQL injection probe |
|
| 150 | + "%27--", // SQL injection |
|
| 151 | + "%27 --", // SQL injection |
|
| 152 | + "%27%23", // SQL injection |
|
| 153 | + "%27 %23", // SQL injection |
|
| 154 | + "benchmark%28", // SQL injection probe |
|
| 155 | + "insert+into+", // SQL injection |
|
| 156 | + "r3dm0v3", // SQL injection probe |
|
| 157 | + "select+1+from", // SQL injection probe |
|
| 158 | + "union+all+select", // SQL injection probe |
|
| 159 | + "union+select", // SQL injection probe |
|
| 160 | + "waitfor+delay+", // SQL injection probe |
|
| 161 | + "w00tw00t", // vulnerability scanner |
|
| 162 | 162 | ); |
| 163 | 163 | |
| 164 | 164 | // Do not edit below this line. |
@@ -31,48 +31,48 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | * @throw Exception if $value is malformed or contains unsupported types (e.g., resources, objects) |
| 33 | 33 | */ |
| 34 | -function _safe_serialize( $value ) |
|
| 34 | +function _safe_serialize($value) |
|
| 35 | 35 | { |
| 36 | - if(is_null($value)) |
|
| 36 | + if (is_null($value)) |
|
| 37 | 37 | { |
| 38 | 38 | return 'N;'; |
| 39 | 39 | } |
| 40 | - if(is_bool($value)) |
|
| 40 | + if (is_bool($value)) |
|
| 41 | 41 | { |
| 42 | - return 'b:'.(int)$value.';'; |
|
| 42 | + return 'b:' . (int) $value . ';'; |
|
| 43 | 43 | } |
| 44 | - if(is_int($value)) |
|
| 44 | + if (is_int($value)) |
|
| 45 | 45 | { |
| 46 | - return 'i:'.$value.';'; |
|
| 46 | + return 'i:' . $value . ';'; |
|
| 47 | 47 | } |
| 48 | - if(is_float($value)) |
|
| 48 | + if (is_float($value)) |
|
| 49 | 49 | { |
| 50 | - return 'd:'.$value.';'; |
|
| 50 | + return 'd:' . $value . ';'; |
|
| 51 | 51 | } |
| 52 | - if(is_string($value)) |
|
| 52 | + if (is_string($value)) |
|
| 53 | 53 | { |
| 54 | - return 's:'.strlen($value).':"'.$value.'";'; |
|
| 54 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
| 55 | 55 | } |
| 56 | - if(is_array($value)) |
|
| 56 | + if (is_array($value)) |
|
| 57 | 57 | { |
| 58 | 58 | $out = ''; |
| 59 | - foreach($value as $k => $v) |
|
| 59 | + foreach ($value as $k => $v) |
|
| 60 | 60 | { |
| 61 | 61 | $out .= _safe_serialize($k) . _safe_serialize($v); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - return 'a:'.count($value).':{'.$out.'}'; |
|
| 64 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
| 65 | 65 | } |
| 66 | - if(is_resource($value)) |
|
| 66 | + if (is_resource($value)) |
|
| 67 | 67 | { |
| 68 | 68 | // built-in returns 'i:0;' |
| 69 | 69 | throw new \Exception('safe_serialize: resources not supported'); |
| 70 | 70 | } |
| 71 | - if(is_object($value) || gettype($value) == 'object') |
|
| 71 | + if (is_object($value) || gettype($value) == 'object') |
|
| 72 | 72 | { |
| 73 | 73 | throw new \Exception('safe_serialize: objects not supported'); |
| 74 | 74 | } |
| 75 | - throw new \Exception('safe_serialize cannot serialize: '.gettype($value)); |
|
| 75 | + throw new \Exception('safe_serialize cannot serialize: ' . gettype($value)); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param mixed $value |
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | -function safe_serialize( $value ) |
|
| 85 | +function safe_serialize($value) |
|
| 86 | 86 | { |
| 87 | 87 | // ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen() |
| 88 | 88 | if (function_exists('mb_internal_encoding') && |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | try { |
| 96 | 96 | $out = _safe_serialize($value); |
| 97 | - } catch(Exception $e) { |
|
| 97 | + } catch (Exception $e) { |
|
| 98 | 98 | $out = false; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function _safe_unserialize($str) |
| 116 | 116 | { |
| 117 | - if(strlen($str) > MAX_SERIALIZED_INPUT_LENGTH) |
|
| 117 | + if (strlen($str) > MAX_SERIALIZED_INPUT_LENGTH) |
|
| 118 | 118 | { |
| 119 | 119 | throw new \Exception('safe_unserialize: input exceeds ' . MAX_SERIALIZED_INPUT_LENGTH); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if(empty($str) || !is_string($str)) |
|
| 122 | + if (empty($str) || !is_string($str)) |
|
| 123 | 123 | { |
| 124 | 124 | return false; |
| 125 | 125 | } |
@@ -128,59 +128,59 @@ discard block |
||
| 128 | 128 | $expected = array(); |
| 129 | 129 | $state = 0; |
| 130 | 130 | |
| 131 | - while($state != 1) |
|
| 131 | + while ($state != 1) |
|
| 132 | 132 | { |
| 133 | 133 | $type = isset($str[0]) ? $str[0] : ''; |
| 134 | 134 | |
| 135 | - if($type == '}') |
|
| 135 | + if ($type == '}') |
|
| 136 | 136 | { |
| 137 | 137 | $str = substr($str, 1); |
| 138 | 138 | } |
| 139 | - else if($type == 'N' && $str[1] == ';') |
|
| 139 | + else if ($type == 'N' && $str[1] == ';') |
|
| 140 | 140 | { |
| 141 | 141 | $value = null; |
| 142 | 142 | $str = substr($str, 2); |
| 143 | 143 | } |
| 144 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 144 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 145 | 145 | { |
| 146 | 146 | $value = $matches[1] == '1' ? true : false; |
| 147 | 147 | $str = substr($str, 4); |
| 148 | 148 | } |
| 149 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 149 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 150 | 150 | { |
| 151 | - $value = (int)$matches[1]; |
|
| 151 | + $value = (int) $matches[1]; |
|
| 152 | 152 | $str = $matches[2]; |
| 153 | 153 | } |
| 154 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 154 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 155 | 155 | { |
| 156 | - $value = (float)$matches[1]; |
|
| 156 | + $value = (float) $matches[1]; |
|
| 157 | 157 | $str = $matches[3]; |
| 158 | 158 | } |
| 159 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 159 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
| 160 | 160 | { |
| 161 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
| 162 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
| 161 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
| 162 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
| 163 | 163 | } |
| 164 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH) |
|
| 164 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH) |
|
| 165 | 165 | { |
| 166 | - $expectedLength = (int)$matches[1]; |
|
| 166 | + $expectedLength = (int) $matches[1]; |
|
| 167 | 167 | $str = $matches[2]; |
| 168 | 168 | } |
| 169 | - else if($type == 'O') |
|
| 169 | + else if ($type == 'O') |
|
| 170 | 170 | { |
| 171 | 171 | throw new \Exception('safe_unserialize: objects not supported'); |
| 172 | 172 | } |
| 173 | 173 | else |
| 174 | 174 | { |
| 175 | - throw new \Exception('safe_unserialize: unknown/malformed type: '.$type); |
|
| 175 | + throw new \Exception('safe_unserialize: unknown/malformed type: ' . $type); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - switch($state) |
|
| 178 | + switch ($state) |
|
| 179 | 179 | { |
| 180 | 180 | case 3: // in array, expecting value or another array |
| 181 | - if($type == 'a') |
|
| 181 | + if ($type == 'a') |
|
| 182 | 182 | { |
| 183 | - if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) |
|
| 183 | + if (count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) |
|
| 184 | 184 | { |
| 185 | 185 | throw new \Exception('safe_unserialize: array nesting exceeds ' . MAX_SERIALIZED_ARRAY_DEPTH); |
| 186 | 186 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $state = 2; |
| 193 | 193 | break; |
| 194 | 194 | } |
| 195 | - if($type != '}') |
|
| 195 | + if ($type != '}') |
|
| 196 | 196 | { |
| 197 | 197 | $list[$key] = $value; |
| 198 | 198 | $state = 2; |
@@ -202,31 +202,31 @@ discard block |
||
| 202 | 202 | throw new \Exception('safe_unserialize: missing array value'); |
| 203 | 203 | |
| 204 | 204 | case 2: // in array, expecting end of array or a key |
| 205 | - if($type == '}') |
|
| 205 | + if ($type == '}') |
|
| 206 | 206 | { |
| 207 | - if(count($list) < end($expected)) |
|
| 207 | + if (count($list) < end($expected)) |
|
| 208 | 208 | { |
| 209 | 209 | throw new \Exception('safe_unserialize: array size less than expected ' . $expected[0]); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | unset($list); |
| 213 | - $list = &$stack[count($stack)-1]; |
|
| 213 | + $list = &$stack[count($stack) - 1]; |
|
| 214 | 214 | array_pop($stack); |
| 215 | 215 | |
| 216 | 216 | // go to terminal state if we're at the end of the root array |
| 217 | 217 | array_pop($expected); |
| 218 | - if(count($expected) == 0) { |
|
| 218 | + if (count($expected) == 0) { |
|
| 219 | 219 | $state = 1; |
| 220 | 220 | } |
| 221 | 221 | break; |
| 222 | 222 | } |
| 223 | - if($type == 'i' || $type == 's') |
|
| 223 | + if ($type == 'i' || $type == 's') |
|
| 224 | 224 | { |
| 225 | - if(count($list) >= MAX_SERIALIZED_ARRAY_LENGTH) |
|
| 225 | + if (count($list) >= MAX_SERIALIZED_ARRAY_LENGTH) |
|
| 226 | 226 | { |
| 227 | 227 | throw new \Exception('safe_unserialize: array size exceeds ' . MAX_SERIALIZED_ARRAY_LENGTH); |
| 228 | 228 | } |
| 229 | - if(count($list) >= end($expected)) |
|
| 229 | + if (count($list) >= end($expected)) |
|
| 230 | 230 | { |
| 231 | 231 | throw new \Exception('safe_unserialize: array size exceeds expected length'); |
| 232 | 232 | } |
@@ -239,9 +239,9 @@ discard block |
||
| 239 | 239 | throw new \Exception('safe_unserialize: illegal array index type'); |
| 240 | 240 | |
| 241 | 241 | case 0: // expecting array or value |
| 242 | - if($type == 'a') |
|
| 242 | + if ($type == 'a') |
|
| 243 | 243 | { |
| 244 | - if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) |
|
| 244 | + if (count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) |
|
| 245 | 245 | { |
| 246 | 246 | throw new \Exception('safe_unserialize: array nesting exceeds ' . MAX_SERIALIZED_ARRAY_DEPTH); |
| 247 | 247 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $state = 2; |
| 253 | 253 | break; |
| 254 | 254 | } |
| 255 | - if($type != '}') |
|
| 255 | + if ($type != '}') |
|
| 256 | 256 | { |
| 257 | 257 | $data = $value; |
| 258 | 258 | $state = 1; |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - if(!empty($str)) |
|
| 266 | + if (!empty($str)) |
|
| 267 | 267 | { |
| 268 | 268 | throw new \Exception('safe_unserialize: trailing data in input'); |
| 269 | 269 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * @param string $str |
| 278 | 278 | * @return mixed |
| 279 | 279 | */ |
| 280 | -function safe_unserialize( $str ) |
|
| 280 | +function safe_unserialize($str) |
|
| 281 | 281 | { |
| 282 | 282 | // ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen() |
| 283 | 283 | if (function_exists('mb_internal_encoding') && |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | try { |
| 291 | 291 | $out = _safe_unserialize($str); |
| 292 | - } catch(Exception $e) { |
|
| 292 | + } catch (Exception $e) { |
|
| 293 | 293 | $out = ''; |
| 294 | 294 | } |
| 295 | 295 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | $base = log($size, 1024); |
| 159 | 159 | $suffixes = array('B', 'K', 'M', 'G', 'T'); |
| 160 | - return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)]; |
|
| 160 | + return round(pow(1024, $base - floor($base)), $precision) . ' ' . $suffixes[floor($base)]; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | protected function formatMicroSeconds($microSecs, $precision = 2) |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | $time = round($microSecs * 1000, $precision); |
| 167 | 167 | |
| 168 | 168 | if ($time >= 60 * 1000) { |
| 169 | - $time = round($time / 60 * 1000, $precision) .' m'; // m |
|
| 169 | + $time = round($time / 60 * 1000, $precision) . ' m'; // m |
|
| 170 | 170 | } elseif ($time >= 1000) { |
| 171 | - $time = round($time / 1000, $precision) .' s'; // s |
|
| 171 | + $time = round($time / 1000, $precision) . ' s'; // s |
|
| 172 | 172 | } else { |
| 173 | 173 | $time .= ' ms'; |
| 174 | 174 | } |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | private function setShortenZeroValuesRegexes() |
| 175 | 175 | { |
| 176 | - $zeroRegex = '0'. $this->unitsGroupRegex; |
|
| 177 | - $numOrPosRegex = '('. $this->numRegex .'|top|left|bottom|right|center) '; |
|
| 176 | + $zeroRegex = '0' . $this->unitsGroupRegex; |
|
| 177 | + $numOrPosRegex = '(' . $this->numRegex . '|top|left|bottom|right|center) '; |
|
| 178 | 178 | $oneZeroSafeProperties = array( |
| 179 | 179 | '(?:line-)?height', |
| 180 | 180 | '(?:(?:min|max)-)?width', |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | ); |
| 193 | 193 | |
| 194 | 194 | // First zero regex |
| 195 | - $regex = '/(^|;)('. implode('|', $oneZeroSafeProperties) .'):%s/Si'; |
|
| 195 | + $regex = '/(^|;)(' . implode('|', $oneZeroSafeProperties) . '):%s/Si'; |
|
| 196 | 196 | $this->shortenOneZeroesRegex = sprintf($regex, $zeroRegex); |
| 197 | 197 | |
| 198 | 198 | // Multiple zeroes regexes |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | // Process strings so their content doesn't get accidentally minified |
| 323 | 323 | $css = preg_replace_callback( |
| 324 | - '/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|'."(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", |
|
| 324 | + '/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|' . "(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", |
|
| 325 | 325 | array($this, 'processStringsCallback'), |
| 326 | 326 | $css |
| 327 | 327 | ); |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $dataStartIndex = $matchStartIndex + 4; // url( length |
| 376 | 376 | $searchOffset = $matchStartIndex + strlen($m[0][0]); |
| 377 | 377 | $terminator = $m[1][0]; // ', " or empty (not quoted) |
| 378 | - $terminatorRegex = '/(?<!\\\\)'. (strlen($terminator) === 0 ? '' : $terminator.'\s*') .'(\))/S'; |
|
| 378 | + $terminatorRegex = '/(?<!\\\\)' . (strlen($terminator) === 0 ? '' : $terminator . '\s*') . '(\))/S'; |
|
| 379 | 379 | |
| 380 | 380 | $ret .= substr($css, $substrOffset, $matchStartIndex - $substrOffset); |
| 381 | 381 | |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | $token = preg_replace('/\s+/S', '', $token); |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - $ret .= 'url('. $this->registerPreservedToken(trim($token)) .')'; |
|
| 393 | + $ret .= 'url(' . $this->registerPreservedToken(trim($token)) . ')'; |
|
| 394 | 394 | // No end terminator found, re-add the whole match. Should we throw/warn here? |
| 395 | 395 | } else { |
| 396 | 396 | $ret .= substr($css, $matchStartIndex, $searchOffset - $matchStartIndex); |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | */ |
| 412 | 412 | private function processCommentsCallback($matches) |
| 413 | 413 | { |
| 414 | - return '/*'. $this->registerCommentToken($matches[1]) .'*/'; |
|
| 414 | + return '/*' . $this->registerCommentToken($matches[1]) . '*/'; |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | */ |
| 422 | 422 | private function processOldIeSpecificMatrixDefinitionCallback($matches) |
| 423 | 423 | { |
| 424 | - return 'filter:progid:DXImageTransform.Microsoft.Matrix('. $this->registerPreservedToken($matches[1]) .')'; |
|
| 424 | + return 'filter:progid:DXImageTransform.Microsoft.Matrix(' . $this->registerPreservedToken($matches[1]) . ')'; |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | */ |
| 456 | 456 | private function processImportUnquotedUrlAtRulesCallback($matches) |
| 457 | 457 | { |
| 458 | - return '@import url('. $this->registerPreservedToken($matches[1]) .')'. $matches[2]; |
|
| 458 | + return '@import url(' . $this->registerPreservedToken($matches[1]) . ')' . $matches[2]; |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | /** |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | private function processComments($css) |
| 467 | 467 | { |
| 468 | 468 | foreach ($this->comments as $commentId => $comment) { |
| 469 | - $commentIdString = '/*'. $commentId .'*/'; |
|
| 469 | + $commentIdString = '/*' . $commentId . '*/'; |
|
| 470 | 470 | |
| 471 | 471 | // ! in the first position of the comment means preserve |
| 472 | 472 | // so push to the preserved tokens keeping the ! |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | // Keep empty comments after child selectors (IE7 hack) |
| 490 | 490 | // e.g. html >/**/ body |
| 491 | - if (strlen($comment) === 0 && strpos($css, '>/*'.$commentId) !== false) { |
|
| 491 | + if (strlen($comment) === 0 && strpos($css, '>/*' . $commentId) !== false) { |
|
| 492 | 492 | $css = str_replace($commentId, $this->registerPreservedToken(''), $css); |
| 493 | 493 | continue; |
| 494 | 494 | } |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | } else { |
| 525 | 525 | $ruleBody = substr($css, $blockStartPos + 1, $blockEndPos - $blockStartPos - 1); |
| 526 | 526 | $ruleBodyToken = $this->registerRuleBodyToken($this->processRuleBody($ruleBody)); |
| 527 | - $ret .= '{'. $ruleBodyToken .'}'; |
|
| 527 | + $ret .= '{' . $ruleBodyToken . '}'; |
|
| 528 | 528 | $searchOffset = $blockEndPos + 1; |
| 529 | 529 | } |
| 530 | 530 | |
@@ -613,8 +613,8 @@ discard block |
||
| 613 | 613 | $body = preg_replace('/([ :,(])\+(\.?\d+)/S', '$1$2', $body); |
| 614 | 614 | |
| 615 | 615 | // shorten ms to s |
| 616 | - $body = preg_replace_callback('/([ :,(])(-?)(\d{3,})ms/Si', function ($matches) { |
|
| 617 | - return $matches[1] . $matches[2] . ((int) $matches[3] / 1000) .'s'; |
|
| 616 | + $body = preg_replace_callback('/([ :,(])(-?)(\d{3,})ms/Si', function($matches) { |
|
| 617 | + return $matches[1] . $matches[2] . ((int) $matches[3] / 1000) . 's'; |
|
| 618 | 618 | }, $body); |
| 619 | 619 | |
| 620 | 620 | // Remove leading zeros from integer and float numbers. |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | // Shorten suitable shorthand properties with repeated values |
| 655 | 655 | $body = preg_replace( |
| 656 | 656 | array( |
| 657 | - '/(margin|padding|border-(?:width|radius)):('.$this->numRegex.')(?: \2)+( !|;|$)/Si', |
|
| 657 | + '/(margin|padding|border-(?:width|radius)):(' . $this->numRegex . ')(?: \2)+( !|;|$)/Si', |
|
| 658 | 658 | '/(border-(?:style|color)):([#a-z0-9]+)(?: \2)+( !|;|$)/Si' |
| 659 | 659 | ), |
| 660 | 660 | '$1:$2$3', |
@@ -662,8 +662,8 @@ discard block |
||
| 662 | 662 | ); |
| 663 | 663 | $body = preg_replace( |
| 664 | 664 | array( |
| 665 | - '/(margin|padding|border-(?:width|radius)):'. |
|
| 666 | - '('.$this->numRegex.') ('.$this->numRegex.') \2 \3( !|;|$)/Si', |
|
| 665 | + '/(margin|padding|border-(?:width|radius)):' . |
|
| 666 | + '(' . $this->numRegex . ') (' . $this->numRegex . ') \2 \3( !|;|$)/Si', |
|
| 667 | 667 | '/(border-(?:style|color)):([#a-z0-9]+) ([#a-z0-9]+) \2 \3( !|;|$)/Si' |
| 668 | 668 | ), |
| 669 | 669 | '$1:$2 $3$4', |
@@ -671,8 +671,8 @@ discard block |
||
| 671 | 671 | ); |
| 672 | 672 | $body = preg_replace( |
| 673 | 673 | array( |
| 674 | - '/(margin|padding|border-(?:width|radius)):'. |
|
| 675 | - '('.$this->numRegex.') ('.$this->numRegex.') ('.$this->numRegex.') \3( !|;|$)/Si', |
|
| 674 | + '/(margin|padding|border-(?:width|radius)):' . |
|
| 675 | + '(' . $this->numRegex . ') (' . $this->numRegex . ') (' . $this->numRegex . ') \3( !|;|$)/Si', |
|
| 676 | 676 | '/(border-(?:style|color)):([#a-z0-9]+) ([#a-z0-9]+) ([#a-z0-9]+) \3( !|;|$)/Si' |
| 677 | 677 | ), |
| 678 | 678 | '$1:$2 $3 $4$5', |
@@ -681,9 +681,9 @@ discard block |
||
| 681 | 681 | |
| 682 | 682 | // Lowercase some common functions that can be values |
| 683 | 683 | $body = preg_replace_callback( |
| 684 | - '/(?:attr|blur|brightness|circle|contrast|cubic-bezier|drop-shadow|ellipse|from|grayscale|'. |
|
| 685 | - 'hsla?|hue-rotate|inset|invert|local|minmax|opacity|perspective|polygon|rgba?|rect|repeat|saturate|sepia|'. |
|
| 686 | - 'steps|to|url|var|-webkit-gradient|'. |
|
| 684 | + '/(?:attr|blur|brightness|circle|contrast|cubic-bezier|drop-shadow|ellipse|from|grayscale|' . |
|
| 685 | + 'hsla?|hue-rotate|inset|invert|local|minmax|opacity|perspective|polygon|rgba?|rect|repeat|saturate|sepia|' . |
|
| 686 | + 'steps|to|url|var|-webkit-gradient|' . |
|
| 687 | 687 | '(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?(?:calc|(?:repeating-)?(?:linear|radial)-gradient))\(/Si', |
| 688 | 688 | array($this, 'strtolowerCallback'), |
| 689 | 689 | $body |
@@ -716,13 +716,13 @@ discard block |
||
| 716 | 716 | $css = preg_replace('/::(before|after|first-(?:line|letter))(\{|,)/Si', ':$1$2', $css); |
| 717 | 717 | |
| 718 | 718 | // Retain space for special IE6 cases |
| 719 | - $css = preg_replace_callback('/:first-(line|letter)(\{|,)/Si', function ($matches) { |
|
| 720 | - return ':first-'. strtolower($matches[1]) .' '. $matches[2]; |
|
| 719 | + $css = preg_replace_callback('/:first-(line|letter)(\{|,)/Si', function($matches) { |
|
| 720 | + return ':first-' . strtolower($matches[1]) . ' ' . $matches[2]; |
|
| 721 | 721 | }, $css); |
| 722 | 722 | |
| 723 | 723 | // Find a fraction that may used in some @media queries such as: (min-aspect-ratio: 1/1) |
| 724 | 724 | // Add token to add the "/" back in later |
| 725 | - $css = preg_replace('/\(([a-z-]+):([0-9]+)\/([0-9]+)\)/Si', '($1:$2'. self::QUERY_FRACTION .'$3)', $css); |
|
| 725 | + $css = preg_replace('/\(([a-z-]+):([0-9]+)\/([0-9]+)\)/Si', '($1:$2' . self::QUERY_FRACTION . '$3)', $css); |
|
| 726 | 726 | |
| 727 | 727 | // Remove empty rule blocks up to 2 levels deep. |
| 728 | 728 | $css = preg_replace(array_fill(0, 2, '/(\{)[^{};\/\n]+\{\}/S'), '$1', $css); |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | |
| 739 | 739 | // Lowercase some popular @directives |
| 740 | 740 | $css = preg_replace_callback( |
| 741 | - '/(?<!\\\\)@(?:charset|document|font-face|import|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?keyframes|media|'. |
|
| 741 | + '/(?<!\\\\)@(?:charset|document|font-face|import|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?keyframes|media|' . |
|
| 742 | 742 | 'namespace|page|supports|viewport)/Si', |
| 743 | 743 | array($this, 'strtolowerCallback'), |
| 744 | 744 | $css |
@@ -753,9 +753,9 @@ discard block |
||
| 753 | 753 | |
| 754 | 754 | // Lowercase some common pseudo-classes & pseudo-elements |
| 755 | 755 | $css = preg_replace_callback( |
| 756 | - '/(?<!\\\\):(?:active|after|before|checked|default|disabled|empty|enabled|first-(?:child|of-type)|'. |
|
| 757 | - 'focus(?:-within)?|hover|indeterminate|in-range|invalid|lang\(|last-(?:child|of-type)|left|link|not\(|'. |
|
| 758 | - 'nth-(?:child|of-type)\(|nth-last-(?:child|of-type)\(|only-(?:child|of-type)|optional|out-of-range|'. |
|
| 756 | + '/(?<!\\\\):(?:active|after|before|checked|default|disabled|empty|enabled|first-(?:child|of-type)|' . |
|
| 757 | + 'focus(?:-within)?|hover|indeterminate|in-range|invalid|lang\(|last-(?:child|of-type)|left|link|not\(|' . |
|
| 758 | + 'nth-(?:child|of-type)\(|nth-last-(?:child|of-type)\(|only-(?:child|of-type)|optional|out-of-range|' . |
|
| 759 | 759 | 'read-(?:only|write)|required|right|root|:selection|target|valid|visited)/Si', |
| 760 | 760 | array($this, 'strtolowerCallback'), |
| 761 | 761 | $css |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | // @import handling |
| 773 | - $css = preg_replace_callback($this->importRegex, function ($matches) use (&$imports) { |
|
| 773 | + $css = preg_replace_callback($this->importRegex, function($matches) use (&$imports) { |
|
| 774 | 774 | // Keep all @import at-rules found for later |
| 775 | 775 | $imports .= $matches[0]; |
| 776 | 776 | // Delete all @import at-rules |
@@ -778,7 +778,7 @@ discard block |
||
| 778 | 778 | }, $css); |
| 779 | 779 | |
| 780 | 780 | // @namespace handling |
| 781 | - $css = preg_replace_callback($this->namespaceRegex, function ($matches) use (&$namespaces) { |
|
| 781 | + $css = preg_replace_callback($this->namespaceRegex, function($matches) use (&$namespaces) { |
|
| 782 | 782 | // Keep all @namespace at-rules found for later |
| 783 | 783 | $namespaces .= $matches[0]; |
| 784 | 784 | // Delete all @namespace at-rules |
@@ -843,10 +843,10 @@ discard block |
||
| 843 | 843 | // Restore space after rgb() or hsl() function in some cases such as: |
| 844 | 844 | // background-image: linear-gradient(to bottom, rgb(210,180,140) 10%, rgb(255,0,0) 90%); |
| 845 | 845 | if (!empty($terminator) && !preg_match('/[ ,);]/S', $terminator)) { |
| 846 | - $terminator = ' '. $terminator; |
|
| 846 | + $terminator = ' ' . $terminator; |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - return '#'. implode('', $hexColors) . $terminator; |
|
| 849 | + return '#' . implode('', $hexColors) . $terminator; |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | /** |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | // Lowercase |
| 867 | - $hex = '#'. strtolower($hex); |
|
| 867 | + $hex = '#' . strtolower($hex); |
|
| 868 | 868 | |
| 869 | 869 | // Replace Hex colors with shorter color names |
| 870 | 870 | $color = array_key_exists($hex, $this->hexToNamedColorsMap) ? $this->hexToNamedColorsMap[$hex] : $hex; |
@@ -47,9 +47,9 @@ |
||
| 47 | 47 | } else { |
| 48 | 48 | $v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l); |
| 49 | 49 | $v1 = (2 * $l) - $v2; |
| 50 | - $r = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h + (1/3))); |
|
| 50 | + $r = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h + (1 / 3))); |
|
| 51 | 51 | $g = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h)); |
| 52 | - $b = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h - (1/3))); |
|
| 52 | + $b = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h - (1 / 3))); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | return array($r, $g, $b); |