0

I would like to ask how to check server configuration (CPU, system, RAM) by "grep" phpinfo sub-information (or any other php commands), if any.

<? if (phpinfo system info == "something A" 
       && phpinfo CPU info == "something B" 
       && phpinfo RAM info == "something C") {

        //Redirect to index.php and not allowed to access in-pages.
        header('Location: index.php'); 

    }
?>
Clay
  • 4,700
  • 3
  • 33
  • 49
CKH
  • 133
  • 9

1 Answers1

0
 // Get CPU name 
 $cpuinfo = file('/proc/cpuinfo');
 $cpu = substr($cpuinfo[4],13);

 // Get memory size
 $meminfo = file('/proc/meminfo');
 $memsize = substr($meminfo[0],10);

 // Get IP address
 $arp = file('/proc/net/arp');
 $arp1 = explode(" ", $arp[1]);
 $ipv4 = $arp1[0];

 if (strpos($ipv4,[your device ip address]) !== false 
        && strpos($memsize,[your device memory size]) !== false
        && strpos($cpu,[your device CPU name]) !== false) {
     // go
 }
CKH
  • 133
  • 9