示例#1
0
$url = null;
/** Check for options */
$dryrun = in_array('-n', $argv) || in_array('dryrun', $argv) ? true : false;
$buildconf = in_array('-b', $argv) || in_array('buildconf', $argv) ? true : false;
$cron = in_array('-c', $argv) || in_array('cron', $argv) ? true : false;
/** Include shared client functions */
$fm_client_functions = dirname(dirname(__FILE__)) . '/functions.php';
if (file_exists($fm_client_functions)) {
    include_once $fm_client_functions;
} else {
    echo fM("The facileManager client scripts are not installed.\n");
    exit(1);
}
/** Check running user */
if (exec(findProgram('whoami')) != $whoami && !$dryrun) {
    echo fM("This script must run as {$whoami}.\n");
    exit(1);
}
/** Check if running supported version */
$data['server_version'] = detectFWVersion();
/** Build everything required via cron */
if ($cron) {
    $data['action'] = 'cron';
}
/** Build the server config */
if ($buildconf) {
    $data['action'] = 'buildconf';
}
/** Build the zone files */
if ($zones) {
    $data['action'] = 'zones';
示例#2
0
/**
 * Deletes specified file and directory contents
 *
 * @since 2.0.1
 * @package facileManager
 *
 * @param string $file Filename to delete
 * @param boolean $debug Debug mode or not
 * @param boolean $dryrun Whether it's a dry-run or not
 * @return boolean
 */
function deleteFile($file, $debug = false, $dryrun = false)
{
    if (is_dir($file)) {
        if ($file == '/') {
            return false;
        }
        foreach (scandir($file) as $item) {
            if (in_array($item, array('.', '..'))) {
                continue;
            }
            $full_path_file = $file . DIRECTORY_SEPARATOR . $item;
            deleteFile($full_path_file, $debug, $dryrun);
        }
    } else {
        $message = "Deleting {$file}.\n";
        if ($debug) {
            echo fM($message);
        }
        if (!$dryrun) {
            addLogEntry($message);
            unlink($file);
        }
    }
    return true;
}
示例#3
0
/**
 * Logs and outputs error messages
 *
 * @since 2.0
 * @package facileManager
 * @subpackage fmDNS
 *
 * @param string $last_line Output from previously run command
 * @return boolean
 */
function processReloadFailure($last_line)
{
    if ($debug) {
        echo fM($last_line);
    }
    addLogEntry($last_line);
    $message = "There was an error reloading the server - please check the logs for details\n";
    if ($debug) {
        echo fM($message);
    }
    addLogEntry($message);
    return false;
}
示例#4
0
function moduleAddServer($url, $data)
{
    /** Add the server to the account */
    $app = detectFWVersion(true);
    if ($app === null) {
        echo "failed\n\n";
        echo fM("Cannot find a supported firewall - please check the README document for supported firewalls.  Aborting.\n");
        exit(1);
    }
    $data['server_type'] = $app['server']['type'];
    $data['server_version'] = $app['app_version'];
    $raw_data = getPostData(str_replace('genserial', 'addserial', $url), $data);
    $raw_data = $data['compress'] ? @unserialize(gzuncompress($raw_data)) : @unserialize($raw_data);
    if (!is_array($raw_data)) {
        if (!$raw_data) {
            echo "An error occurred\n";
        } else {
            echo $raw_data;
        }
        exit(1);
    }
    return array('data' => $data, 'add_result' => "Success\n");
}