function checkFileOptions($arch_path, $temp_path) { $fail = array(); $fail[] = checkDirectoryIsRW($arch_path); $fail[] = checkDirectoryIsRW($temp_path); // ok to try and delete these, because rmdir will fail if there are not empty @rmdir($temp_path); @rmdir($arch_path); if ($fail[0] === true && $fail[1] === true) { return true; } return $fail; }
function check_SLAM_options() { $errors = array(); if (count($ini = get_SLAM_options()) < 4) { $not_present = array_intersect(array_keys($ini), array('1', '2', '3', '4')); foreach ($not_present as $step) { $errors["Step {$step}"] = "Not completed."; } return $errors; } $options = array_merge($ini[0], $ini[1], $ini[2], $ini[3]); /* step 1 options */ $path = rtrim($options['SLAM_CONF_PATH'], '/'); if (($ret = checkDirectoryIsRW($path)) !== true) { $errors['Step 1 A'] = "SLAM installation path error: {$ret}"; } if (strlen($options['SLAM_CONF_PREFIX']) != 2) { $errors['Step 1 B'] = 'SLAM lab prefix must be precisely 2 characters'; } if (($ret = checkDbOptions($options['SLAM_DB_HOST'], $options['SLAM_DB_NAME'], $options['SLAM_DB_USER'], $options['SLAM_DB_PASS'])) !== true) { $errors['Step 1 C'] = "SLAM database connection error: {$ret[0]}"; } $arch_path = rtrim(base64_decode($options['SLAM_FILE_ARCH_DIR']), '/'); $temp_path = rtrim(base64_decode($options['SLAM_FILE_TEMP_DIR']), '/'); if (($ret = checkFileOptions($arch_path, $temp_path)) !== true) { $errors['Step 1 D'] = "SLAM attached file settings: {$ret[0]} {$ret[1]}"; } /* step 4 options */ if ($options['SLAM_ROOT_NAME'] == '') { $errors['Step 4 A'] = "Must specify a root user."; } if ($options['SLAM_ROOT_PASS_1'] != $options['SLAM_ROOT_PASS_2']) { $errors['Step 4 B'] = "Root user passwords do not match."; } if ($options['SLAM_ROOT_PASS_1'] == '') { $errors['Step 4 B'] = "Must specify a root password."; } return $errors; }
<?php require '../lib/file_actions.inc.php'; $path = rtrim($_REQUEST['SLAM_CONF_PATH'], '/'); $message = true; // check and make sure that the lab prefix is kosher if (strlen($_REQUEST['SLAM_CONF_PREFIX']) != 2) { $message = 'Please use a lab prefix that is exactly two (2) characters long'; } else { $message = checkDirectoryIsRW($path); } if ($message === true) { print "<span style='color:green'>These settings are OK.</span>"; } else { print "<span style='color:red'>{$message}</span>"; }