=$brojPristupa) && ($fc[$i][1]+1>$sad)){ //echo $sad-$start; //flock($h, LOCK_UN); //fclose($h); $fc[$i][1] = $sad; error_log($_SERVER['REMOTE_ADDR']."|index.php lock ".$sad." | ".$fc[$i][2]); header('HTTP/1.1 429 Too Many Requests'); header('Retry-After: 3'); $right = false; } if($fc[$i][1]+1<$sad) { $fc[$i][2] = 1; $fc[$i][3] = $sad; //error_log($_SERVER['REMOTE_ADDR']."reset5 ".$sad); } else { $fc[$i][2]++; //$fc[$i][4] = $sad-$start; //error_log($_SERVER['REMOTE_ADDR']."+1 ".$sad); } $fc[$i][1] = $sad; //$fc[$i][4] = $sad-$start; $nadjen = true; //echo time().'nadjen'.$fc[$i][1]; }elseif($fc[$i][1]+2<$sad) { $fc[$i]=0; //error_log($_SERVER['REMOTE_ADDR']."reset15 ".$sad); }//else $fc[$i][4] = $sad-$start; $i++; } if(!$nadjen) { $fc[] = array($_SERVER['REMOTE_ADDR'].@$_SERVER['HTTP_CLIENT_IP'].@$_SERVER['HTTP_X_FORWARDED_FOR'], $sad, '1', $sad); //error_log($_SERVER['REMOTE_ADDR']."new ".$sad); } ftruncate ($h , 0 ); //print_r($fc); rewind($h); foreach ($fc as $fl) if($fl) fputcsv($h, $fl); flock($h, LOCK_UN); fclose($h); //error_log(print_r($fc, true).(microtime(true)-$start)); if(!$right) { sleep(2); exit("Slow down, please. Wait a little and try again."); } } //checkDDOS(); $Time = microtime(true); define ("IZNUTRA",1); //session_name("_pc"); //session_start(); $Error=''; include_once INCDIR.'/funkcije.php'; $_SESSION['prethodna_strana'] = kes('strana'); $_SESSION['strana'] = $_SERVER['REQUEST_URI']; $_SESSION["Markeri"]=array(0); $_SESSION["MarkeriCity"] = array(0); //$_SESSION['chaters'] = array(); $_SESSION['chatsStarted'] = 0; if(LOG_QUERIES) Mysql::skalarIzBaze("SET profiling = 1"); $Latinica = jelLatinica(); $Client = new Client(); header("Content-Type: text/html; charset=UTF-8", true); $cachefile = false; if(CACHE_ON AND !count($_POST) AND !$Client->isLogged()){ $file = md5($_SERVER['REQUEST_URI']); $cachedir =dirname(__FILE__).DIRECTORY_SEPARATOR. "sitecache"; $dir = $cachedir.DIRECTORY_SEPARATOR.substr($file, 0, 2); if(!is_dir($dir)) md($dir); $fn = pocistiURL($_SERVER['REQUEST_URI']).$file; $cachefile =$dir.DIRECTORY_SEPARATOR.$Latinica.$fn.'.gz'; $resettime = @filemtime($cachedir.DIRECTORY_SEPARATOR.'resetcache.txt'); if(file_exists($cachefile) AND ($resettime evalb("?>".file_get_contents($cachefile.'.txt')))){ $HTTP_ACCEPT = @$_SERVER['HTTP_ACCEPT_ENCODING']; if (headers_sent()) { $encoding = false; } elseif (strpos($HTTP_ACCEPT, 'x-gzip') !== false) { $encoding = 'x-gzip'; } elseif (strpos($HTTP_ACCEPT, 'gzip') !== false) { $encoding = 'gzip'; } else { $encoding = false; } if( $encoding ) { header('Content-Encoding: ' . $encoding); header('Vary: Accept-Encoding'); header('Content-Length: '.(filesize($cachefile)+4)); print("\x1f\x8b\x08\x00\x00\x00\x00\x00"); echo file_get_contents($cachefile); $naziv = "cache-gz"; } else{ echo gzuncompress(file_get_contents($cachefile)); $naziv = "cache-nogz"; } Mysql::skalarIzBaze("INSERT INTO log (naziv, ip, url, pocetak, agent, time, kraj) VALUES ('c$encoding', ".qs(@$_SERVER[REMOTE_ADDR]).", ".qs(@$_SERVER[REQUEST_URI]).", NOW(),".qs(@$_SERVER[HTTP_USER_AGENT]).", ".(microtime(true) - $Time).", NOW()) "); dbClose(); exit; } } function CirLatOnly($nov){ $cir=array('Ćirlica', 'А', 'а', 'Б', 'б', 'В', 'в', 'Г', 'г', 'Д', 'д', 'Ђ', 'ђ', 'Е', 'е', 'Ж', 'ж', 'З', 'з', 'И', 'и', 'Ј', 'ј', 'К', 'к', 'Л', 'л', 'Љ', 'љ', 'М', 'м', 'Н', 'н', 'Њ', 'њ', 'О', 'о', 'П', 'п', 'Р', 'р', 'С', 'с', 'Т', 'т', 'Ћ', 'ћ', 'У', 'у', 'Ф', 'ф', 'Х', 'х', 'Ц', 'ц', 'Ч', 'ч', 'Џ', 'џ', 'Ш', 'ш', 'Ćirlica'); $lat=array('Ћирилица', 'A', 'a', 'B', 'b', 'V', 'v', 'G', 'g', 'D', 'd', 'Ð', 'đ', 'E', 'e', 'Ž', 'ž', 'Z', 'z', 'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'LJ', 'lj', 'M', 'm', 'N', 'n', 'NJ', 'nj', 'O', 'o', 'P', 'p', 'R', 'r', 'S', 's', 'T', 't', 'Ć', 'ć', 'U', 'u', 'F', 'f', 'H', 'h', 'C', 'c', 'Č', 'č', 'Dž', 'dž', 'Š', 'š', 'Ћирилица'); $out=str_replace($cir,$lat,$nov); return $out; } $St = dajStranu(dajParams()); // print_r(dajParams()); //print_r(dajPurlPart(0)); $Jezik = $St->dajJezik(); $_REQUEST['st'] = $St->dajUID(); ob_start(/*'mb_output_handler'*/ $Latinica ? "CirLatOnly" : 'mb_output_handler', $cachefile ? 0 : 4096); include_once './'.INCDIR.'/_strana_sablon.php'; //$buffer = ob_get_clean(); $buffer = ob_get_flush(); //if($Latinica) $buffer = CirLat($buffer); //echo $buffer; if($cachefile && ($_REQUEST['st']!=7) && ($_REQUEST['st']!=6)){ //substr(gzcompress($buffer, 3), 0, -4) @file_put_contents($cachefile, gzcompress($buffer, 6) , LOCK_EX); @file_put_contents($cachefile.'.txt', $St->dajCacheTime() , LOCK_EX); } Mysql::skalarIzBaze("INSERT DELAYED INTO log (naziv, ip, url, pocetak, agent, time, kraj) VALUES ('', ".qs(@$_SERVER[REMOTE_ADDR]).", ".qs(@$_SERVER[REQUEST_URI]).", NOW(), ".qs(@$_SERVER[HTTP_USER_AGENT]).", ".(microtime(true) - $Time).", NOW()) "); if(LOG_QUERIES){ $f=fopen($_SERVER["DOCUMENT_ROOT"].DIRECTORY_SEPARATOR.INCDIR.DIRECTORY_SEPARATOR."tmp".DIRECTORY_SEPARATOR.'query-log.csv', 'a'); fputcsv($f, array(count($CONN))); $pr = Mysql::nizIzBaze("SHOW PROCESSLIST"); foreach ($pr as $p) fputcsv($f, $p); $s = array(); $pr = Mysql::nizIzBaze("SHOW PROFILES"); foreach ($pr as $p) $s[] = $p['Duration']; array_multisort($s, SORT_DESC, $pr); foreach ($pr as $p) fputcsv($f, $p); fclose($f); } dbClose(); if(_DEBUG) echo $Error; ?>