Skip to content

Commit

Permalink
Merge pull request #178 from leojonathanoh/fix/asp-testconfig-print-u…
Browse files Browse the repository at this point in the history
…rl-and-error-for-fail-tests-when-using-test-system

Fix (ASP/testconfig): Print URL and error for fail tests when using `Test System`
  • Loading branch information
leojonathanoh authored Mar 16, 2024
2 parents 9d37ce5 + b6167bf commit 4ff69bb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
12 changes: 8 additions & 4 deletions src/ASP/system/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ function getPageContents($url)
{
// Try file() first
$results = null;
$err = '';
if( function_exists('file') && function_exists('fopen') && ini_get('allow_url_fopen') )
{
ini_set("user_agent", "GameSpyHTTP/1.0");
Expand All @@ -434,14 +435,17 @@ function getPageContents($url)
curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10);
$results = curl_exec($curl_handle);
$err = curl_error($curl_handle);
if( $err != '' )
return false;
if( $err != '' ) {
return array($results, $err);
}
$results = explode("\n",trim($results));
curl_close($curl_handle);
}

// still nothing, forgetd a'bout it
if( !$results ) return false;
return $results;
if( !$results ) {
return array($results, "None of these functions exist: file, fopen, allow_url_fopen, curl_exec");
};
return array($results, $err);
}
?>
34 changes: 18 additions & 16 deletions src/ASP/system/modules/Testconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,80 +221,82 @@ public function ProcessTest()
$out .= " > Checking BF2Statistics Processing...<br />";

// Post the headers and snapshot data
$url = "http://{$_SERVER['HTTP_HOST']}/ASP/bf2statistics.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://{$_SERVER['HTTP_HOST']}/ASP/bf2statistics.php");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $tst_snapshot);
curl_setopt($ch, CURLOPT_USERAGENT, "GameSpyHTTP/1.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$result = curl_exec($ch);
$err = curl_error($ch);
$curlInfo = curl_getinfo($ch);
curl_close($ch);

if ($result && $curlInfo['http_code'] == 200)
{
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- BF2Statistics Processing Check: ".__PASS;
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- BF2Statistics Processing Check (URL: $url): ".__PASS;
}
else
{
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- BF2Statistics Processing Check: ".__FAIL;
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- BF2Statistics Processing Check (URL: $url): Error: $err. ".__FAIL;
$errors = true;
}

// Check .aspx Page Responses
$out .= " > Checking Gamespy (.aspx) File Basic Response...<br />";
$url = "http://".$_SERVER['HTTP_HOST']."/ASP/getbackendinfo.aspx";
$response = getPageContents($url);
list($response, $err) = getPageContents($url);
if ($response === false || trim($response[0]) != 'O')
{
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Basic Response: ".__FAIL;
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Basic Response (URL: $url): Error: $err. ".__FAIL;
$errors = true;
}
else
{
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Basic Response: ".__PASS;
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Basic Response (URL: $url): ".__PASS;
}

// Advanced request (1)
$out .= " > Checking Gamespy (.aspx) File Advanced Responses...<br />";
$url = "http://".$_SERVER['HTTP_HOST']."/ASP/getawardsinfo.aspx?pid=". $tst_pid;
$response = getPageContents($url);
list($response, $err) = getPageContents($url);
if ($response === false || trim($response[0]) != 'O')
{
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (1) Response: ".__FAIL;
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (1) Response (URL: $url): Error: $err. ".__FAIL;
$errors = true;
}
else
{
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (1) Response: ".__PASS;
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (1) Response (URL: $url): ".__PASS;
}

// Advanced Request (2)
$url = "http://".$_SERVER['HTTP_HOST']."/ASP/getrankinfo.aspx?pid=". $tst_pid;
$response = getPageContents($url);
list($response, $err) = getPageContents($url);
if ($response === false || trim($response[0]) != 'O')
{
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (2) Response: ".__FAIL;
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (2) Response (URL: $url): Error: $err. ".__FAIL;
$errors = true;
}
else
{
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (2) Response: ".__PASS;
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (2) Response (URL: $url): ".__PASS;
}

// Advanced Request (3)
$url = "http://".$_SERVER['HTTP_HOST']."/ASP/getunlocksinfo.aspx?pid=". $tst_pid;
$response = getPageContents($url);
list($response, $err) = getPageContents($url);
if ($response === false || trim($response[0]) != 'O')
{
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (3) Response: ".__FAIL;
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (3) Response (URL: $url): Error: $err. ".__FAIL;
$errors = true;
}
else
{
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (3) Response: ".__PASS;
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Gamespy (.aspx) Advanced (3) Response (URL: $url): ".__PASS;
}
}

Expand Down

0 comments on commit 4ff69bb

Please sign in to comment.