Example #1
0
function readHddInfo()
{
    $hdd = array();
    foreach (simpleExec('/bin/df', array('-lk', '/')) as $line) {
        $matches = preg_split("/\\s+/", $line);
        if (sizeof($matches) == 6) {
            $hdd['size'] = intval($matches[1]) / 1024.0;
            $hdd['used'] = intval($matches[2]) / 1024.0;
        }
    }
    return $hdd;
}
 public static function importMachine($file)
 {
     $path = BASE_PATH . '/exports/' . $file;
     if (!file_exists($path)) {
         return FALSE;
     }
     $lines = simpleExec(VIRTUALBOX_MGT_BIN, array('-q', 'import', $path));
     foreach ($lines as $line) {
         if (preg_match('/^UUID: ([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$/', $line, $matches)) {
             return self::getMachine($matches[1]);
         }
     }
     return FALSE;
 }