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'; $arch_path = rtrim($_REQUEST['SLAM_FILE_ARCH_DIR'], '/'); $temp_path = rtrim($_REQUEST['SLAM_FILE_TEMP_DIR'], '/'); $ret = checkFileOptions($arch_path, $temp_path); if ($ret === true) { print "<span style='color:green'>These settings are OK.</span>"; } else { print "<span style='color:red'>{$ret[0]}<br />{$ret[1]}</span>"; }