Skip to content

Commit 07d1b11

Browse files
committed
added a feature to test the internet connection status
this feature calls the gethostbyname() function to reach www.google.fr and get its IP. If the function cannot get the IP we can change the internet status
1 parent 1f2cd4a commit 07d1b11

File tree

1 file changed

+5
-32
lines changed

1 file changed

+5
-32
lines changed

phpwpinfo.php

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,6 @@ function phpwpinfo() {
3838
$info->init_all_tests();
3939
}
4040

41-
function command_exists ($command) {
42-
$whereIsCommand = (PHP_OS == 'WINNT') ? 'where' : 'which';
43-
44-
$process = proc_open(
45-
"$whereIsCommand $command",
46-
array(
47-
0 => array("pipe", "r"), //STDIN
48-
1 => array("pipe", "w"), //STDOUT
49-
2 => array("pipe", "w"), //STDERR
50-
),
51-
$pipes
52-
);
53-
if ($process !== false) {
54-
$stdout = stream_get_contents($pipes[1]);
55-
$stderr = stream_get_contents($pipes[2]);
56-
fclose($pipes[1]);
57-
fclose($pipes[2]);
58-
proc_close($process);
59-
60-
return $stdout != '';
61-
}
62-
63-
return false;
64-
}
65-
6641
/**
6742
* TODO: Use or not session for save DB configuration
6843
*/
@@ -167,16 +142,14 @@ public function test_versions() {
167142
$this->html_table_row( 'MySQL Version', $this->mysqli_version, '-', 'Not available, needs credentials.', 'warning' );
168143
}
169144

170-
//Test if the command 'git' exists, so it tests if Git is installed
171-
if(command_exists('git') == 1){
172-
$this->html_table_row('Presence of Git', 'No', 'Yes', 'Yes');
145+
//Test if the server is connected to the server by attempt to find the IP(v4) of www.google.fr
146+
if(gethostbyname('www.google.fr') != 'www.google.fr'){
147+
$this->html_table_row('Internet connection', 'No', 'Yes', 'Yes', 'success');
173148
}else{
174-
$this->html_table_row('Presence of Git', 'No', 'Yes', 'No', 'error');
149+
$this->html_table_row('Internet connection', 'No', 'Yes', 'No', 'error');
175150
}
176151

177-
$this->html_table_close();
178-
}
179-
152+
180153
public function test_php_extensions() {
181154
$this->html_table_open( 'PHP Extensions', '', 'Required', 'Recommended','Current' );
182155

0 commit comments

Comments
 (0)