Skip to content

Commit

Permalink
WIP #2: Seguridad.
Browse files Browse the repository at this point in the history
  • Loading branch information
duhow committed May 2, 2017
1 parent 184e45d commit a1c53ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@
}
}

$headers = apache_request_headers();
// Need this headers
$check = [
"Content-Type" => "application/json"
"Connection" => "keep-alive"
];

if($pass){
foreach($check as $h => $v){
$get = FALSE;
$h = strtolower($h);
// $v = strtolower($v);
foreach($headers as $ah => $av){
if($h == trim(strtolower($ah)) and $v == $av){
$get = TRUE;
break;
}
}
if(!$get){
$pass = FALSE;
break;
}
}
}

if(!$pass){
error_log("Access denied from " .$_SERVER['REMOTE_ADDR'] ." to bot " .$config['telegram']['username']);
http_response_code(401);
Expand Down
2 changes: 2 additions & 0 deletions robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /

0 comments on commit a1c53ae

Please sign in to comment.