Skip to content

Commit 31328f4

Browse files
committed
Merging Pull Request "Update for PHP 7.2 compatibility" from jsmitty12 for testing purpose
1 parent 7facdf9 commit 31328f4

29 files changed

+235
-528
lines changed

.gitignore

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
### Composer template
12
composer.lock
3+
composer.phar
24
/vendor
5+
36
nbproject
4-
.idea
7+
8+
### JetBrains template
9+
.idea/
10+
11+
*.phar

.travis.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
language: php
22

33
php:
4-
- 5.3
5-
- 5.4
6-
- 5.5
7-
- 5.6
8-
- 7
9-
- hhvm
10-
- hhvm-nightly
4+
- 7.0
5+
- 7.1
6+
- 7.2
7+
- nightly
118

129
matrix:
1310
fast_finish: true
1411
allow_failures:
15-
- php: hhvm-nightly
12+
- php: nightly
1613

1714
# faster builds on new travis containers
1815
sudo: false
@@ -22,6 +19,7 @@ install:
2219
- composer install --prefer-dist
2320

2421
script:
22+
- php testsuite.php --ci
2523
- vendor/bin/phpunit --verbose --coverage-clover=coverage.clover
2624

2725
after_script:

CHANGELOG.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
---
33
* Disable support for non ICANN domains (Used new.net doesn't exist anymore)
44

5+
v4.2.5
6+
------
7+
* New whois servers
8+
59
2011/07/09
610
----------
711
* html & cosmetic changes in examples
@@ -1147,7 +1151,7 @@ David Saez <[email protected]>
11471151

11481152
2000/12/12
11491153
----------
1150-
* v2.3
1154+
* v2.3
11511155
* PHP4 BUG IS FIXED!!!! Very special thanks to all who submitted fixes, used one provided by Stephen Leavitt <[email protected]> as it was the easiest and backwards compatible to PHP3
11521156
* added Enom handler, also by Stephen Leavitt <[email protected]>
11531157
* changed .ca whois to whois.cira.ca, using same handler for now.
@@ -1160,7 +1164,7 @@ David Saez <[email protected]>
11601164

11611165
2000/08/07
11621166
----------
1163-
* v2.2-3
1167+
* v2.2-3
11641168
* gtld.whois, "TUCOWS.COM INC." now, "TUCOWS.COM, INC." an unannounced change by the NSI registry once again breaks scripts all over the world...(thanks to Fred Andrews <[email protected]> for the report and fix on this)
11651169
* servers.whois, added .ke Kenyan whois server, thanks to "Peter Anampiu" <[email protected]> for digging that up.:x
11661170

composer.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323
"email": "[email protected]"
2424
}
2525
],
26-
"minimum-stability": "dev",
2726
"require": {
28-
"php": ">=5.3.0",
29-
"mso/idna-convert": "*"
27+
"php": ">=7.0",
28+
"mso/idna-convert": "^1.1"
3029
},
3130
"require-dev": {
32-
"phpunit/phpunit": "4.4.1"
31+
"phpunit/phpunit": "^6.0"
3332
},
3433
"suggest": {
3534
"lib-openssl": "*"

phpunit.xml.dist

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1+
12
<?xml version="1.0" encoding="utf-8"?>
2-
<phpunit bootstrap="./tests/bootstrap.php"
3-
colors="true"
4-
convertErrorsToExceptions="true"
5-
convertNoticesToExceptions="true"
6-
convertWarningsToExceptions="true"
7-
stopOnFailure="false">
3+
<!--
4+
You should copy this file into phpunit.xml and customize it to your needs.
5+
You'll need to update the paths in here if you use a directory other than
6+
one in which this file resides.
7+
-->
8+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd"
10+
bootstrap="./tests/bootstrap.php"
11+
colors="true"
12+
convertErrorsToExceptions="true"
13+
convertNoticesToExceptions="true"
14+
convertWarningsToExceptions="true"
15+
stopOnFailure="false">
816
<testsuites>
917
<testsuite name="phpWhois Test suite">
1018
<directory>./tests</directory>
1119
</testsuite>
1220
</testsuites>
1321
<filter>
14-
<blacklist>
15-
<directory>./vendor</directory>
16-
<directory>./tests</directory>
17-
</blacklist>
22+
<whitelist addUncoveredFilesFromWhitelist="true">
23+
<directory suffix=".php">src</directory>
24+
</whitelist>
1825
</filter>
19-
</phpunit>
26+
</phpunit>

src/Utils.php

+1-24
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
* @copyright Maintained by David Saez
2222
* @copyright Copyright (c) 2014 Dmitry Lukashin
2323
*/
24-
2524
namespace phpWhois;
26-
2725
/**
2826
* Additional utils
2927
*/
@@ -39,7 +37,6 @@ public function showObject(&$obj)
3937
$r = $this->debugObject($obj);
4038
return "<pre>$r</pre>\n";
4139
}
42-
4340
/**
4441
* Return object or array as formatted string
4542
* @param $obj
@@ -62,30 +59,23 @@ public function debugObject($obj, $indent = 0)
6259
return $return;
6360
}
6461
}
65-
6662
public function nsRrDefined($query)
6763
{
6864
return checkdnsrr($query, 'NS');
6965
}
70-
7166
/**
7267
* Get nice HTML output
7368
*/
7469
public function showHTML($result, $link_myself = true, $params = 'query=$0&amp;output=nice')
7570
{
76-
7771
// adds links for HTML output
78-
7972
$email_regex = "/([-_\w\.]+)(@)([-_\w\.]+)\b/i";
8073
$html_regex = "/(?:^|\b)((((http|https|ftp):\/\/)|(www\.))([\w\.]+)([,:%#&\/?~=\w+\.-]+))(?:\b|$)/is";
8174
$ip_regex = "/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/i";
82-
8375
$out = '';
8476
$lempty = true;
85-
8677
foreach ($result['rawdata'] as $line) {
8778
$line = trim($line);
88-
8979
if ($line == '') {
9080
if ($lempty) {
9181
continue;
@@ -95,14 +85,11 @@ public function showHTML($result, $link_myself = true, $params = 'query=$0&amp;o
9585
} else {
9686
$lempty = false;
9787
}
98-
9988
$out .= $line . "\n";
10089
}
101-
10290
if ($lempty) {
10391
$out = trim($out);
10492
}
105-
10693
$out = strip_tags($out);
10794
$out = preg_replace($email_regex, '<a href="mailto:$0">$0</a>', $out);
10895
$out = preg_replace_callback(
@@ -115,47 +102,37 @@ function ($matches) {
115102
$web = $matches[0];
116103
$url = $web;
117104
}
118-
119105
return '<a href="' . $url . '" target="_blank">' . $web . '</a>';
120106
},
121107
$out
122108
);
123-
124109
if ($link_myself) {
125110
if ($params[0] == '/') {
126111
$link = $params;
127112
} else {
128113
$link = $_SERVER['PHP_SELF'] . '?' . $params;
129114
}
130-
131115
$out = preg_replace($ip_regex, '<a href="' . $link . '">$0</a>', $out);
132-
133116
if (isset($result['regrinfo']['domain']['nserver'])) {
134117
$nserver = $result['regrinfo']['domain']['nserver'];
135118
} else {
136119
$nserver = false;
137120
}
138-
139121
if (isset($result['regrinfo']['network']['nserver'])) {
140122
$nserver = $result['regrinfo']['network']['nserver'];
141123
}
142-
143124
if (is_array($nserver)) {
144-
reset($nserver);
145-
while (list($host, $ip) = each($nserver)) {
125+
foreach ($nserver as $host => $ip) {
146126
$url = '<a href="' . str_replace('$0', $ip, $link) . "\">$host</a>";
147127
$out = str_replace($host, $url, $out);
148128
$out = str_replace(strtoupper($host), $url, $out);
149129
}
150130
}
151131
}
152-
153132
// Add bold field names
154133
$out = preg_replace("/(?m)^([-\s\.&;'\w\t\(\)\/]+:\s*)/", '<b>$1</b>', $out);
155-
156134
// Add italics for disclaimer
157135
$out = preg_replace("/(?m)^(%.*)/", '<i>$0</i>', $out);
158-
159136
return str_replace("\n", "<br/>\n", $out);
160137
}
161138
}

0 commit comments

Comments
 (0)