-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.php
46 lines (38 loc) · 1017 Bytes
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
spl_autoload_register(function ($class_name) {
if (file_exists('.\\'.$class_name.'.php')){
include_once('.\\'.$class_name.'.php');
}
});
date_default_timezone_set('America/Sao_Paulo');
session_start();
define('HOME', 'APIRestFulCrud');
define('URL', 'http://localhost/');
define('HOME_URL', URL.HOME.'/');
define('DATABASE_CONFIGS', [
'HOST' => 'localhost',
'DB_NAME' => 'crud',
'USERNAME' => 'root',
'PASSWORD' => ''
]);
reescreverHTACCESS();
function reescreverHTACCESS()
{
$strHtaccess = "Options -Indexes
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php [NC,L]
SetEnvIf Referer ".HOME_URL." localreferer
<FilesMatch \.(jpg|jpeg|png|gif|css|json|gz|xml)$>
Order deny,allow
Deny from all
Allow from env=localreferer
</FilesMatch>
ErrorDocument 403 /".HOME."/index.php
";
$file = fopen('.htaccess', 'w');
fwrite($file, $strHtaccess);
fclose($file);
}
?>