This repository has been archived by the owner on Aug 1, 2019. It is now read-only.
/
class.hvconfig.inc
311 lines (309 loc) · 12.5 KB
/
class.hvconfig.inc
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<?php
#############################################################################
# HistView (c) 2003-2017 by Itzchak Rehberg #
# written by Itzchak Rehberg <devel AT izzysoft DOT de> #
# http://www.izzysoft.de/ #
# ------------------------------------------------------------------------- #
# This program is free software; you can redistribute and/or modify it #
# under the terms of the GNU General Public License (see doc/LICENSE) #
# ------------------------------------------------------------------------- #
# Configuration for HistView and Download Class #
#############################################################################
/* $Id$ */
/** Configuration for HistView and Download Class
* @package Api
* @class hvconfig
* @author Izzy (devel@izzysoft.de)
* @copyright (c) 2003-2017 by Itzchak Rehberg and IzzySoft
* @version $Revision$ $Date$
*/
class hvconfig {
function hvconfig() {
//====================================================[ General Settings ]===
/** Separator for arguments in the URL
* @class hvconfig
* @attribute string argsep
* @brief Though "&" works for most sites (and even is used by most sites),
* this does not conform to the W3C standards since it usually
* introduces some entity. So if you can, use ";" instead.
*/
$this->argsep = ";";
/** How to handle files to download: Use Download Class ("internal"),
* or directly link to them ("direct")
* @class hvconfig
* @attribute string dltype
*/
$this->dltype = "internal";
//===================================================[ HistView Settings ]===
//-----------------------------------------[ ChangeLog formatting issues ]---
/** ChangeLog Symbol for new feature
* @class hvconfig
* @attribute string plus
*/
$this->plus = "+";
/** ChangeLog Symbol for removed things
* @class hvconfig
* @attribute string minus
*/
$this->minus = "-";
/** ChangeLog Symbol for a change
* @class hvconfig
* @attribute string change
*/
$this->change = "*";
/** ChangeLog Symbol for a bug
* @class hvconfig
* @attribute string bug
*/
$this->bug = "!";
/** ChangeLog Symbol introducing the version number
* @class hvconfig
* @attribute string ver
*/
$this->ver = "v";
/** ChangeLog Symbol introducing a line to be ignored
* @class hvconfig
* @attribute string ignore
*/
$this->ignore = array("\$","#","--","==");
//----------------------------------------------------[ Icons to be used ]---
/** Icon for new feature
* @class hvconfig
* @attribute string iplus
*/
$this->iplus = "<IMG SRC='/icons/burst.gif' BORDER='0' ALT='+' TITLE='New!'>";
/** Icon for removed stuff
* @class hvconfig
* @attribute string iminus
*/
$this->iminus = "<IMG SRC='/icons/transfer.gif' BORDER='0' ALT='-' TITLE='Removed'>";
/** Icon for a change
* @class hvconfig
* @attribute string ichange
*/
$this->ichange = "<IMG SRC='/icons/image1.gif' BORDER='0' ALT='*' TITLE='Changed'>";
/** Icon for a bug
* @class hvconfig
* @attribute string ibug
*/
$this->ibug = "<IMG SRC='/icons/alert.red.gif' BORDER='0' ALT='!' TITLE='Bugfix'>";
/** Icon for tar files
* @class hvconfig
* @attribute string itar
*/
$this->itar = "<IMG SRC='icons/tgz.png' BORDER='0' ALT='*' TITLE='Tar Archive'>";
/** Icon for Debian packages
* @class hvconfig
* @attribute string ideb
*/
$this->ideb = "<IMG SRC='icons/deb.png' BORDER='0' ALT='*' TITLE='Debian Package'>";
/** Icon for RPM packages
* @class hvconfig
* @attribute string irpm
*/
$this->irpm = "<IMG SRC='icons/rpm.png' BORDER='0' ALT='*' TITLE='RPM Package'>";
//---------------------------------------------------------[ CSS classes ]---
/** CSS class for a new feature
* @class hvconfig
* @attribute string cplus
*/
$this->cplus = "feature";
/** CSS class for removed stuff
* @class hvconfig
* @attribute string cminus
*/
$this->cminus = "removed";
/** CSS class for a change comment
* @class hvconfig
* @attribute string cchange
*/
$this->cchange = "changed";
/** CSS class for a bug comment
* @class hvconfig
* @attribute string cbug
*/
$this->cbug = "bugfix";
//--------------------------------------------------[ Directory Settings ]---
/** Base directory. Most times this is your web servers DOCUMENT_ROOT.
* For details, see also histview::set_basedir(). Leave empty if you are
* using the download class (i.e. hvconfig::dltype is set to "internal").
* @class hvconfig
* @attribute string basedir
*/
$this->basedir = "";
/** Directory holding the *.deb files for download. This is often the same
* for all your apps, since it mostly points to the same repository
* @class hvconfig
* @attribute string debbase
*/
$this->debbase = "/var/repo/debian";
/** Directory holding the *.rpm files for download. This is often the same
* for all your apps, since it mostly points to the same repository
* @class hvconfig
* @attribute string rpmbase
*/
$this->rpmbase = "/var/repo/redhat.dist";
/** Directory holding your *.tar.gz files for download. If you have only one,
* it will be sufficient to define it here. Otherwise, you will have to
* override this setting in the corresponding PHP file
* @class hvconfig
* @attribute string tarbase
*/
$this->tarbase = "/var/www/downloads";
//-------------------------------------------------------[ Miscellaneous ]---
/** Default architecture for packages (RPM style - for Debian, it will be
* calculated based on this)
* @class hvconfig
* @attribute string arch
*/
$this->arch = "noarch";
/** Release Name - this is the (optional) string appended to the official
* version number, as you find it e.g. for Medibuntu with "medibuntu" in
* "googleearth-4.3_4.3.7204.836-0medibuntu1_i386.deb"
* @class hvconfig
* @attribute string relname
*/
$this->relname = "";
/** Highest release number to expect. The release number is the number
* following the relname (or, if relname is not set, the version).
* Example: "prog-0.3.5-1_i386.deb" and "prog-0.3.5-johnny1_i386.deb"
* both have the relnum set to "1". HistView is looping to find the latest
* release - so here we tell it when to stop at latest.
* @class hvconfig
* @attribute integer max_relnum
*/
$this->max_relnum = 9;
/** Map filenames to prognames. If the filename does not directly reflect
* the prog name you want to record into your stats table, you can set up
* a map entry here. Example: A new version of your lib package is not
* 100% backwards compatible, so you name the new packages "mylib2"
* instead of simply "mylib" as it was before. But for statistics you
* do not want a new progname. So in your hv-localconf.inc, you write:
* $this->map_names['mylib2'] = 'mylib';
* @class hvconfig
* @attribute array map_names (array[filename]=progname]
*/
$this->map_names = array();
//===================================================[ Download Settings ]===
/** Action for requests w/o referer
* Valid actions are: "pass" (no action), "deny" (reject request), "whois"
* (network check - and reject crawler networks)
* @class hvconfig
* @attribute string noRefererAction
*/
$this->noRefererAction = "pass";
/** IP Blacklist file (e.g. from http://sblam.com/blacklist.txt)
* @class hvconfig
* @attribute string blacklistfile
*/
$this->blacklistfile = dirname(__FILE__)."/hv_ipblacklist";
/** Action to perform when remote address is contained in blacklist file
* Valid actions are: "pass" (no action), "deny" (reject request)
* @class hvconfig
* @attribute string blacklistAction
*/
$this->blacklistAction = "pass";
/** Read crawler network names from a file
* @class hvconfig
* @attribute string crawlerfile
*/
$this->crawlerfile = dirname(__FILE__)."/histview_crawlernets";
/** Read bots to ignore from a file
* @class hvconfig
* @attribute string ignorefile
*/
$this->ignorefile = dirname(__FILE__)."/histview_ignorebots";
/** Read bots to reject from a file
* @class hvconfig
* @attribute string rejectfile
*/
$this->rejectfile = dirname(__FILE__)."/histview_rejectbots";
/** Header for rejected clients
* @class hvconfig
* @attribute string rejectheader
*/
$this->rejectheader = "HTTP/1.1 403 Forbidden";
/** Message to give to rejected clients
* @class hvconfig
* @attribute string rejectmsg
*/
$this->rejectmsg = "<html><head><title>403 Forbidden</title></head><body>Bots should not download files here.</body></html>";
/** Files to exclude
* @class hvconfig
* @attribute array excludes
*/
$this->excludes = array(".","..","files.htm","files.php","index.php","index.htm","index.html");
/** Icon to use by default. This must be a complete <IMG> tag.
* @class hvconfig
* @attribute string deficon
*/
$this->deficon = "<IMG SRC='/icons/generic.gif' ALT='[*]' BORDER='0'>";
/** URL directory where all other icons are stored
* @class hvconfig
* @attribute string icondir
*/
$this->icondir = "/images/icons";
/** Shall we use the statistic functions (download counter)?
* 0-No, 1-Yes
* @class hvconfig
* @attribute integer statisticsmode
*/
$this->statisticsmode = 1;
//-----------------------------------------------------[ Download Limits ]---
/** Limit the download per IP and prog to a given number within a given time.
* If set to 0, there will be no limit. If you want to use this, keep in
* mind there may be good reasons for multiple downloads of the same prog,
* e.g. if you provide multiple formats (RPM,DEB,TGZ) - so a good number
* for the limit is the number of formats provided plus a "chance" for trouble,
* say formats + 2
* @class hvconfig
* @attribute integer dlFileLimit
*/
$this->dlFileLimit = 0;
/** Time interval (in seconds) to monitor for limits. Make it small enough,
* but not too small. The best setting also depends on the average size of
* the files you offer for download, your setting for $dlFileLimit, and the
* assumed transfer rates. Say you assume a single download to be done in
* 30s, and you want to permit 5 downloads, they would take 2:30 minutes.
* If a bot/crawler is firing them, it's done by that. Add a bit for
* eventual trouble in routing, so you should be fine with 5min (300s).
* Remember that every *ATTEMPT* will be considered, so this value should
* be fine in this case.
* @class hvconfig
* @attribute integer dlTimeLimit
*/
$this->dlTimeLimit = 300;
/** Shall the database table recording data to check the download attempts
* for limiting them be purged automatically? This is recommended, so the
* sample config sets this to TRUE.
* @class hvconfig
* @attribute boolean dlLimitAutopurge
*/
$this->dlLimitAutopurge = TRUE;
//-----------------------------------------------------[ Database to use ]---
/** Database to store download statistics. Irrelevant (i.e. not used) when
* statistics are turned off (statisticsmode=0). To override these settings
* later, it won't work this way -- use the <code>db_setup</code> method
* instead! The array defined here has the elements host, database, user,
* pass, table
* @class hvconfig
* @attribute array db
*/
$this->db["host"] = "localhost";
$this->db["database"] = "webstat";
$this->db["user"] = "guest";
$this->db["pass"] = "guest";
$this->db["table"] = "downloads";
$this->db["limitTable"] = "hvlimits";
//------------------------------------------[ local/personal adjustments ]---
// to make your future updates easier, place your personal preferences into
// a personal file named "hv-localconf.inc" in the same directory as this
// file is located in - we include it here to override the defaults:
if (file_exists(dirname(__FILE__)."/hv-localconf.inc"))
include(dirname(__FILE__)."/hv-localconf.inc");
//------------------------------------------------------[ internal stuff ]---
// please don't touch this ;)
$this->hv_version = "0.1.7";
$this->homepage = "https://github.com/IzzySoft/HistView";
}
}