-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
130 lines (114 loc) · 3.6 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
###################################
# ____ #
# ||| ||| /// \\\ ||| // |||||||||||||| #
# ||| /\ ||| ||| ||| ||| // ||| #
# ||| / \ ||| ||| ||| ||| \\ |||``````` #
# |||/ \||| \\\____/// ||| \\ |||||||||||||| #
# #
###################################
**/
// This File will be used for the global configuration of Link Stats
// the .htaccess will be generated from here to match changes
//***************
//* Files
// ********************
// * target list file name
// ********************
$targetsListFileName = "targs.list";
// ********************
// * target log file name
// ********************
$targetsFileName = "targs.log";
// *********************
// * default log file name
// *********************
$defaultsFileName = "defs.log";
// **************
// * Folders
// ******************
// * log folder name
// ******************
$logsFolderName = "pit";
// ********************
// * Configuration
// *****************************
// * allow target URL to be used
// *****************************
$allowTargetURL = true;
// *****************************
// * Do Not Log Repeated Visitors
// *****************************
$useUniqueLogs = false;
// *****************
// * stats URL part
// *****************
$statsUrlPart = "info";
// ******************************
// * userKey for api.userstack
// ******************************
$userStackApiKey = "f72b58b8f09ada350ced485b2444bdb8";
// *********************************
// * Htaccess Auto Update Section
// *********************************
// This will cause extended load times & security implications.
// Only added for first installation of custom htaccess file parameters
// *******************
// * update htaccess
// *******************
$actualPage = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$end = strripos($actualPage,'/');
$rootPath = substr($actualPage,0,$end);
$htaccessFile = '.htaccess';
$htaccess = file_get_contents($htaccessFile);
if (needsUpdate())
{
$rules = '#
# set home to index.php
DirectoryIndex index.php
#
# stop directory viewing
Options -Indexes
# stop log and target views
RewriteRule ^('.str_replace(".","\\.",$targetsListFileName).'|'.str_replace(".","\\.",$targetsFileName).'|'.str_replace(".","\\.",$defaultsFileName).') - [R=404,L]
ErrorDocument 404 '.$rootPath.'/home.php
#
# remove .php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\$ $1.php [NC]
';
if (!file_exists($htaccessFile))
{
$fp = fopen($htaccessFile, "w");
fclose($fp);
}
file_put_contents($htaccessFile, $rules);
}
// **************************
// * Check Htaccess Params
// **************************
function needsUpdate()
{
global $targetsFileName;
global $defaultsFileName;
global $targetsListFileName;
global $rootPath;
global $htaccess;
$needsNewConfig = false;
if (!hasConfig($targetsListFileName) |! hasConfig($targetsFileName) |! hasConfig($defaultsFileName) |! (strpos($htaccess, $rootPath) !== false))
{
$needsNewConfig = true;
}
return $needsNewConfig;
}
function hasConfig($configPart)
{
global $htaccess;
$partToCheck = str_replace(".","\\.",$configPart);
return strpos($htaccess,$partToCheck)!==false;
}
?>