Jump to content
moshair

Need help with this json_decode result

Recommended Posts

Hello,

I used a class called metascan to scan file for viruses using metascan-online.com

I use this code to get information from metascan-online.com using their API
 

$FileScanner = $Metascan->SearchFile($UploadDirectory . $NewFileName,'all');
$Arr = json_decode($FileScanner);
print_r($Arr);

Result:
 

stdClass Object ( [file_id] => c5914bc87f6e416d9efa5004d4145903 [top_threat] => -1 [scan_results] => stdClass Object ( [scan_details] => stdClass Object ( [AegisLab] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 1997 ) [Agnitum] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 1794 ) [Ahnlab] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 281 ) [Antiy] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 1997 ) [AVG] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 858 ) [Avira] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 1576 ) [Baidu] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 2855 ) [BitDefender] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 390 ) [ByteHero] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 1607 ) [ClamAV] => stdClass Object ( [scan_result_i] => 1 [threat_found] => Trojan.Adaebook [def_time] => 2016-01-23T00:00:00Z [scan_time] => 1794 ) [CYREN] => stdClass Object ( [scan_result_i] => 1 [threat_found] => W32/AdaEbook.A.gen!Eldorado [def_time] => 2016-01-23T00:00:00Z [scan_time] => 1357 ) [DrWebGateway] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 702 ) [Emsisoft] => stdClass Object ( [scan_result_i] => 10 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 0 ) [ESET] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 2091 ) [Filseclab] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 4571 ) [Fortinet] => stdClass Object ( [scan_result_i] => 10 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 0 ) [F-prot] => stdClass Object ( [scan_result_i] => 1 [threat_found] => W32/AdaEbook.A.gen!Eldorado [def_time] => 2016-01-23T00:00:00Z [scan_time] => 31 ) [F-secure] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 2013 ) [Hauri] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 889 ) [Ikarus] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 1638 ) [Jiangmin] => stdClass Object ( [scan_result_i] => 1 [threat_found] => Trojan.Heur.coy [def_time] => 2016-01-23T00:00:00Z [scan_time] => 2184 ) [K7] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 453 ) [Kaspersky] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 609 ) [Lavasoft] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 3105 ) [McAfee] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 297 ) [Microsoft] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 1794 ) [NANO] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 453 ) [nProtect] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 281 ) [Preventon] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-21T00:00:00Z [scan_time] => 484 ) [QuickHeal] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 702 ) [Sophos] => stdClass Object ( [scan_result_i] => 1 [threat_found] => App/ebookws-A [def_time] => 2016-01-23T00:00:00Z [scan_time] => 1498 ) [STOPzilla] => stdClass Object ( [scan_result_i] => 1 [threat_found] => System Tool 2011 [def_time] => 2016-01-21T00:00:00Z [scan_time] => 3292 ) [SUPERAntiSpyware] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 1794 ) [Symantec] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 1794 ) [ThreatTrack] => stdClass Object ( [scan_result_i] => 1 [threat_found] => AdaEbook (v) [def_time] => 2016-01-23T00:00:00Z [scan_time] => 312 ) [TotalDefense] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 453 ) [TrendMicro] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-23T00:00:00Z [scan_time] => 1794 ) [TrendMicroHouseCall] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 1857 ) [VirIT] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 531 ) [VirusBlokAda] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 1513 ) [Xvirus] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-22T00:00:00Z [scan_time] => 2808 ) [Zillya!] => stdClass Object ( [scan_result_i] => 1 [threat_found] => Trojan.BestaFera.Win32.279 [def_time] => 2016-01-22T00:00:00Z [scan_time] => 63 ) [Zoner] => stdClass Object ( [scan_result_i] => 0 [threat_found] => [def_time] => 2016-01-20T00:00:00Z [scan_time] => 702 ) ) [rescan_available] => [data_id] => 1481a80ce31042f29060eba3ad3f7d2a [scan_all_result_i] => 1 [start_time] => 2016-01-23T18:08:01.977Z [total_time] => 4571 [total_avs] => 43 [progress_percentage] => 100 [in_queue] => 0 [scan_all_result_a] => Infected ) [file_info] => stdClass Object ( [file_size] => 308858 [upload_timestamp] => 2016-01-23T12:02:48.988Z [md5] => 53FC372F2A045E73CCF39765A73D04E0 [sha1] => 5E6AA63C4C995E327B3F517192F6D2A453E02B13 [sha256] => 50EC7F4D8E311C6678B4AC6F441C45CB59FBC3AEFC78699DDEEC6DD1E4E9CCAB [file_type_category] => E [file_type_description] => ASPack compressed Win32 Executable (generic) [file_type_extension] => EXE/DLL/OCX [display_name] => ahtuni36i7xav72k7lqu.exe ) [data_id] => 1481a80ce31042f29060eba3ad3f7d2a

How can I only get for example 'F-prot' scan result. 1 or 0

Regards,

Edited by moshair

Share this post


Link to post
Share on other sites

can you alter your code to this

$Arr = json_decode($FileScanner, true);
echo '<pre>' . print_r($Arr, true) . '</pre>';

