| INSTALL |
| 1 | TightURL |
| 2 | Installation |
| 3 | version 0.1.3.2 |
| 4 | |
| 5 | Installing TightURL |
| 6 | ------------------- |
| 7 | |
| 8 | 1. Untar the file: tar zxvf tighturl-0.1.3.2.tar.gz or |
| 9 | unzip the file: unzip tighturl-0.1.3.2.zip |
| 10 | |
| 11 | 2. Move the files in the directory to where you want to run |
| 12 | your installation of TightURL. |
| 13 | |
| 14 | 3. Rename tighturl.php to index.php if desired. (highly desirable!) |
| 15 | |
| 16 | 4. A. New installations should move the contents of the ./local directory |
| 17 | into the main TightURL directory. |
| 18 | B. Upgrades should review the contents of ./local and adjust existing |
| 19 | config file and templates as seen fit. Things probably won't work |
| 20 | correctly unless you modify the tighturl.config.inc in ./local with |
| 21 | your desired settings and use that. |
| 22 | |
| 23 | 5. New installations should create a MySQL database and user if |
| 24 | necessary. If you don't know how, (we were all beginners once) it |
| 25 | goes something like this: |
| 26 | mysql -u root -p |
| 27 | Enter password: ********** |
| 28 | mysql> create database tighturl; |
| 29 | mysql> quit |
| 30 | |
| 31 | If you also need to add a MySQL user (you should never use "root"), |
| 32 | then before you quit MySQL, you should enter a command like this: |
| 33 | |
| 34 | mysql> grant all on dbname.* to dbuser@localhost identified by 'pass'; |
| 35 | |
| 36 | substituting the name of your database for "dbname", the name of the |
| 37 | MySQL user you want to create for "dbuser", and the desired password |
| 38 | in place of "pass". |
| 39 | |
| 40 | 6. Edit the config settings in tighturl.config.inc.php as needed. |
| 41 | New installs will need to change at least the MySQL database settings. |
| 42 | See 'Configuration Settings' below. |
| 43 | |
| 44 | 7. Run the script: tighturl-install.php |
| 45 | When this is done, you will need to remove or rename this script |
| 46 | before your TightURL installation will work. |
| 47 | |
| 48 | 8. If you can set a custom 404 page for your Web site/directory, you |
| 49 | can set it to tighturl/index.php and get shorter URLs. To take |
| 50 | advantage of this, set $FOFMethod=TRUE in tighturl.config.inc.php. |
| 51 | |
| 52 | 9. Change the $svcname in tighturl.config.inc.php if desired. |
| 53 | |
| 54 | 10. Edit the master site HTML template tighturl.tmpl if desired. |
| 55 | See 'TightURL Templates' below. |
| 56 | |
| 57 | 11. Edit the HTML sub-templates if desired. These are: |
| 58 | A. tighturl.main.tmpl : HTML shown for your TightURL homepage |
| 59 | B. tighturl.save.tmpl : HTML shown when a URL is saved |
| 60 | C. tighturl.help.tmpl : HTML shown for Help info (may not exist yet) |
| 61 | D. tighturl.faq.tmpl : HTML shown for FAQ (may not exist yet) |
| 62 | D. tighturl.blacklist.tmpl : HTML shown for blacklisted URL submissions |
| 63 | D. tighturl.policy.tmpl : HTML shown for URL submissions that violate |
| 64 | your local policy. |
| 65 | |
| 66 | See 'TightURL Templates' below for more information. |
| 67 | |
| 68 | Configuration Settings |
| 69 | ---------------------- |
| 70 | |
| 71 | These are the configuration (variables) settings that can and should |
| 72 | be changed in tighturl.config.inc.php : |
| 73 | |
| 74 | MySQL: |
| 75 | $dbhost : DNS name of your MySQL server |
| 76 | $dbuser : MySQL user name |
| 77 | $dbpass : password for MySQL user name |
| 78 | $dbname : database containing TightURL's table |
| 79 | $dbtable : name of TightURL's table |
| 80 | |
| 81 | Operating modes: |
| 82 | $FOFMethod : Use 404-Method or mod_rewrite to compress TightURLs |
| 83 | 0 (FALSE) = full URL path (not compressed) TightURLs |
| 84 | 1 = 404-Method compressed TightURLs |
| 85 | 2 = mod_rewrite compressed TightURLs |
| 86 | |
| 87 | URIBL variables: |
| 88 | $uribl : Array of URIBLs to check |
| 89 | $uriblurl : Array of Web sites corresponding to URIBLs checked |
| 90 | |
| 91 | Text strings and style variables: |
| 92 | $svcname : One-word name for your TightURL service |
| 93 | $verbtext : One-word name for the act of tightening URLs |
| 94 | $pasttext : Past-tense name for a tightended URL |
| 95 | $tagline : "tag line" for your TightURL service |
| 96 | $headcolor : Color for the TightURL <H1> HTML header |
| 97 | $tablecolor : Color for the table the URL input field appears in |
| 98 | $copystart : 4-digit year of start of your copyright on your content. |
| 99 | defaults to current year if not given. |
| 100 | |
| 101 | NEVER CHANGE SETTINGS IN tighturl.php OR YOU WILL LOSE YOUR CHANGES |
| 102 | any time you upgrade to a newer version of TightURL. Always put your |
| 103 | configuration settings in tighturl.config.inc.php where they will |
| 104 | survive upgrades. Values in tighturl.config.inc.php override the |
| 105 | defaults (garbage) in tinyurl.php . |
| 106 | |
| 107 | Reserved URLs |
| 108 | ------------- |
| 109 | |
| 110 | Because we use Base-36 numbers as TightURL IDs, as time goes on, |
| 111 | certain desirable URLs will be issued that we might want to keep |
| 112 | for ourselves. |
| 113 | |
| 114 | For instance, the letters 'faq' are well-understood around the Internet |
| 115 | to mean "Frequently Answered Questions". We might want to use the URL |
| 116 | http://example.com/faq to point to our FAQ page, rather than issue it |
| 117 | as a regular TightURL to a random visitor. Reserved URLs allow you to |
| 118 | specify Base-36 IDs that should never be issued as TightURLs. |
| 119 | |
| 120 | There are two kinds of Reserved URLs. External (implicit) and Internal |
| 121 | (explicit) Reserved URLs. |
| 122 | |
| 123 | External Reserved URLs: |
| 124 | |
| 125 | Any URL which exists in your Web space will be served up by |
| 126 | your Web server, and not TightURL. For this reason, any URL |
| 127 | reasonably within your TightURL ID space that you want to use |
| 128 | with your TightURL site itself should be reserved so that you |
| 129 | don't issue a TightURL to anyone that won't actually work. |
| 130 | |
| 131 | For example, if you have a directory named: /www/example.com/faq |
| 132 | your Web server will attempt to serve index.html from within |
| 133 | that directory, and TightURL will never even see the request. |
| 134 | This kind of reservation is implicit, and TightURL must be |
| 135 | made aware of it. |
| 136 | |
| 137 | Internal Reserved URLs: |
| 138 | |
| 139 | Any URL which does not exist in your Web space but is Reserved |
| 140 | within TightURL will cause TightURL to look for a correspondingly |
| 141 | named TightURL Template, and serve that. If the template does |
| 142 | not exist, a 404 error is generated. |
| 143 | |
| 144 | For example, if you have reserved the ID 'faq', and TightURL |
| 145 | sees a request for this reserved ID, it will attempt to open a |
| 146 | template named tighturl.faq.tmpl and return that to the browser. |
| 147 | |
| 148 | It is VERY IMPORTANT that you decide what your Reserved URLs will be |
| 149 | before your TightURL service is put into operation, or else you run |
| 150 | the risk of wanting to reserve a URL that's already been issued as |
| 151 | a TightURL to someone. For example, by the time you've issued your |
| 152 | 19826th TightURL, you will have lost the opportunity to use 'faq' as |
| 153 | a Reserved URL, because decimal (Base-10) number '19826' is number |
| 154 | 'faq' in sexigesimal (Base-36). |
| 155 | |
| 156 | Reserving URLs: |
| 157 | |
| 158 | To reserve a URL, add it to the configuration array $ReservedURL . |
| 159 | The following URLs are reserved by default: |
| 160 | |
| 161 | faq, help, code, source, docs, cvs, arch, url, |
| 162 | about, admin, setup, svn |
| 163 | |
| 164 | There is little point in reserving URLs larger than 5 charcters long. |
| 165 | The first 6 character ID is '100000' sexigesimal, which would be far |
| 166 | past your 60 millionth TightURL issued. Since each additional Reserved |
| 167 | URL adds a little more processing time, you don't want to add URLs |
| 168 | that will never be issued anyway. |
| 169 | |
| 170 | TightURL presently uses the ID "api" with the template that describes |
| 171 | how to use the TightURL API. It would be the 13878th TightURL in the |
| 172 | system, which can easily be achieved on a moderately-used corporate- |
| 173 | wide TightURL installation. |
| 174 | |
| 175 | TightURL Templates |
| 176 | ------------------ |
| 177 | TightURL supports a simple variable-substitution templating system with |
| 178 | one level of template nesting. |
| 179 | |
| 180 | The outer template is *always* the main site template, tighturl.tmpl . |
| 181 | This template controls your site design and is *always* used to generate |
| 182 | output pages to the browser. |
| 183 | |
| 184 | The inner template is *always* one of the following sub-templates |
| 185 | (or no sub-template): |
| 186 | tighturl.main.tmpl : HTML shown for your TightURL homepage |
| 187 | tighturl.save.tmpl : HTML shown when a URL is saved |
| 188 | tighturl.help.tmpl : HTML shown for Help info (may not exist yet) |
| 189 | (none) : No inner template. |
| 190 | |
| 191 | Please note that many screens are generated using only the main site |
| 192 | (outer) template. All error screens are generated this way. |
| 193 | |
| 194 | The variables supported by TightURL Templates are: |
| 195 | |
| 196 | $HTML : In the innermost or only template, replaced by a HTML |
| 197 | message from TightURL. In an outer template, it is |
| 198 | replaced by contents of the inner (sub-)template. |
| 199 | You should never remove this variable from a template. |
| 200 | $PARM : Parameter when 404-Method not used. |
| 201 | $URL : Replaced by browser submitted URL. |
| 202 | $URLLEN : Replaced by lenghth of the submitted URL. |
| 203 | $TIGHTURL : Replaced by TightURL generated by the submission. |
| 204 | $TIGHTURLLEN : Replaced by length of the generated TightURL. |
| 205 | $DIFF : Replaced by difference in length between URLs. |
| 206 | $INPUT : Replaced by submitted URL for use when there has |
| 207 | been an error detected in the input. |
| 208 | $SVCNAME : Replaced by name chosen for your TightURL service. |
| 209 | $HEADCOLOR : Replaced by color value chosen for <H1> HTML tags. |
| 210 | $TABLECOLOR : Replaced by color value chosen for the table. |
| 211 | $TAGLINE : Replaced by "tag line" for your TightURL service. |
| 212 | $CPASTTEXT : Replaced by capitalized past tense description of |
| 213 | tightened URLs. |
| 214 | $PASTTEXT : Same as $CPASTTEXT, but first letter not capitalized. |
| 215 | $CVERBTEXT : Replaced by capitalized verb description of your |
| 216 | TightURL service. |
| 217 | $VERBTEXT : Same as $CVERBTEXT, but first letter not capitalized. |
| 218 | $COPYRIGHT : Replaced by generated copyright string created from |
| 219 | $copystart config value and current year. |
| 220 | $URIBLS : Replaced by HTML showing URIBLs being checked. |
| 221 | $HOST : Replaced by hostname of Web site. |
| 222 | $SELF : Replaced by the URL path to the TightURL script. |
| 223 | $BBSTATS : Replaced by Bad Behavior stats when BB2 is enabled. |
| 224 | $TIGHTURLVER : Replaced by the TightURL running version number. |
| 225 | |
| 226 | TightURL Operating Modes |
| 227 | ------------------------ |
| 228 | |
| 229 | TightURL supports three distinct "operating modes". These are known as |
| 230 | "basic", "mod_rewrite", and "404 Method". You want to avoid changing your |
| 231 | operating mode later, as changes to or from basic mode will cause all your |
| 232 | URLs to change. Changes between mod_rewrite and the 404 Method do not |
| 233 | result in changes to your URLs, but your operating mode is something you |
| 234 | should choose carefully and then stick with. |
| 235 | |
| 236 | Using basic mode |
| 237 | ---------------- |
| 238 | |
| 239 | This operating mode produces URLs that follow this pattern: |
| 240 | http://example.com/?i=id or http://example.com/yoursite/?i=id |
| 241 | |
| 242 | No changes to httpd.conf or .htaccess are required for basic mode, but |
| 243 | this produces slightly longer and more inconvenient to type URLs. If you |
| 244 | can use mod_rewrite or the 404 Method, it is highly recommended that you |
| 245 | do so. |
| 246 | |
| 247 | |
| 248 | Using mod_rewrite with Apache |
| 249 | ----------------------------- |
| 250 | |
| 251 | PLEASE NOTE: There was a longstanding bug in Apache mod_rewrite that |
| 252 | probably makes TightURL or anything like it unable to work except with |
| 253 | what are still very recent versions of Apache. |
| 254 | https://issues.apache.org/bugzilla/show_bug.cgi?id=34602 |
| 255 | |
| 256 | Users are encouraged to use "404 Mode", and especially in the event |
| 257 | their Apache version has the bug shown above. |
| 258 | |
| 259 | |
| 260 | This operating mode produces URLs that follow this pattern: |
| 261 | http://example.com/id or http://example.com/yoursite/id |
| 262 | |
| 263 | TightURL can be used with mod_rewrite by adding the following lines to |
| 264 | httpd.conf or if you can't modify httpd.conf, you can use .htaccess : |
| 265 | |
| 266 | <IfModule mod_rewrite.c> |
| 267 | RewriteEngine On |
| 268 | RewriteRule ^view/([a-z0-9-]+)/?$ index.php?v=$1 [NC,L] |
| 269 | RewriteRule ^([a-z0-9-]+)/?$ index.php?i=$1 [NC,L] |
| 270 | </IfModule> |
| 271 | |
| 272 | If you change the parameters (form variables) from "i" for the TightURL ID |
| 273 | to look up, and "v" for the TightURL ID to preview, then you'll need to |
| 274 | adjust these lines accordingly. |
| 275 | |
| 276 | Be aware that http.conf is read once when the Web server is started or |
| 277 | reloaded, but .htaccess must be read and parsed for *every request*, so |
| 278 | you always want to use http.conf over .htaccess whenever possible. |
| 279 | |
| 280 | |
| 281 | Using "The 404-Method" with Apache |
| 282 | ---------------------------------- |
| 283 | |
| 284 | This operating mode produces URLs that follow this pattern: |
| 285 | http://example.com/id or http://example.com/yoursite/id |
| 286 | |
| 287 | The "404-Method" refers to instructing your Web server to direct all |
| 288 | requests that generate a "Not found" error (which is an HTTP error code |
| 289 | 404) to the TightURL script. By doing this, TightURL will run for URLs in |
| 290 | your TightURL site that don't exist, such as would be the case for |
| 291 | http://example.com/tighturl.php/xxyy |
| 292 | |
| 293 | The xxyy is a TightURL ID number, not an actual Web page in your site. By |
| 294 | sending non-existent page requests to the TightURL script, you can look up |
| 295 | those IDs and issue an HTTP Redirect without the need for mod_rewrite. |
| 296 | |
| 297 | To use the 404-Method, set $FOFMethod=1 in tighturl.config.inc.php. |
| 298 | |
| 299 | Using .htaccess |
| 300 | --------------- |
| 301 | |
| 302 | Then put this in your .htaccess file: |
| 303 | |
| 304 | ErrorDocument 404 /index.php |
| 305 | |
| 306 | This change should take effect immediately after saving .htaccess . |
| 307 | If it doesn't work, make sure you have AllowOverride FileInfo on in the |
| 308 | directory you're running TightURL from. |
| 309 | |
| 310 | Using httpd.conf |
| 311 | ---------------- |
| 312 | |
| 313 | Alternatively to using .htaccess (and for improved performance), put the |
| 314 | following line in your httpd.conf in the appropriate Directory section |
| 315 | (and VirtualHost if applicable): |
| 316 | |
| 317 | ErrorDocument 404 /index.php |
| 318 | |
| 319 | You will need to reload your Apache configuration for this change to take |
| 320 | effect. |
| 321 | |
| 322 | See the Apache documentation for more information. |
| 323 | http://httpd.apache.org/docs/mod/core.html#errordocument |
| 324 | http://httpd.apache.org/docs/mod/core.html#allowoverride |
| 325 | |
| 326 | |
| 327 | AntiAbuse: Generally if your web site is connected to the Internet and |
| 328 | and the TightURL library can make outbound network connections, you should |
| 329 | run with the antiabuse system turned on. When the antiabuse system is |
| 330 | turned off, virtually everything will be accepted into your database that |
| 331 | can be shortened. |
| 332 | |
| 333 | NetChecks: Generally if your web site is connected to the Internet and |
| 334 | and the TightURL library can make outbound network connections, you should |
| 335 | run with the netchecks system turned on. If your site has no connectivity |
| 336 | or ability to make outbound network connections, you should turn the |
| 337 | netchecks off. When netchecks are off, TightURL will not be able to resolve |
| 338 | URLs through redirections to their final destination, check for new versions |
| 339 | of TightURL, or check submitted URLs against URI blacklists. |
| 340 | |
| 341 | |
| 342 | Adding more URIBLs |
| 343 | ------------------ |
| 344 | |
| 345 | In the event other URIBLs beside SURBL become available, and you wish |
| 346 | to check those also, edit $uribl and $uriblurl in |
| 347 | tighturl.config.inc.php . |
| 348 | |
| 349 | To add a new URIBL named uribl.example.com whose Web site is located |
| 350 | at http://www.example.com |
| 351 | |
| 352 | Change this: |
| 353 | |
| 354 | $uribl = array("multi.surbl.org"); |
| 355 | $uriblurl = array("www.surbl.org"); |
| 356 | |
| 357 | To this: |
| 358 | |
| 359 | $uribl = array("multi.surbl.org","uribl.example.com"); |
| 360 | $uriblurl = array("www.surbl.org","www.example.com"); |
| 361 | |
| 362 | You can add as many URIBLs as you want this way. |
| 363 | |
| 364 | Squeezing Your Base URL Down to the Smallest Possible Size |
| 365 | ---------------------------------------------------------- |
| 366 | The "base URL" is the fixed portion of your TightURL URLs. This |
| 367 | would be everything up to the TightURL ID at the end of the URL. |
| 368 | The length of the TightURL ID will start out at 1 character and may |
| 369 | get up to 6 characters after tens of millions of TightURLs have been |
| 370 | created in your system. (Most TightURL installations are not |
| 371 | expected to get into the tens of thousands, let alone tens of |
| 372 | millions) Because the ID is at most 6 characters, the most |
| 373 | important thing you can do to get the shortest URL possible is to |
| 374 | "squeeze" as many characters out of the base portion of the URL |
| 375 | as possible. |
| 376 | |
| 377 | The following URL is "unfortunately long", but should still allow |
| 378 | you to create tens of millions of TightURLs that can be used without |
| 379 | wrapping in most e-mail programs. It is 72 characters long: |
| 380 | |
| 381 | http://www.a-really-quite-long-name.com/~example01/tighturl.php?i=abcdef |
| 382 | |
| 383 | This URL is not only unfortunately long, it is unnecessarily long |
| 384 | as well. The following optimizations can be attempted: |
| 385 | |
| 386 | 1. Drop the "www." |
| 387 | 2. Rename tighturl.php to something shorter. |
| 388 | 3. Rename tighturl.php to index.php and put it in a 1-character subdir. |
| 389 | |
| 390 | If optimizations 1 and 3 are successfully applied, we get a 58 |
| 391 | character URL (14 characters shorter): |
| 392 | |
| 393 | http://a-really-quite-long-name.com/~example01/t/?i=abcdef |
| 394 | |
| 395 | A more optimistic domain name (39 characters): |
| 396 | |
| 397 | http://example.com/~example/t/?i=abcdef |
| 398 | |
| 399 | Ideal scenario with own domain (29 characters): |
| 400 | |
| 401 | http://tighturl.com/?i=abcdef |
| 402 | |
| 403 | If you are able to use Mod_Rewrite or the 404-Method as shown |
| 404 | above, you can also drop the "?i=" portion of the URL, saving |
| 405 | another 3 characters. |
| 406 | |
| 407 | Mod_Rewrite or 404-Method scenario (26 characters): |
| 408 | |
| 409 | http://tighturl.com/abcdef |
| 410 | |
| 411 | This also works with the "unfortunately long" URL, bringing |
| 412 | it down to 56 characters: |
| 413 | |
| 414 | http://a-really-quite-long-name.com/~example01/t/abcdef |
| 415 | |
| 416 | ******************************************************************************** |
| LICENSE |
| 1 | GNU GENERAL PUBLIC LICENSE |
| 2 | Version 2, June 1991 |
| 3 | |
| 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. |
| 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 6 | Everyone is permitted to copy and distribute verbatim copies |
| 7 | of this license document, but changing it is not allowed. |
| 8 | |
| 9 | Preamble |
| 10 | |
| 11 | The licenses for most software are designed to take away your |
| 12 | freedom to share and change it. By contrast, the GNU General Public |
| 13 | License is intended to guarantee your freedom to share and change free |
| 14 | software--to make sure the software is free for all its users. This |
| 15 | General Public License applies to most of the Free Software |
| 16 | Foundation's software and to any other program whose authors commit to |
| 17 | using it. (Some other Free Software Foundation software is covered by |
| 18 | the GNU Library General Public License instead.) You can apply it to |
| 19 | your programs, too. |
| 20 | |
| 21 | When we speak of free software, we are referring to freedom, not |
| 22 | price. Our General Public Licenses are designed to make sure that you |
| 23 | have the freedom to distribute copies of free software (and charge for |
| 24 | this service if you wish), that you receive source code or can get it |
| 25 | if you want it, that you can change the software or use pieces of it |
| 26 | in new free programs; and that you know you can do these things. |
| 27 | |
| 28 | To protect your rights, we need to make restrictions that forbid |
| 29 | anyone to deny you these rights or to ask you to surrender the rights. |
| 30 | These restrictions translate to certain responsibilities for you if you |
| 31 | distribute copies of the software, or if you modify it. |
| 32 | |
| 33 | For example, if you distribute copies of such a program, whether |
| 34 | gratis or for a fee, you must give the recipients all the rights that |
| 35 | you have. You must make sure that they, too, receive or can get the |
| 36 | source code. And you must show them these terms so they know their |
| 37 | rights. |
| 38 | |
| 39 | We protect your rights with two steps: (1) copyright the software, and |
| 40 | (2) offer you this license which gives you legal permission to copy, |
| 41 | distribute and/or modify the software. |
| 42 | |
| 43 | Also, for each author's protection and ours, we want to make certain |
| 44 | that everyone understands that there is no warranty for this free |
| 45 | software. If the software is modified by someone else and passed on, we |
| 46 | want its recipients to know that what they have is not the original, so |
| 47 | that any problems introduced by others will not reflect on the original |
| 48 | authors' reputations. |
| 49 | |
| 50 | Finally, any free program is threatened constantly by software |
| 51 | patents. We wish to avoid the danger that redistributors of a free |
| 52 | program will individually obtain patent licenses, in effect making the |
| 53 | program proprietary. To prevent this, we have made it clear that any |
| 54 | patent must be licensed for everyone's free use or not licensed at all. |
| 55 | |
| 56 | The precise terms and conditions for copying, distribution and |
| 57 | modification follow. |
| 58 | |
| 59 | GNU GENERAL PUBLIC LICENSE |
| 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
| 61 | |
| 62 | 0. This License applies to any program or other work which contains |
| 63 | a notice placed by the copyright holder saying it may be distributed |
| 64 | under the terms of this General Public License. The "Program", below, |
| 65 | refers to any such program or work, and a "work based on the Program" |
| 66 | means either the Program or any derivative work under copyright law: |
| 67 | that is to say, a work containing the Program or a portion of it, |
| 68 | either verbatim or with modifications and/or translated into another |
| 69 | language. (Hereinafter, translation is included without limitation in |
| 70 | the term "modification".) Each licensee is addressed as "you". |
| 71 | |
| 72 | Activities other than copying, distribution and modification are not |
| 73 | covered by this License; they are outside its scope. The act of |
| 74 | running the Program is not restricted, and the output from the Program |
| 75 | is covered only if its contents constitute a work based on the |
| 76 | Program (independent of having been made by running the Program). |
| 77 | Whether that is true depends on what the Program does. |
| 78 | |
| 79 | 1. You may copy and distribute verbatim copies of the Program's |
| 80 | source code as you receive it, in any medium, provided that you |
| 81 | conspicuously and appropriately publish on each copy an appropriate |
| 82 | copyright notice and disclaimer of warranty; keep intact all the |
| 83 | notices that refer to this License and to the absence of any warranty; |
| 84 | and give any other recipients of the Program a copy of this License |
| 85 | along with the Program. |
| 86 | |
| 87 | You may charge a fee for the physical act of transferring a copy, and |
| 88 | you may at your option offer warranty protection in exchange for a fee. |
| 89 | |
| 90 | 2. You may modify your copy or copies of the Program or any portion |
| 91 | of it, thus forming a work based on the Program, and copy and |
| 92 | distribute such modifications or work under the terms of Section 1 |
| 93 | above, provided that you also meet all of these conditions: |
| 94 | |
| 95 | a) You must cause the modified files to carry prominent notices |
| 96 | stating that you changed the files and the date of any change. |
| 97 | |
| 98 | b) You must cause any work that you distribute or publish, that in |
| 99 | whole or in part contains or is derived from the Program or any |
| 100 | part thereof, to be licensed as a whole at no charge to all third |
| 101 | parties under the terms of this License. |
| 102 | |
| 103 | c) If the modified program normally reads commands interactively |
| 104 | when run, you must cause it, when started running for such |
| 105 | interactive use in the most ordinary way, to print or display an |
| 106 | announcement including an appropriate copyright notice and a |
| 107 | notice that there is no warranty (or else, saying that you provide |
| 108 | a warranty) and that users may redistribute the program under |
| 109 | these conditions, and telling the user how to view a copy of this |
| 110 | License. (Exception: if the Program itself is interactive but |
| 111 | does not normally print such an announcement, your work based on |
| 112 | the Program is not required to print an announcement.) |
| 113 | |
| 114 | These requirements apply to the modified work as a whole. If |
| 115 | identifiable sections of that work are not derived from the Program, |
| 116 | and can be reasonably considered independent and separate works in |
| 117 | themselves, then this License, and its terms, do not apply to those |
| 118 | sections when you distribute them as separate works. But when you |
| 119 | distribute the same sections as part of a whole which is a work based |
| 120 | on the Program, the distribution of the whole must be on the terms of |
| 121 | this License, whose permissions for other licensees extend to the |
| 122 | entire whole, and thus to each and every part regardless of who wrote it. |
| 123 | |
| 124 | Thus, it is not the intent of this section to claim rights or contest |
| 125 | your rights to work written entirely by you; rather, the intent is to |
| 126 | exercise the right to control the distribution of derivative or |
| 127 | collective works based on the Program. |
| 128 | |
| 129 | In addition, mere aggregation of another work not based on the Program |
| 130 | with the Program (or with a work based on the Program) on a volume of |
| 131 | a storage or distribution medium does not bring the other work under |
| 132 | the scope of this License. |
| 133 | |
| 134 | 3. You may copy and distribute the Program (or a work based on it, |
| 135 | under Section 2) in object code or executable form under the terms of |
| 136 | Sections 1 and 2 above provided that you also do one of the following: |
| 137 | |
| 138 | a) Accompany it with the complete corresponding machine-readable |
| 139 | source code, which must be distributed under the terms of Sections |
| 140 | 1 and 2 above on a medium customarily used for software interchange; or, |
| 141 | |
| 142 | b) Accompany it with a written offer, valid for at least three |
| 143 | years, to give any third party, for a charge no more than your |
| 144 | cost of physically performing source distribution, a complete |
| 145 | machine-readable copy of the corresponding source code, to be |
| 146 | distributed under the terms of Sections 1 and 2 above on a medium |
| 147 | customarily used for software interchange; or, |
| 148 | |
| 149 | c) Accompany it with the information you received as to the offer |
| 150 | to distribute corresponding source code. (This alternative is |
| 151 | allowed only for noncommercial distribution and only if you |
| 152 | received the program in object code or executable form with such |
| 153 | an offer, in accord with Subsection b above.) |
| 154 | |
| 155 | The source code for a work means the preferred form of the work for |
| 156 | making modifications to it. For an executable work, complete source |
| 157 | code means all the source code for all modules it contains, plus any |
| 158 | associated interface definition files, plus the scripts used to |
| 159 | control compilation and installation of the executable. However, as a |
| 160 | special exception, the source code distributed need not include |
| 161 | anything that is normally distributed (in either source or binary |
| 162 | form) with the major components (compiler, kernel, and so on) of the |
| 163 | operating system on which the executable runs, unless that component |
| 164 | itself accompanies the executable. |
| 165 | |
| 166 | If distribution of executable or object code is made by offering |
| 167 | access to copy from a designated place, then offering equivalent |
| 168 | access to copy the source code from the same place counts as |
| 169 | distribution of the source code, even though third parties are not |
| 170 | compelled to copy the source along with the object code. |
| 171 | |
| 172 | 4. You may not copy, modify, sublicense, or distribute the Program |
| 173 | except as expressly provided under this License. Any attempt |
| 174 | otherwise to copy, modify, sublicense or distribute the Program is |
| 175 | void, and will automatically terminate your rights under this License. |
| 176 | However, parties who have received copies, or rights, from you under |
| 177 | this License will not have their licenses terminated so long as such |
| 178 | parties remain in full compliance. |
| 179 | |
| 180 | 5. You are not required to accept this License, since you have not |
| 181 | signed it. However, nothing else grants you permission to modify or |
| 182 | distribute the Program or its derivative works. These actions are |
| 183 | prohibited by law if you do not accept this License. Therefore, by |
| 184 | modifying or distributing the Program (or any work based on the |
| 185 | Program), you indicate your acceptance of this License to do so, and |
| 186 | all its terms and conditions for copying, distributing or modifying |
| 187 | the Program or works based on it. |
| 188 | |
| 189 | 6. Each time you redistribute the Program (or any work based on the |
| 190 | Program), the recipient automatically receives a license from the |
| 191 | original licensor to copy, distribute or modify the Program subject to |
| 192 | these terms and conditions. You may not impose any further |
| 193 | restrictions on the recipients' exercise of the rights granted herein. |
| 194 | You are not responsible for enforcing compliance by third parties to |
| 195 | this License. |
| 196 | |
| 197 | 7. If, as a consequence of a court judgment or allegation of patent |
| 198 | infringement or for any other reason (not limited to patent issues), |
| 199 | conditions are imposed on you (whether by court order, agreement or |
| 200 | otherwise) that contradict the conditions of this License, they do not |
| 201 | excuse you from the conditions of this License. If you cannot |
| 202 | distribute so as to satisfy simultaneously your obligations under this |
| 203 | License and any other pertinent obligations, then as a consequence you |
| 204 | may not distribute the Program at all. For example, if a patent |
| 205 | license would not permit royalty-free redistribution of the Program by |
| 206 | all those who receive copies directly or indirectly through you, then |
| 207 | the only way you could satisfy both it and this License would be to |
| 208 | refrain entirely from distribution of the Program. |
| 209 | |
| 210 | If any portion of this section is held invalid or unenforceable under |
| 211 | any particular circumstance, the balance of the section is intended to |
| 212 | apply and the section as a whole is intended to apply in other |
| 213 | circumstances. |
| 214 | |
| 215 | It is not the purpose of this section to induce you to infringe any |
| 216 | patents or other property right claims or to contest validity of any |
| 217 | such claims; this section has the sole purpose of protecting the |
| 218 | integrity of the free software distribution system, which is |
| 219 | implemented by public license practices. Many people have made |
| 220 | generous contributions to the wide range of software distributed |
| 221 | through that system in reliance on consistent application of that |
| 222 | system; it is up to the author/donor to decide if he or she is willing |
| 223 | to distribute software through any other system and a licensee cannot |
| 224 | impose that choice. |
| 225 | |
| 226 | This section is intended to make thoroughly clear what is believed to |
| 227 | be a consequence of the rest of this License. |
| 228 | |
| 229 | 8. If the distribution and/or use of the Program is restricted in |
| 230 | certain countries either by patents or by copyrighted interfaces, the |
| 231 | original copyright holder who places the Program under this License |
| 232 | may add an explicit geographical distribution limitation excluding |
| 233 | those countries, so that distribution is permitted only in or among |
| 234 | countries not thus excluded. In such case, this License incorporates |
| 235 | the limitation as if written in the body of this License. |
| 236 | |
| 237 | 9. The Free Software Foundation may publish revised and/or new versions |
| 238 | of the General Public License from time to time. Such new versions will |
| 239 | be similar in spirit to the present version, but may differ in detail to |
| 240 | address new problems or concerns. |
| 241 | |
| 242 | Each version is given a distinguishing version number. If the Program |
| 243 | specifies a version number of this License which applies to it and "any |
| 244 | later version", you have the option of following the terms and conditions |
| 245 | either of that version or of any later version published by the Free |
| 246 | Software Foundation. If the Program does not specify a version number of |
| 247 | this License, you may choose any version ever published by the Free Software |
| 248 | Foundation. |
| 249 | |
| 250 | 10. If you wish to incorporate parts of the Program into other free |
| 251 | programs whose distribution conditions are different, write to the author |
| 252 | to ask for permission. For software which is copyrighted by the Free |
| 253 | Software Foundation, write to the Free Software Foundation; we sometimes |
| 254 | make exceptions for this. Our decision will be guided by the two goals |
| 255 | of preserving the free status of all derivatives of our free software and |
| 256 | of promoting the sharing and reuse of software generally. |
| 257 | |
| 258 | NO WARRANTY |
| 259 | |
| 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
| 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
| 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
| 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED |
| 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS |
| 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE |
| 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, |
| 268 | REPAIR OR CORRECTION. |
| 269 | |
| 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
| 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
| 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, |
| 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING |
| 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED |
| 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY |
| 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER |
| 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE |
| 278 | POSSIBILITY OF SUCH DAMAGES. |
| 279 | |
| 280 | END OF TERMS AND CONDITIONS |
| 281 | |
| 282 | How to Apply These Terms to Your New Programs |
| 283 | |
| 284 | If you develop a new program, and you want it to be of the greatest |
| 285 | possible use to the public, the best way to achieve this is to make it |
| 286 | free software which everyone can redistribute and change under these terms. |
| 287 | |
| 288 | To do so, attach the following notices to the program. It is safest |
| 289 | to attach them to the start of each source file to most effectively |
| 290 | convey the exclusion of warranty; and each file should have at least |
| 291 | the "copyright" line and a pointer to where the full notice is found. |
| 292 | |
| 293 | <one line to give the program's name and a brief idea of what it does.> |
| 294 | Copyright (C) <year> <name of author> |
| 295 | |
| 296 | This program is free software; you can redistribute it and/or modify |
| 297 | it under the terms of the GNU General Public License as published by |
| 298 | the Free Software Foundation; either version 2 of the License, or |
| 299 | (at your option) any later version. |
| 300 | |
| 301 | This program is distributed in the hope that it will be useful, |
| 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 304 | GNU General Public License for more details. |
| 305 | |
| 306 | You should have received a copy of the GNU General Public License |
| 307 | along with this program; if not, write to the Free Software |
| 308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 309 | |
| 310 | |
| 311 | Also add information on how to contact you by electronic and paper mail. |
| 312 | |
| 313 | If the program is interactive, make it output a short notice like this |
| 314 | when it starts in an interactive mode: |
| 315 | |
| 316 | Gnomovision version 69, Copyright (C) year name of author |
| 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
| 318 | This is free software, and you are welcome to redistribute it |
| 319 | under certain conditions; type `show c' for details. |
| 320 | |
| 321 | The hypothetical commands `show w' and `show c' should show the appropriate |
| 322 | parts of the General Public License. Of course, the commands you use may |
| 323 | be called something other than `show w' and `show c'; they could even be |
| 324 | mouse-clicks or menu items--whatever suits your program. |
| 325 | |
| 326 | You should also get your employer (if you work as a programmer) or your |
| 327 | school, if any, to sign a "copyright disclaimer" for the program, if |
| 328 | necessary. Here is a sample; alter the names: |
| 329 | |
| 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program |
| 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. |
| 332 | |
| 333 | <signature of Ty Coon>, 1 April 1989 |
| 334 | Ty Coon, President of Vice |
| 335 | |
| 336 | This General Public License does not permit incorporating your program into |
| 337 | proprietary programs. If your program is a subroutine library, you may |
| 338 | consider it more useful to permit linking proprietary applications with the |
| 339 | library. If this is what you want to do, use the GNU Library General |
| 340 | Public License instead of this License. |
| bad-behavior/COPYING |
| 1 | GNU GENERAL PUBLIC LICENSE |
| 2 | Version 2, June 1991 |
| 3 | |
| 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., |
| 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 6 | Everyone is permitted to copy and distribute verbatim copies |
| 7 | of this license document, but changing it is not allowed. |
| 8 | |
| 9 | Preamble |
| 10 | |
| 11 | The licenses for most software are designed to take away your |
| 12 | freedom to share and change it. By contrast, the GNU General Public |
| 13 | License is intended to guarantee your freedom to share and change free |
| 14 | software--to make sure the software is free for all its users. This |
| 15 | General Public License applies to most of the Free Software |
| 16 | Foundation's software and to any other program whose authors commit to |
| 17 | using it. (Some other Free Software Foundation software is covered by |
| 18 | the GNU Lesser General Public License instead.) You can apply it to |
| 19 | your programs, too. |
| 20 | |
| 21 | When we speak of free software, we are referring to freedom, not |
| 22 | price. Our General Public Licenses are designed to make sure that you |
| 23 | have the freedom to distribute copies of free software (and charge for |
| 24 | this service if you wish), that you receive source code or can get it |
| 25 | if you want it, that you can change the software or use pieces of it |
| 26 | in new free programs; and that you know you can do these things. |
| 27 | |
| 28 | To protect your rights, we need to make restrictions that forbid |
| 29 | anyone to deny you these rights or to ask you to surrender the rights. |
| 30 | These restrictions translate to certain responsibilities for you if you |
| 31 | distribute copies of the software, or if you modify it. |
| 32 | |
| 33 | For example, if you distribute copies of such a program, whether |
| 34 | gratis or for a fee, you must give the recipients all the rights that |
| 35 | you have. You must make sure that they, too, receive or can get the |
| 36 | source code. And you must show them these terms so they know their |
| 37 | rights. |
| 38 | |
| 39 | We protect your rights with two steps: (1) copyright the software, and |
| 40 | (2) offer you this license which gives you legal permission to copy, |
| 41 | distribute and/or modify the software. |
| 42 | |
| 43 | Also, for each author's protection and ours, we want to make certain |
| 44 | that everyone understands that there is no warranty for this free |
| 45 | software. If the software is modified by someone else and passed on, we |
| 46 | want its recipients to know that what they have is not the original, so |
| 47 | that any problems introduced by others will not reflect on the original |
| 48 | authors' reputations. |
| 49 | |
| 50 | Finally, any free program is threatened constantly by software |
| 51 | patents. We wish to avoid the danger that redistributors of a free |
| 52 | program will individually obtain patent licenses, in effect making the |
| 53 | program proprietary. To prevent this, we have made it clear that any |
| 54 | patent must be licensed for everyone's free use or not licensed at all. |
| 55 | |
| 56 | The precise terms and conditions for copying, distribution and |
| 57 | modification follow. |
| 58 | |
| 59 | GNU GENERAL PUBLIC LICENSE |
| 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
| 61 | |
| 62 | 0. This License applies to any program or other work which contains |
| 63 | a notice placed by the copyright holder saying it may be distributed |
| 64 | under the terms of this General Public License. The "Program", below, |
| 65 | refers to any such program or work, and a "work based on the Program" |
| 66 | means either the Program or any derivative work under copyright law: |
| 67 | that is to say, a work containing the Program or a portion of it, |
| 68 | either verbatim or with modifications and/or translated into another |
| 69 | language. (Hereinafter, translation is included without limitation in |
| 70 | the term "modification".) Each licensee is addressed as "you". |
| 71 | |
| 72 | Activities other than copying, distribution and modification are not |
| 73 | covered by this License; they are outside its scope. The act of |
| 74 | running the Program is not restricted, and the output from the Program |
| 75 | is covered only if its contents constitute a work based on the |
| 76 | Program (independent of having been made by running the Program). |
| 77 | Whether that is true depends on what the Program does. |
| 78 | |
| 79 | 1. You may copy and distribute verbatim copies of the Program's |
| 80 | source code as you receive it, in any medium, provided that you |
| 81 | conspicuously and appropriately publish on each copy an appropriate |
| 82 | copyright notice and disclaimer of warranty; keep intact all the |
| 83 | notices that refer to this License and to the absence of any warranty; |
| 84 | and give any other recipients of the Program a copy of this License |
| 85 | along with the Program. |
| 86 | |
| 87 | You may charge a fee for the physical act of transferring a copy, and |
| 88 | you may at your option offer warranty protection in exchange for a fee. |
| 89 | |
| 90 | 2. You may modify your copy or copies of the Program or any portion |
| 91 | of it, thus forming a work based on the Program, and copy and |
| 92 | distribute such modifications or work under the terms of Section 1 |
| 93 | above, provided that you also meet all of these conditions: |
| 94 | |
| 95 | a) You must cause the modified files to carry prominent notices |
| 96 | stating that you changed the files and the date of any change. |
| 97 | |
| 98 | b) You must cause any work that you distribute or publish, that in |
| 99 | whole or in part contains or is derived from the Program or any |
| 100 | part thereof, to be licensed as a whole at no charge to all third |
| 101 | parties under the terms of this License. |
| 102 | |
| 103 | c) If the modified program normally reads commands interactively |
| 104 | when run, you must cause it, when started running for such |
| 105 | interactive use in the most ordinary way, to print or display an |
| 106 | announcement including an appropriate copyright notice and a |
| 107 | notice that there is no warranty (or else, saying that you provide |
| 108 | a warranty) and that users may redistribute the program under |
| 109 | these conditions, and telling the user how to view a copy of this |
| 110 | License. (Exception: if the Program itself is interactive but |
| 111 | does not normally print such an announcement, your work based on |
| 112 | the Program is not required to print an announcement.) |
| 113 | |
| 114 | These requirements apply to the modified work as a whole. If |
| 115 | identifiable sections of that work are not derived from the Program, |
| 116 | and can be reasonably considered independent and separate works in |
| 117 | themselves, then this License, and its terms, do not apply to those |
| 118 | sections when you distribute them as separate works. But when you |
| 119 | distribute the same sections as part of a whole which is a work based |
| 120 | on the Program, the distribution of the whole must be on the terms of |
| 121 | this License, whose permissions for other licensees extend to the |
| 122 | entire whole, and thus to each and every part regardless of who wrote it. |
| 123 | |
| 124 | Thus, it is not the intent of this section to claim rights or contest |
| 125 | your rights to work written entirely by you; rather, the intent is to |
| 126 | exercise the right to control the distribution of derivative or |
| 127 | collective works based on the Program. |
| 128 | |
| 129 | In addition, mere aggregation of another work not based on the Program |
| 130 | with the Program (or with a work based on the Program) on a volume of |
| 131 | a storage or distribution medium does not bring the other work under |
| 132 | the scope of this License. |
| 133 | |
| 134 | 3. You may copy and distribute the Program (or a work based on it, |
| 135 | under Section 2) in object code or executable form under the terms of |
| 136 | Sections 1 and 2 above provided that you also do one of the following: |
| 137 | |
| 138 | a) Accompany it with the complete corresponding machine-readable |
| 139 | source code, which must be distributed under the terms of Sections |
| 140 | 1 and 2 above on a medium customarily used for software interchange; or, |
| 141 | |
| 142 | b) Accompany it with a written offer, valid for at least three |
| 143 | years, to give any third party, for a charge no more than your |
| 144 | cost of physically performing source distribution, a complete |
| 145 | machine-readable copy of the corresponding source code, to be |
| 146 | distributed under the terms of Sections 1 and 2 above on a medium |
| 147 | customarily used for software interchange; or, |
| 148 | |
| 149 | c) Accompany it with the information you received as to the offer |
| 150 | to distribute corresponding source code. (This alternative is |
| 151 | allowed only for noncommercial distribution and only if you |
| 152 | received the program in object code or executable form with such |
| 153 | an offer, in accord with Subsection b above.) |
| 154 | |
| 155 | The source code for a work means the preferred form of the work for |
| 156 | making modifications to it. For an executable work, complete source |
| 157 | code means all the source code for all modules it contains, plus any |
| 158 | associated interface definition files, plus the scripts used to |
| 159 | control compilation and installation of the executable. However, as a |
| 160 | special exception, the source code distributed need not include |
| 161 | anything that is normally distributed (in either source or binary |
| 162 | form) with the major components (compiler, kernel, and so on) of the |
| 163 | operating system on which the executable runs, unless that component |
| 164 | itself accompanies the executable. |
| 165 | |
| 166 | If distribution of executable or object code is made by offering |
| 167 | access to copy from a designated place, then offering equivalent |
| 168 | access to copy the source code from the same place counts as |
| 169 | distribution of the source code, even though third parties are not |
| 170 | compelled to copy the source along with the object code. |
| 171 | |
| 172 | 4. You may not copy, modify, sublicense, or distribute the Program |
| 173 | except as expressly provided under this License. Any attempt |
| 174 | otherwise to copy, modify, sublicense or distribute the Program is |
| 175 | void, and will automatically terminate your rights under this License. |
| 176 | However, parties who have received copies, or rights, from you under |
| 177 | this License will not have their licenses terminated so long as such |
| 178 | parties remain in full compliance. |
| 179 | |
| 180 | 5. You are not required to accept this License, since you have not |
| 181 | signed it. However, nothing else grants you permission to modify or |
| 182 | distribute the Program or its derivative works. These actions are |
| 183 | prohibited by law if you do not accept this License. Therefore, by |
| 184 | modifying or distributing the Program (or any work based on the |
| 185 | Program), you indicate your acceptance of this License to do so, and |
| 186 | all its terms and conditions for copying, distributing or modifying |
| 187 | the Program or works based on it. |
| 188 | |
| 189 | 6. Each time you redistribute the Program (or any work based on the |
| 190 | Program), the recipient automatically receives a license from the |
| 191 | original licensor to copy, distribute or modify the Program subject to |
| 192 | these terms and conditions. You may not impose any further |
| 193 | restrictions on the recipients' exercise of the rights granted herein. |
| 194 | You are not responsible for enforcing compliance by third parties to |
| 195 | this License. |
| 196 | |
| 197 | 7. If, as a consequence of a court judgment or allegation of patent |
| 198 | infringement or for any other reason (not limited to patent issues), |
| 199 | conditions are imposed on you (whether by court order, agreement or |
| 200 | otherwise) that contradict the conditions of this License, they do not |
| 201 | excuse you from the conditions of this License. If you cannot |
| 202 | distribute so as to satisfy simultaneously your obligations under this |
| 203 | License and any other pertinent obligations, then as a consequence you |
| 204 | may not distribute the Program at all. For example, if a patent |
| 205 | license would not permit royalty-free redistribution of the Program by |
| 206 | all those who receive copies directly or indirectly through you, then |
| 207 | the only way you could satisfy both it and this License would be to |
| 208 | refrain entirely from distribution of the Program. |
| 209 | |
| 210 | If any portion of this section is held invalid or unenforceable under |
| 211 | any particular circumstance, the balance of the section is intended to |
| 212 | apply and the section as a whole is intended to apply in other |
| 213 | circumstances. |
| 214 | |
| 215 | It is not the purpose of this section to induce you to infringe any |
| 216 | patents or other property right claims or to contest validity of any |
| 217 | such claims; this section has the sole purpose of protecting the |
| 218 | integrity of the free software distribution system, which is |
| 219 | implemented by public license practices. Many people have made |
| 220 | generous contributions to the wide range of software distributed |
| 221 | through that system in reliance on consistent application of that |
| 222 | system; it is up to the author/donor to decide if he or she is willing |
| 223 | to distribute software through any other system and a licensee cannot |
| 224 | impose that choice. |
| 225 | |
| 226 | This section is intended to make thoroughly clear what is believed to |
| 227 | be a consequence of the rest of this License. |
| 228 | |
| 229 | 8. If the distribution and/or use of the Program is restricted in |
| 230 | certain countries either by patents or by copyrighted interfaces, the |
| 231 | original copyright holder who places the Program under this License |
| 232 | may add an explicit geographical distribution limitation excluding |
| 233 | those countries, so that distribution is permitted only in or among |
| 234 | countries not thus excluded. In such case, this License incorporates |
| 235 | the limitation as if written in the body of this License. |
| 236 | |
| 237 | 9. The Free Software Foundation may publish revised and/or new versions |
| 238 | of the General Public License from time to time. Such new versions will |
| 239 | be similar in spirit to the present version, but may differ in detail to |
| 240 | address new problems or concerns. |
| 241 | |
| 242 | Each version is given a distinguishing version number. If the Program |
| 243 | specifies a version number of this License which applies to it and "any |
| 244 | later version", you have the option of following the terms and conditions |
| 245 | either of that version or of any later version published by the Free |
| 246 | Software Foundation. If the Program does not specify a version number of |
| 247 | this License, you may choose any version ever published by the Free Software |
| 248 | Foundation. |
| 249 | |
| 250 | 10. If you wish to incorporate parts of the Program into other free |
| 251 | programs whose distribution conditions are different, write to the author |
| 252 | to ask for permission. For software which is copyrighted by the Free |
| 253 | Software Foundation, write to the Free Software Foundation; we sometimes |
| 254 | make exceptions for this. Our decision will be guided by the two goals |
| 255 | of preserving the free status of all derivatives of our free software and |
| 256 | of promoting the sharing and reuse of software generally. |
| 257 | |
| 258 | NO WARRANTY |
| 259 | |
| 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
| 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
| 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
| 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED |
| 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS |
| 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE |
| 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, |
| 268 | REPAIR OR CORRECTION. |
| 269 | |
| 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
| 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
| 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, |
| 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING |
| 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED |
| 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY |
| 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER |
| 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE |
| 278 | POSSIBILITY OF SUCH DAMAGES. |
| 279 | |
| 280 | END OF TERMS AND CONDITIONS |
| 281 | |
| 282 | How to Apply These Terms to Your New Programs |
| 283 | |
| 284 | If you develop a new program, and you want it to be of the greatest |
| 285 | possible use to the public, the best way to achieve this is to make it |
| 286 | free software which everyone can redistribute and change under these terms. |
| 287 | |
| 288 | To do so, attach the following notices to the program. It is safest |
| 289 | to attach them to the start of each source file to most effectively |
| 290 | convey the exclusion of warranty; and each file should have at least |
| 291 | the "copyright" line and a pointer to where the full notice is found. |
| 292 | |
| 293 | <one line to give the program's name and a brief idea of what it does.> |
| 294 | Copyright (C) <year> <name of author> |
| 295 | |
| 296 | This program is free software; you can redistribute it and/or modify |
| 297 | it under the terms of the GNU General Public License as published by |
| 298 | the Free Software Foundation; either version 2 of the License, or |
| 299 | (at your option) any later version. |
| 300 | |
| 301 | This program is distributed in the hope that it will be useful, |
| 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 304 | GNU General Public License for more details. |
| 305 | |
| 306 | You should have received a copy of the GNU General Public License along |
| 307 | with this program; if not, write to the Free Software Foundation, Inc., |
| 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 309 | |
| 310 | Also add information on how to contact you by electronic and paper mail. |
| 311 | |
| 312 | If the program is interactive, make it output a short notice like this |
| 313 | when it starts in an interactive mode: |
| 314 | |
| 315 | Gnomovision version 69, Copyright (C) year name of author |
| 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
| 317 | This is free software, and you are welcome to redistribute it |
| 318 | under certain conditions; type `show c' for details. |
| 319 | |
| 320 | The hypothetical commands `show w' and `show c' should show the appropriate |
| 321 | parts of the General Public License. Of course, the commands you use may |
| 322 | be called something other than `show w' and `show c'; they could even be |
| 323 | mouse-clicks or menu items--whatever suits your program. |
| 324 | |
| 325 | You should also get your employer (if you work as a programmer) or your |
| 326 | school, if any, to sign a "copyright disclaimer" for the program, if |
| 327 | necessary. Here is a sample; alter the names: |
| 328 | |
| 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program |
| 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. |
| 331 | |
| 332 | <signature of Ty Coon>, 1 April 1989 |
| 333 | Ty Coon, President of Vice |
| 334 | |
| 335 | This General Public License does not permit incorporating your program into |
| 336 | proprietary programs. If your program is a subroutine library, you may |
| 337 | consider it more useful to permit linking proprietary applications with the |
| 338 | library. If this is what you want to do, use the GNU Lesser General |
| 339 | Public License instead of this License. |
| bad-behavior/bad-behavior-wordpress-admin.php |
| 1 | <?php if (!defined('BB2_CORE')) die('I said no cheating!'); |
| 2 | |
| 3 | require_once("bad-behavior/responses.inc.php"); |
| 4 | |
| 5 | function bb2_admin_pages() { |
| 6 | global $wp_db_version; |
| 7 | |
| 8 | if (function_exists('current_user_can')) { |
| 9 | // The new 2.x way |
| 10 | if (current_user_can('manage_options')) { |
| 11 | $bb2_is_admin = true; |
| 12 | } |
| 13 | } else { |
| 14 | // The old 1.x way |
| 15 | global $user_ID; |
| 16 | if (user_can_edit_user($user_ID, 0)) { |
| 17 | $bb2_is_admin = true; |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | if ($bb2_is_admin) { |
| 22 | add_options_page(__("Bad Behavior"), __("Bad Behavior"), 8, 'bb2_options', 'bb2_options'); |
| 23 | if ($wp_db_version >= 4772) { // Version 2.1 or later |
| 24 | add_management_page(__("Bad Behavior"), __("Bad Behavior"), 8, 'bb2_manage', 'bb2_manage'); |
| 25 | } |
| 26 | @session_start(); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | function bb2_clean_log_link($uri) { |
| 31 | foreach (array("paged", "ip", "key", "blocked", "request_method", "user_agent") as $arg) { |
| 32 | $uri = remove_query_arg($arg, $uri); |
| 33 | } |
| 34 | return $uri; |
| 35 | } |
| 36 | |
| 37 | function bb2_httpbl_lookup($ip) { |
| 38 | $engines = array( |
| 39 | 2 => "Bloglines", |
| 40 | 5 => "Googlebot", |
| 41 | 8 => "msnbot", |
| 42 | 9 => "Yahoo! Slurp", |
| 43 | ); |
| 44 | $settings = bb2_read_settings(); |
| 45 | $httpbl_key = $settings['httpbl_key']; |
| 46 | if (!$httpbl_key) return false; |
| 47 | |
| 48 | $r = $_SESSION['httpbl'][$ip]; |
| 49 | $d = ""; |
| 50 | if (!$r) { // Lookup |
| 51 | $find = implode('.', array_reverse(explode('.', $ip))); |
| 52 | $result = gethostbynamel("${httpbl_key}.${find}.dnsbl.httpbl.org."); |
| 53 | if (!empty($result)) { |
| 54 | $r = $result[0]; |
| 55 | $_SESSION['httpbl'][$ip] = $r; |
| 56 | } |
| 57 | } |
| 58 | if ($r) { // Interpret |
| 59 | $ip = explode('.', $r); |
| 60 | if ($ip[0] == 127) { |
| 61 | if ($ip[3] == 0) { |
| 62 | if ($engines[$ip[2]]) { |
| 63 | $d .= $engines[$ip[2]]; |
| 64 | } else { |
| 65 | $d .= "Search engine ${ip[2]}<br/>\n"; |
| 66 | } |
| 67 | } |
| 68 | if ($ip[3] & 1) { |
| 69 | $d .= "Suspicious<br/>\n"; |
| 70 | } |
| 71 | if ($ip[3] & 2) { |
| 72 | $d .= "Harvester<br/>\n"; |
| 73 | } |
| 74 | if ($ip[3] & 4) { |
| 75 | $d .= "Comment Spammer<br/>\n"; |
| 76 | } |
| 77 | if ($ip[3] & 7) { |
| 78 | $d .= "Threat level ${ip[2]}<br/>\n"; |
| 79 | } |
| 80 | if ($ip[3] > 0) { |
| 81 | $d .= "Age ${ip[1]} days<br/>\n"; |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | return $d; |
| 86 | } |
| 87 | |
| 88 | function bb2_manage() { |
| 89 | global $wpdb; |
| 90 | |
| 91 | $request_uri = $_SERVER["REQUEST_URI"]; |
| 92 | $settings = bb2_read_settings(); |
| 93 | $rows_per_page = 100; |
| 94 | $where = ""; |
| 95 | |
| 96 | // Get query variables desired by the user with input validation |
| 97 | $paged = 0 + $_GET['paged']; if (!$paged) $paged = 1; |
| 98 | if ($_GET['key']) $where .= "AND `key` = '" . $wpdb->escape($_GET['key']) . "' "; |
| 99 | if ($_GET['blocked']) $where .= "AND `key` != '00000000' "; |
| 100 | if ($_GET['ip']) $where .= "AND `ip` = '" . $wpdb->escape($_GET['ip']) . "' "; |
| 101 | if ($_GET['user_agent']) $where .= "AND `user_agent` = '" . $wpdb->escape($_GET['user_agent']) . "' "; |
| 102 | if ($_GET['request_method']) $where .= "AND `request_method` = '" . $wpdb->escape($_GET['request_method']) . "' "; |
| 103 | |
| 104 | // Query the DB based on variables selected |
| 105 | $r = bb2_db_query("SELECT COUNT(*) FROM `" . $settings['log_table']); |
| 106 | $results = bb2_db_rows($r); |
| 107 | $totalcount = $results[0]["COUNT(*)"]; |
| 108 | $r = bb2_db_query("SELECT COUNT(*) FROM `" . $settings['log_table'] . "` WHERE 1=1 " . $where); |
| 109 | $results = bb2_db_rows($r); |
| 110 | $count = $results[0]["COUNT(*)"]; |
| 111 | $pages = ceil($count / 100); |
| 112 | $r = bb2_db_query("SELECT * FROM `" . $settings['log_table'] . "` WHERE 1=1 " . $where . "ORDER BY `date` DESC LIMIT " . ($paged - 1) * $rows_per_page . "," . $rows_per_page); |
| 113 | $results = bb2_db_rows($r); |
| 114 | |
| 115 | // Display rows to the user |
| 116 | ?> |
| 117 | <div class="wrap"> |
| 118 | <h2><?php _e("Bad Behavior"); ?></h2> |
| 119 | <form method="post" action="<?php echo $request_uri; ?>"> |
| 120 | <p>For more information please visit the <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> homepage.</p> |
| 121 | <p>If you find Bad Behavior valuable, please consider making a <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=error%40ioerror%2eus&item_name=Bad%20Behavior%20<?php echo BB2_VERSION; ?>%20%28From%20Admin%29&no_shipping=1&cn=Comments%20about%20Bad%20Behavior&tax=0¤cy_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8">financial contribution</a> to further development of Bad Behavior.</p> |
| 122 | |
| 123 | <div class="tablenav"> |
| 124 | <?php |
| 125 | $page_links = paginate_links(array('base' => add_query_arg("paged", "%#%"), 'format' => '', 'total' => $pages, 'current' => $paged)); |
| 126 | if ($page_links) echo "<div class=\"tablenav-pages\">$page_links</div>\n"; |
| 127 | ?> |
| 128 | <div class="alignleft"> |
| 129 | <?php if ($count < $totalcount): ?> |
| 130 | Displaying <strong><?php echo $count; ?></strong> of <strong><?php echo $totalcount; ?></strong> records filtered by:<br/> |
| 131 | <?php if ($_GET['key']) echo "Status [<a href=\"" . remove_query_arg(array("paged", "key"), $request_uri) . "\">X</a>] "; ?> |
| 132 | <?php if ($_GET['blocked']) echo "Blocked [<a href=\"" . remove_query_arg(array("paged", "blocked"), $request_uri) . "\">X</a>] "; ?> |
| 133 | <?php if ($_GET['ip']) echo "IP [<a href=\"" . remove_query_arg(array("paged", "ip"), $request_uri) . "\">X</a>] "; ?> |
| 134 | <?php if ($_GET['user_agent']) echo "User Agent [<a href=\"" . remove_query_arg(array("paged", "user_agent"), $request_uri) . "\">X</a>] "; ?> |
| 135 | <?php if ($_GET['request_method']) echo "GET/POST [<a href=\"" . remove_query_arg(array("paged", "request_method"), $request_uri) . "\">X</a>] "; ?> |
| 136 | <?php else: ?> |
| 137 | Displaying all <strong><?php echo $totalcount; ?></strong> records<br/> |
| 138 | <?php endif; ?> |
| 139 | <?php if (!$_GET['key'] && !$_GET['blocked']) { ?><a href="<?php echo add_query_arg(array("blocked" => "true", "paged" => false), $request_uri); ?>">Show Blocked</a><?php } ?> |
| 140 | </div> |
| 141 | </div> |
| 142 | |
| 143 | <table class="widefat"> |
| 144 | <thead> |
| 145 | <tr> |
| 146 | <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('request-filter'));" /></th> |
| 147 | <th scope="col"><?php _e("IP/Date/Status"); ?></th> |
| 148 | <th scope="col"><?php _e("Headers"); ?></th> |
| 149 | <th scope="col"><?php _e("Entity"); ?></th> |
| 150 | </tr> |
| 151 | </thead> |
| 152 | <tbody> |
| 153 | <?php |
| 154 | $alternate = 0; |
| 155 | if ($results) foreach ($results as $result) { |
| 156 | $key = bb2_get_response($result["key"]); |
| 157 | $alternate++; |
| 158 | if ($alternate % 2) { |
| 159 | echo "<tr id=\"request-" . $result["id"] . "\" valign=\"top\">\n"; |
| 160 | } else { |
| 161 | echo "<tr id=\"request-" . $result["id"] . "\" class=\"alternate\" valign=\"top\">\n"; |
| 162 | } |
| 163 | echo "<th scope=\"row\" class=\"check-column\"><input type=\"checkbox\" name=\"submit[]\" value=\"" . $result["id"] . "\" /></th>\n"; |
| 164 | $httpbl = bb2_httpbl_lookup($result["ip"]); |
| 165 | echo "<td><a href=\"" . add_query_arg("ip", $result["ip"], remove_query_arg("paged", $request_uri)) . "\">" . $result["ip"] . "</a><br/><br/>\n" . $result["date"] . "<br/><br/><a href=\"" . add_query_arg("key", $result["key"], remove_query_arg(array("paged", "blocked"), $request_uri)) . "\">" . $key["log"] . "</a>\n"; |
| 166 | if ($httpbl) echo "<br/><br/>http:BL:<br/>$httpbl\n"; |
| 167 | echo "</td>\n"; |
| 168 | $headers = str_replace("\n", "<br/>\n", htmlspecialchars($result['http_headers'])); |
| 169 | if (@strpos($headers, $result['user_agent']) !== FALSE) $headers = substr_replace($headers, "<a href=\"" . add_query_arg("user_agent", rawurlencode($result["user_agent"]), remove_query_arg("paged", $request_uri)) . "\">" . $result['user_agent'] . "</a>", strpos($headers, $result['user_agent']), strlen($result['user_agent'])); |
| 170 | if (strpos($headers, $result['request_method']) !== FALSE) $headers = substr_replace($headers, "<a href=\"" . add_query_arg("request_method", rawurlencode($result["request_method"]), remove_query_arg("paged", $request_uri)) . "\">" . $result['request_method'] . "</a>", strpos($headers, $result['request_method']), strlen($result['request_method'])); |
| 171 | echo "<td>$headers</td>\n"; |
| 172 | echo "<td>" . str_replace("\n", "<br/>\n", htmlspecialchars($result["request_entity"])) . "</td>\n"; |
| 173 | echo "</tr>\n"; |
| 174 | } |
| 175 | ?> |
| 176 | </tbody> |
| 177 | </table> |
| 178 | <div class="tablenav"> |
| 179 | <?php |
| 180 | $page_links = paginate_links(array('base' => add_query_arg("paged", "%#%"), 'format' => '', 'total' => $pages, 'current' => $paged)); |
| 181 | if ($page_links) echo "<div class=\"tablenav-pages\">$page_links</div>\n"; |
| 182 | ?> |
| 183 | <div class="alignleft"> |
| 184 | </div> |
| 185 | </div> |
| 186 | </form> |
| 187 | </div> |
| 188 | <?php |
| 189 | } |
| 190 | |
| 191 | function bb2_options() |
| 192 | { |
| 193 | $settings = bb2_read_settings(); |
| 194 | |
| 195 | if ($_POST) { |
| 196 | if ($_POST['display_stats']) { |
| 197 | $settings['display_stats'] = true; |
| 198 | } else { |
| 199 | $settings['display_stats'] = false; |
| 200 | } |
| 201 | if ($_POST['strict']) { |
| 202 | $settings['strict'] = true; |
| 203 | } else { |
| 204 | $settings['strict'] = false; |
| 205 | } |
| 206 | if ($_POST['verbose']) { |
| 207 | $settings['verbose'] = true; |
| 208 | } else { |
| 209 | $settings['verbose'] = false; |
| 210 | } |
| 211 | if ($_POST['logging']) { |
| 212 | if ($_POST['logging'] == 'verbose') { |
| 213 | $settings['verbose'] = true; |
| 214 | $settings['logging'] = true; |
| 215 | } else if ($_POST['logging'] == 'normal') { |
| 216 | $settings['verbose'] = false; |
| 217 | $settings['logging'] = true; |
| 218 | } else { |
| 219 | $settings['verbose'] = false; |
| 220 | $settings['logging'] = false; |
| 221 | } |
| 222 | } else { |
| 223 | $settings['verbose'] = false; |
| 224 | $settings['logging'] = false; |
| 225 | } |
| 226 | if ($_POST['httpbl_key']) { |
| 227 | $settings['httpbl_key'] = $_POST['httpbl_key']; |
| 228 | } else { |
| 229 | $settings['httpbl_key'] = ''; |
| 230 | } |
| 231 | if ($_POST['httpbl_threat']) { |
| 232 | $settings['httpbl_threat'] = $_POST['httpbl_threat']; |
| 233 | } else { |
| 234 | $settings['httpbl_threat'] = '25'; |
| 235 | } |
| 236 | if ($_POST['httpbl_maxage']) { |
| 237 | $settings['httpbl_maxage'] = $_POST['httpbl_maxage']; |
| 238 | } else { |
| 239 | $settings['httpbl_maxage'] = '30'; |
| 240 | } |
| 241 | bb2_write_settings($settings); |
| 242 | ?> |
| 243 | <div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div> |
| 244 | <?php |
| 245 | } |
| 246 | ?> |
| 247 | <div class="wrap"> |
| 248 | <h2><?php _e("Bad Behavior"); ?></h2> |
| 249 | <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 250 | <p>For more information please visit the <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> homepage.</p> |
| 251 | <p>If you find Bad Behavior valuable, please consider making a <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=error%40ioerror%2eus&item_name=Bad%20Behavior%20<?php echo BB2_VERSION; ?>%20%28From%20Admin%29&no_shipping=1&cn=Comments%20about%20Bad%20Behavior&tax=0¤cy_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8">financial contribution</a> to further development of Bad Behavior.</p> |
| 252 | |
| 253 | <h3><?php _e('Statistics'); ?></h3> |
| 254 | <?php bb2_insert_stats(true); ?> |
| 255 | <table class="form-table"> |
| 256 | <tr><td><label><input type="checkbox" name="display_stats" value="true" <?php if ($settings['display_stats']) { ?>checked="checked" <?php } ?>/> <?php _e('Display statistics in blog footer'); ?></label></td></tr> |
| 257 | </table> |
| 258 | |
| 259 | <h3><?php _e('Logging'); ?></h3> |
| 260 | <table class="form-table"> |
| 261 | <tr><td><label><input type="radio" name="logging" value="verbose" <?php if ($settings['verbose'] && $settings['logging']) { ?>checked="checked" <?php } ?>/> <?php _e('Verbose HTTP request logging'); ?></label></td></tr> |
| 262 | <tr><td><label><input type="radio" name="logging" value="normal" <?php if ($settings['logging'] && !$settings['verbose']) { ?>checked="checked" <?php } ?>/> <?php _e('Normal HTTP request logging (recommended)'); ?></label></td></tr> |
| 263 | <tr><td><label><input type="radio" name="logging" value="false" <?php if (!$settings['logging']) { ?>checked="checked" <?php } ?>/> <?php _e('Do not log HTTP requests (not recommended)'); ?></label></td></tr> |
| 264 | </table> |
| 265 | |
| 266 | <h3><?php _e('Strict Mode'); ?></h3> |
| 267 | <table class="form-table"> |
| 268 | <tr><td><label><input type="checkbox" name="strict" value="true" <?php if ($settings['strict']) { ?>checked="checked" <?php } ?>/> <?php _e('Strict checking (blocks more spam but may block some people)'); ?></label></td></tr> |
| 269 | </table> |
| 270 | |
| 271 | <h3><?php _e('http:BL'); ?></h3> |
| 272 | <p>To use Bad Behavior's http:BL features you must have an <a href="http://www.projecthoneypot.org/httpbl_configure.php?rf=24694">http:BL Access Key</a>.</p> |
| 273 | <table class="form-table"> |
| 274 | <tr><td><label><input type="text" size="12" maxlength="12" name="httpbl_key" value="<?php echo $settings['httpbl_key']; ?>" /> http:BL Access Key</label></td></tr> |
| 275 | <tr><td><label><input type="text" size="3" maxlength="3" name="httpbl_threat" value="<?php echo $settings['httpbl_threat']; ?>" /> Minimum Threat Level (25 is recommended)</label></td></tr> |
| 276 | <tr><td><label><input type="text" size="3" maxlength="3" name="httpbl_maxage" value="<?php echo $settings['httpbl_maxage']; ?>" /> Maximum Age of Data (30 is recommended)</label></td></tr> |
| 277 | </table> |
| 278 | |
| 279 | <p class="submit"><input class="button" type="submit" name="submit" value="<?php _e('Update »'); ?>" /></p> |
| 280 | </form> |
| 281 | </div> |
| 282 | <?php |
| 283 | } |
| 284 | |
| 285 | add_action('admin_menu', 'bb2_admin_pages'); |
| 286 | |
| 287 | ?> |
| bad-behavior/bad-behavior/core.inc.php |
| 1 | <?php if (!defined('BB2_CWD')) die("I said no cheating!"); |
| 2 | |
| 3 | // Bad Behavior entry point is start_bad_behavior(). |
| 4 | // If you're reading this, you are probably lost. |
| 5 | // Go read the bad-behavior-generic.php file. |
| 6 | |
| 7 | define('BB2_CORE', dirname(__FILE__)); |
| 8 | define('BB2_COOKIE', 'bb2_screener_'); |
| 9 | |
| 10 | require_once(BB2_CORE . "/functions.inc.php"); |
| 11 | |
| 12 | // Our log table structure |
| 13 | function bb2_table_structure($name) |
| 14 | { |
| 15 | // It's not paranoia if they really are out to get you. |
| 16 | $name_escaped = bb2_db_escape($name); |
| 17 | return "CREATE TABLE IF NOT EXISTS `$name_escaped` ( |
| 18 | `id` INT(11) NOT NULL auto_increment, |
| 19 | `ip` TEXT NOT NULL, |
| 20 | `date` DATETIME NOT NULL default '0000-00-00 00:00:00', |
| 21 | `request_method` TEXT NOT NULL, |
| 22 | `request_uri` TEXT NOT NULL, |
| 23 | `server_protocol` TEXT NOT NULL, |
| 24 | `http_headers` TEXT NOT NULL, |
| 25 | `user_agent` TEXT NOT NULL, |
| 26 | `request_entity` TEXT NOT NULL, |
| 27 | `key` TEXT NOT NULL, |
| 28 | INDEX (`ip`(15)), |
| 29 | INDEX (`user_agent`(10)), |
| 30 | PRIMARY KEY (`id`) );"; // TODO: INDEX might need tuning |
| 31 | } |
| 32 | |
| 33 | // Insert a new record |
| 34 | function bb2_insert($settings, $package, $key) |
| 35 | { |
| 36 | $ip = bb2_db_escape($package['ip']); |
| 37 | $date = bb2_db_date(); |
| 38 | $request_method = bb2_db_escape($package['request_method']); |
| 39 | $request_uri = bb2_db_escape($package['request_uri']); |
| 40 | $server_protocol = bb2_db_escape($package['server_protocol']); |
| 41 | $user_agent = bb2_db_escape($package['user_agent']); |
| 42 | $headers = "$request_method $request_uri $server_protocol\n"; |
| 43 | foreach ($package['headers'] as $h => $v) { |
| 44 | $headers .= bb2_db_escape("$h: $v\n"); |
| 45 | } |
| 46 | $request_entity = ""; |
| 47 | if (!strcasecmp($request_method, "POST")) { |
| 48 | foreach ($package['request_entity'] as $h => $v) { |
| 49 | $request_entity .= bb2_db_escape("$h: $v\n"); |
| 50 | } |
| 51 | } |
| 52 | return "INSERT INTO `" . bb2_db_escape($settings['log_table']) . "` |
| 53 | (`ip`, `date`, `request_method`, `request_uri`, `server_protocol`, `http_headers`, `user_agent`, `request_entity`, `key`) VALUES |
| 54 | ('$ip', '$date', '$request_method', '$request_uri', '$server_protocol', '$headers', '$user_agent', '$request_entity', '$key')"; |
| 55 | } |
| 56 | |
| 57 | // Kill 'em all! |
| 58 | function bb2_banned($settings, $package, $key, $previous_key=false) |
| 59 | { |
| 60 | // Some spambots hit too hard. Slow them down a bit. |
| 61 | sleep(2); |
| 62 | |
| 63 | require_once(BB2_CORE . "/banned.inc.php"); |
| 64 | bb2_display_denial($settings, $key, $previous_key); |
| 65 | bb2_log_denial($settings, $package, $key, $previous_key); |
| 66 | if (is_callable('bb2_banned_callback')) { |
| 67 | bb2_banned_callback($settings, $package, $key); |
| 68 | } |
| 69 | // Penalize the spammers some more |
| 70 | require_once(BB2_CORE . "/housekeeping.inc.php"); |
| 71 | bb2_housekeeping($settings, $package); |
| 72 | die(); |
| 73 | } |
| 74 | |
| 75 | function bb2_approved($settings, $package) |
| 76 | { |
| 77 | // Dirk wanted this |
| 78 | if (is_callable('bb2_approved_callback')) { |
| 79 | bb2_approved_callback($settings, $package); |
| 80 | } |
| 81 | |
| 82 | // Decide what to log on approved requests. |
| 83 | if (($settings['verbose'] && $settings['logging']) || empty($package['user_agent'])) { |
| 84 | bb2_db_query(bb2_insert($settings, $package, "00000000")); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // Check the results of a particular test; see below for usage |
| 89 | // Returns FALSE if test passed (yes this is backwards) |
| 90 | function bb2_test($settings, $package, $result) |
| 91 | { |
| 92 | if ($result !== FALSE) |
| 93 | { |
| 94 | bb2_banned($settings, $package, $result); |
| 95 | return TRUE; |
| 96 | } |
| 97 | return FALSE; |
| 98 | } |
| 99 | |
| 100 | |
| 101 | // Let God sort 'em out! |
| 102 | function bb2_start($settings) |
| 103 | { |
| 104 | // Gather up all the information we need, first of all. |
| 105 | $headers = bb2_load_headers(); |
| 106 | // Postprocess the headers to mixed-case |
| 107 | // FIXME: get the world to stop using PHP as CGI |
| 108 | $headers_mixed = array(); |
| 109 | foreach ($headers as $h => $v) { |
| 110 | $headers_mixed[uc_all($h)] = $v; |
| 111 | } |
| 112 | |
| 113 | // We use these frequently. Keep a copy close at hand. |
| 114 | $ip = $_SERVER['REMOTE_ADDR']; |
| 115 | $request_method = $_SERVER['REQUEST_METHOD']; |
| 116 | $request_uri = $_SERVER['REQUEST_URI']; |
| 117 | $server_protocol = $_SERVER['SERVER_PROTOCOL']; |
| 118 | @$user_agent = $_SERVER['HTTP_USER_AGENT']; |
| 119 | |
| 120 | // Reconstruct the HTTP entity, if present. |
| 121 | $request_entity = array(); |
| 122 | if (!strcasecmp($request_method, "POST") || !strcasecmp($request_method, "PUT")) { |
| 123 | foreach ($_POST as $h => $v) { |
| 124 | $request_entity[$h] = $v; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | $package = array('ip' => $ip, 'headers' => $headers, 'headers_mixed' => $headers_mixed, 'request_method' => $request_method, 'request_uri' => $request_uri, 'server_protocol' => $server_protocol, 'request_entity' => $request_entity, 'user_agent' => $user_agent, 'is_browser' => false); |
| 129 | |
| 130 | // Please proceed to the security checkpoint and have your |
| 131 | // identification and boarding pass ready. |
| 132 | |
| 133 | // First check the whitelist |
| 134 | require_once(BB2_CORE . "/whitelist.inc.php"); |
| 135 | if (!bb2_whitelist($package)) { |
| 136 | // Now check the blacklist |
| 137 | require_once(BB2_CORE . "/blacklist.inc.php"); |
| 138 | bb2_test($settings, $package, bb2_blacklist($package)); |
| 139 | |
| 140 | // Check the http:BL |
| 141 | require_once(BB2_CORE . "/blackhole.inc.php"); |
| 142 | bb2_test($settings, $package, bb2_httpbl($settings, $package)); |
| 143 | |
| 144 | // Check for common stuff |
| 145 | require_once(BB2_CORE . "/common_tests.inc.php"); |
| 146 | bb2_test($settings, $package, bb2_protocol($settings, $package)); |
| 147 | bb2_test($settings, $package, bb2_cookies($settings, $package)); |
| 148 | bb2_test($settings, $package, bb2_misc_headers($settings, $package)); |
| 149 | |
| 150 | // Specific checks |
| 151 | @$ua = $headers_mixed['User-Agent']; |
| 152 | // MSIE checks |
| 153 | if (stripos($ua, "MSIE") !== FALSE) { |
| 154 | $package['is_browser'] = true; |
| 155 | if (stripos($ua, "Opera") !== FALSE) { |
| 156 | require_once(BB2_CORE . "/opera.inc.php"); |
| 157 | bb2_test($settings, $package, bb2_opera($package)); |
| 158 | } else { |
| 159 | require_once(BB2_CORE . "/msie.inc.php"); |
| 160 | bb2_test($settings, $package, bb2_msie($package)); |
| 161 | } |
| 162 | } elseif (stripos($ua, "Konqueror") !== FALSE) { |
| 163 | $package['is_browser'] = true; |
| 164 | require_once(BB2_CORE . "/konqueror.inc.php"); |
| 165 | bb2_test($settings, $package, bb2_konqueror($package)); |
| 166 | } elseif (stripos($ua, "Opera") !== FALSE) { |
| 167 | $package['is_browser'] = true; |
| 168 | require_once(BB2_CORE . "/opera.inc.php"); |
| 169 | bb2_test($settings, $package, bb2_opera($package)); |
| 170 | } elseif (stripos($ua, "Safari") !== FALSE) { |
| 171 | $package['is_browser'] = true; |
| 172 | require_once(BB2_CORE . "/safari.inc.php"); |
| 173 | bb2_test($settings, $package, bb2_safari($package)); |
| 174 | } elseif (stripos($ua, "Lynx") !== FALSE) { |
| 175 | $package['is_browser'] = true; |
| 176 | require_once(BB2_CORE . "/lynx.inc.php"); |
| 177 | bb2_test($settings, $package, bb2_lynx($package)); |
| 178 | } elseif (stripos($ua, "MovableType") !== FALSE) { |
| 179 | require_once(BB2_CORE . "/movabletype.inc.php"); |
| 180 | bb2_test($settings, $package, bb2_movabletype($package)); |
| 181 | } elseif (stripos($ua, "msnbot") !== FALSE || stripos($ua, "MS Search") !== FALSE) { |
| 182 | require_once(BB2_CORE . "/msnbot.inc.php"); |
| 183 | bb2_test($settings, $package, bb2_msnbot($package)); |
| 184 | } elseif (stripos($ua, "Googlebot") !== FALSE || stripos($ua, "Mediapartners-Google") !== FALSE) { |
| 185 | require_once(BB2_CORE . "/google.inc.php"); |
| 186 | bb2_test($settings, $package, bb2_google($package)); |
| 187 | } elseif (stripos($ua, "Mozilla") !== FALSE && stripos($ua, "Mozilla") == 0) { |
| 188 | $package['is_browser'] = true; |
| 189 | require_once(BB2_CORE . "/mozilla.inc.php"); |
| 190 | bb2_test($settings, $package, bb2_mozilla($package)); |
| 191 | } |
| 192 | |
| 193 | // More intensive screening applies to POST requests |
| 194 | if (!strcasecmp('POST', $package['request_method'])) { |
| 195 | require_once(BB2_CORE . "/post.inc.php"); |
| 196 | bb2_test($settings, $package, bb2_post($settings, $package)); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | // Last chance screening. |
| 201 | require_once(BB2_CORE . "/screener.inc.php"); |
| 202 | bb2_screener($settings, $package); |
| 203 | |
| 204 | // And that's about it. |
| 205 | bb2_approved($settings, $package); |
| 206 | return true; |
| 207 | } |
| 208 | ?> |
| gettext.php |
| 1 | <?php |
| 2 | /** |
| 3 | * PHP-Gettext External Library: gettext_reader class |
| 4 | * |
| 5 | * @package External |
| 6 | * @subpackage PHP-gettext |
| 7 | * @version 1.0.7-WordPress.2.8.5 |
| 8 | * |
| 9 | * @internal |
| 10 | Copyright (c) 2003 Danilo Segan <danilo@kvota.net>. |
| 11 | Copyright (c) 2005 Nico Kaiser <nico@siriux.net> |
| 12 | |
| 13 | This file is part of PHP-gettext. |
| 14 | |
| 15 | PHP-gettext is free software; you can redistribute it and/or modify |
| 16 | it under the terms of the GNU General Public License as published by |
| 17 | the Free Software Foundation; either version 2 of the License, or |
| 18 | (at your option) any later version. |
| 19 | |
| 20 | PHP-gettext is distributed in the hope that it will be useful, |
| 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | GNU General Public License for more details. |
| 24 | |
| 25 | You should have received a copy of the GNU General Public License |
| 26 | along with PHP-gettext; if not, write to the Free Software |
| 27 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 28 | |
| 29 | */ |
| 30 | |
| 31 | /** |
| 32 | * Provides a simple gettext replacement that works independently from |
| 33 | * the system's gettext abilities. |
| 34 | * It can read MO files and use them for translating strings. |
| 35 | * The files are passed to gettext_reader as a Stream (see streams.php) |
| 36 | * |
| 37 | * This version has the ability to cache all strings and translations to |
| 38 | * speed up the string lookup. |
| 39 | * While the cache is enabled by default, it can be switched off with the |
| 40 | * second parameter in the constructor (e.g. whenusing very large MO files |
| 41 | * that you don't want to keep in memory) |
| 42 | */ |
| 43 | class gettext_reader { |
| 44 | //public: |
| 45 | var $error = 0; // public variable that holds error code (0 if no error) |
| 46 | |
| 47 | //private: |
| 48 | var $BYTEORDER = 0; // 0: low endian, 1: big endian |
| 49 | var $STREAM = NULL; |
| 50 | var $short_circuit = false; |
| 51 | var $enable_cache = false; |
| 52 | var $originals = NULL; // offset of original table |
| 53 | var $translations = NULL; // offset of translation table |
| 54 | var $pluralheader = NULL; // cache header field for plural forms |
| 55 | var $select_string_function = NULL; // cache function, which chooses plural forms |
| 56 | var $total = 0; // total string count |
| 57 | var $table_originals = NULL; // table for original strings (offsets) |
| 58 | var $table_translations = NULL; // table for translated strings (offsets) |
| 59 | var $cache_translations = NULL; // original -> translation mapping |
| 60 | |
| 61 | |
| 62 | /* Methods */ |
| 63 | |
| 64 | |
| 65 | /** |
| 66 | * Reads a 32bit Integer from the Stream |
| 67 | * |
| 68 | * @access private |
| 69 | * @return Integer from the Stream |
| 70 | */ |
| 71 | function readint() { |
| 72 | if ($this->BYTEORDER == 0) { |
| 73 | // low endian |
| 74 | $low_end = unpack('V', $this->STREAM->read(4)); |
| 75 | return array_shift($low_end); |
| 76 | } else { |
| 77 | // big endian |
| 78 | $big_end = unpack('N', $this->STREAM->read(4)); |
| 79 | return array_shift($big_end); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Reads an array of Integers from the Stream |
| 85 | * |
| 86 | * @param int count How many elements should be read |
| 87 | * @return Array of Integers |
| 88 | */ |
| 89 | function readintarray($count) { |
| 90 | if ($this->BYTEORDER == 0) { |
| 91 | // low endian |
| 92 | return unpack('V'.$count, $this->STREAM->read(4 * $count)); |
| 93 | } else { |
| 94 | // big endian |
| 95 | return unpack('N'.$count, $this->STREAM->read(4 * $count)); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Constructor |
| 101 | * |
| 102 | * @param object Reader the StreamReader object |
| 103 | * @param boolean enable_cache Enable or disable caching of strings (default on) |
| 104 | */ |
| 105 | function gettext_reader($Reader, $enable_cache = true) { |
| 106 | // If there isn't a StreamReader, turn on short circuit mode. |
| 107 | if (! $Reader || isset($Reader->error) ) { |
| 108 | $this->short_circuit = true; |
| 109 | return; |
| 110 | } |
| 111 | |
| 112 | // Caching can be turned off |
| 113 | $this->enable_cache = $enable_cache; |
| 114 | |
| 115 | // $MAGIC1 = (int)0x950412de; //bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565 |
| 116 | $MAGIC1 = (int) - 1794895138; |
| 117 | // $MAGIC2 = (int)0xde120495; //bug |
| 118 | $MAGIC2 = (int) - 569244523; |
| 119 | // 64-bit fix |
| 120 | $MAGIC3 = (int) 2500072158; |
| 121 | |
| 122 | $this->STREAM = $Reader; |
| 123 | $magic = $this->readint(); |
| 124 | if ($magic == $MAGIC1 || $magic == $MAGIC3) { // to make sure it works for 64-bit platforms |
| 125 | $this->BYTEORDER = 0; |
| 126 | } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) { |
| 127 | $this->BYTEORDER = 1; |
| 128 | } else { |
| 129 | $this->error = 1; // not MO file |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | // FIXME: Do we care about revision? We should. |
| 134 | $revision = $this->readint(); |
| 135 | |
| 136 | $this->total = $this->readint(); |
| 137 | $this->originals = $this->readint(); |
| 138 | $this->translations = $this->readint(); |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Loads the translation tables from the MO file into the cache |
| 143 | * If caching is enabled, also loads all strings into a cache |
| 144 | * to speed up translation lookups |
| 145 | * |
| 146 | * @access private |
| 147 | */ |
| 148 | function load_tables() { |
| 149 | if (is_array($this->cache_translations) && |
| 150 | is_array($this->table_originals) && |
| 151 | is_array($this->table_translations)) |
| 152 | return; |
| 153 | |
| 154 | /* get original and translations tables */ |
| 155 | $this->STREAM->seekto($this->originals); |
| 156 | $this->table_originals = $this->readintarray($this->total * 2); |
| 157 | $this->STREAM->seekto($this->translations); |
| 158 | $this->table_translations = $this->readintarray($this->total * 2); |
| 159 | |
| 160 | if ($this->enable_cache) { |
| 161 | $this->cache_translations = array (); |
| 162 | /* read all strings in the cache */ |
| 163 | for ($i = 0; $i < $this->total; $i++) { |
| 164 | $this->STREAM->seekto($this->table_originals[$i * 2 + 2]); |
| 165 | $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]); |
| 166 | $this->STREAM->seekto($this->table_translations[$i * 2 + 2]); |
| 167 | $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]); |
| 168 | $this->cache_translations[$original] = $translation; |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Returns a string from the "originals" table |
| 175 | * |
| 176 | * @access private |
| 177 | * @param int num Offset number of original string |
| 178 | * @return string Requested string if found, otherwise '' |
| 179 | */ |
| 180 | function get_original_string($num) { |
| 181 | $length = $this->table_originals[$num * 2 + 1]; |
| 182 | $offset = $this->table_originals[$num * 2 + 2]; |
| 183 | if (! $length) |
| 184 | return ''; |
| 185 | $this->STREAM->seekto($offset); |
| 186 | $data = $this->STREAM->read($length); |
| 187 | return (string)$data; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Returns a string from the "translations" table |
| 192 | * |
| 193 | * @access private |
| 194 | * @param int num Offset number of original string |
| 195 | * @return string Requested string if found, otherwise '' |
| 196 | */ |
| 197 | function get_translation_string($num) { |
| 198 | $length = $this->table_translations[$num * 2 + 1]; |
| 199 | $offset = $this->table_translations[$num * 2 + 2]; |
| 200 | if (! $length) |
| 201 | return ''; |
| 202 | $this->STREAM->seekto($offset); |
| 203 | $data = $this->STREAM->read($length); |
| 204 | return (string)$data; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Binary search for string |
| 209 | * |
| 210 | * @access private |
| 211 | * @param string string |
| 212 | * @param int start (internally used in recursive function) |
| 213 | * @param int end (internally used in recursive function) |
| 214 | * @return int string number (offset in originals table) |
| 215 | */ |
| 216 | function find_string($string, $start = -1, $end = -1) { |
| 217 | if (($start == -1) or ($end == -1)) { |
| 218 | // find_string is called with only one parameter, set start end end |
| 219 | $start = 0; |
| 220 | $end = $this->total; |
| 221 | } |
| 222 | if (abs($start - $end) <= 1) { |
| 223 | // We're done, now we either found the string, or it doesn't exist |
| 224 | $txt = $this->get_original_string($start); |
| 225 | if ($string == $txt) |
| 226 | return $start; |
| 227 | else |
| 228 | return -1; |
| 229 | } else if ($start > $end) { |
| 230 | // start > end -> turn around and start over |
| 231 | return $this->find_string($string, $end, $start); |
| 232 | } else { |
| 233 | // Divide table in two parts |
| 234 | $half = (int)(($start + $end) / 2); |
| 235 | $cmp = strcmp($string, $this->get_original_string($half)); |
| 236 | if ($cmp == 0) |
| 237 | // string is exactly in the middle => return it |
| 238 | return $half; |
| 239 | else if ($cmp < 0) |
| 240 | // The string is in the upper half |
| 241 | return $this->find_string($string, $start, $half); |
| 242 | else |
| 243 | // The string is in the lower half |
| 244 | return $this->find_string($string, $half, $end); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * Translates a string |
| 250 | * |
| 251 | * @access public |
| 252 | * @param string string to be translated |
| 253 | * @return string translated string (or original, if not found) |
| 254 | */ |
| 255 | function translate($string) { |
| 256 | if ($this->short_circuit) |
| 257 | return $string; |
| 258 | $this->load_tables(); |
| 259 | |
| 260 | if ($this->enable_cache) { |
| 261 | // Caching enabled, get translated string from cache |
| 262 | if (array_key_exists($string, $this->cache_translations)) |
| 263 | return $this->cache_translations[$string]; |
| 264 | else |
| 265 | return $string; |
| 266 | } else { |
| 267 | // Caching not enabled, try to find string |
| 268 | $num = $this->find_string($string); |
| 269 | if ($num == -1) |
| 270 | return $string; |
| 271 | else |
| 272 | return $this->get_translation_string($num); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | /** |
| 277 | * Get possible plural forms from MO header |
| 278 | * |
| 279 | * @access private |
| 280 | * @return string plural form header |
| 281 | */ |
| 282 | function get_plural_forms() { |
| 283 | // lets assume message number 0 is header |
| 284 | // this is true, right? |
| 285 | $this->load_tables(); |
| 286 | |
| 287 | // cache header field for plural forms |
| 288 | if (! is_string($this->pluralheader)) { |
| 289 | if ($this->enable_cache) { |
| 290 | $header = $this->cache_translations[""]; |
| 291 | } else { |
| 292 | $header = $this->get_translation_string(0); |
| 293 | } |
| 294 | $header .= "\n"; //make sure our regex matches |
| 295 | if (eregi("plural-forms: ([^\n]*)\n", $header, $regs)) |
| 296 | $expr = $regs[1]; |
| 297 | else |
| 298 | $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
| 299 | |
| 300 | // add parentheses |
| 301 | // important since PHP's ternary evaluates from left to right |
| 302 | $expr.= ';'; |
| 303 | $res= ''; |
| 304 | $p= 0; |
| 305 | for ($i= 0; $i < strlen($expr); $i++) { |
| 306 | $ch= $expr[$i]; |
| 307 | switch ($ch) { |
| 308 | case '?': |
| 309 | $res.= ' ? ('; |
| 310 | $p++; |
| 311 | break; |
| 312 | case ':': |
| 313 | $res.= ') : ('; |
| 314 | break; |
| 315 | case ';': |
| 316 | $res.= str_repeat( ')', $p) . ';'; |
| 317 | $p= 0; |
| 318 | break; |
| 319 | default: |
| 320 | $res.= $ch; |
| 321 | } |
| 322 | } |
| 323 | $this->pluralheader = $res; |
| 324 | } |
| 325 | |
| 326 | return $this->pluralheader; |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * Detects which plural form to take |
| 331 | * |
| 332 | * @access private |
| 333 | * @param n count |
| 334 | * @return int array index of the right plural form |
| 335 | */ |
| 336 | function select_string($n) { |
| 337 | if (is_null($this->select_string_function)) { |
| 338 | $string = $this->get_plural_forms(); |
| 339 | if (preg_match("/nplurals\s*=\s*(\d+)\s*\;\s*plural\s*=\s*(.*?)\;+/", $string, $matches)) { |
| 340 | $nplurals = $matches[1]; |
| 341 | $expression = $matches[2]; |
| 342 | $expression = str_replace("n", '$n', $expression); |
| 343 | } else { |
| 344 | $nplurals = 2; |
| 345 | $expression = ' $n == 1 ? 0 : 1 '; |
| 346 | } |
| 347 | $func_body = " |
| 348 | \$plural = ($expression); |
| 349 | return (\$plural <= $nplurals)? \$plural : \$plural - 1;"; |
| 350 | $this->select_string_function = create_function('$n', $func_body); |
| 351 | } |
| 352 | return call_user_func($this->select_string_function, $n); |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * Plural version of gettext |
| 357 | * |
| 358 | * @access public |
| 359 | * @param string single |
| 360 | * @param string plural |
| 361 | * @param string number |
| 362 | * @return translated plural form |
| 363 | */ |
| 364 | function ngettext($single, $plural, $number) { |
| 365 | if ($this->short_circuit) { |
| 366 | if ($number != 1) |
| 367 | return $plural; |
| 368 | else |
| 369 | return $single; |
| 370 | } |
| 371 | |
| 372 | // find out the appropriate form |
| 373 | $select = $this->select_string($number); |
| 374 | |
| 375 | // this should contains all strings separated by NULLs |
| 376 | $key = $single.chr(0).$plural; |
| 377 | |
| 378 | |
| 379 | if ($this->enable_cache) { |
| 380 | if (! array_key_exists($key, $this->cache_translations)) { |
| 381 | return ($number != 1) ? $plural : $single; |
| 382 | } else { |
| 383 | $result = $this->cache_translations[$key]; |
| 384 | $list = explode(chr(0), $result); |
| 385 | return $list[$select]; |
| 386 | } |
| 387 | } else { |
| 388 | $num = $this->find_string($key); |
| 389 | if ($num == -1) { |
| 390 | return ($number != 1) ? $plural : $single; |
| 391 | } else { |
| 392 | $result = $this->get_translation_string($num); |
| 393 | $list = explode(chr(0), $result); |
| 394 | return $list[$select]; |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | } |
| 400 | |
| 401 | ?> |
| tighturl.lib.inc.php |
| 1 | <?php |
| 2 | define("TLVERSION", "0.1.4"); |
| 3 | define("TLREQUIRED_PHP_VERSION", "4.3.0"); |
| 4 | error_reporting (E_ALL); |
| 5 | |
| 6 | // You REALLY don't want to edit below here unless you know what you're doing. |
| 7 | |
| 8 | // ************************************************************************* |
| 9 | |
| 10 | if (version_compare(phpversion(), REQUIRED_PHP_VERSION)<0) { |
| 11 | die("$svcname Error: TightURL ".VERSION." needs PHP >= ".REQUIRED_PHP_VERSION." (you are using ".phpversion().")"); |
| 12 | } |
| 13 | |
| 14 | |
| 15 | $validipv4pattern = "/^(http|https|ftp|sftp):\/\/(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\."; |
| 16 | $validipv4pattern .= "(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])"; |
| 17 | $validipv4pattern .= "\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\/*/"; |
| 18 | |
| 19 | // ****** !All overridable configuration variables must go above this line! ****** |
| 20 | |
| 21 | function TightURL_version_check() { |
| 22 | global $VUCycle; |
| 23 | |
| 24 | // check http://tighturl.com/version.php and/or http://tighturl.sf.net/version.php |
| 25 | // parse out if there's a security release |
| 26 | // notify admin of this tighturl installation once if there's a new version, |
| 27 | // once a week, if there's a security fix. |
| 28 | // Possibly display "newer version available" on templates. |
| 29 | // Possibly disable vulnerable versions after a certain amount of time. |
| 30 | // ie, only show "Site down for emergency maintenance. If you are the administrator, click here." |
| 31 | // validate against mysql database password, show vulnerability screen. |
| 32 | |
| 33 | if ($VUCycle < 24) $VUCycle = 24; // someone's trying to get banned. |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Checks accepted URLs against URI blacklists and marks listed URLs as abused. |
| 38 | */ |
| 39 | function TightURL_KillBot($query='') { |
| 40 | |
| 41 | global $dbtable; |
| 42 | |
| 43 | if ($query == "") $query="SELECT * FROM $dbtable;"; |
| 44 | |
| 45 | // Query records with status normal, and added within last 2 weeks or records with status normal and more than 7 hits and hit within the last 2 weeks |
| 46 | // "SELECT * FROM $dbtable where status=0 && (DATE_SUB(CURDATE(), INTERVAL 14 DAY) <= adddate || (hits > 7 && DATE_SUB(CURDATE(), INTERVAL 14 DAY) <= lasthit)) ORDER BY id;" |
| 47 | $set = mysql_query($query); |
| 48 | $rows = @mysql_num_rows($set) or $rows = 0; |
| 49 | |
| 50 | for ($i = 0; $i <$rows; $i++) { |
| 51 | |
| 52 | $row = mysql_fetch_array($set); |
| 53 | $id = $row["id"]; |
| 54 | $url = $row["url"]; |
| 55 | $status = $row["status"]; |
| 56 | $hits = $row["hits"]; |
| 57 | |
| 58 | $hit = URI_on_URIBL($url); |
| 59 | if ($hit) { |
| 60 | // Change this to disable instead of delete, delete at some future point. |
| 61 | $req ="update $dbtable set status=3 where id='$id';"; |
| 62 | $res = mysql_query($req); |
| 63 | } |
| 64 | // elseif ($hits > 4000) { |
| 65 | // // Change this to disable instead of delete, delete at some future point. |
| 66 | // $req ="update $dbtable set status=5 where id='$id';"; |
| 67 | // $res = mysql_query($req); |
| 68 | // } |
| 69 | else { |
| 70 | $req = "update $dbtable set lastcheck=NOW(), checkcount=checkcount+1 where id='$id';"; |
| 71 | $res = mysql_query($req); |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | function TightURL_NewReport($query='') { |
| 77 | |
| 78 | global $dbtable; |
| 79 | |
| 80 | if ($query == "") $query="SELECT * FROM $dbtable;"; |
| 81 | |
| 82 | $set = mysql_query($query); |
| 83 | $rows = @mysql_num_rows($set) or $rows = 0; |
| 84 | |
| 85 | if ($rows > 0) { |
| 86 | $MP = "/usr/sbin/sendmail -t ron@vnetworx.net"; |
| 87 | $fd = popen($MP, "w"); |
| 88 | fputs($fd, "To: ron@vnetworx.net\n"); |
| 89 | fputs($fd, "From: killbot@tighturl.com <killbot@tighturl.com>\n"); |
| 90 | fputs($fd, "Subject: TightURL additions report\n"); |
| 91 | fputs($fd, "\n"); |
| 92 | |
| 93 | for ($i = 0; $i <$rows; $i++) { |
| 94 | $row = mysql_fetch_array($set); |
| 95 | $id = $row["id"]; |
| 96 | $url = $row["url"]; |
| 97 | fputs($fd, "Block: http://tighturl.com/?p=" . base_convert($id, 10, 36) . " URL: $url\n\n"); |
| 98 | } |
| 99 | pclose($fd); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Checks to see if a given URI is on a URI blacklist. |
| 105 | * Currently this means SURBL (http://www.surbl.org) and URIBL (http://www.uribl.com) |
| 106 | * |
| 107 | * Returns TRUE if the domain is listed on any configured URIBLs. |
| 108 | * |
| 109 | * A companion URI extractor must be written for the below issues |
| 110 | * Must be changed to do full resolution of redirections on URI, simulating a browser |
| 111 | * Must be changed to do IPv6 lookups |
| 112 | * Must be changed to check multiple URIs |
| 113 | * Must be changed to optionally check HTML entity encoded versions of URIs |
| 114 | * Must be changed to handle URIBL's inclusion of some third-level domains. |
| 115 | * |
| 116 | */ |
| 117 | function URI_on_URIBL($uri) { |
| 118 | |
| 119 | // This code does not yet properly implement a correct and efficient querying |
| 120 | // of URI BL data. |
| 121 | |
| 122 | global $uribl, $uribluri, $validurlpattern, $validipv4pattern, $tltlds, $validschemes; |
| 123 | |
| 124 | $uribls = ""; |
| 125 | |
| 126 | if ($uri) { |
| 127 | // Test for IPv4 address, reverse the quads if found |
| 128 | if (preg_match($validipv4pattern,$uri,$matches)) { |
| 129 | $domain=$matches[5] . "." . $matches[4] . "." . $matches[3] . "." . $matches[2]; |
| 130 | } |
| 131 | else { |
| 132 | // strip out second-level domain name, *unless* on exception list, |
| 133 | // in which case, strip out third level also and test that instead. |
| 134 | preg_match("/^".$validschemes.$validurlpattern."$/", $uri, $matches); |
| 135 | //preg_match($validurlpattern, $uri, $matches); |
| 136 | $domain = $matches[4]; |
| 137 | if (preg_match("/".$tltlds."$/", $domain, $matches)) {$levels = 2;} else {$levels = 1;} |
| 138 | //if (preg_match($tltlds, $domain, $matches)) {$levels = 2;} else {$levels = 1;} |
| 139 | |
| 140 | // klugey stripping routine to reduce domain to base domain name |
| 141 | // expect regex wojuld be better |
| 142 | // (.*\..*){2} matches vnetworx.co.uk but not vnetworx.com |
| 143 | // .*(\.co\.uk) matches[1] .co.uk |
| 144 | |
| 145 | $ss = countSubstrs($domain, "."); |
| 146 | while ($ss > $levels) { |
| 147 | $chop = strpos($domain, "."); |
| 148 | $domain = substr($domain, $chop + 1); |
| 149 | $ss = countSubstrs($domain, "."); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | // Query URI blacklists to see if domain/IP appears as target in known spam |
| 154 | // or something involved in a malware/phishing attack. |
| 155 | for ($i=0; $i<count($uribl); $i++) { |
| 156 | $fqdn = $domain . "." . $uribl[$i]; |
| 157 | $recexists = gethostbyname($fqdn); // ghbn weirdly returns the name on failure |
| 158 | if ($recexists != $fqdn) { |
| 159 | if ($i > 0) $uribls .= ", "; |
| 160 | $uribls .= $uribl[$i]; |
| 161 | } |
| 162 | } |
| 163 | if ($uribls) return $uribls; else return FALSE; // change to return an array of indexes into the URIBL array |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * Checks to see if a given URL is a Reserved URL. |
| 169 | * |
| 170 | * Returns TRUE if the ID is listed as a Reserved URL. |
| 171 | */ |
| 172 | function on_Reserve($decimal) { |
| 173 | global $ReservedURL; |
| 174 | |
| 175 | $res=FALSE; |
| 176 | |
| 177 | if ($decimal) { |
| 178 | $sexatrigesimal = base_convert($decimal, 10, 36); |
| 179 | for ($i=0; $i<count($ReservedURL); $i++) { |
| 180 | if ($sexatrigesimal == strtolower($ReservedURL[$i])) return TRUE; |
| 181 | } |
| 182 | return FALSE; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | function http_headers ($uri) { |
| 187 | array ($headers); |
| 188 | // Split URI into host and resource parts |
| 189 | $parsed = parse_url($uri); |
| 190 | |
| 191 | if ($parsed[port] == 0) $parsed[port] = 80; |
| 192 | |
| 193 | $connection = fsockopen ($parsed[host], $parsed[port]); |
| 194 | if ($connection) { |
| 195 | stream_set_timeout($connection, 2); |
| 196 | fwrite($connection, "HEAD $parsed[path] HTTP/1.1\r\nHOST: $parsed[host]\r\n\r\n"); |
| 197 | while (!feof($connection)) { |
| 198 | $line_read=fgets($connection); |
| 199 | if ($line_read == "") break; |
| 200 | $headers[] = $line_read; |
| 201 | } |
| 202 | fclose ($connection); |
| 203 | } |
| 204 | return $headers; |
| 205 | } |
| 206 | |
| 207 | // ***************** Non-TightURL-specific functions ********************* |
| 208 | |
| 209 | /** |
| 210 | * sanitize a string for MySQL input |
| 211 | */ |
| 212 | if (! function_exists('sanitize_sql_string')) { |
| 213 | function sanitize_sql_string($string) { |
| 214 | if (get_magic_quotes_gpc()) $string = stripslashes($string); |
| 215 | return mysql_escape_string($string); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Counts the number of times a substring is contained in a given string. |
| 221 | */ |
| 222 | if (! function_exists('countSubstrs')) { |
| 223 | function countSubstrs($haystack, $needle) { |
| 224 | return (($p = strpos($haystack, $needle)) === false) ? 0 : (1 + countSubstrs(substr($haystack, $p+1), $needle)); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | // ***************** PHP compatibility functions ********************* |
| 229 | |
| 230 | /** |
| 231 | * Add back get_magic_quotes_gpc() if this is PHP6 or later |
| 232 | */ |
| 233 | if (! function_exists('get_magic_quotes_gpc')) { |
| 234 | function get_magic_quotes_gpc() |
| 235 | { |
| 236 | return 0; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * Add in version_compare for PHP < 4.0.7 |
| 242 | */ |
| 243 | if (! function_exists('version_compare')) { |
| 244 | function version_compare($version1, $version2) |
| 245 | { |
| 246 | $v1 = explode('.', $version1); |
| 247 | $v2 = explode('.', $version2); |
| 248 | |
| 249 | if ($v1[0] > $v2[0]) $ret = 1; |
| 250 | elseif ($v1[0] < $v2[0]) $ret = -1; |
| 251 | else { |
| 252 | // Major version numbers are equal |
| 253 | if ($v1[1] > $v2[1]) $ret = 1; |
| 254 | elseif ($v1[1] < $v2[1]) $ret = -1; |
| 255 | else { |
| 256 | // Minor version numbers are equal |
| 257 | if ($v1[2] > $v2[2]) $ret = 1; |
| 258 | elseif ($v1[2] < $v2[2]) $ret = -1; |
| 259 | else $ret = 0; |
| 260 | } |
| 261 | } |
| 262 | return $ret; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Add in file_get_contents for PHP < 4.3.0 |
| 268 | */ |
| 269 | if (! function_exists('file_get_contents')) { |
| 270 | function file_get_contents($filename, $incpath = false, $resource_context = null) |
| 271 | { |
| 272 | if (false === $fh = fopen($filename, 'rb', $incpath)) { |
| 273 | trigger_error('file_get_contents() failed to open stream: No such file or directory', E_USER_WARNING); |
| 274 | return false; |
| 275 | } |
| 276 | clearstatcache(); |
| 277 | if ($fsize = @filesize($filename)) $data = fread($fh, $fsize); |
| 278 | else { |
| 279 | $data = ''; |
| 280 | while (!feof($fh)) $data .= fread($fh, 8192); |
| 281 | } |
| 282 | fclose($fh); |
| 283 | return $data; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | ?> |
| tighturl.php |
| 1 | <?php |
| 2 | /** |
| 3 | * TightURL :: A blind redirection service |
| 4 | * |
| 5 | * Copyright (c) 2004-2008, Ron Guerin <ron@vnetworx.net> |
| 6 | * portions Copyright (c) 2002,2003 Free Software Foundation |
| 7 | * |
| 8 | * This file implements a blind redirection service named TightURL. |
| 9 | * TightURL is Free Software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * TightURL is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 17 | * See the GNU General Public License for more details. |
| 18 | * |
| 19 | * If you are not able to view the LICENSE, which should |
| 20 | * always be possible within a valid and working TightURL release, |
| 21 | * please write to the Free Software Foundation, Inc., |
| 22 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 | * to get a copy of the GNU General Public License or to report a |
| 24 | * possible license violation. |
| 25 | * |
| 26 | * @package TightURL |
| 27 | * @author Ron Guerin <ron@vnetworx.net> |
| 28 | * @license http://www.fsf.org/licenses/gpl.html GNU Public License |
| 29 | * @copyright Copyright © 2004-2009 Ron Guerin |
| 30 | * @filesource |
| 31 | * @link http://tighturl.com TightURL |
| 32 | * @version 0.1.4 |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | define("VERSION", "0.1.4"); |
| 37 | define("REQUIRED_PHP_VERSION", "4.3.0"); |
| 38 | |
| 39 | // System defaults, DO NOT EDIT THIS FILE |
| 40 | // Edit tighturl.config.inc.php instead! |
| 41 | |
| 42 | global $copyright, $conn, $db, $os, $svcname; |
| 43 | |
| 44 | $dbhost = "localhost"; |
| 45 | $dbuser = "dbuser"; |
| 46 | $dbpass = "dbpass"; |
| 47 | $dbname = "tighturl"; |
| 48 | $dbtable = "urls"; |
| 49 | $FOFMethod=FALSE; //0=Full URL path or mod_rewrite, 1=404-Method compressed URLs |
| 50 | $os=""; |
| 51 | |
| 52 | // URIBL variables |
| 53 | $uribl = array("multi.surbl.org", "black.uribl.com"); |
| 54 | $uriblurl = array("www.surbl.org", "www.uribl.com"); |
| 55 | |
| 56 | // Bad Behavior variables |
| 57 | $BB2 = true; |
| 58 | $BBstats = true; |
| 59 | $BBstrict = false; |
| 60 | $BBverbose = true; |
| 61 | $BBLogging = true; |
| 62 | $bb2_settings_defaults = ""; |
| 63 | |
| 64 | // Require submitted URLs to exist? |
| 65 | $mustexist = true; |
| 66 | |
| 67 | // Text strings and style variables |
| 68 | $svcname = "URLSquisher"; |
| 69 | $verbtext = "Squish"; |
| 70 | $pasttext = "Squished"; |
| 71 | $tagline = "Squish long URLs to make short ones"; |
| 72 | $headcolor = "#006600"; |
| 73 | $tablecolor = "#00CC99"; |
| 74 | $copystart = date("Y"); |
| 75 | $copyrightholder = "SquishURL Enterprises"; |
| 76 | |
| 77 | // Reserved URLs |
| 78 | $ReservedURL = array("x", "rest", "xmlrpc", "soap", "xml", "atom", "rss", "blog", |
| 79 | "faq", "help", "about", "api", "code", "source", "docs", |
| 80 | "git", "cvs", "arch", "url", "admin", "setup", "svn", "project", |
| 81 | "abuse", "cgi-sys", "exploited"); |
| 82 | |
| 83 | // You REALLY don't want to edit below here unless you know what you're doing. |
| 84 | |
| 85 | // ************************************************************************* |
| 86 | |
| 87 | if (version_compare(phpversion(), REQUIRED_PHP_VERSION)<0) { |
| 88 | die_HTML($svcname, "Error: TightURL ".VERSION." needs PHP >= ".REQUIRED_PHP_VERSION." (you are using ".phpversion().")"); |
| 89 | } |
| 90 | |
| 91 | if (file_exists("tighturl-install.php")) die_HTML($svcname, "Error: You must remove tighturl-install.php before using $svcname."); |
| 92 | |
| 93 | $os=strpos(strtolower(PHP_OS), "win")===false?"nix":"win"; |
| 94 | |
| 95 | $validurlpattern = "\:\/\/([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)" |
| 96 | . "*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])" |
| 97 | . "\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)" |
| 98 | . "\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)" |
| 99 | . "\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])" |
| 100 | . "|((([0-9A-F]{1,4}(((:[0-9A-F]{1,4}){5}::[0-9A-F]{1,4})|((:[0-9A-F]{1,4}){4}" |
| 101 | . "::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,1})|((:[0-9A-F]{1,4}){3}::[0-9A-F]{1,4}" |
| 102 | . "(:[0-9A-F]{1,4}){0,2})|((:[0-9A-F]{1,4}){2}::[0-9A-F]{1,4}(:[0-9A-F]{1,4})" |
| 103 | . "{0,3})|(:[0-9A-F]{1,4}::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,4})|(::[0-9A-F]{1,4}" |
| 104 | . "(:[0-9A-F]{1,4}){0,5})|(:[0-9A-F]{1,4}){7}))|(::[0-9A-F]{1,4}(:[0-9A-F]{1,4}" |
| 105 | . "){0,6}))|::)|((([0-9A-F]{1,4}(((:[0-9A-F]{1,4}){3}::([0-9A-F]{1,4}){1})" |
| 106 | . "|((:[0-9A-F]{1,4}){2}::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,1})|((:[0-9A-F]{1,4})" |
| 107 | . "{1}::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,2})|(::[0-9A-F]{1,4}(:[0-9A-F]{1,4}" |
| 108 | . "){0,3})|((:[0-9A-F]{1,4}){0,5})))|([:]{2}[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,4}))" |
| 109 | . ":|::)((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{0,2})\.){3}(25[0-5]|2[0-4][0-9]|" |
| 110 | . "[0-1]?[0-9]{0,2})" |
| 111 | . "|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org" |
| 112 | . "|mobi|biz|arpa|info|name|pro|aero|coop|museum" |
| 113 | . "|[a-zA-Z]{2}))(\:[0-9]+)*(\/.($|[a-zA-Z0-9\.\:\,\?\'\(\)\\\*\+&%\$;|#\=~_\-\s@]*))*\/*"; |
| 114 | |
| 115 | $validipv4pattern = ":\/\/(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\." |
| 116 | . "(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])" |
| 117 | . "\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\/*"; |
| 118 | |
| 119 | $forbid = "\.(cmd|bat|exe|scr|pif|vbs|js|pif|msi|cdr)"; |
| 120 | |
| 121 | // ****** !All overridable configuration variables must go above this line! ****** |
| 122 | |
| 123 | if (! isset($antiabuse)) $antiabuse = true; |
| 124 | if (! isset($netchecks)) $netchecks = true; |
| 125 | if (! isset($mustexist)) $mustexist = true; |
| 126 | |
| 127 | // Status: 0=Ok, 1=Warn, 2=Black, 3=Policy, 4=Complaints |
| 128 | |
| 129 | if (file_exists("tighturl.urlpattern.inc.php")) include("tighturl.urlpattern.inc.php"); |
| 130 | if (file_exists("tighturl.tltpattern.inc.php")) include("tighturl.tltpattern.inc.php"); |
| 131 | if (file_exists("tighturl.redirpattern.inc.php")) include("tighturl.redirpattern.inc.php"); |
| 132 | if (file_exists("tighturl.ptcpattern.inc.php")) include("tighturl.ptcpattern.inc.php"); |
| 133 | if (file_exists("tighturl.blpattern.inc.php")) include("tighturl.blpattern.inc.php"); |
| 134 | if (file_exists("tighturl.config.inc.php")) include("tighturl.config.inc.php"); |
| 135 | |
| 136 | // Figure out our copyright string |
| 137 | $thisyear = date("Y"); |
| 138 | $copyright = $copystart; |
| 139 | if ($copystart != $thisyear) $copyright .= "-" . $thisyear; |
| 140 | $uribls = ""; |
| 141 | for ($i=0; $i<count($uribl); $i++) { |
| 142 | if ($i > 0) $uribls .= ", "; |
| 143 | $uribls .= "<a href='http://" . $uriblurl[$i] . "'>" . $uribl[$i] . "</a>"; |
| 144 | } |
| 145 | |
| 146 | if (! $FOFMethod) $parm = "?i="; // We need the parameter tag |
| 147 | |
| 148 | // Figure out correct self |
| 149 | if (strncmp($_SERVER['PHP_SELF'], $_SERVER['REQUEST_URI'], strlen($_SERVER['PHP_SELF'])) != 0) { |
| 150 | if (preg_match("|(.*)/.*$|",$_SERVER['PHP_SELF'],$matches)) $self = $matches[1]; |
| 151 | if (! preg_match("|.*/$|", $self)) $self .= "/"; |
| 152 | } |
| 153 | else { |
| 154 | $self = $_SERVER['PHP_SELF']; // We need the script name |
| 155 | if (! preg_match("|.*/$|", $self)) $self .= "/"; |
| 156 | } |
| 157 | |
| 158 | // Connect to MySQL, open database. |
| 159 | $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die_HTML($svcname, "Error: Cannot connect to database."); |
| 160 | $db = mysql_select_db($dbname, $conn) or die_HTML($svcname, "Error: Cannot select database. ". mysql_error()); |
| 161 | |
| 162 | // When in doubt, turn Bad Behavior on, set it to FALSE in the config to turn it off. |
| 163 | if (! isset($BB2)) $BB2 = true; |
| 164 | |
| 165 | // If user has not turned off Bad Behavior in the config, use BB2 (highly recommended) TODO: warn user if $BB2 but not BB2 |
| 166 | if ($BB2 && file_exists("bad-behavior/bad-behavior-tighturl.php")) require_once("bad-behavior/bad-behavior-tighturl.php"); |
| 167 | else $BB2 = FALSE; |
| 168 | |
| 169 | // Figure out what kind of request this is and service it. |
| 170 | |
| 171 | // This is klugey. Clean up later. |
| 172 | // also I think data should be sanitized immediately |
| 173 | if ((isset($_REQUEST['save']) && $_REQUEST['save'] == 'y') |
| 174 | && (isset($_REQUEST['url']) && ! empty($_REQUEST['url']) && trim($_REQUEST['url']) != "" |
| 175 | && (preg_match("/^.*url=(.*)$/", $_SERVER['QUERY_STRING'], $matches) != 0))) { |
| 176 | $url = trim($matches[1]); |
| 177 | if (preg_match("/^(.*)&tighturlaction.*$/", $matches[1], $matches)) $url = $matches[1]; |
| 178 | save_URL(urldecode($url)); |
| 179 | } |
| 180 | elseif (isset($_REQUEST['i']) && !empty($_REQUEST['i'])) { |
| 181 | lookup_ID($_REQUEST['i']); |
| 182 | } |
| 183 | elseif (isset($pbi) && !empty($pbi) && isset($_REQUEST[$pbi]) && !empty($_REQUEST[$pbi])) { |
| 184 | PolicyBan_ID($_REQUEST[$pbi]); |
| 185 | } |
| 186 | elseif ($FOFMethod && preg_match("/^\/+([a-zA-Z0-9]+)\/*(.*)\/*$/", $_SERVER['REQUEST_URI'], $matches)) { |
| 187 | lookup_ID($matches[1]); |
| 188 | } |
| 189 | elseif ($FOFMethod && $_SERVER['REQUEST_URI'] != "/") { |
| 190 | display_HTML("", "", "Error: Couldn't find a valid " . $svcname . " URI."); |
| 191 | } |
| 192 | else { |
| 193 | display_HTML("", "main"); |
| 194 | } |
| 195 | exit; |
| 196 | |
| 197 | // ************************************************************************* |
| 198 | |
| 199 | |
| 200 | /** |
| 201 | * sanitize a string for SQL input |
| 202 | */ |
| 203 | function sanitize_sql_string($string) { |
| 204 | return(mysql_real_escape_string($string)); |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Counts the number of times a substring is contained in a given string. |
| 209 | */ |
| 210 | function countSubstrs($haystack, $needle) { |
| 211 | return (($p = strpos($haystack, $needle)) === false) ? 0 : (1 + countSubstrs(substr($haystack, $p+1), $needle)); |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Checks to see if a given URI is on a URI blacklist. |
| 216 | * Currently this means SURBL (http://www.surbl.org) and URIBL (http://www.uribl.com) |
| 217 | * |
| 218 | * Returns TRUE if the domain is listed on any configured URIBLs, returns FALSE if |
| 219 | * anything goes wrong or the anti-abuse system is turned off. |
| 220 | * |
| 221 | * A companion URI extractor must be written for the below issues |
| 222 | * Must be changed to do full resolution of redirections on URI, simulating a browser |
| 223 | * Must be changed to do IPv6 lookups |
| 224 | * Must be changed to check multiple URIs (maybe a wrapper instead) |
| 225 | * Must be changed to optionally check HTML entity encoded versions of URIs |
| 226 | * Must be changed to handle URIBL's inclusion of some third-level domains. |
| 227 | * |
| 228 | */ |
| 229 | function URI_on_URIBL($uri) { |
| 230 | |
| 231 | // This code does not yet properly implement a correct and efficient querying |
| 232 | // of URI BL data. |
| 233 | |
| 234 | global $uribl, $uribluri, $validschemes, $validurlpattern, $validipv4pattern, |
| 235 | $antiabuse, $netchecks, $tltlds; |
| 236 | |
| 237 | // Everything gets a pass if antiabuse or network tests are off. |
| 238 | if ((! $antiabuse) || (! $netchecks)) return(false); |
| 239 | |
| 240 | $uribls = ""; |
| 241 | |
| 242 | if ($uri) { |
| 243 | // Test for IPv4 address, reverse the quads if found |
| 244 | if (preg_match("/^".$validschemes.$validipv4pattern."/", $uri, $matches)) { |
| 245 | $domain=$matches[5] . "." . $matches[4] . "." . $matches[3] . "." . $matches[2]; |
| 246 | } |
| 247 | else { |
| 248 | // strip out second-level domain name, *unless* on exception list, |
| 249 | // in which case, strip out third level also and test that instead. |
| 250 | // FIX: when testing uribl.com lists, also test additional level. First hit wins. |
| 251 | |
| 252 | preg_match("/^".$validschemes.$validurlpattern."$/", $uri, $matches); |
| 253 | $domain = $matches[4]; |
| 254 | if (preg_match("/".$tltlds."$/", $domain, $matches)) {$levels = 2;} else {$levels = 1;} |
| 255 | |
| 256 | // klugey stripping routine to reduce domain to base domain name |
| 257 | // expect regex wojuld be better |
| 258 | |
| 259 | $ss = countSubstrs($domain, "."); |
| 260 | while ($ss > $levels) { |
| 261 | $chop = strpos($domain, "."); |
| 262 | $domain = substr($domain, $chop + 1); |
| 263 | $ss = countSubstrs($domain, "."); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | // Query URI blacklists to see if domain/IP appears as target in known spam |
| 268 | // or something involved in a malware/phishing attack. |
| 269 | for ($i=0; $i<count($uribl); $i++) { |
| 270 | $fqdn = $domain . "." . $uribl[$i]; |
| 271 | $recexists = gethostbyname($fqdn); // ghbn weirdly returns the name on failure |
| 272 | if (($recexists != $fqdn) && preg_match("<^127\.>", $recexists)) { |
| 273 | if ($i > 0) $uribls .= ", "; |
| 274 | $uribls .= $uribl[$i]; |
| 275 | } |
| 276 | } |
| 277 | return ($uribls); // change to return an array of indexes into the URIBL array |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | /** |
| 282 | * Checks to see if a given URL is a Reserved URL. |
| 283 | * |
| 284 | * Returns TRUE if the ID is listed as a Reserved URL. |
| 285 | */ |
| 286 | function on_Reserve($decimal) { |
| 287 | global $ReservedURL; |
| 288 | |
| 289 | $res=FALSE; |
| 290 | |
| 291 | if ($decimal) { |
| 292 | $sexatrigesimal = base_convert($decimal, 10, 36); |
| 293 | for ($i=0; $i<count($ReservedURL); $i++) { |
| 294 | if ($sexatrigesimal == strtolower($ReservedURL[$i])) return TRUE; |
| 295 | } |
| 296 | return FALSE; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Save the given URL in the database if unique and return the ID or return an existing ID for given URL. |
| 302 | * The ID returned will be a sexatrigesimal (Base-36) number. |
| 303 | * |
| 304 | * Saves the URL in the database, converts the decimal ID value returned by the database to |
| 305 | * a sexatrigesimal value, and displays the generated TightURL. |
| 306 | */ |
| 307 | function save_URL($url) { |
| 308 | global $dbtable, $svcname, $FOFMethod, $validschemes, $validurlpattern, $pasttext, $self, $redir, $bl, |
| 309 | $antiabuse, $netchecks, $ptc, $forbid, $mustexist; |
| 310 | |
| 311 | if ($_SERVER['HTTP_USER_AGENT'] == "Python-urllib/2.5") { |
| 312 | display_HTML("", "save", "", $url, "http://tighturl.com/haibot"); |
| 313 | exit; |
| 314 | } |
| 315 | |
| 316 | $selfref = "|^(http://" . $_SERVER['HTTP_HOST'] . $self . ")|i"; |
| 317 | $aliasref = "|^(http://www." . $_SERVER['HTTP_HOST'] . $self . ")|i"; |
| 318 | $remote = $_SERVER['REMOTE_ADDR']; |
| 319 | |
| 320 | if (preg_match($selfref, $url) || preg_match($aliasref, $url)) { |
| 321 | display_HTML("", "", "Error: A " . $svcname . " URL cannot point to another URL within " . $_SERVER['HTTP_HOST'] . $self . " .", $url, "", $url); |
| 322 | } |
| 323 | elseif (! preg_match("/^".$validschemes.$validurlpattern."$/", $url)) { |
| 324 | display_HTML("", "", "Error: That URL (".htmlspecialchars(strip_tags($url)).") is not valid.", $url, "", $url); |
| 325 | } |
| 326 | elseif (($forbid != "") && (preg_match("!.*".$forbid."$!i", $url))) { |
| 327 | display_HTML("", "", "Error: Executable URIs are not accepted here due to phishing/malware abuse.", $url, "", $url); |
| 328 | } |
| 329 | // This code was never meant to be in a release. oops |
| 330 | // elseif (preg_match("!.*\.gif$!", $url)) { // replace this with image comparison |
| 331 | // display_HTML("", "", "Error: URL rejected for service abuse.", $url, "", $url); |
| 332 | // } |
| 333 | //RR elseif (isset($mustexist) && $mustexist && isset($netchecks) && $netchecks && (! Resolve_URL($url, $chain))) { |
| 334 | //RR display_HTML("", "", "Error: Submitted URL does not exist on the public Internet.", $url, "", $url); |
| 335 | //RR } |
| 336 | elseif (isset($bl) && preg_match("/.*".$bl.".*/i", $url)) { // delete this crap |
| 337 | // echo "url: $url bl: $bl\n"; |
| 338 | display_HTML("", "", "Error: URL rejected for violating our terms of use.", $url, "", $url); |
| 339 | } |
| 340 | elseif (preg_match("<.*".$redir.".*>i", $url)) { |
| 341 | display_HTML("", "", "Error: ".$svcname." is not a URL obfuscation service, and does not accept redirection links.", $url, "", $url); |
| 342 | } |
| 343 | elseif (isset($ptc) && preg_match("/.*".$ptc.".*/i", $url)) { |
| 344 | display_HTML("", "", "Error: ".$svcname." does not accept PTC (Pay To Click) links due to spamming abuse.", $url, "", $url); |
| 345 | } |
| 346 | else { |
| 347 | $safeurl = sanitize_sql_string($url); |
| 348 | $result = mysql_query("SELECT MAX(id) FROM $dbtable") or display_HTML("", "", "Error: $svcname system error.", $url, "", $url); |
| 349 | $lastid = mysql_result($result, 0) + 1; |
| 350 | $guesssexatrigesimal = base_convert($lastid, 10, 36); |
| 351 | $guessurl = "http://" . $_SERVER['HTTP_HOST'] . $self; |
| 352 | if (! $FOFMethod) $guessurl .= "?i="; // We need the parameter tag |
| 353 | $guessurl .= $guesssexatrigesimal; // Append the Base-36 ID to the URL |
| 354 | if ( strlen($guessurl) >= strlen($url) ) { |
| 355 | display_HTML("", "", "Fail: That URL cannot be shortened by $svcname. Sorry!", $url, "", $url); |
| 356 | } |
| 357 | else { |
| 358 | if ($antiabuse && $netchecks) {$lists = URI_on_URIBL($url);} else {$lists = false;} |
| 359 | if (! $lists) { |
| 360 | $rows=0; $srows=0; $testurl=$safeurl; |
| 361 | if (preg_match("/\/$/", $testurl)) $testurl = rtrim($testurl,"/"); |
| 362 | $req = "SELECT * FROM $dbtable WHERE url = '$testurl/';"; |
| 363 | $res = mysql_query($req); |
| 364 | $srows = @mysql_num_rows($res) or $srows = 0; |
| 365 | if ($srows == 0) { |
| 366 | $req = "SELECT * FROM $dbtable WHERE url = '$testurl';"; |
| 367 | $res = mysql_query($req); |
| 368 | $rows = @mysql_num_rows($res) or $rows = 0; |
| 369 | } |
| 370 | if ($rows == 0 && $srows == 0) { |
| 371 | do { |
| 372 | $req ="INSERT INTO $dbtable (id, url, adddate, addip) "; |
| 373 | $req .= "VALUES ('', '$safeurl', NOW(), '$remote');"; |
| 374 | if (mysql_query($req)) { |
| 375 | $decimal = mysql_insert_id(); |
| 376 | } |
| 377 | else { |
| 378 | die_HTML($svcname, "Error: Database failure."); |
| 379 | } |
| 380 | $reserved_id = on_Reserve($decimal); |
| 381 | if ($reserved_id) { |
| 382 | // Delete this record so it doesn't override the reserved ID. (?) |
| 383 | $req = "DELETE FROM $dbtable WHERE id = '$decimal';"; |
| 384 | $res = mysql_query($req) or die_HTML($svcname, "Error: Database failure."); |
| 385 | } |
| 386 | } while ($reserved_id); |
| 387 | } |
| 388 | else { |
| 389 | // Return existing ID for this duplicate request |
| 390 | $decimal = mysql_result($res, 0, "id"); |
| 391 | } |
| 392 | $sexatrigesimal = base_convert($decimal, 10, 36); |
| 393 | $address = "http://" . $_SERVER['HTTP_HOST'] . $self; |
| 394 | if (! $FOFMethod) $address .= "?i="; // We need the parameter tag |
| 395 | $address .= $sexatrigesimal; // Append the Base-36 ID to the URL |
| 396 | display_HTML("", "save", "", $url, $address); |
| 397 | } |
| 398 | else { |
| 399 | display_HTML("HTTP/1.0 403 Forbidden", "", "Error: Submitted URL (" . $url . ") is listed in " . $lists . ". You may not create a " . $svcname . " link for it."); |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * |
| 407 | */ |
| 408 | function PolicyBan_ID($sexatrigesimal) { |
| 409 | global $dbtable, $svcname; |
| 410 | |
| 411 | // First, convert unsafe user input sexatrigesimal to decimal, which will be safe. |
| 412 | $decimal = base_convert ($sexatrigesimal, 36, 10); |
| 413 | |
| 414 | $req = "SELECT * FROM $dbtable WHERE id = '$decimal';"; |
| 415 | $res = mysql_query($req) or die_HTML($svcname, "Error: Query failed"); |
| 416 | |
| 417 | $rows = mysql_num_rows($res); |
| 418 | if (($rows != 0) && (mysql_result($res, 0, "url") != "")) { |
| 419 | $req ="update $dbtable set status='4' where id='$decimal';"; |
| 420 | $res = mysql_query($req); |
| 421 | die_HTML($svcname, "ID: " . $sexatrigesimal . " banned for policy violation.", $code="HTTP/1.0 200 OK"); |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * Looks up given ID in the database and redirects, displays template, or |
| 427 | * displays error page. Expects the ID to be a sexatrigesimal (Base-36) number, |
| 428 | * which is the format used by TightURLs. |
| 429 | * |
| 430 | * We convert the ID to decimal before looking it up in the database, as the |
| 431 | * ID field is a MySQL autoincrement decimal value. |
| 432 | */ |
| 433 | function lookup_ID($sexatrigesimal) { |
| 434 | global $dbtable, $svcname; |
| 435 | |
| 436 | // First, convert unsafe user input sexatrigesimal to decimal, which will be safe. |
| 437 | $decimal = base_convert ($sexatrigesimal, 36, 10); |
| 438 | |
| 439 | $req = "SELECT * FROM $dbtable WHERE id = '$decimal';"; |
| 440 | $res = mysql_query($req) or die_HTML($svcname, "Error: Query failed"); |
| 441 | |
| 442 | $rows = mysql_num_rows($res); |
| 443 | if (($rows != 0) && (mysql_result($res, 0, "url") != "")) { |
| 444 | // Change this logic to display a templated page instead? |
| 445 | switch (mysql_result($res, 0, "status")) { |
| 446 | case 5: |
| 447 | display_HTML("HTTP/1.0 403 Forbidden", "complaints"); |
| 448 | return; |
| 449 | break; |
| 450 | case 4: |
| 451 | display_HTML("HTTP/1.0 403 Forbidden", "policy"); |
| 452 | return; |
| 453 | break; |
| 454 | case 3: |
| 455 | display_HTML("HTTP/1.0 403 Forbidden", "blacklist"); |
| 456 | return; |
| 457 | break; |
| 458 | default: |
| 459 | $url = stripslashes(mysql_result($res, 0, "url")); |
| 460 | break; |
| 461 | } |
| 462 | $req ="update $dbtable set lasthit=NOW(), hits=hits+1 where id='$decimal';"; |
| 463 | $res = mysql_query($req); |
| 464 | header("HTTP/1.0 301 Moved Permanently"); |
| 465 | header("Location: $url"); |
| 466 | } |
| 467 | elseif (! on_Reserve($decimal)) { // Not found, Not on reserve |
| 468 | display_HTML("HTTP/1.0 404 Not Found", "", "Error: That " . $svcname . " ID is not in our database."); |
| 469 | } |
| 470 | else { // It's a(n implied) Reserved URL |
| 471 | // Is this a template or an API? |
| 472 | $sexatrigesimal = strtolower($sexatrigesimal); |
| 473 | switch ($sexatrigesimal) { |
| 474 | case "rest": |
| 475 | api_REST(); |
| 476 | break; |
| 477 | case "xmlrpc": |
| 478 | api_XMLRPC(); |
| 479 | break; |
| 480 | case "soap": |
| 481 | api_SOAP(); |
| 482 | break; |
| 483 | default: |
| 484 | display_HTML("", $sexatrigesimal); |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | function api_REST() { |
| 490 | die_HTML($svcname, "Error: REST API not implemented yet.", "HTTP/1.0 501 Not Implemented"); |
| 491 | } |
| 492 | |
| 493 | function api_XMLRPC() { |
| 494 | die_HTML($svcname, "Error: XML-RPC API not implemented yet.", "HTTP/1.0 501 Not Implemented"); |
| 495 | } |
| 496 | |
| 497 | function api_SOAP() { |
| 498 | die_HTML($svcname, "Error: SOAP API not implemented yet.", "HTTP/1.0 501 Not Implemented"); |
| 499 | } |
| 500 | |
| 501 | /** |
| 502 | * Display HTML page using template and template variables. |
| 503 | * |
| 504 | * Reads in the main system template file (tighturl.tmpl) into $html . |
| 505 | * |
| 506 | * $code |
| 507 | * HTTP 1.0 status code and message. |
| 508 | * |
| 509 | * $template |
| 510 | * Checks for the existence of a subtemplate named tighturl.$template.tmpl |
| 511 | * and replaces template variable $HTML in the main template tighturl.tmpl |
| 512 | * with the contents of tighturl.$template.tmpl if any. |
| 513 | * |
| 514 | * Then any remaining $HTML from the only or inner template is replaced by $content, |
| 515 | * along with $url, $tighturl, and $input. A variety of other replacements are |
| 516 | * made using various global variables. |
| 517 | * |
| 518 | * $content |
| 519 | * HTML content to be replace template variable $HTML |
| 520 | * |
| 521 | * $url |
| 522 | * URL submitted to TightURL |
| 523 | * |
| 524 | * $tighturl |
| 525 | * TightURL generated for $url |
| 526 | * |
| 527 | * $input |
| 528 | * When submitted URL does not validate it is passed back as $input |
| 529 | * |
| 530 | * Template variables are words in all capital letters that start with a |
| 531 | * $ symbol, such as $TEMPLATEVARIABLE. TightURL now supports at least |
| 532 | * 20 template variables. At runtime, these template variables are replaced |
| 533 | * by program variables. |
| 534 | * - $HTML : HTML passed into the function as $input by the program or an inner template |
| 535 | * - $PARM : Parameter tag when not using 404-Method |
| 536 | * - $URL : URL submitted to TightURL |
| 537 | * - $URLLEN : Length of the submitted URL |
| 538 | * - $TIGHTURL : TightURL generated for the submitted URL |
| 539 | * - $TIGHTURLLEN : Length of generated TightURL |
| 540 | * - $DIFF : Difference in length between submitted and TightURLs |
| 541 | * - $INPUT : Bad input URL being passed back to output form |
| 542 | * - $SVCNAME : Name of the TightURL service |
| 543 | * - $HEADCOLOR : Color of the H1 Header tag |
| 544 | * - $TABLECOLOR : Color of the table containing URL input field |
| 545 | * - $TAGLINE : Tagline of the TightURL service |
| 546 | * - $CPASTTEXT : Capitalized past-tense word for tightening URLs |
| 547 | * - $PASTTEXT : Non-Capitalized past-tense word for tightening URLs |
| 548 | * - $CVERBTEXT : Capitalized action word for tightening URLs |
| 549 | * - $VERBTEXT : Non-Capitalized action word for tightening URLs |
| 550 | * - $COPYRIGHT : Copyright duration string generated from $copystart global variable, |
| 551 | * will be current 4-digit year if $copystart not defined. |
| 552 | * - $COPYRIGHTHOLDER : Name of copyright holder |
| 553 | * - $URLBLS : HTML string of URIBLs TightURL is checking |
| 554 | * - $HOST : Hostname TightURL is running on |
| 555 | * - $SELF : Name TightURL is invoked as |
| 556 | */ |
| 557 | function display_HTML ($code, $template, $content="", $url="", $tighturl="", $input="") { |
| 558 | global $svcname, $verbtext, $pasttext, $tagline, $uribls, $parm, |
| 559 | $headcolor, $tablecolor, $copyright, $copyrightholder, $self, $BB2; |
| 560 | |
| 561 | // $url = htmlspecialchars($url); |
| 562 | if ($code="") $code = "HTTP/1.0 200 OK"; |
| 563 | if (preg_match("/\/$/", $template)) $template = rtrim($template,"/"); |
| 564 | if (file_exists("tighturl.tmpl")) { |
| 565 | $html = file_get_contents("tighturl.tmpl"); |
| 566 | if (($template != "") && file_exists("tighturl." . $template . ".tmpl")) { |
| 567 | $template = file_get_contents("tighturl." . $template . ".tmpl"); |
| 568 | $html = preg_replace("/\\\$HTML/", $template, $html); |
| 569 | } |
| 570 | elseif ($template != "") { |
| 571 | die_HTML($svcname, "Error: Template file tighturl." . $template . ".tmpl cannot be found."); |
| 572 | } |
| 573 | if (substr($content, 0, 6) == "Error:") { |
| 574 | $content = preg_replace("/Error:/", "<big><font color='red'>Error:", $content)."</font></big>"; |
| 575 | } |
| 576 | if ($content) $content .= "<br />\n"; |
| 577 | // Always replace longer similar tokens before shorter ones. Things won't work the |
| 578 | // way you expect if you replace $URL first, and then replace $URLMORELETTERS. |
| 579 | $html = preg_replace("/\\\$HTML/", $content, $html); |
| 580 | $html = preg_replace("/\\\$PARM/", $parm, $html); |
| 581 | $html = preg_replace("/\\\$URLLEN/", strlen($url), $html); |
| 582 | $html = preg_replace("/\\\$URL/", htmlspecialchars(strip_tags($url), ENT_QUOTES), $html); |
| 583 | $html = preg_replace("/\\\$INPUT/", $input, $html); |
| 584 | $html = preg_replace("/\\\$TIGHTURLVER/", VERSION, $html); |
| 585 | $html = preg_replace("/\\\$TIGHTURLLEN/", strlen($tighturl), $html); |
| 586 | $html = preg_replace("/\\\$TIGHTURL/", $tighturl, $html); |
| 587 | $html = preg_replace("/\\\$DIFF/", strlen($url)-strlen($tighturl), $html); |
| 588 | $html = preg_replace("/\\\$SVCNAME/", $svcname, $html); |
| 589 | $html = preg_replace("/\\\$HEADCOLOR/", $headcolor, $html); |
| 590 | $html = preg_replace("/\\\$TABLECOLOR/", $tablecolor, $html); |
| 591 | $html = preg_replace("/\\\$TAGLINE/", $tagline, $html); |
| 592 | $html = preg_replace("/\\\$CPASTTEXT/", $pasttext, $html); |
| 593 | $html = preg_replace("/\\\$PASTTEXT/", strtolower($pasttext), $html); |
| 594 | $html = preg_replace("/\\\$VERBTEXT/", strtolower($verbtext), $html); |
| 595 | $html = preg_replace("/\\\$CVERBTEXT/", $verbtext, $html); |
| 596 | $html = preg_replace("/\\\$COPYRIGHTHOLDER/", $copyrightholder, $html); |
| 597 | $html = preg_replace("/\\\$COPYRIGHT/", $copyright, $html); |
| 598 | $html = preg_replace("/\\\$URIBLS/", $uribls, $html); |
| 599 | $html = preg_replace("/\\\$HOST/", $_SERVER['HTTP_HOST'], $html); |
| 600 | $html = preg_replace("/\\\$SELF/", $self, $html); |
| 601 | $html = preg_replace("/\\\$__/", "$", $html); // Template Variables shown as text instead of substituted |
| 602 | if (preg_match("|<title>(.*)</title>|is", $html, $matches)) |
| 603 | $html = preg_replace("|<title>(.*)</title>|is", "<title>" . strip_tags($matches[1]) . "</title>", $html); |
| 604 | if ($BB2) { |
| 605 | $html = preg_replace("/\\\$BBSTATS/", bb2_insert_stats(), $html); |
| 606 | $bb2code = bb2_insert_head(); |
| 607 | if (preg_match("|<head>(.*)</head>|is", $html, $matches)) |
| 608 | $html = preg_replace("|<head>(.*)</head>|is", "<head>\n" . $bb2code . $matches[1] . "</head>", $html); |
| 609 | } |
| 610 | else { |
| 611 | $html = preg_replace("/\\\$BBSTATS/", "", $html); |
| 612 | } |
| 613 | header($code); |
| 614 | echo $html; |
| 615 | } |
| 616 | else { |
| 617 | die_HTML($svcname, "Error: <big><font color='red'>Error: TightURL Redirection service (" . $svcname . ") site template not found.</font></big>"); |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | /** |
| 622 | * Die in an HTML-friendly way, without the benefit of a template. |
| 623 | * Use display_HTML to "die" using the TightURL site template. |
| 624 | */ |
| 625 | function die_HTML($svcname, $errmsg, $code="HTTP/1.0 500 Internal Server Error") { |
| 626 | |
| 627 | header($code); |
| 628 | echo "<html>\n <head>\n <title>" . $svcname . "</title>\n </head>\n <body>\n"; |
| 629 | echo " " . $errmsg . "<br />\n"; |
| 630 | echo " </body>\n</html>"; |
| 631 | die; |
| 632 | } |
| 633 | |
| 634 | /** |
| 635 | * Verifies the existence and accessibility of a resource in a given URL. |
| 636 | * |
| 637 | * Returns FALSE if the resource does not exist or cannot be accessed using |
| 638 | * supplied authentication information, else returns the resolved and verified |
| 639 | * URL. Given URL is returned as resolved to itself if $netchecks are off. |
| 640 | * |
| 641 | * Will recurse through redirection chains up to 12 times by default. This |
| 642 | * value is preferably selectable by the user in a configuration screen |
| 643 | * somewhere, but probably should not be lower than 12, as attempts are made |
| 644 | * to detect HTML and JavaScript redirects in addition to HTTP redirects, and |
| 645 | * a dozen redirects to find the end is quite possible. |
| 646 | * |
| 647 | * Unfortunately Google's GFE server erroneously returns 404 errors when |
| 648 | * they should be returning something like a 405, making it impossible to |
| 649 | * use HTTP HEAD to verify the existence of resources front-ended by GFE. |
| 650 | * Additionally Amazon throws a 405 attempting to HEAD some of their resources |
| 651 | * so this function does not attempt to use HEAD at all. |
| 652 | * |
| 653 | * BUG: Presently only does HTTP |
| 654 | * |
| 655 | */ |
| 656 | //function Resolve_URL ($url, &$resolvedchain=array(""), $chainlen=12) { |
| 657 | function Resolve_URL ($url, &$resolvedchain, $chainlen=12) { |
| 658 | // $resolvedchain = array($url); |
| 659 | |
| 660 | if (! isset($resolvedchain)) $resolvedchain=array(""); |
| 661 | |
| 662 | global $netchecks; |
| 663 | |
| 664 | if (! $netchecks) { |
| 665 | // If network checks off, accept submitted URL as resolved. |
| 666 | return($url); |
| 667 | } |
| 668 | |
| 669 | $parsed = parse_url($url); |
| 670 | |
| 671 | $pre = isset($parsed['scheme']) ? $parsed['scheme'].':'.((strtolower($parsed['scheme']) == 'mailto') ? '' : '//') : ''; |
| 672 | $pre .= isset($parsed['user']) ? $parsed['user'].(isset($parsed['pass']) ? ':'.$parsed['pass'] : '').'@' : ''; |
| 673 | $pre .= isset($parsed['host']) ? $parsed['host'] : ''; |
| 674 | $pre .= isset($parsed['port']) ? ':'.$parsed['port'] : ''; |
| 675 | if(isset($parsed['path'])) |
| 676 | $post = (substr($parsed['path'], 0, 1) == '/') ? $parsed['path'] : ('/'.$parsed['path']); |
| 677 | else |
| 678 | $post = "/"; |
| 679 | $post .= isset($parsed['query']) ? '?'.$parsed['query'] : ''; |
| 680 | $post .= isset($parsed['fragment']) ? '#'.$parsed['fragment'] : ''; |
| 681 | |
| 682 | $resolved = false; |
| 683 | |
| 684 | // Change this to support all protocols TightURL supports, not just HTTP |
| 685 | if (! isset($parsed['port']) || $parsed['port'] == 0) $parsed['port'] = 80; |
| 686 | //if($connection = @fsockopen ($parsed['host'], $parsed['port'], $errno, $errstr, 5)) { |
| 687 | $ip = gethostbyname($parsed['host']); // This is supposed to avoid unnecessary DNS lookups |
| 688 | if($connection = @fsockopen ($ip, $parsed['port'], $errno, $errstr, 5)) { |
| 689 | stream_set_timeout($connection, 5); |
| 690 | // HTTP send Connection: Close so we don't have to wait |
| 691 | // Google's GFE handling of HEAD is broken, and Amazon returns 405 on HEAD so had to use GET |
| 692 | fwrite($connection, "GET ".$post." HTTP/1.0\r\nHost: ".$parsed['host']."\r\nConnection: Close\r\n\r\n"); |
| 693 | while (!feof($connection)) { |
| 694 | $line_read=fgets($connection); |
| 695 | if ($line_read == "") break; //blank line is header delimiter, if you see it you're done here |
| 696 | //Fix: change this and start parsing the body for HTML-based redirections. |
| 697 | |
| 698 | if (preg_match("/HTTP\/\S* +(\S*) /", $line_read, $matches)) { // Look for certain HTTP status codes |
| 699 | switch ($matches[1]) { |
| 700 | case 200: // Ok, we have a final destination (as far as HTTP is concerned) |
| 701 | case 201: // Created, we have a final destination |
| 702 | case 202: // Accepted, we have a final destination |
| 703 | case 203: // Non-authoritative reply, we have a final destination |
| 704 | case 204: // No content, we have a final destination |
| 705 | case 205: // Reset content, we have a final destination |
| 706 | case 206: // Partial content, we have a final destination |
| 707 | case 207: // Multi-status, we have a final destination |
| 708 | case 304: // Not Modified (this is ok) |
| 709 | case 401: // Authorization required (this is ok) |
| 710 | case 402: // Payment required (this is ok) |
| 711 | case 403: // Forbidden (but also ok) |
| 712 | case 405: // Method not allowed (but also ok) |
| 713 | case 406: // Not acceptable (acceptable here unless someone tells us otherwise) |
| 714 | case 409: // Conflict (acceptable unless someone tells us otherwise) |
| 715 | case 421: // Too many connections (fail ok) |
| 716 | case 426: // Use TLS (fail ok) |
| 717 | case 500: // Internal server error (fail ok) |
| 718 | case 502: // Bad gateway (fail ok) |
| 719 | case 503: // Service unavailable (fail ok) |
| 720 | case 504: // Gateway timeout (fail ok) |
| 721 | case 505: // HTTP version not supported (fail ok) |
| 722 | case 509: // Bandwidth exceeded pseudo code (fail ok) |
| 723 | $resolved = $url; |
| 724 | $resolvedchain[] = $url; |
| 725 | break 2; |
| 726 | case 300: |
| 727 | case 301: |
| 728 | case 302: |
| 729 | case 307: |
| 730 | break; |
| 731 | case 404: // Not found |
| 732 | case 408: // Request timeout (this URL will never work again) |
| 733 | case 410: // Gone (and not coming back) |
| 734 | break 2; |
| 735 | default: |
| 736 | $resolved = $url; |
| 737 | $resolvedchain[] = $url; |
| 738 | break 2; |
| 739 | } |
| 740 | } |
| 741 | |
| 742 | // If this is a redirect (300, 301, 302, 307), follow it if the chain isn't too long |
| 743 | if (preg_match("/Location: (.*)\r\n/", $line_read, $matches)) { |
| 744 | fclose($connection); |
| 745 | $connection = false; |
| 746 | $resolvedchain[] = $url; |
| 747 | if ($chainlen > 0 ) $resolved = Resolve_URL($matches[1], $resolvedchain, $chainlen - 1); |
| 748 | break; |
| 749 | } |
| 750 | |
| 751 | } |
| 752 | // Parse body here? |
| 753 | if ($connection) fclose($connection); |
| 754 | } |
| 755 | return($resolved); |
| 756 | } |
| 757 | ?> |
| tighturl.ptcpattern.inc.php |
| 1 | <?php |
| 2 | define("TLPTCBLVERSION", "0.1.4"); |
| 3 | $ptc = "(1-800-mail\.com|1000clicksptr\.com|100cents-1000dollars\.com|" |
| 4 | . "100-dollars-mail\.com|100dollarsbonus\.info|100dollarsmails\.com|" |
| 5 | . "100euromails\.com|100usd\.com|10bux\.net|10dollar-mail\.com|" |
| 6 | . "10euromails.com|168paid\.com|1-dollar-mail\.com|1stprofit\.com|" |
| 7 | . "2-dollar-mail\.com|2-opt\.com|2008mails\.com|200dollars-email\.com|" |
| 8 | . "200dollarsmail\.com|200eurocent-200euro\.com|200euromails\.com|" |
| 9 | . "200euromails\.net|20dollarsmail\.com|247payouts\.com|25dollarsmail\.com|" |
| 10 | . "25-dollars-mail\.com|2dollaremails\.com|3-dollar-mail\.com|" |
| 11 | . "300dollarsmail\.com|30dollarsmail\.com|37-21mail\.com|400dollarsmail\.com|" |
| 12 | . "4bux\.info|5-dollar-mail\.com|500cents-500dollars\.net|" |
| 13 | . "500cents-500dollars\.org|500pounds-and-500pence\.com|50centptr\.com|" |
| 14 | . "50dollarsmail\.com|520searcher\.com|5dollarmails\.com|60euromail\.com|" |
| 15 | . "60de\.com|7878clicks\.com|7centsolos\.com|7thheavenptr\.net|" |
| 16 | . "8cent-emails\.com|80euromail\.com|a-n-cash\.com|an-cash\.com|" |
| 17 | . "aaa-mails\.com|activeptr\.net|ad5\.biz|ad-fortune\.com|adsbux\.org|" |
| 18 | . "adsmaker\.net|adsneed\.com|advercash\.net|aglocomails\.com|ahacash\.com|" |
| 19 | . "allcashmail\.com|allyousubmitters\.com|almiyachts\.com|alwayspay\.com|" |
| 20 | . "american-mails\.com|amigoemail\.com|amity-cash\.com|ans-advertising\.com|" |
| 21 | . "anycallmails\.com|apachemails\.com|applemails\.com|appolomails\.com|" |
| 22 | . "arab-gpt\.com|arabbux\.com|arcane-mails\.com|arcsurvey\.com|" |
| 23 | . "arcticmails\.com|asonewishes\.com|at-mails\.com|atom-mails\.com|" |
| 24 | . "atomsmails\.com|auction-emails\.com|awsurveys\.com|b-u-x\.net|" |
| 25 | . "babyloncash\.com|ban-mail\.com|banboocash\.com|bank-mails\.com|" |
| 26 | . "bank-mails\.net|bearshare-mails\.com|beautymails\.com|beeptr\.com|" |
| 27 | . "beetrmails\.com|best-mails\.com|best-hyip\.be|bestflymails\.com|" |
| 28 | . "beta-cash\.com|bettybucks\.com|beyondemails\.com|bez-minimum\.info|" |
| 29 | . "bigdollar-mails\.com|biggestdollars\.com|bigluck-mails\.com|" |
| 30 | . "bigpaymail\.com|billiondollarmails\.com|bluemaniacs\.com|" |
| 31 | . "bluerwebmail\.com|boa-mails\.com|bobomails\.com|bobmail\.com|" |
| 32 | . "boffopaidmail\.com|bonniemails\.com|boratmails\.com|businessptr\.com|" |
| 33 | . "boss-mails\.com|bournemouthbreeze\.com|bravevolitation\.com|bugcash\.com|" |
| 34 | . "bux\.to|bux-cash\.com|buxer\.org|buxeuro\.com|buxgalore\.com|buxone\.com|" |
| 35 | . "buxforever\.com|buxp\.info|buxbank\.com|camel-mails\.com|" |
| 36 | . "can-discount\.com|candy-mail\.com|cannabismails\.com|capitalmails\.net|" |
| 37 | . "cashbux\.com|cashbux\.org|casheden\.com|cash-kitty\.com|cashfiesta\.com|" |
| 38 | . "cash-harvest\.com|cash4grabs\.info|cashnclicks\.com|cashorigin\.com|" |
| 39 | . "cashpointclicks\.com|cashread\.com|cashsea\.com|casino-mails\.com|" |
| 40 | . "cat-mail\.com|cat-mails\.com|cat-ptr\.com|catch-cash\.com|" |
| 41 | . "class-act-clicks\.com|classical-mail\.com|cgcash\.info|charm-mail\.com|" |
| 42 | . "chicago-ptr\.com|chick-mails\.com|chobit-mails\.com|chobitmails\.com|" |
| 43 | . "chobitsmails\.net|click2earnmoney\.com|click-mails\.com|click-wizard\.net|" |
| 44 | . "clickandbux\.com|clickbux\.org|clickbuxx\.com|clickcent\.net|" |
| 45 | . "clickearnmoney\.com|clickingmoney4u\.com|click-monkey\.biz|clickoly\.com|" |
| 46 | . "clicks-4-cash\.com|clicksensation\.info|clicktopsites\.com|clixsense\.com|" |
| 47 | . "clixy\.net|clonebux\.com|cloudmails\.com|closet-clickers\.com|" |
| 48 | . "cloverclicks\.net|coast-mail\.com|coastmail\.com|coinclicks\.info|" |
| 49 | . "comeongain\.com|compactmails\.com|cookie-mails\.com|cooperativemail\.com|" |
| 50 | . "copymails\.com|cosplaymails\.com|coverclicks\.com|cowboy-mail\.com|" |
| 51 | . "crabmails\.com|crazy-4-cash\.com|cream-mails\.com|dallas-ptr\.com|" |
| 52 | . "danger-mails\.com|davemails\.com|darkangelmailsdaydayupemails\.com|" |
| 53 | . "dayscash\.com|dayseeking\.net|deepseacash\.com|deliriouspaidemails\.com|" |
| 54 | . "delta-cash\.com|devclix\.com|diamondbux\.com|digital-ptr\.com|" |
| 55 | . "dj-mails\.com|dog-mails\.com|dollar-factory\.com|dollarsmaker\.net|" |
| 56 | . "dollarslove\.com|dollarsmaker\.com|dolphincents\.com|domainmail\.com|" |
| 57 | . "donkeycash\.info|donut-m\.biz|duno\.com|dragone-search\.com|" |
| 58 | . "dragonhole\.com|dreamstarmail\.com|drumcash\.com|dynasty-mails\.com|" |
| 59 | . "dungeonanddragonemails\.com|d-biz\.com|e-mailptr\.com|eagleclicknet\.com|" |
| 60 | . "earn-emails\.com|earn4read\.com|earnptr\.com|earnup\.com|easy-gain\.com|" |
| 61 | . "easyhits\.org|egoldclicks\.net|electric-mails\.com|" |
| 62 | . "elephantadvertising\.com|elephant-mails\.com|e-mailptr\.com|" |
| 63 | . "email2rewards\.com|e-mailpaysu\.com|emailpremium\.com|emailprofit.us" |
| 64 | . "emails-empire\.com|emailspayu\.net|emails-empire\.com|" |
| 65 | . "emeraldcoastptc\.info|energy-mails\.com|englandbux\.com|englandbux\.org|" |
| 66 | . "enjoyfunds\.com|eqmails\.com|eurocentsmail\.com|eurobux\.org|" |
| 67 | . "euro-mails\.com|europtr.\net|everylooking\.com|eceryrich\.com|" |
| 68 | . "expert-mails\.com|extra10\.com|eyemails\.com|fairydollars\.com|" |
| 69 | . "fairytaleptr\.com|farland-cash\.com|fastbux\.com|fastbux\.org|" |
| 70 | . "fastcashemaills\.com|fastpaidptr\.com|fellowequality\.com|" |
| 71 | . "fillmyaccount\.com|filmyinbox\.com|fire-mails\.com|flashrich\.com|" |
| 72 | . "flaviomails\.be|fly-field\.com|freeclickcash\.net|free-kingdom\.com|" |
| 73 | . "freemoneymails\.net|feer-mial\.com|feermial\.com|fortuneemail\.com|" |
| 74 | . "fourleafclovermail\.com|foxcash\.com|ft-mails\.com|funkycashmail\.com|futureptr\.com|" |
| 75 | . "fx-mails\.com|gamma-cash\.com|gem-mails\.com|getpaid4clicks\.com|" |
| 76 | . "getpaidbyemail\.com|getpaideasy\.com|getpaidlinks\.net|getpaidwatch\.com|" |
| 77 | . "getor-mails\.com|giga-cash\.com|giga-mails\.com|goaio\.com|godmail\.info|" |
| 78 | . "godmails\.com|gogoplease\.cn|goldencatch\.com|goldenemail\.com|" |
| 79 | . "goldptr\.net|golfmails\.com|goodluck-email\.com|google-mails\.com|" |
| 80 | . "gothic-mail\.com|gowellup\.com|gp2profits\.com|graspaftertime\.com|" |
| 81 | . "grassmails\.com|green-cash\.com|greetgold\.com|halfmillionmails\.com|" |
| 82 | . "halomoney\.com|happyearning\.com|happyptr\.com|healthyptc\.com|" |
| 83 | . "heroptr\.com|highbidppc\.com|\happybizs\.com|hkbux\.com|" |
| 84 | . "holiday-mails\.com|hollywood-mail\.com|honestmails\.com|honestptr\.com|" |
| 85 | . "horse-mails\.com|huge-mails\.com|husky-mails\.com|icashout\.com|" |
| 86 | . "ice-mails\.net|ilikeemails\.com|insaneptr\.net|inspiremarrow\.com|" |
| 87 | . "instant-dollars\.com|instantads\.org|intgold\.com|invest-mail\.com|" |
| 88 | . "iphonemails\.com|ippomails\.com|ippomails\.net|jackpot-ads\.biz|" |
| 89 | . "jays-paidmail\.com|job-readmail\.com|junglecash\.com|jungleclicks\.com|" |
| 90 | . "justcashinc\.com|kiddays\.com|kitcatcash\.com|klikini\.net|kukmail\.com|" |
| 91 | . "libertycash\.biz|lifeisabeachclicks\.net|lightstarmail\.com|linkread\.com|" |
| 92 | . "lion-mails\.com|littleengineptr\.com|loading-mails\.com|logans-legacy\.com|" |
| 93 | . "lolclicks\.com|lookingemail\.com|lovebird-mails\.com|loveburd-mails\.com|" |
| 94 | . "loving-mail\.com|magicalmails\.com|magicash\.com|magic-mails\.com|" |
| 95 | . "magnetismail\.com|mailbling\.com|mails2earn\.net|mainbux\.com|" |
| 96 | . "make-free-money-online\.info|malisanko-emails\.com|mangoemails\.com|" |
| 97 | . "many-mails\.com|mapleptr\.com|maystromails\.com|maystromails\.net|" |
| 98 | . "mdbux\.com|medal-mails\.com|mega-ptr\.com|megaptr\.com|" |
| 99 | . "meggarichemails\.com|mellow-mails\.com|metal-emails\.com|" |
| 100 | . "metalpaidread\.com|meteor-mails\.com|michellesrandomizer\.com|" |
| 101 | . "milion-mail\.com|million-mails\.com|millionaire-mail\.com|mimimcash\.com|" |
| 102 | . "minbux\.com|mincashbux\.com|mintysmails\.com|minibux\.com|" |
| 103 | . "moneybagsmail\.com|moneybux\.com|moneybux\.org|moneyclicks\.biz|" |
| 104 | . "moneyems\.com|moneydogptc\.com|moneymouser\.com|moneysbank\.com|" |
| 105 | . "moonbux\.com|mushroomsmail\.com|mybux\.info|mygpt\.com|myspacetoearn\.net|" |
| 106 | . "mysweetheartmail\.com|nature-mails\.com|neobux\.com|netgold4u\.com|" |
| 107 | . "newsptr\.com|niceptr\.com|nickelsbyemail\.com|nickoftime-email\.com|" |
| 108 | . "njgirl\.biz|no2allmails\.com|nocs.usnokiamails\.com|number-emails\.com|" |
| 109 | . "numenmail\.com|oceansoflife\.com|ohomails\.com|onedollarmail\.com|" |
| 110 | . "one-mails\.com|oneperson-mail\.com|onlygravy\.com|onlythebestptr\.com|" |
| 111 | . "ok-mails\.com|ok-ptr\.com|ok-usd\.com|okayemail\.com|onlygravy\.com|" |
| 112 | . "on-sunday\.com|orangemails\.com|oursharedsuccess\.com|ourpaidmail\.com|" |
| 113 | . "paidbux\.com|paidclicks\.ws|paidemail\.com|paidmail\.ru|" |
| 114 | . "paidmailagency\.com|paidmailengine\.com|paidstation\.com|paidworld\.com|" |
| 115 | . "paidmail\.ru|papajuan\.info|pay-to-mail\.info|payingcoins\.com|paytc\.net|" |
| 116 | . "payyou123\.com|payyoudollar\.com|perfect-emails\.com|pekingcash\.com|" |
| 117 | . "petromails\.com|pcash\.info|phoenixcash\.info|pig-mails\.com|" |
| 118 | . "pizzamails\.com|platinum-investment\.com|platinum-mails\.com|" |
| 119 | . "pleasant-mails\.com|polarbearmails\.com|pomoterprosemail\.com|" |
| 120 | . "popomails\.com|post4cash\.com|powerbux\.org|power-mails\.net|" |
| 121 | . "powersmails\.net|premiermails\.com|pretti.mail\.com|prettyptr\.com|" |
| 122 | . "pretty-mail\.com|probux\.net|professionalmails\.com|profers\.com|" |
| 123 | . "profitfrommails\.com|profitptr\.net|propaidemail\.com|ptcad\.net|" |
| 124 | . "ptindex\.com|ptp8\.com|ptr-enterprise\.com|ptr-enterprises\.com|" |
| 125 | . "ptrforce\.com|ptr-hun\.info|ptrland\.com|ptr-trading\.com|puma-mails\.com|" |
| 126 | . "pumpkin-mails\.com|puppypaid2clicks\.com|quality-profits\.com|" |
| 127 | . "quickbux\.org|rabbit-mails\.com|racingemails\.com|rainbow-mails\.com|" |
| 128 | . "rainbow-mail\.net|ranoscash\.com|rat-mails\.com|readformoney.us" |
| 129 | . "realmails\.com|readrevenue\.com|reliableclix\.com|richmails\.com|" |
| 130 | . "rivermails\.com|road-mails\.com|rock-mails\.com|rolex-mails\.com|" |
| 131 | . "rosenet-emails\.com|royalcash-mails\.com|royalinvest\.biz|" |
| 132 | . "rushnsuccess\.com|saytheirmail\.com|scarlettmails\.com|secret-mails\.net|" |
| 133 | . "sea-mails\.com|seekbizs\.com|seekmails\.com|sepooq\.com|seriousbucks\.com|" |
| 134 | . "seven-bux\.com|sharedmails\.com|sheepmails\.com|shirecash\.com|" |
| 135 | . "silvanamails\.com|silvanamails\.net|siteclubemail\.com|sky-mails\.net|" |
| 136 | . "sky-wolf\.net|smile-email\.com|smoothlinks\.com|snapdollars\.com|" |
| 137 | . "snowman-mails\.com|solarclick\.com|\southmails\.com|space-mails\.com|" |
| 138 | . "spaz-emails\.com|spedia\.com|speed-mails\.com|spicemails\.com|" |
| 139 | . "spiderchess\.com|spidermanemails\.com|sprint-cash\.com|startmails\.com|" |
| 140 | . "strongptr\.com|studio-mail\.com|summer-mails.ussunday-mails\.com|" |
| 141 | . "sunflowersptr\.com|sun-cash\.com|suns-cash\.com|sunsetclix\.com|" |
| 142 | . "super-mails\.com|super-program\.com|superstarmail\.com|surfjunky\.com|" |
| 143 | . "surfjunky\.com|surfanearn\.net|surforhits\.com|surprisemails\.com|" |
| 144 | . "surveyking\.com|sweet-mails\.com|symantec-mail\.com|systemmails\.com|" |
| 145 | . "tarbux\.com|tata-cash\.com|tendollarsmail\.com|teneuromail\.com|" |
| 146 | . "tomails\.com|thebux\.com|thebux\.helloweb\.eu|theclickers\.net|" |
| 147 | . "thegoldclick\.com|thegoldmail\.com|therichcash\.com|thinkbux\.com|" |
| 148 | . "timelessearn\.com|tnt-e-mail\.com|tombmailer\.com|tomoonmail\.com|" |
| 149 | . "tons-referrals\.com|tradingptr\.com|trafficcool\.com|trafficinvader\.com|" |
| 150 | . "travelmails\.com|treasureclicks\.info|trustfulmail\.com|trustmails\.com|" |
| 151 | . "trusturbux\.com|turtle-mails\.com|twistedclickers\.com|twodollarsmail\.com|" |
| 152 | . "tycoonmails\.com|unionptr\.com|united-empire\.com|unitmails\.com|" |
| 153 | . "universalclix\.com\.br|usa-canada-email\.com|usa-clicks\.us|" |
| 154 | . "usd-ad\.com|vegas-mails\.com|velocityclicks\.com|verdiencredits\.nl|" |
| 155 | . "vice-ptr\.com|viennamails\.com|viper-clicks\.com|virtualcardzone\.com|" |
| 156 | . "visionptr\.com|warm-mails\.com|wc-mails\.com|weapon-earnings\.info|" |
| 157 | . "webbercash\.com|well-email\.com|welovepay\.com|western-clicks\.com|" |
| 158 | . "western-mails\.com|wet-clicks\.com|wingmails\.com|womail\.com|" |
| 159 | . "woderemails\.com|wonderful-mails\.com|woo-mails\.com|worldbux\.info|" |
| 160 | . "worldwidemails\.com|workmails\.com|wowearnings\.com|wow-mails\.com|" |
| 161 | . "xsc-mail\.com|xtremeptc\.com|y2e\.info|yippeemails\.com|" |
| 162 | . "yourspiderweb\.com|zero-investments\.com|zy-mails\.com)"; |
| 163 | ?> |
| tighturl.tltpattern.inc.php |
| 1 | <?php |
| 2 | define("TLTLTPVERSION", "0.1.4.4"); |
| 3 | $tltlds = ".*\.(2000\.hu|ab\.ca|ab\.se|abo\.pa|ac\.ae|ac\.am|ac\.at|ac\.bd|" |
| 4 | . "ac\.be|ac\.cn|ac\.com|ac\.cr|ac\.cy|ac\.fj|ac\.fk|ac\.gg|ac\.gn|" |
| 5 | . "ac\.hu|ac\.id|ac\.il|ac\.im|ac\.in|ac\.ir|ac\.je|ac\.jp|ac\.ke|" |
| 6 | . "ac\.kr|ac\.lk|ac\.ma|ac\.mw|ac\.ng|ac\.nz|ac\.om|ac\.pa|ac\.pg|" |
| 7 | . "ac\.rs|ac\.ru|ac\.rw|ac\.se|ac\.th|ac\.tj|ac\.tz|ac\.ug|ac\.uk|" |
| 8 | . "ac\.vn|ac\.yu|ac\.za|ac\.zm|ac\.zw|act\.au|ad\.jp|adm\.br|" |
| 9 | . "adult\.ht|adv\.br|adygeya\.ru|aero\.mv|aero\.tt|aeroport\.fr|" |
| 10 | . "agr\.br|agrar\.hu|agro\.pl|ah\.cn|aichi\.jp|aid\.pl|ak\.us|" |
| 11 | . "akita\.jp|al\.us|aland\.fi|alderney\.gg|alt\.na|alt\.za|" |
| 12 | . "altai\.ru|am\.br|amur\.ru|amursk\.ru|aomori\.jp|ar\.us|" |
| 13 | . "arkhangelsk\.ru|army\.mil|arq\.br|art\.br|art\.do|art\.dz|" |
| 14 | . "art\.ht|art\.pl|arts\.co|arts\.ro|arts\.ve|asn\.au|asn\.lv|" |
| 15 | . "ass\.dz|assedic\.fr|assn\.lk|asso\.dz|asso\.fr|asso\.gp|asso\.ht|" |
| 16 | . "asso\.mc|asso\.re|astrakhan\.ru|at\.tf|at\.tt|atm\.pl|ato\.br|" |
| 17 | . "au\.com|au\.tt|auto\.pl|av\.tr|avocat\.fr|avoues\.fr|az\.us|" |
| 18 | . "baikal\.ru|barreau\.fr|bashkiria\.ru|bbs\.tr|bc\.ca|bd\.se|be\.tt|" |
| 19 | . "bel\.tr|belgie\.be|belgorod\.ru|bg\.tf|bialystok\.pl|bib\.ve|" |
| 20 | . "bio\.br|bir\.ru|biz\.az|biz\.bh|biz\.cy|biz\.et|biz\.fj|biz\.ly|" |
| 21 | . "biz\.mv|biz\.nr|biz\.om|biz\.pk|biz\.pl|biz\.pr|biz\.tj|biz\.tr|" |
| 22 | . "biz\.tt|biz\.vn|bj\.cn|bl\.uk|bmd\.br|bolt\.hu|bourse\.za|br\.com|" |
| 23 | . "brand\.se|british-library\.uk|bryansk\.ru|buryatia\.ru|busan\.kr|" |
| 24 | . "c\.se|ca\.tf|ca\.tt|ca\.us|casino\.hu|cbg\.ru|cc\.bh|cci\.fr|" |
| 25 | . "ch\.tf|ch\.vu|chambagri\.fr|chel\.ru|chelyabinsk\.ru|" |
| 26 | . "cherkassy\.ua|chernigov\.ua|chernovtsy\.ua|chiba\.jp|" |
| 27 | . "chirurgiens-dentistes\.fr|chita\.ru|chukotka\.ru|chungbuk\.kr|" |
| 28 | . "chungnam\.kr|chuvashia\.ru|cim\.br|city\.hu|city\.za|ck\.ua|" |
| 29 | . "club\.tw|cmw\.ru|cn\.com|cn\.ua|cng\.br|cnt\.br|co\.ae|co\.ag|" |
| 30 | . "co\.am|co\.ao|co\.at|co\.ba|co\.bw|co\.ck|co\.cr|co\.dk|co\.ee|" |
| 31 | . "co\.fk|co\.gg|co\.hu|co\.id|co\.il|co\.im|co\.in|co\.ir|co\.je|" |
| 32 | . "co\.jp|co\.ke|co\.kr|co\.ls|co\.ma|co\.mu|co\.mw|co\.mz|co\.nz|" |
| 33 | . "co\.om|co\.rs|co\.rw|co\.st|co\.th|co\.tj|co\.tt|co\.tv|co\.tz|" |
| 34 | . "co\.ua|co\.ug|co\.uk|co\.us|co\.uz|co\.ve|co\.vi|co\.yu|co\.za|" |
| 35 | . "co\.zm|co\.zw|com\.ac|com\.ae|com\.af|com\.ag|com\.ai|com\.al|" |
| 36 | . "com\.am|com\.an|com\.ar|com\.au|com\.aw|com\.az|com\.ba|com\.bb|" |
| 37 | . "com\.bd|com\.bh|com\.bm|com\.bn|com\.bo|com\.br|com\.bs|com\.bt|" |
| 38 | . "com\.bz|com\.cd|com\.ch|com\.cn|com\.co|com\.cu|com\.cy|com\.dm|" |
| 39 | . "com\.do|com\.dz|com\.ec|com\.ee|com\.eg|com\.er|com\.es|com\.et|" |
| 40 | . "com\.fj|com\.fk|com\.fr|com\.ge|com\.gh|com\.gi|com\.gn|com\.gp|" |
| 41 | . "com\.gr|com\.gt|com\.gu|com\.hk|com\.hn|com\.hr|com\.ht|com\.io|" |
| 42 | . "com\.jm|com\.jo|com\.kg|com\.kh|com\.ki|com\.kw|com\.ky|com\.kz|" |
| 43 | . "com\.la|com\.lb|com\.lc|com\.li|com\.lk|com\.lr|com\.lv|com\.ly|" |
| 44 | . "com\.mg|com\.mk|com\.mm|com\.mn|com\.mo|com\.mt|com\.mu|com\.mv|" |
| 45 | . "com\.mw|com\.mx|com\.my|com\.na|com\.nc|com\.nf|com\.ng|com\.ni|" |
| 46 | . "com\.np|com\.nr|com\.om|com\.pa|com\.pe|com\.pf|com\.pg|com\.ph|" |
| 47 | . "com\.pk|com\.pl|com\.pr|com\.ps|com\.pt|com\.py|com\.qa|com\.re|" |
| 48 | . "com\.ro|com\.ru|com\.rw|com\.sa|com\.sb|com\.sc|com\.sd|com\.sg|" |
| 49 | . "com\.sh|com\.st|com\.sv|com\.sy|com\.tj|com\.tn|com\.tr|com\.tt|" |
| 50 | . "com\.tw|com\.ua|com\.uy|com\.uz|com\.vc|com\.ve|com\.vi|com\.vn|" |
| 51 | . "com\.vu|com\.ws|com\.ye|conf\.au|conf\.lv|consulado\.st|coop\.br|" |
| 52 | . "coop\.ht|coop\.mv|coop\.mw|coop\.tt|cpa\.pro|cq\.cn|cri\.nz|" |
| 53 | . "crimea\.ua|csiro\.au|ct\.us|cul\.na|cv\.ua|cz\.tf|d\.se|" |
| 54 | . "daejeon\.kr|dagestan\.ru|dc\.us|de\.com|de\.net|de\.tf|de\.tt|" |
| 55 | . "de\.us|de\.vu|dk\.org|dk\.tt|dn\.ua|dnepropetrovsk\.ua|dni\.us|" |
| 56 | . "dns\.be|donetsk\.ua|dp\.ua|dpn\.br|dr\.tr|dudinka\.ru|" |
| 57 | . "e-burg\.ru|e\.se|e164\.arpa|ebiz\.tw|ecn\.br|ed\.ao|ed\.cr|ed\.jp|" |
| 58 | . "edu\.ac|edu\.af|edu\.ai|edu\.al|edu\.am|edu\.an|edu\.ar|edu\.au|" |
| 59 | . "edu\.az|edu\.ba|edu\.bb|edu\.bd|edu\.bh|edu\.bm|edu\.bn|edu\.bo|" |
| 60 | . "edu\.br|edu\.bt|edu\.ck|edu\.cn|edu\.co|edu\.cu|edu\.dm|edu\.do|" |
| 61 | . "edu\.dz|edu\.ec|edu\.ee|edu\.eg|edu\.er|edu\.es|edu\.et|edu\.ge|" |
| 62 | . "edu\.gh|edu\.gi|edu\.gp|edu\.gr|edu\.gt|edu\.gu|edu\.hk|edu\.hn|" |
| 63 | . "edu\.ht|edu\.hu|edu\.in|edu\.it|edu\.jm|edu\.jo|edu\.kg|edu\.kh|" |
| 64 | . "edu\.kw|edu\.ky|edu\.kz|edu\.lb|edu\.lc|edu\.lk|edu\.lr|edu\.lv|" |
| 65 | . "edu\.ly|edu\.mg|edu\.mm|edu\.mn|edu\.mo|edu\.mt|edu\.mv|edu\.mw|" |
| 66 | . "edu\.mx|edu\.my|edu\.na|edu\.ng|edu\.ni|edu\.np|edu\.nr|edu\.om|" |
| 67 | . "edu\.pa|edu\.pe|edu\.pf|edu\.ph|edu\.pk|edu\.pl|edu\.pr|edu\.ps|" |
| 68 | . "edu\.pt|edu\.py|edu\.qa|edu\.rs|edu\.ru|edu\.rw|edu\.sa|edu\.sb|" |
| 69 | . "edu\.sc|edu\.sd|edu\.sg|edu\.sh|edu\.sk|edu\.st|edu\.sv|edu\.tf|" |
| 70 | . "edu\.tj|edu\.tr|edu\.tt|edu\.tw|edu\.ua|edu\.uk|edu\.uy|edu\.ve|" |
| 71 | . "edu\.vi|edu\.vn|edu\.vu|edu\.ws|edu\.ye|edu\.yu|edu\.za|" |
| 72 | . "edunet\.tn|ehime\.jp|ekloges\.cy|embaixada\.st|eng\.br|ens\.tn|" |
| 73 | . "ernet\.in|erotica\.hu|erotika\.hu|es\.kr|es\.tt|esp\.br|etc\.br|" |
| 74 | . "eti\.br|eu\.com|eu\.org|eu\.tf|eu\.tt|eun\.eg|" |
| 75 | . "experts-comptables\.fr|f\.se|fam\.pk|far\.br|fareast\.ru|fax\.nr|" |
| 76 | . "fed\.us|fgov\.be|fh\.se|fhs\.no|fhsk\.se|fhv\.se|fi\.cr|fie\.ee|" |
| 77 | . "film\.hu|fin\.ec|fin\.tn|firm\.co|firm\.ht|firm\.in|firm\.ro|" |
| 78 | . "firm\.ve|fj\.cn|fl\.us|fm\.br|fnd\.br|folkebibl\.no|forum\.hu|" |
| 79 | . "fot\.br|fr\.tt|fr\.vu|from\.hr|fst\.br|fukui\.jp|fukuoka\.jp|" |
| 80 | . "fukushima\.jp|fylkesbibl\.no|g\.se|g12\.br|ga\.us|game\.tw|" |
| 81 | . "games\.hu|gangwon\.kr|gb\.com|gb\.net|gc\.ca|gd\.cn|gda\.pl|" |
| 82 | . "gdansk\.pl|geek\.nz|gen\.in|gen\.nz|gen\.tr|geometre-expert\.fr|" |
| 83 | . "ggf\.br|gifu\.jp|mina\.pl|go\.cr|go\.id|go\.jp|go\.ke|go\.kr|" |
| 84 | . "go\.th|go\.tj|go\.tz|go\.ug|gob\.bo|gob\.do|gob\.es|gob\.gt|" |
| 85 | . "gob\.hn|gob\.mx|gob\.ni|gob\.pa|gob\.pe|gob\.pk|gob\.sv|gok\.pk|" |
| 86 | . "gon\.pk|gop\.pk|gos\.pk|gouv\.fr|gouv\.ht|gouv\.rw|gov\.ac|" |
| 87 | . "gov\.ae|gov\.af|gov\.ai|gov\.al|gov\.am|gov\.ar|gov\.au|gov\.az|" |
| 88 | . "gov\.ba|gov\.bb|gov\.bd|gov\.bf|gov\.bh|gov\.bm|gov\.bo|gov\.br|" |
| 89 | . "gov\.bt|gov\.by|gov\.ch|gov\.ck|gov\.cn|gov\.co|gov\.cu|gov\.cx|" |
| 90 | . "gov\.cy|gov\.dm|gov\.do|gov\.dz|gov\.ec|gov\.eg|gov\.er|gov\.et|" |
| 91 | . "gov\.fj|gov\.fk|gov\.ge|gov\.gg|gov\.gh|gov\.gi|gov\.gn|gov\.gr|" |
| 92 | . "gov\.gu|gov\.hu|gov\.hu|gov\.ie|gov\.il|gov\.im|gov\.in|gov\.io|" |
| 93 | . "gov\.ir|gov\.it|gov\.je|gov\.jm|gov\.jo|gov\.jp|gov\.kg|gov\.kh|" |
| 94 | . "gov\.kw|gov\.ky|gov\.kz|gov\.lb|gov\.lc|gov\.li|gov\.lk|gov\.lr|" |
| 95 | . "gov\.lt|gov\.lu|gov\.lv|gov\.ly|gov\.ma|gov\.mg|gov\.mm|gov\.mn|" |
| 96 | . "gov\.mo|gov\.mt|gov\.mv|gov\.mw|gov\.my|gov\.ng|gov\.np|gov\.nr|" |
| 97 | . "gov\.om|gov\.ph|gov\.pk|gov\.pl|gov\.pr|gov\.ps|gov\.pt|gov\.py|" |
| 98 | . "gov\.qa|gov\.rs|gov\.ru|gov\.rw|gov\.sa|gov\.sb|gov\.sc|gov\.sd|" |
| 99 | . "gov\.sg|gov\.sh|gov\.sk|gov\.st|gov\.sy|gov\.tj|gov\.tn|gov\.to|" |
| 100 | . "gov\.tp|gov\.tr|gov\.tt|gov\.tv|gov\.tw|gov\.ua|gov\.uk|gov\.ve|" |
| 101 | . "gov\.vi|gov\.vn|gov\.ws|gov\.ye|gov\.za|gov\.zm|gov\.zw|govt\.nz|" |
| 102 | . "gr\.jp|greta\.fr|grozny\.ru|grp\.lk|gs\.cn|gsm\.pl|gub\.uy|" |
| 103 | . "guernsey\.gg|gunma\.jp|gv\.ao|gv\.at|gwangju\.kr|gx\.cn|" |
| 104 | . "gyeongbuk\.kr|gyeonggi\.kr|gyeongnam\.kr|gz\.cn|h\.se|ha\.cn|" |
| 105 | . "hb\.cn|he\.cn|health\.vn|herad\.no|hi\.cn|hi\.us|hiroshima\.jp|" |
| 106 | . "hk\.cn|hl\.cn|hn\.cn|hokkaido\.jp|hotel\.hu|hotel\.lk|hs\.kr|" |
| 107 | . "hu\.com|huissier-justice\.fr|hyogo\.jp|i\.se|ia\.us|ibaraki\.jp|" |
| 108 | . "icnet\.uk|id\.au|id\.fj|id\.ir|id\.lv|id\.ly|id\.us|idf\.il|" |
| 109 | . "idn\.sg|idrett\.no|idv\.hk|idv\.tw|if\.ua|il\.us|imb\.br|" |
| 110 | . "in-addr\.arpa|in\.rs|in\.th|in\.ua|in\.us|incheon\.kr|ind\.br|" |
| 111 | . "ind\.er|ind\.gg|ind\.gt|ind\.in|ind\.je|ind\.tn|inf\.br|inf\.cu|" |
| 112 | . "info\.au|info\.az|info\.bh|info\.co|info\.cu|info\.cy|info\.ec|" |
| 113 | . "info\.et|info\.fj|info\.ht|info\.hu|info\.mv|info\.nr|info\.pl|" |
| 114 | . "info\.pr|info\.ro|info\.sd|info\.tn|info\.tr|info\.tt|info\.ve|" |
| 115 | . "info\.vn|ing\.pa|ingatlan\.hu|inima\.al|int\.am|int\.ar|int\.az|" |
| 116 | . "int\.bo|int\.co|int\.lk|int\.mv|int\.mw|int\.pt|int\.ru|int\.rw|" |
| 117 | . "int\.tf|int\.tj|int\.tt|int\.ve|int\.vn|intl\.tn|ip6\.arpa|" |
| 118 | . "iris\.arpa|irkutsk\.ru|isa\.us|ishikawa\.jp|isla\.pr|it\.ao|" |
| 119 | . "it\.tt|ivano-frankivsk\.ua|ivanovo\.ru|iwate\.jp|iwi\.nz|iz\.hr|" |
| 120 | . "izhevsk\.ru|jamal\.ru|jar\.ru|jeju\.kr|jeonbuk\.kr|jeonnam\.kr|" |
| 121 | . "jersey\.je|jet\.uk|jl\.cn|jobs\.tt|jogasz\.hu|jor\.br|" |
| 122 | . "joshkar-ola\.ru|js\.cn|jx\.cn|k-uralsk\.ru|k\.se|k12\.ec|k12\.il|" |
| 123 | . "k12\.tr|kagawa\.jp|kagoshima\.jp|kalmykia\.ru|kaluga\.ru|" |
| 124 | . "kamchatka\.ru|kanagawa\.jp|kanazawa\.jp|karelia\.ru|katowice\.pl|" |
| 125 | . "kawasaki\.jp|kazan\.ru|kchr\.ru|kemerovo\.ru|kg\.kr|kh\.ua|" |
| 126 | . "khabarovsk\.ru|khakassia\.ru|kharkov\.ua|kherson\.ua|" |
| 127 | . "khmelnitskiy\.ua|khv\.ru|kids\.us|kiev\.ua|kirov\.ru|" |
| 128 | . "kirovograd\.ua|kitakyushu\.jp|km\.ua|kms\.ru|kobe\.jp|kochi\.jp|" |
| 129 | . "koenig\.ru|komforb\.se|komi\.ru|kommunalforbund\.se|kommune\.no|" |
| 130 | . "komvux\.se|konyvelo\.hu|kostroma\.ru|kr\.ua|krakow\.pl|" |
| 131 | . "krasnoyarsk\.ru|ks\.ua|ks\.us|kuban\.ru|kumamoto\.jp|kurgan\.ru|" |
| 132 | . "kursk\.ru|kustanai\.ru|kuzbass\.ru|kv\.ua|ky\.us|kyonggi\.kr|" |
| 133 | . "kyoto\.jp|la\.us|lakas\.hu|lanarb\.se|lanbib\.se|law\.pro|" |
| 134 | . "law\.za|lel\.br|lg\.jp|lg\.ua|lipetsk\.ru|lkd\.co\.im|ln\.cn|" |
| 135 | . "lodz\.pl|ltd\.co\.im|ltd\.cy|ltd\.gg|ltd\.gi|ltd\.je|ltd\.lk|" |
| 136 | . "ltd\.uk|lublin\.pl|lugansk\.ua|lutsk\.ua|lviv\.ua|m\.se|ma\.us|" |
| 137 | . "magadan\.ru|magnitka\.ru|mail\.pl|maori\.nz|mari-el\.ru|mari\.ru|" |
| 138 | . "marine\.ru|mat\.br|matsuyama\.jp|mb\.ca|md\.us|me\.uk|me\.us|" |
| 139 | . "med\.br|med\.ec|med\.ee|med\.ht|med\.ly|med\.om|med\.pa|med\.pro|" |
| 140 | . "med\.sa|med\.sd|medecin\.fr|media\.hu|media\.pl|mi\.th|mi\.us|" |
| 141 | . "miasta\.pl|mie\.jp|mil\.ac|mil\.ae|mil\.am|mil\.ar|mil\.az|" |
| 142 | . "mil\.ba|mil\.bd|mil\.bo|mil\.br|mil\.by|mil\.co|mil\.do|mil\.ec|" |
| 143 | . "mil\.eg|mil\.er|mil\.fj|mil\.ge|mil\.gh|mil\.gt|mil\.gu|mil\.hn|" |
| 144 | . "mil\.id|mil\.in|mil\.io|mil\.jo|mil\.kg|mil\.kh|mil\.kr|mil\.kw|" |
| 145 | . "mil\.kz|mil\.lb|mil\.lt|mil\.lu|mil\.lv|mil\.mg|mil\.mv|mil\.my" |
| 146 | . "mil\.no|mil\.np|mil\.nz|mil\.om|mil\.pe|mil\.ph|mil\.pl|mil\.ru|" |
| 147 | . "mil\.rw|mil\.se|mil\.sh|mil\.sk|mil\.st|mil\.tj|mil\.tr|mil\.tw|" |
| 148 | . "mil\.uk|mil\.uy|mil\.ve|mil\.ye|mil\.za|miyagi\.jp|miyazaki\.jp|" |
| 149 | . "mk\.ua|mn\.us|mo\.cn|mo\.us|mob\.nr|mobi\.tt|mobil\.nr|mobile\.nr|" |
| 150 | . "mod\.gi|mod\.om|mod\.uk|mordovia\.ru|mosreg\.ru|ms\.kr|ms\.us|" |
| 151 | . "msk\.ru|mt\.us|muni\.il|murmansk\.ru|mus\.br|museum\.mn|" |
| 152 | . "museum\.mv|museum\.mw|museum\.no|museum\.om|museum\.tt|" |
| 153 | . "music\.mobi|mytis\.ru|n\.se|nagano\.jp|nagasaki\.jp|nagoya\.jp|" |
| 154 | . "nakhodka\.ru|nalchik\.ru|name\.ae|name\.az|name\.cy|name\.et|" |
| 155 | . "name\.fj|name\.hr|name\.mv|name\.my|name\.pr|name\.tj|name\.tr|" |
| 156 | . "name\.tt|name\.vn|nara\.jp|nat\.tn|national-library-scotland\.uk|" |
| 157 | . "naturbruksgymn\.se|navy\.mil|nb\.ca|nc\.us|nd\.us|ne\.jp|ne\.ke|" |
| 158 | . "ne\.kr|ne\.tz|ne\.ug|ne\.us|nel\.uk|net\.ac|net\.ae|net\.af|" |
| 159 | . "net\.ag|net\.ai|net\.al|net\.am|net\.an|net\.ar|net\.au|net\.az|" |
| 160 | . "net\.ba|net\.bb|net\.bd|net\.bh|net\.bm|net\.bn|net\.bo|net\.br|" |
| 161 | . "net\.bs|net\.bt|net\.bz|net\.cd|net\.ch|net\.ck|net\.cn|net\.co|" |
| 162 | . "net\.cu|net\.cy|net\.dm|net\.do|net\.dz|net\.ec|net\.eg|net\.er|" |
| 163 | . "net\.et|net\.fj|net\.fk|net\.ge|net\.gg|net\.gn|net\.gp|net\.gr|" |
| 164 | . "net\.gt|net\.gu|net\.hk|net\.hn|net\.ht|net\.id|net\.il|net\.im|" |
| 165 | . "net\.in|net\.io|net\.ir|net\.je|net\.jm|net\.jo|net\.jp|net\.kg|" |
| 166 | . "net\.kh|net\.ki|net\.kw|net\.ky|net\.kz|net\.la|net\.lb|net\.lc|" |
| 167 | . "net\.li|net\.lk|net\.lr|net\.lu|net\.lv|net\.ly|net\.ma|net\.mm|" |
| 168 | . "net\.mo|net\.mt|net\.mu|net\.mv|net\.mw|net\.mx|net\.my|net\.na|" |
| 169 | . "net\.nc|net\.nf|net\.ng|net\.ni|net\.np|net\.nr|net\.nz|net\.om|" |
| 170 | . "net\.pa|net\.pe|net\.pg|net\.ph|net\.pk|net\.pl|net\.pr|net\.ps|" |
| 171 | . "net\.pt|net\.py|net\.qa|net\.ru|net\.rw|net\.sa|net\.sb|net\.sc|" |
| 172 | . "net\.sd|net\.sg|net\.sh|net\.st|net\.sy|net\.tf|net\.th|net\.tj|" |
| 173 | . "net\.tn|net\.tr|net\.tt|net\.tw|net\.ua|net\.uk|net\.uy|net\.uz|" |
| 174 | . "net\.vc|net\.ve|net\.vi|net\.vn|net\.vu|net\.ws|net\.ye|net\.za|" |
| 175 | . "new\.ke|news\.hu|nf\.ca|ngo\.lk|ngo\.ph|ngo\.pl|ngo\.za|nh\.us|" |
| 176 | . "nhs\.uk|nic\.im|nic\.in|nic\.tt|nic\.uk|nieruchomosci\.pl|" |
| 177 | . "niigata\.jp|nikolaev\.ua|nj\.us|nkz\.ru|nl\.ca|nls\.uk|nm\.cn|" |
| 178 | . "nm\.us|nnov\.ru|no\.com|nom\.ad|nom\.ag|nom\.br|nom\.co|nom\.es|" |
| 179 | . "nom\.fk|nom\.fr|nom\.mg|nom\.ni|nom\.pa|nom\.pe|nom\.pl|nom\.re|" |
| 180 | . "nom\.ro|nom\.ve|nom\.za|nome\.pt|norilsk\.ru|not\.br|notaires\.fr|" |
| 181 | . "nov\.ru|novosibirsk\.ru|ns\.ca|nsk\.ru|nsn\.us|nsw\.au|nt\.au|" |
| 182 | . "nt\.ca|nt\.ro|ntr\.br|nu\.ca|nui\.hu|nv\.us|nx\.cn|ny\.us|o\.se|" |
| 183 | . "od\.ua|odessa\.ua|odo\.br|off\.ai|odessa\.ua|odo\.br|off\.ai|" |
| 184 | . "og\.ao|oh\.us|oita\.jp|ok\.us|okayama\.jp|okinawa\.jp|olsztyn\.pl|" |
| 185 | . "omsk\.ru|on\.ca|opole\.pl|or\.at|or\.cr|or\.id|or\.jp|or\.ke|" |
| 186 | . "or\.kr|or\.th|or\.tz|or\.ug|or\.us|orenburg\.ru|org\.ac|org\.ae|" |
| 187 | . "org\.ag|org\.ai|org\.al|org\.am|org\.an|org\.ar|org\.au|org\.az|" |
| 188 | . "org\.ba|org\.bb|org\.bd|org\.bh|org\.bm|org\.bn|org\.bo|org\.br|" |
| 189 | . "org\.bs|org\.bt|org\.bw|org\.bz|org\.cd|org\.ch|org\.ck|org\.cn|" |
| 190 | . "org\.co|org\.cu|org\.cy|org\.dm|org\.do|org\.dz|org\.ec|org\.ee|" |
| 191 | . "org\.eg|org\.er|org\.es|org\.et|org\.fj|org\.fk|org\.ge|org\.gg|" |
| 192 | . "org\.gh|org\.gi|org\.gn|org\.gp|org\.gr|org\.gt|org\.gu|org\.hk|" |
| 193 | . "org\.hn|org\.ht|org\.hu|org\.il|org\.im|org\.in|org\.io|org\.ir|" |
| 194 | . "org\.je|org\.jm|org\.jo|org\.jp|org\.kg|org\.kh|org\.ki|org\.kw|" |
| 195 | . "org\.ky|org\.kz|org\.la|org\.lb|org\.lc|org\.li|org\.lk|org\.lr|" |
| 196 | . "org\.ls|org\.lu|org\.lv|org\.ly|org\.ma|org\.mg|org\.mk|org\.mm|" |
| 197 | . "org\.mn|org\.mo|org\.mt|org\.mu|org\.mv|org\.mw|org\.mx|org\.my|" |
| 198 | . "org\.na|org\.nc|org\.ng|org\.ni|org\.np|org\.nr|org\.nz|org\.om|" |
| 199 | . "org\.pa|org\.pe|org\.pf|org\.ph|org\.pk|org\.pl|org\.pr|org\.ps|" |
| 200 | . "org\.pt|org\.py|org\.qa|org\.ro|org\.rs|org\.ru|org\.sa|org\.sb|" |
| 201 | . "org\.sc|org\.sd|org\.se|org\.sg|org\.sh|org\.st|org\.sv|org\.sy|" |
| 202 | . "org\.tj|org\.tn|org\.tr|org\.tt|org\.tw|org\.ua|org\.uk|org\.uy|" |
| 203 | . "org\.uz|org\.vc|org\.ve|org\.vi|org\.vn|org\.vu|org\.ws|org\.ye|" |
| 204 | . "org\.yu|org\.za|org\.zm|org\.zw|oryol\.ru|osaka\.jp|oskol\.ru|" |
| 205 | . "otc\.au|oz\.au|pa\.us|palana\.ru|parliament\.cy|parliament\.uk|" |
| 206 | . "parti\.se|pb\.ao|pc\.pl|pe\.ca|pe\.kr|penza\.ru|per\.kh|per\.sg|" |
| 207 | . "perm\.ru|perso\.ht|pharmacien\.fr|pl\.tf|pl\.ua|plc\.co\.im|" |
| 208 | . "plc\.ly|plc\.uk|plo\.ps|pol\.dz|pol\.ht|pol\.tr|police\.uk|" |
| 209 | . "poltava\.ua|port\.fr|powiat\.pl|poznan\.pl|pp\.az|pp\.ru|pp\.se|" |
| 210 | . "ppg\.br|prd\.fr|prd\.mg|press\.cy|press\.ma|press\.se|presse\.fr|" |
| 211 | . "pri\.ee|principe\.st|priv\.at|priv\.hu|priv\.no|priv\.pl|pro\.ae|" |
| 212 | . "pro\.br|pro\.cy|pro\.ec|pro\.fj|pro\.ht|pro\.mv|pro\.om|pro\.pr|" |
| 213 | . "pro\.tt|pro\.vn|psc\.br|psi\.br|pskov\.ru|ptz\.ru|pub\.sa|" |
| 214 | . "publ\.pt|pvt\.ge|pyatigorsk\.ru|qc\.ca|qc\.com|qh\.cn|qld\.au|" |
| 215 | . "qsl\.br|re\.kr|realestate\.pl|rec\.br|rec\.co|rec\.ro|rec\.ve|" |
| 216 | . "red\.sv|reklam\.hu|rel\.ht|rel\.pl|res\.in|ri\.us|rnd\.ru|" |
| 217 | . "rnrt\.tn|rns\.tn|rnu\.tn|rovno\.ua|rs\.ba|ru\.com|ru\.tf|" |
| 218 | . "rubtsovsk\.ru|rv\.ua|ryazan\.ru|s\.se|sa\.au|sa\.com|sa\.cr|" |
| 219 | . "saga\.jp|saitama\.jp|sakhalin\.ru|samara\.ru|saotome\.st|" |
| 220 | . "sapporo\.jp|saratov\.ru|sark\.gg|sc\.cn|sc\.ke|sc\.kr|sc\.ug|" |
| 221 | . "sc\.us|sch\.ae|sch\.gg|sch\.id|sch\.ir|sch\.je|sch\.lk|sch\.ly|" |
| 222 | . "sch\.ng|sch\.om|sch\.sa|sch\.sd|sch\.uk|sch\.zm|school\.fj|" |
| 223 | . "school\.nz|school\.za|sci\.eg|sd\.cn|sd\.us|se\.com|se\.tt|" |
| 224 | . "sebastopol\.ua|sec\.ps|sendai\.jp|seoul\.kr|sex\.hu|sex\.pl|" |
| 225 | . "sg\.tf|sh\.cn|shiga\.jp|shimane\.jp|shizuoka\.jp|shop\.ht|" |
| 226 | . "shop\.hu|shop\.pl|simbirsk\.ru|sk\.ca|sklep\.pl|sld\.do|sld\.pa|" |
| 227 | . "slg\.br|slupsk\.pl|smolensk\.ru|sn\.cn|snz\.ru|soc\.lk|" |
| 228 | . "soros\.al|sos\.pl|spb\.ru|sport\.hu|srv\.br|sshn\.se|stat\.no|" |
| 229 | . "stavropol\.ru|store\.co|store\.ro|store\.st|store\.ve|stv\.ru|" |
| 230 | . "suli\.hu|sumy\.ua|surgut\.ru|sx\.cn|syzran\.ru|szczecin\.pl|" |
| 231 | . "szex\.hu|szkola\.pl|t\.se|takamatsu\.jp|tambov\.ru|targi\.pl|" |
| 232 | . "tas\.au|tatarstan\.ru|te\.ua|tec\.ve|tel\.no|tel\.nr|tel\.tr|" |
| 233 | . "telecom\.na|telememo\.au|ternopil\.ua|test\.ru|tirana\.al|tj\.cn|" |
| 234 | . "tld\.am|tlf\.nr|tm\.cy|tm\.fr|tm\.hu|tm\.mc|tm\.mg|tm\.mt|" |
| 235 | . "tm\.pl|tm\.ro|tm\.se|tm\.za|tmp\.br|tn\.us|tochigi\.jp|" |
| 236 | . "tokushima\.jp|tokyo\.jp|tom\.ru|tomsk\.ru|torun\.pl|tottori\.jp|" |
| 237 | . "tourism\.pl|tourism\.tn|toyama\.jp|tozsde\.hu|travel\.pl|" |
| 238 | . "travel\.tt|trd\.br|tsaritsyn\.ru|tsk\.ru|tula\.ru|tur\.br|" |
| 239 | . "turystyka\.pl|tuva\.ru|tv\.bo|tv\.br|tv\.sd|tver\.ru|tw\.cn|" |
| 240 | . "tx\.us|tyumen\.ru|u\.se|udm\.ru|udmurtia\.ru|uk\.com|uk\.net|" |
| 241 | . "uk\.tt|ulan-ude\.ru|ulsan\.kr|unam\.na|unbi\.ba|uniti\.al|" |
| 242 | . "unsa\.ba|upt\.al|uri\.arpa|urn\.arpa|us\.com|us\.tf|us\.tt|" |
| 243 | . "ut\.us|utazas\.hu|utsunomiya\.jp|uu\.mt|uy\.com|uzhgorod\.ua|" |
| 244 | . "va\.us|vatican\.va|vdonsk\.ru|vet\.br|veterinaire\.fr|vgs\.no|" |
| 245 | . "vic\.au|video\.hu|vinnica\.ua|vladikavkaz\.ru|vladimir\.ru|" |
| 246 | . "vladivostok\.ru|vn\.ua|volgograd\.ru||vologda\.ru|voronezh\.ru|" |
| 247 | . "vrn\.ru|vt\.us|vyatka\.ru|w\.se|wa\.au|wa\.us|wakayama\.jp|" |
| 248 | . "warszawa\.pl|waw\.pl|weather\.mobi|web\.co|web\.do|web\.id|" |
| 249 | . "web\.lk|web\.pk|web\.tj|web\.tr|web\.ve|web\.za|wi\.us|wroc\.pl|" |
| 250 | . "wroclaw\.pl|wv\.us|www\.ro|wy\.us|x\.se|xj\.cn|xz\.cn|y\.se|" |
| 251 | . "yakutia\.ru|yamagata\.jp|yamaguchi\.jp|yamal\.ru|yamanashi\.jp|" |
| 252 | . "yaroslavl\.ru|yekaterinburg\.ru|yk\.ca|yn\.cn|yokohama\.jp|" |
| 253 | . "yuzhno-sakhalinsk\.ru|z\.se|za\.com|za\.pl|zaporizhzhe\.ua|" |
| 254 | . "zgora\.pl|zgrad\.ru|zhitomir\.ua|zj\.cn|zlg\.br|zp\.ua|zt\.ua)"; |
| 255 | ?> |