par
GeGaX » 29 avr. 2019, 13:49
Bonjour @rthur,
J'ai galéré mais j'arrive à quelque chose de correct même si ce n'est pas parfait (on peut toujours faire mieux).
# htaccess
# PHP v5.6.34
<IfDefine Free>
php56 1
</IfDefine>
# Directory protection
Options -Indexes
# .htaccess protection
<Files ".htaccess">
Order Deny,Allow
Deny from all
</Files>
# Error 404
ErrorDocument 404 /404.php
# code pour log 404
// Page / Folder / File requested
$request = $_SERVER["REQUEST_URI"];
if (empty($new_address)) {
// Select path log file
$file = $_SERVER["DOCUMENT_ROOT"].'/404.txt';
// Format date, hour, time
$date_hour = date("Y-m-d H:i:s", time());
// Infos of the request
$ip_request = $_SERVER["REMOTE_ADDR"];
$port_request = $_SERVER["REMOTE_PORT"];
$text = "\n".'Error 404 => '.$date_hour.' => Request : '.$request.' => IP: '.$ip_request.' => Port: '.$port_request;
// Add $text in $file
$fp = fopen($file, "a+");
fputs($fp, $text);
fclose($fp);
// Do not work at Free.fr
//$referer = $_SERVER["HTTP_REFERER"];
//$ip_client = $_SERVER["HTTP_CLIENT_IP"];
//$ip_forwarded = $_SERVER["HTTP_X_FORWARDED_FOR"]
};
# 404.txt
Error 404 => 2019-04-29 13:31:29 => Request : /DossierB/ => IP: aaa.bbb.ccc.ddd => Port: 58975
Error 404 => 2019-04-29 13:31:44 => Request : /file.kmz => IP: aaa.bbb.ccc.ddd => Port: 58977
Error 404 => 2019-04-29 13:32:12 => Request : /page.php => IP: aaa.bbb.ccc.ddd => Port: 58980
Error 404 => 2019-04-29 13:32:22 => Request : /page.html => IP: aaa.bbb.ccc.ddd => Port: 58982
Error 404 => 2019-04-29 13:33:32 => Request : /DossierB/file.kmz => IP: aaa.bbb.ccc.ddd => Port: 58994
Error 404 => 2019-04-29 13:33:48 => Request : /DossierB/page.php => IP: aaa.bbb.ccc.ddd => Port: 58996
Error 404 => 2019-04-29 13:33:56 => Request : /DossierB/page.html => IP: aaa.bbb.ccc.ddd => Port: 58998
Ces 3 fonctions php ne fonctionnent pas chez Free.fr, elles doivent être désactivées ...
$referer = $_SERVER["HTTP_REFERER"];
$ip_client = $_SERVER["HTTP_CLIENT_IP"];
$ip_forwarded = $_SERVER["HTTP_X_FORWARDED_FOR"];
Le code pour le log n'est pas de moi, je l'ai trouvé sur le net et je l'ai modifié à ma sauce.
Je te remercie pour m'avoir aiguillé / conseillé pour tout ça, c'est cool
# index.php
<?php
header("X-Robots-Tag: noindex, nofollow, noarchive");
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: ".gmdate('D, d M Y H:i:s', time() - 3600)." GMT"); // Proxies.
header("Content-Type: text/html; charset=utf-8");
?>
<!doctype html>
<html>
<head>
<title>MonSite.free.fr</title>
</head>
<body>
<style>
body {
background-image: url(/img/image.png);
background-size: cover;
}
</style>
</body>
</html>
# 404.php
<?php
header("X-Robots-Tag: noindex, nofollow, noarchive");
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: ".gmdate('D, d M Y H:i:s', time() - 3600)." GMT"); // Proxies.
header("Content-Type: text/html; charset=utf-8");
// Page / Folder / File requested
$request = $_SERVER["REQUEST_URI"];
if (empty($new_address)) {
// Select path log file
$file = $_SERVER["DOCUMENT_ROOT"].'/404.txt';
// Format date, hour, time
$date_hour = date("Y-m-d H:i:s", time());
// Infos of the request
$ip_request = $_SERVER["REMOTE_ADDR"];
$port_request = $_SERVER["REMOTE_PORT"];
$text = "\n".'Error 404 => '.$date_hour.' => Request : '.$request.' => IP: '.$ip_request.' => Port: '.$port_request;
// Add $text in $file
$fp = fopen($file, "a+");
fputs($fp, $text);
fclose($fp);
// Do not work at Free.fr
//$referer = $_SERVER["HTTP_REFERER"];
//$ip_client = $_SERVER["HTTP_CLIENT_IP"];
//$ip_forwarded = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
?>
<!doctype html>
<html>
<head>
<title>MonSite.free.fr - 404</title>
</head>
<body>
<style>
body {
background-image: url(/img/image_404.png);
background-size: cover;
}
</style>
</body>
</html>
Bonjour @rthur,
J'ai galéré mais j'arrive à quelque chose de correct même si ce n'est pas parfait (on peut toujours faire mieux).
# htaccess
[PHP]# PHP v5.6.34
<IfDefine Free>
php56 1
</IfDefine>
# Directory protection
Options -Indexes
# .htaccess protection
<Files ".htaccess">
Order Deny,Allow
Deny from all
</Files>
# Error 404
ErrorDocument 404 /404.php[/PHP]
# code pour log 404
[PHP] // Page / Folder / File requested
$request = $_SERVER["REQUEST_URI"];
if (empty($new_address)) {
// Select path log file
$file = $_SERVER["DOCUMENT_ROOT"].'/404.txt';
// Format date, hour, time
$date_hour = date("Y-m-d H:i:s", time());
// Infos of the request
$ip_request = $_SERVER["REMOTE_ADDR"];
$port_request = $_SERVER["REMOTE_PORT"];
$text = "\n".'Error 404 => '.$date_hour.' => Request : '.$request.' => IP: '.$ip_request.' => Port: '.$port_request;
// Add $text in $file
$fp = fopen($file, "a+");
fputs($fp, $text);
fclose($fp);
// Do not work at Free.fr
//$referer = $_SERVER["HTTP_REFERER"];
//$ip_client = $_SERVER["HTTP_CLIENT_IP"];
//$ip_forwarded = $_SERVER["HTTP_X_FORWARDED_FOR"]
};[/PHP]
# 404.txt
[PHP]Error 404 => 2019-04-29 13:31:29 => Request : /DossierB/ => IP: aaa.bbb.ccc.ddd => Port: 58975
Error 404 => 2019-04-29 13:31:44 => Request : /file.kmz => IP: aaa.bbb.ccc.ddd => Port: 58977
Error 404 => 2019-04-29 13:32:12 => Request : /page.php => IP: aaa.bbb.ccc.ddd => Port: 58980
Error 404 => 2019-04-29 13:32:22 => Request : /page.html => IP: aaa.bbb.ccc.ddd => Port: 58982
Error 404 => 2019-04-29 13:33:32 => Request : /DossierB/file.kmz => IP: aaa.bbb.ccc.ddd => Port: 58994
Error 404 => 2019-04-29 13:33:48 => Request : /DossierB/page.php => IP: aaa.bbb.ccc.ddd => Port: 58996
Error 404 => 2019-04-29 13:33:56 => Request : /DossierB/page.html => IP: aaa.bbb.ccc.ddd => Port: 58998[/PHP]
Ces 3 fonctions php ne fonctionnent pas chez Free.fr, elles doivent être désactivées ...
[PHP]$referer = $_SERVER["HTTP_REFERER"];
$ip_client = $_SERVER["HTTP_CLIENT_IP"];
$ip_forwarded = $_SERVER["HTTP_X_FORWARDED_FOR"];[/PHP]
Le code pour le log n'est pas de moi, je l'ai trouvé sur le net et je l'ai modifié à ma sauce.
Je te remercie pour m'avoir aiguillé / conseillé pour tout ça, c'est cool :wink:
# index.php
[PHP]<?php
header("X-Robots-Tag: noindex, nofollow, noarchive");
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: ".gmdate('D, d M Y H:i:s', time() - 3600)." GMT"); // Proxies.
header("Content-Type: text/html; charset=utf-8");
?>
<!doctype html>
<html>
<head>
<title>MonSite.free.fr</title>
</head>
<body>
<style>
body {
background-image: url(/img/image.png);
background-size: cover;
}
</style>
</body>
</html>
[/PHP]
# 404.php
[PHP]<?php
header("X-Robots-Tag: noindex, nofollow, noarchive");
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: ".gmdate('D, d M Y H:i:s', time() - 3600)." GMT"); // Proxies.
header("Content-Type: text/html; charset=utf-8");
// Page / Folder / File requested
$request = $_SERVER["REQUEST_URI"];
if (empty($new_address)) {
// Select path log file
$file = $_SERVER["DOCUMENT_ROOT"].'/404.txt';
// Format date, hour, time
$date_hour = date("Y-m-d H:i:s", time());
// Infos of the request
$ip_request = $_SERVER["REMOTE_ADDR"];
$port_request = $_SERVER["REMOTE_PORT"];
$text = "\n".'Error 404 => '.$date_hour.' => Request : '.$request.' => IP: '.$ip_request.' => Port: '.$port_request;
// Add $text in $file
$fp = fopen($file, "a+");
fputs($fp, $text);
fclose($fp);
// Do not work at Free.fr
//$referer = $_SERVER["HTTP_REFERER"];
//$ip_client = $_SERVER["HTTP_CLIENT_IP"];
//$ip_forwarded = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
?>
<!doctype html>
<html>
<head>
<title>MonSite.free.fr - 404</title>
</head>
<body>
<style>
body {
background-image: url(/img/image_404.png);
background-size: cover;
}
</style>
</body>
</html>
[/PHP]