Popravek izgleda strani za cakalno vrsto (kliki na minuto)

This commit is contained in:
pero1203 2020-09-24 13:07:07 +02:00
parent 7b65aaaa37
commit ff0c2391c1
2 changed files with 65 additions and 5 deletions

View File

@ -258,9 +258,67 @@ if (!function_exists('is_countable')) {
// Preverimo klike na minuto pri izpolnjevanju anekte da se ne zapolni sql // Preverimo klike na minuto pri izpolnjevanju anekte da se ne zapolni sql
if(!checkClicksPerMinute()){ if(!checkClicksPerMinute()){
global $site_url;
http_response_code(425); $refresh_every = 5;
echo '<h1>Service Unavailable.</h1>';
echo '<!DOCTYPE html>';
echo '<html>';
echo '<head>';
echo ' <title>Server Limit Reached</title>';
echo ' <meta http-equiv="refresh" content="'.$refresh_every.'" />';
echo ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
echo ' <style>
body{
display: flex;
align-content: center;
height: 90vh;
flex-wrap: wrap;
align-content: center;
}
.main{
max-width: 1200px;
margin: 50px auto;
padding: 0 20px;
font-family: Montserrat, Arial, Sans-Serif !important;
color: #505050;
}
h1{
color: #1e88e5;
text-align: center;
margin: 30px 0;
}
hr{
margin: 50px 0;
border: 0;
border-top: 1px solid #ddeffd;
}
.loading{
margin: 50px 0;
text-align: center;
}
img{
width: 80px;
height: 80px;
}
</style>';
echo '</head>';
echo '<body><div class="main">';
echo ' <div class="loading"><img src="'.$site_url.'/public/img/icons/spinner.gif" /></div>';
echo ' <h1>Dosežena omejitev strežnika</h1>';
echo ' <h3>Prosimo, počakajte nekaj trenutkov. Trenutno je doseženo maksimalno število vnosov ankete na minuto.</h3>';
echo ' <hr>';
echo ' <h1>Server Limit Reached</h1>';
echo ' <h3>Please wait a few moments. Currently, the maximum number of survey entries per minute has been reached.</h3>';
echo '</div></body>';
echo '</html>';
die(); die();
} }
@ -1148,9 +1206,11 @@ function root_dir($file = null)
// Pri izpolnjevanju ankete preverimo stevilo klikov na minuto - ce jih je prevec, respondenta zavrnemo, drugace se lahko sql zafila in streznik ni vec odziven // Pri izpolnjevanju ankete preverimo stevilo klikov na minuto - ce jih je prevec, respondenta zavrnemo, drugace se lahko sql zafila in streznik ni vec odziven
function checkClicksPerMinute(){ function checkClicksPerMinute(){
global $clicks_per_minute_limit;
// Stevilo klikov/minuto na anketo (izpolnjevanje), ki jih se pustimo preden zablokiramo dostop // Ce maximum na minuto ni nastavljen ignoriramo limit
$click_minute_limit = 100; if(!isset($clicks_per_minute_limit) || $clicks_per_minute_limit == 0)
return true;
// Preverimo ce gre za izpolnjevanje ankete // Preverimo ce gre za izpolnjevanje ankete
if($_SERVER["SCRIPT_NAME"] != '/main/survey/index.php') if($_SERVER["SCRIPT_NAME"] != '/main/survey/index.php')
@ -1179,7 +1239,7 @@ function checkClicksPerMinute(){
} }
// Click count je ok - pustimo naprej // Click count je ok - pustimo naprej
if($click_count < $click_minute_limit){ if($click_count < $clicks_per_minute_limit){
$sqlI = sisplet_query("UPDATE srv_clicks SET click_count=click_count+1 WHERE ank_id='".$_GET['anketa']."'"); $sqlI = sisplet_query("UPDATE srv_clicks SET click_count=click_count+1 WHERE ank_id='".$_GET['anketa']."'");
return true; return true;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB