
11-14-2018, 07:38 PM
|
|
|
Join Date: Oct 2012
Location: Dundee, Scotland
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили:
0 раз(а) в 0 сообщениях
|
|
Quote:
Originally Posted by jetkai
Match array no longer works as expected on 4.2.5 vb (PHP 7.1)
[shame this is no longer supported]
Had to do some modifications to the functions_steamconnect.php file to get Avatar, DisplayName & Community URL to show.
Replace Previous Code in (functions_steamconnect.php):
Code:
$match = array();
preg_match_all("/\w*(\".+\": .+,?)\n/", $raw_json, $match);
if (!isset($match[1]) || !is_array($match[1])) {
DEVDEBUG("stc_profiling[] = Time: ".(microtime(1)-$time).", ret: http404");
return false;
}
$steam_info = array();
// We filter just for the fields we actually need.
$additional_fields2 = explode("\n",$vbulletin->options['stc_additionalfields']);
$whitelist = array_unique(array_merge(array('steamid', 'communityvisibilitystate', 'personaname', 'profileurl', 'avatar', 'avatarmedium', 'avatarfull'),$additional_fields,$additional_fields2));
$values = $match[1];
foreach ($values AS $val) {
$match = array();
preg_match("/\"(.+)\": ([^,]*),?/", $val, $match);
if (is_array($match) && count($match) == 3) {
$name = $match[1];
$value = trim($match[2]);
if (!in_array($name, $whitelist)) continue; // Not a setting we're looking for. skip..
// Strip quotes and slashes
if ($value{0} == '"' && $value{strlen($value)-1} == '"')
$value = stripslashes(substr($value, 1, -1));
$steam_info[$name] = $value;
}
}
With either options below
Code:
$steam_info = array();
$json_decoded = json_decode($raw_json);
foreach ($json_decoded->response->players as $player) {
$steam_info['steamid'] = $player->steamid;
$steam_info['communityvisibilitystate'] = $player->communityvisibilitystate;
$steam_info['personaname'] = $player->personaname;
$steam_info['profileurl'] = $player->profileurl;
$steam_info['avatar'] = $player->avatar;
$steam_info['avatarfull'] = $player->avatarfull;
$steam_info['avatarmedium'] = $player->avatarmedium;
}
or
Code:
$steam_info = array();
$json_decoded = json_decode($raw_json);
$steam_values = array('steamid', 'communityvisibilitystate', 'personaname', 'profileurl', 'avatar', 'avatarmedium', 'avatarfull');
foreach ($json_decoded->response->players as $player) {
foreach ($steam_values as $steam_value) {
$data = $player->$steam_value;
if($data != null && $player != null)
$steam_info[$steam_value] = $data;
}
}
No idea if this causes any further security issues, just a quick fix to showing Avatars & URL's. Haven't come across any other issues yet.
|
Thanks for your help, that 1st fix worked fine on my side!
|