That should make it easier to read.

Share this post


Link to post
Share on other sites

can you alter your code to this

$Arr = json_decode($FileScanner, true);
echo '<pre>' . print_r($Arr, true) . '</pre>';

That should make it easier to read.

 

 

 

Thanks Barand this is the result:

Array
(
    [file_id] => c5914bc87f6e416d9efa5004d4145903
    [top_threat] => -1
    [scan_results] => Array
        (
            [scan_details] => Array
                (
                    [Ahnlab] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-22T00:00:00Z
                            [scan_time] => 827
                        )

                    [Antiy] => Array
                        (
                            [scan_result_i] => 10
                            [threat_found] => 
                            [def_time] => 2016-01-22T00:00:00Z
                            [scan_time] => 0
                        )

                    [AVG] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 749
                        )

                    [BitDefender] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 998
                        )

                    [ByteHero] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 1435
                        )

                    [ClamAV] => Array
                        (
                            [scan_result_i] => 1
                            [threat_found] => Trojan.Adaebook
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 1513
                        )

                    [CYREN] => Array
                        (
                            [scan_result_i] => 1
                            [threat_found] => W32/AdaEbook.A.gen!Eldorado
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 47
                        )

                    [DrWebGateway] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 936
                        )

                    [Emsisoft] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 15
                        )

                    [Filseclab] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 1404
                        )

                    [Fortinet] => Array
                        (
                            [scan_result_i] => 10
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 0
                        )

                    [F-prot] => Array
                        (
                            [scan_result_i] => 1
                            [threat_found] => W32/AdaEbook.A.gen!Eldorado
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 31
                        )

                    [Hauri] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 31
                        )

                    [Ikarus] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 1045
                        )

                    [K7] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 733
                        )

                    [Kaspersky] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 1045
                        )

                    [McAfee] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 1123
                        )

                    [NANO] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 327
                        )

                    [Preventon] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-21T00:00:00Z
                            [scan_time] => 717
                        )

                    [QuickHeal] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-22T00:00:00Z
                            [scan_time] => 749
                        )

                    [Sophos] => Array
                        (
                            [scan_result_i] => 1
                            [threat_found] => App/ebookws-A
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 1154
                        )

                    [Symantec] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-22T00:00:00Z
                            [scan_time] => 858
                        )

                    [ThreatTrack] => Array
                        (
                            [scan_result_i] => 1
                            [threat_found] => AdaEbook (v)
                            [def_time] => 2016-01-23T00:00:00Z
                            [scan_time] => 749
                        )

                    [TotalDefense] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-22T00:00:00Z
                            [scan_time] => 62
                        )

                    [VirIT] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-22T00:00:00Z
                            [scan_time] => 1014
                        )

                    [VirusBlokAda] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-22T00:00:00Z
                            [scan_time] => 1482
                        )

                    [Zillya!] => Array
                        (
                            [scan_result_i] => 1
                            [threat_found] => Trojan.BestaFera.Win32.279
                            [def_time] => 2016-01-22T00:00:00Z
                            [scan_time] => 47
                        )

                    [Zoner] => Array
                        (
                            [scan_result_i] => 0
                            [threat_found] => 
                            [def_time] => 2016-01-20T00:00:00Z
                            [scan_time] => 468
                        )

                )

            [rescan_available] => 
            [data_id] => c4b2cca473f74ec0a03a7089263d1ca1
            [scan_all_result_i] => -1
            [start_time] => 2016-01-23T19:56:38.3825111Z
            [total_time] => 0
            [total_avs] => 43
            [progress_percentage] => 65
            [in_queue] => 0
            [scan_all_result_a] => 
        )

    [file_info] => Array
        (
            [file_size] => 308858
            [upload_timestamp] => 2016-01-23T12:02:48.988Z
            [md5] => 53FC372F2A045E73CCF39765A73D04E0
            [sha1] => 5E6AA63C4C995E327B3F517192F6D2A453E02B13
            [sha256] => 50EC7F4D8E311C6678B4AC6F441C45CB59FBC3AEFC78699DDEEC6DD1E4E9CCAB
            [file_type_category] => E
            [file_type_description] => ASPack compressed Win32 Executable (generic)
            [file_type_extension] => EXE/DLL/OCX
            [display_name] => 2kquw5igyysmn2r8y36l.exe
        )

    [data_id] => c4b2cca473f74ec0a03a7089263d1ca1
)

Share this post


Link to post
Share on other sites

try

foreach ($Arr['scan_results']['scan_details']['F-prot'] as $k => $v) {
    echo "$k : $v <br>";
}

Share this post


Link to post
Share on other sites

scan_result_i : 1
threat_found : W32/AdaEbook.A.gen!Eldorado
def_time : 2016-01-23T00:00:00Z
scan_time : 31

Share this post


Link to post
Share on other sites

I wrote this code to get scan_result_i value 1 or 0:

$i = 0;
foreach ($Arr['scan_results']['scan_details']['F-prot'] as $k => $v) {
$Arr2[$i] = $v;
$i++;
}
echo $Arr2[0];

Is it good or do you have better code?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.