phpsysinfo / phpsysinfo

phpSysInfo: a customizable PHP script that displays information about your system nicely
http://phpsysinfo.github.io/phpsysinfo
GNU General Public License v2.0
1.38k stars 233 forks source link

FileSystem Mount structure #384

Closed eisler closed 8 months ago

eisler commented 9 months ago

Describe the bug If one Mount is found, a different structure is returned than if multiple Mounts are found.

To Reproduce $output = new WebpageXML(); $xmlString = $output->getXMLString();

Expected behavior the same structure for one or more mounts

Screenshots

[FileSystem] => SimpleXMLElement Object
        (
            [0] => SimpleXMLElement Object
                (
                    [Mount] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [MountPointID] => 1
                                    [FSType] => NTFS
                                    [Name] => Local Disk
                                    [Free] => 258839732224
                                    [Used] => 252327432192
                                    [Total] => 511167164416
                                    [Percent] => 50
                                    [MountPoint] => C:
                                )

                        )

                )

        )
[FileSystem] => SimpleXMLElement Object
        (
            [Mount] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [MountPointID] => 1
                                    [FSType] => NTFS
                                    [Name] => Local Disk
                                    [Free] => 114555355136
                                    [Used] => 90210562048
                                    [Total] => 204765917184
                                    [Percent] => 45
                                    [MountPoint] => C:
                                )

                        )

                    [1] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [MountPointID] => 2
                                    [FSType] => NTFS
                                    [Name] => Local Disk
                                    [Free] => 49857564672
                                    [Used] => 1196548096
                                    [Total] => 51054112768
                                    [Percent] => 3
                                    [MountPoint] => D:
                                )

                        )

                    [2] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [MountPointID] => 3
                                    [Name] => Compact Disc
                                    [Free] => 0
                                    [Used] => 0
                                    [Total] => 0
                                    [Percent] => 0
                                    [MountPoint] => E:
                                )

                        )

                    [3] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [MountPointID] => 4
                                    [FSType] => NTFS
                                    [Name] => Network Drive
                                    [Free] => 213616881664
                                    [Used] => -210395656192
                                    [Total] => 3221225472
                                    [Percent] => 0
                                    [MountPoint] => X:
                                )

                        )

                )

        )
namiltd commented 9 months ago

This is not a bug. Take a look at the items() function in phpsysinfo_bootstrap.js

function items(data) {
    if (data !== undefined) {
        if ((data.length > 0) &&  (data[0] !== undefined) && (data[0]["@attributes"] !== undefined)) {
            return data;
        } else if (data["@attributes"] !== undefined ) {
            return [data];
        } else {
            return [];
        }
    } else {
        return [];
    }
}

It reads the data correctly.