Skip to content

Commit 65326b5

Browse files
committed
wip
1 parent f0a1c14 commit 65326b5

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

ghost.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function setup( $args ) {
8787
// Await startup of Ghost and POST credentials to complete setup
8888
$post_url = $url . '/ghost/#/setup';
8989
$retry = 0;
90-
while( ! $this->is_url_available( $post_url ) ) {
90+
while( ! $this->is_form_ready( $post_url ) ) {
9191
sleep( 1 );
9292
$retry++;
9393
if ( $retry > 300 ) {
@@ -122,18 +122,22 @@ public function setup( $args ) {
122122
curl_close($curl);
123123
}
124124

125-
public function is_url_available( $url ) {
126-
$ch = curl_init( $url );
127-
curl_setopt( $ch, CURLOPT_NOBODY, true );
128-
curl_exec( $ch );
129-
$code = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
130-
if ( $code == 200 ) {
131-
$status = true;
132-
}else{
133-
$status = false;
125+
public function is_form_ready( $url ) {
126+
// Perform a HEAD request to get the HTTP response code
127+
$headers = get_headers($url, 1);
128+
129+
if (strpos($headers[0], '200') !== false) {
130+
// If the HTTP response code is 200 (OK), fetch the content
131+
$content = file_get_contents($url);
132+
133+
if (strpos($content, '<form id="setup"') !== false) {
134+
return true;
135+
} else {
136+
return false;
137+
}
138+
} else {
139+
return false;
134140
}
135-
curl_close( $ch );
136-
return $status;
137141
}
138142

139143
// Customize the install page

0 commit comments

Comments
 (0)