Fix CMD output when using shell_exec() from PHP

/** * Fix weird output encoding. */ function run_command( $command ) { $string = shell_exec( $command ); $string = mb_convert_encoding( $string, ‘UTF-8’, ‘UTF-16LE’ ); return $string; } Source: https://www.reddit.com/r/PHPhelp/comments/de27u8/why_output_of_shell_exec_is_different/f2uwy7s

Get system ipv4 addresses as array in PHP

/** * Get system ipv4 addresses. * Works on Linux only. * @return [array] */ function getSystemIPs() { $ips = shell_exec( ‘hostname -I’ ); $ips = preg_split( ‘/\s+/’, $ips, -1, PREG_SPLIT_NO_EMPTY ); foreach ( $ips as $ip ) { if