fix curl issue

This commit is contained in:
Frank Harris 2025-11-23 17:07:21 -05:00
parent 5f5008b377
commit f79bec0a16
2 changed files with 25 additions and 9 deletions

View file

@ -305,14 +305,19 @@ function ogpHome()
$msg = "Admin Login :warning: \nIP:".$client_ip." \nID:".$userInfo['user_id']." \nUser:".$userInfo['users_login'];
$json_data = array ('content'=>"$msg");
$make_json = json_encode($json_data);
$ch = curl_init( $webhookurl );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
if(!function_exists('curl_init')){
error_log("OGP Discord webhook skipped: PHP curl extension is not loaded.");
}else{
$ch = curl_init( $webhookurl );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
curl_close($ch);
}
//end WEBHOOK Discord
}
@ -500,4 +505,3 @@ function ogpHome()

View file

@ -29,6 +29,18 @@ define("XML_SCHEMA","modules/config_games/schema_server_config.xml");
/// \return array containing the elements on success.
function read_server_config( $filename )
{
if ( !class_exists('DOMDocument') )
{
print_failure("PHP DOM extension not found. Install the php-xml package to enable game configuration parsing.");
return FALSE;
}
if ( !function_exists('simplexml_load_file') )
{
print_failure("PHP SimpleXML extension not found. Install the php-xml package to enable game configuration parsing.");
return FALSE;
}
$dom = new DOMDocument();
if ( $dom->load($filename) === FALSE )
{