Exemplo n.º 1
0
        $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'><a href='" . $Scan->settings->siteURL . "" . create_link("subnets", $section->id, $subnet->id) . "'>" . $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask . " - " . $subnet->description . "</a></td>";
        $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'><a href='" . $Scan->settings->siteURL . "" . create_link("subnets", $section->id) . "'>{$section->name} {$section->description}</a></td>";
        $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$ago}</td>";
        $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$oldStatus}</td>";
        $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$newStatus}</td>";
        $content[] = "</tr>";
        //plain content
        $content_plain[] = "\t * " . $Subnets->transform_to_dotted($change['ip_addr']) . " (" . $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask . ")\r\n \t  " . strip_tags($oldStatus) . " => " . strip_tags($newStatus);
    }
    $content[] = "</table>";
    # set content
    $content = $phpipam_mail->generate_message(implode("\r\n", $content));
    $content_plain = implode("\r\n", $content_plain);
    # try to send
    try {
        $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName);
        //add all admins to CC
        foreach ($recepients as $admin) {
            $phpipam_mail->Php_mailer->addAddress($admin['email'], $admin['name']);
        }
        $phpipam_mail->Php_mailer->Subject = $subject;
        $phpipam_mail->Php_mailer->msgHTML($content);
        $phpipam_mail->Php_mailer->AltBody = $content_plain;
        //send
        $phpipam_mail->Php_mailer->send();
    } catch (phpmailerException $e) {
        $Result->show_cli("Mailer Error: " . $e->errorMessage(), true);
    } catch (Exception $e) {
        $Result->show_cli("Mailer Error: " . $e->errorMessage(), true);
    }
}
Exemplo n.º 2
0
 *	either provide it by first argument or via readline
 *
 */
# include required scripts
require dirname(__FILE__) . '/../functions.php';
# set debugging
$debugging = false;
$fail = false;
# initialize objects
$Database = new Database_PDO();
$Admin = new Admin($Database, false);
$User = new User($Database, true);
$Result = new Result();
// script can only be run from cli
if (php_sapi_name() != "cli") {
    $Result->show_cli("This script can only be run from cli", true);
}
// check if argv[1] provided, if not check readline support and wait for user pass
if (isset($argv[1])) {
    $password = $argv[1];
} else {
    // get available extensions
    $available_extensions = get_loaded_extensions();
    // not in array
    if (!in_array("readline", $available_extensions)) {
        $Result->show_cli("readline php extension is required.\nOr provide password as first argument", true);
    } else {
        // read password
        $line = readline("Enter password: ");
        readline_add_history($line);
        // save
Exemplo n.º 3
0
# verbose response - prints results, cron will email it to you!
# include required scripts
require dirname(__FILE__) . '/../functions.php';
require dirname(__FILE__) . '/../../functions/classes/class.Thread.php';
# initialize objects
$Database = new Database_PDO();
$Admin = new Admin($Database, false);
$Subnets = new Subnets($Database);
$DNS = new DNS($Database);
$Result = new Result();
// set to 1 in case of errors
ini_set('display_errors', 0);
error_reporting(E_ERROR);
# cli required
if ($resolve_config['clionly'] && !defined('STDIN')) {
    $Result->show_cli("cli only\n", true);
} elseif (!$resolve_config['clionly'] && !defined('STDIN')) {
    $User = new User($Database);
    # verify that user is logged in
    $User->check_user_session();
}
#
# If id is provided via STDIN resolve hosts for 1 subnet only,
# otherwise check all
#
# check all subnets
if (sizeof($resolve_config['subnets']) == 0) {
    # get ony ip's with empty DNS
    if ($resolve_config['emptyonly'] == 1) {
        $query = 'select `id`,`ip_addr`,`dns_name`,`subnetId` from `ipaddresses` where `dns_name` like "" order by `ip_addr` ASC;';
    } else {
Exemplo n.º 4
0
$resolve_config['verbose'] = true;
# verbose response - prints results, cron will email it to you!
# include required scripts
require dirname(__FILE__) . '/../functions.php';
# initialize objects
$Database = new Database_PDO();
$Admin = new Admin($Database, false);
$Subnets = new Subnets($Database);
$DNS = new DNS($Database);
$Result = new Result();
// set to 1 in case of errors
ini_set('display_errors', 0);
error_reporting(E_ERROR);
# cli required
if (php_sapi_name() != "cli") {
    $Result->show_cli("cli only\n", true);
}
# set subnet
if (isset($argv[1])) {
    $req_subnets = explode(",", $argv[1]);
    foreach ($req_subnets as $s) {
        if (!is_numeric($s)) {
            $Result->show_cli("Invalid subnetId provided - {$s}\n", true);
        } else {
            $resolve_config['subnets'][] = $s;
        }
    }
}
#
# If id is provided via STDIN resolve hosts for 1 subnet only,
# otherwise check all