function new_info(&$db, &$state)
{
    if (!isset($_POST["recID"])) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST", true);
    }
    if (!audit_counts($db, $state)) {
        return false;
    }
    $recID = $_POST["recID"];
    if ($recID == 0) {
        //adding
        add_log($db, $state);
        return true;
    }
    log_list($db, $state);
    if (!array_key_exists(strval($recID), $state->records)) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid recID " . $recID, true);
    }
    if ($state->records[$recID]["event_id"] != $_POST["event"]) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid record " . $recID, true);
    }
    if ($_POST["sessions"] == 0) {
        delete_log($db, $state);
    } else {
        update_log($db, $state);
    }
    return true;
}
Example #2
0
    } else {
        $target_name = '';
    }
}
if ($type == '' && (xmlrpc_isComputerRegistered($target_uuid) || xmlrpc_isComputerInProfileRegistered($target_uuid)) || $type == 'group' && xmlrpc_isProfileRegistered($target_uuid)) {
    if (isset($_GET['mod'])) {
        $mod = $_GET['mod'];
    } else {
        $mod = "none";
    }
    switch ($mod) {
        case 'details':
            log_details();
            break;
        default:
            log_list();
            break;
    }
} else {
    # register the target (computer or profile)
    $params = array('target_uuid' => $target_uuid, 'type' => $type, 'from' => "services", "target_name" => $target_name);
    header("Location: " . urlStrRedirect("base/computers/" . $type . "register_target", $params));
    exit;
}
function log_details()
{
    echo 'details';
}
function log_list()
{
    $ajax = new AjaxFilter("modules/imaging/imaging/ajaxLogs.php", "container", getParams());
Example #3
0
function audit_hours(&$state, &$logdate, &$status)
{
    global $_DB;
    $ID = 0;
    if ($state->row > 0) {
        //0 is add row
        log_list($state);
        foreach ($state->records as $ID => $record) {
            //find this row's records
            if ($record["row"] == $state->row) {
                break;
            }
            array_shift($state->records);
        }
        if ($ID == 0) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST 1", true);
        }
    }
    $day = clone $logdate;
    for ($ndx = 0; $ndx < abs($state->columns); $ndx++, $day->add(new DateInterval('P1D'))) {
        if (!isset($_POST["hours" . $ndx]) || $ndx < $state->closedCols || $_POST["hours" . $ndx] == "") {
            $status[] = '';
            //no change to this record
            continue;
        }
        if (!isset($_POST["rec" . $ndx])) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST 2", true);
        }
        $hours = $_POST["hours" . $ndx];
        $recID = $_POST["rec" . $ndx];
        //from data-recid attribute
        $state->msgStatus = "!Please enter valid hours (" . $ndx . ")";
        if (!audit_hour($state, $recID, $hours, $day->format("Y-m-d"))) {
            return false;
        }
        if ($recID == 0) {
            //if adding hours, we're done
            if ($hours == 0) {
                $status[] = '';
            } else {
                $status[] = 'a';
            }
            continue;
        }
        foreach ($state->records as $ID => $record) {
            //find our record
            if ($record["row"] != $state->row) {
                throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST 3", true);
            }
            if ($record["column"] == $ndx) {
                break;
            }
            array_shift($state->records);
        }
        if ($record["ID"] != $recID) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST 4", true);
        }
        if ($hours == 0) {
            $status[] = 'd';
        } elseif ($hours == $record["hours"]) {
            $status[] = '';
        } else {
            $status[] = 'u';
        }
    }
    if ($state->row > 0) {
        //0 is add row
        $state->task_id = intval($_POST["task"]);
        $state->subtask_id = intval($_POST["subtask"]);
        $state->account_id = intval($_POST["account"]);
        $state->activity_id = intval($_POST["activity"]);
        $sql = "SELECT COUNT(*) AS count FROM " . $_DB->prefix . "v00_timelog\n\t\t\t\tWHERE (person_id=" . $state->person_id . ") AND (project_id=" . $state->project_id . ")\n\t\t\t\tAND (logdate BETWEEN '" . $state->from_date->format('Y-m-d') . "' AND '" . $state->to_date->format('Y-m-d') . "')\n\t\t\t\tAND (task_id=" . $state->task_id . ") AND (subtask_id=" . $state->subtask_id . ")\n\t\t\t\tAND (account_id=" . $state->account_id . ") AND (activity_id=" . $state->activity_id . ");";
        $stmt = $_DB->query($sql);
        if ($stmt->fetchObject()->count == 0) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST 5", true);
        }
    }
    $state->msgStatus = "-";
    //tell server_call to reset page
    return true;
}
Example #4
0
function log_multi_edit()
{
    $deleted = event_multi_edit('txp_log', 'id');
    if ($deleted) {
        $message = gTxt('logs_deleted', array('{list}' => $deleted));
        return log_list($message);
    }
    return log_list();
}
Example #5
0
function change_activity(&$state)
{
    global $_DB;
    if ($state->activity_id == 0) {
        //creating a new one
        add_activity($state);
    } else {
        activity_list($state);
        //restore the record list
        if (!array_key_exists($state->activity_id, $state->records)) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid activity id " . $state->activity_id, true);
        }
    }
    log_list($state, $state->row);
    //find this row's records
    $record = reset($state->records);
    $old_activity = $record["activity_id"];
    if ($state->activity_id == $old_activity) {
        return;
    }
    foreach ($state->records as $ID => $record) {
        if ($record["column"] < $state->columns[COL_OPEN]) {
            continue;
        }
        $sql = "UPDATE " . $_DB->prefix . "b00_timelog\n\t\t\t\tSET activity_idref=" . $state->activity_id . " WHERE timelog_id=" . $ID . ";";
        $_DB->exec($sql);
    }
    $sql = "SELECT COUNT(*) AS count FROM " . $_DB->prefix . "b00_timelog WHERE activity_idref=" . $old_activity . "";
    $stmt = $_DB->query($sql);
    if ($stmt->fetchObject()->count == 0) {
        $sql = "DELETE FROM " . $_DB->prefix . "b02_activity WHERE activity_id=" . $old_activity . "";
        $_DB->exec($sql);
    }
    $stmt->closeCursor();
}
Example #6
0
function change_event(&$state)
{
    global $_DB;
    event_list($state);
    //restore the record list
    if (!array_key_exists($state->event_id, $state->records)) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid eventing id " . $state->event_id, true);
    }
    log_list($state, $state->row);
    //find this row's records
    $record = reset($state->records);
    $old_event = $record["event_id"];
    if ($state->event_id == $old_event) {
        return;
    }
    foreach ($state->records as $ID => $record) {
        if ($record["column"] < $state->columns[COL_OPEN]) {
            continue;
        }
        $sql = "UPDATE " . $_DB->prefix . "b10_eventlog\n\t\t\t\tSET event_idref=" . $state->event_id . " WHERE eventlog_id=" . $ID . ";";
        $_DB->exec($sql);
    }
}
Example #7
0
function new_info(&$state)
{
    $state->recID = 0;
    if ($state->row > 0) {
        //0 is add row
        log_list($state);
        foreach ($state->records as $recID => $record) {
            $state->recID = $recID;
            if ($record["row"] == $state->row) {
                break;
            }
        }
        if ($state->recID == 0) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST", true);
        }
    }
    if (!audit_counts($state)) {
        return false;
    }
    if (substr($_POST["comments"], 0, 1) == "\n") {
        $_POST["comments"] = "---";
    }
    $logdate = clone $state->from_date;
    if ($state->recID == 0) {
        //adding
        if (!audit_date($state, $logdate)) {
            return false;
        }
        add_log($state);
        return;
    }
    if ($state->records[$state->recID]["event_id"] != $_POST["event"] || $state->records[$state->recID]["account_id"] != $_POST["account"]) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid record " . $recID, true);
    }
    if ($_POST["sessions"] == 0) {
        delete_log($state);
    } else {
        update_log($state);
    }
}
Example #8
0
function export_logs() {

	/* search field: filter (searchs device description and hostname) */
	$filter_array = array();
	if (isset_get_var("search_filter")) {
		$filter_array["message"] = get_get_var("search_filter");
	}
	if (isset_get_var("search_facility")) {
		$filter_array["facility"] = get_get_var("search_facility");
	}
	if (isset_get_var("search_severity")) {
		$filter_array["severity"] = get_get_var("search_severity");
	}
	if (isset_get_var("search_poller")) {
		$filter_array["poller_id"] = get_get_var("search_poller");
	}
	if (isset_get_var("search_host")) {
		$filter_array["host_id"] = get_get_var("search_host");
	}
	if (isset_get_var("search_plugin")) {
		$filter_array["plugin"] = get_get_var("search_plugin");
	}
	if (isset_get_var("search_username")) {
		$filter_array["username"] = get_get_var("search_username");
	}
	if (isset_get_var("search_source")) {
		$filter_array["source"] = get_get_var("search_source");
	}

	/* Search and Replace chars */
	$search = array("\"","\t","\n","\r");
	$replace = array(""," "," "," ");

	/* get log entires */
	$logs = log_list($filter_array);

	/* Output CSV */
	header("Content-type: text/plain");
	header("Content-Disposition: attachment; filename=cacti_system_log." . date("Ymd.Hms") . ".csv");

	print "\"" . _("Date") . "\",";
	print "\"" . _("Facility") . "\",";
	print "\"" . _("Severity") . "\",";
	print "\"" . _("Poller") . "\",";
	print "\"" . _("Host") . "\",";
	print "\"" . _("Plugin") . "\",";
	print "\"" . _("User") . "\",";
	print "\"" . _("Source") . "\",";
	print "\"" . _("Message") . "\"\n";

	$i = 0;
	if ((is_array($logs)) && (sizeof($logs) > 0)) {
		foreach ($logs as $log) {
			print "\"" . $log["logdate"] . "\",";
			print "\"" . log_get_facility($log["facility"]) . "\",";
			print "\"" . log_get_severity($log["severity"]) . "\",";
			print "\"";
			if ($log["poller_name"] == "") {
				print "SYSTEM";
			}else{
				print $log["poller_name"];
			}
			print "\",\"";
			if ($log["host"] == "") {
				print "SYSTEM";
			}else{
				print $log["host"];
			}
			print "\",\"";
			if ($log["plugin"] == "") {
				print "N/A";
			}else{
				print $log["plugin"];
			}
			print "\",\"";
			if ($log["username"] == "") {
				print "SYSTEM";
			}else{
				print $log["username"];
			}
			print "\",\"";
			if ($log["source"] == "") {
				print "SYSTEM";
			}else{
				print $log["source"];
			}

			print "\",\"" . str_replace($search,$replace,$log["message"]) . "\"\n";
		}
	}

}
Example #9
0
function new_info(&$state)
{
    global $_DB;
    $state->recID = 0;
    if ($state->process == "u") {
        log_list($state);
        foreach ($state->records as $recID => $record) {
            $state->recID = $recID;
            if ($record["row"] == $state->row) {
                break;
            }
        }
        if ($state->recID == 0) {
            throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid POST", true);
        }
    }
    if (!audit_counts($state)) {
        return false;
    }
    if (substr($_POST["comments"], 0, 1) == "\n") {
        $_POST["comments"] = "---";
    }
    if ($state->recID == 0) {
        //adding
        add_log($state);
        return true;
    }
    if ($state->records[$state->recID]["event_id"] != $_POST["event"]) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid record " . $recID, true);
    }
    if ($_POST["sessions"] == 0) {
        delete_log($state);
    } else {
        update_log($state);
    }
    return true;
}