mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Rebased
This commit is contained in:
+4
-1
@@ -1764,4 +1764,7 @@ tr.search:nth-child(odd) {
|
||||
|
||||
label {
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
.nav>li>a.dropdown-toggle {
|
||||
padding: 15px 6px;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,16 @@ function auth_usermanagement() {
|
||||
function adduser($username) {
|
||||
// Check to see if user is already added in the database
|
||||
if (!user_exists_in_db($username)) {
|
||||
return dbInsert(array('username' => $username, 'user_id' => get_userid($username), 'level' => "0", 'can_modify_passwd' => 0, 'twofactor' => 0), 'users');
|
||||
$userid = dbInsert(array('username' => $username, 'user_id' => get_userid($username), 'level' => "0", 'can_modify_passwd' => 0, 'twofactor' => 0), 'users');
|
||||
if ($userid == false) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
|
||||
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
|
||||
}
|
||||
}
|
||||
return $userid;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
@@ -44,11 +44,20 @@ function auth_usermanagement() {
|
||||
}
|
||||
|
||||
|
||||
function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd='1') {
|
||||
function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd=1, $description='', $twofactor=0) {
|
||||
if (!user_exists($username)) {
|
||||
$hasher = new PasswordHash(8, false);
|
||||
$encrypted = $hasher->HashPassword($password);
|
||||
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname), 'users');
|
||||
$userid = dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
|
||||
if ($userid == false) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
|
||||
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
|
||||
}
|
||||
}
|
||||
return $userid;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
@@ -104,7 +104,16 @@ function adduser($username, $password, $level, $email='', $realname='', $can_mod
|
||||
if (!user_exists($username)) {
|
||||
$hasher = new PasswordHash(8, false);
|
||||
$encrypted = $hasher->HashPassword($password);
|
||||
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
|
||||
$userid = dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
|
||||
if ($userid == false) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
|
||||
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
|
||||
}
|
||||
}
|
||||
return $userid;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
@@ -150,18 +150,18 @@ var greenMarker = L.AwesomeMarkers.icon({
|
||||
// Checking user permissions
|
||||
if (is_admin() || is_read()) {
|
||||
// Admin or global read-only - show all devices
|
||||
$sql = "SELECT DISTINCT(`device_id`),`hostname`,`os`,`status`,`lat`,`lng` FROM `devices`
|
||||
$sql = "SELECT DISTINCT(`device_id`),`devices`.`location`,`hostname`,`os`,`status`,`lat`,`lng` FROM `devices`
|
||||
LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location`
|
||||
WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != ''
|
||||
WHERE `disabled`=0 AND `ignore`=0 AND ((`lat` != '' AND `lng` != '') OR (`devices`.`location` REGEXP '\[[0-9\.\, ]+\]'))
|
||||
AND `status` IN (".$widget_settings['status'].")
|
||||
ORDER BY `status` ASC, `hostname`";
|
||||
}
|
||||
else {
|
||||
// Normal user - grab devices that user has permissions to
|
||||
$sql = "SELECT DISTINCT(`devices`.`device_id`) as `device_id`,`hostname`,`os`,`status`,`lat`,`lng`
|
||||
$sql = "SELECT DISTINCT(`devices`.`device_id`) as `device_id`,`devices`.`location`,`hostname`,`os`,`status`,`lat`,`lng`
|
||||
FROM `devices_perms`, `devices`
|
||||
LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location`
|
||||
WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != ''
|
||||
WHERE `disabled`=0 AND `ignore`=0 AND ((`lat` != '' AND `lng` != '') OR (`devices`.`location` REGEXP '\[[0-9\.\, ]+\]'))
|
||||
AND `devices`.`device_id` = `devices_perms`.`device_id`
|
||||
AND `devices_perms`.`user_id` = ? AND `status` IN (".$widget_settings['status'].")
|
||||
ORDER BY `status` ASC, `hostname`";
|
||||
@@ -170,6 +170,11 @@ var greenMarker = L.AwesomeMarkers.icon({
|
||||
foreach (dbFetchRows($sql, $param) as $map_devices) {
|
||||
$icon = 'greenMarker';
|
||||
$z_offset = 0;
|
||||
$tmp_loc = parse_location($map_devices['location']);
|
||||
if (!empty($tmp_loc['lat']) && !empty($tmp_loc['lng'])) {
|
||||
$map_devices['lat'] = $tmp_loc['lat'];
|
||||
$map_devices['lng'] = $tmp_loc['lng'];
|
||||
}
|
||||
if ($map_devices['status'] == 0) {
|
||||
$icon = 'redMarker';
|
||||
$z_offset = 10000; // move marker to foreground
|
||||
|
||||
@@ -78,7 +78,10 @@ if ($device['location']) {
|
||||
}
|
||||
}
|
||||
|
||||
$loc = dbFetchRow("SELECT `lat`,`lng` FROM `locations` WHERE `location`=? LIMIT 1", array($device['location']));
|
||||
$loc = parse_location($device['location']);
|
||||
if (!is_array($loc)) {
|
||||
$loc = dbFetchRow("SELECT `lat`,`lng` FROM `locations` WHERE `location`=? LIMIT 1", array($device['location']));
|
||||
}
|
||||
if (is_array($loc)) {
|
||||
echo '<tr>
|
||||
<td>Lat / Lng</td>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker, QuxLabs UG <[email protected]>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/**
|
||||
* Notification Page
|
||||
* @author Daniel Preussker
|
||||
* @copyright 2015 Daniel Preussker, QuxLabs UG
|
||||
* @license GPL
|
||||
* @package LibreNMS
|
||||
* @subpackage Notifications
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
if (isset($_REQUEST['notification_id']) && isset($_REQUEST['action'])) {
|
||||
if ($_REQUEST['action'] == 'read' && dbInsert(array('notifications_id'=>$_REQUEST['notification_id'],'user_id'=>$_SESSION['user_id'],'key'=>'read','value'=>1),'notifications_attribs')) {
|
||||
$status = 'ok';
|
||||
$message = 'Set as Read';
|
||||
}
|
||||
elseif ($_SESSION['userlevel'] == 10 && $_REQUEST['action'] == 'stick' && dbInsert(array('notifications_id'=>$_REQUEST['notification_id'],'user_id'=>$_SESSION['user_id'],'key'=>'sticky','value'=>1),'notifications_attribs')) {
|
||||
$status = 'ok';
|
||||
$message = 'Set as Sticky';
|
||||
}
|
||||
elseif ($_SESSION['userlevel'] == 10 && $_REQUEST['action'] == 'unstick' && dbUpdate(array('key'=>'sticky','value'=>0),'notifications_attribs','notifications_id = ? && user_id = ?',array($_REQUEST['notification_id'],$_SESSION['user_id']))) {
|
||||
$status = 'ok';
|
||||
$message = 'Removed Sticky';
|
||||
}
|
||||
}
|
||||
elseif ($_REQUEST['action'] == 'create' && $_SESSION['userlevel'] == 10 && (isset($_REQUEST['title']) && isset($_REQUEST['body']))) {
|
||||
if (dbInsert(array('title'=>$_REQUEST['title'],'body'=>$_REQUEST['body'],'checksum'=>hash('sha512',$_SESSION['user_id'].'.LOCAL.'.$_REQUEST['title']),'source'=>$_SESSION['user_id']),'notifications')) {
|
||||
$status = 'ok';
|
||||
$message = 'Created';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: Missing Params';
|
||||
}
|
||||
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
)));
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
$parameter = mres($_POST['parameter']);
|
||||
if (isset($parameter)) {
|
||||
$data_param = mres($_POST['data_param']);
|
||||
$query_param = mres($_POST['query_param']);
|
||||
if (isset($data_param) && isset($query_param)) {
|
||||
$status = 'ok';
|
||||
$message = 'Queried';
|
||||
$output = get_ripe_api_whois_data_json($parameter);
|
||||
$output = get_ripe_api_whois_data_json($data_param, $query_param);
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
@@ -25,6 +26,7 @@ else {
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
'parameter' => $parameter,
|
||||
'data_param' => $data_param,
|
||||
'query_param' => $query_param,
|
||||
'output' => $output
|
||||
)));
|
||||
|
||||
@@ -1253,8 +1253,8 @@ function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$it
|
||||
return $output;
|
||||
}//end generate_dynamic_config_panel()
|
||||
|
||||
function get_ripe_api_whois_data_json($ripe_parameter) {
|
||||
$ripe_whois_url = 'https://stat.ripe.net/data/whois/data.json?resource=' . $ripe_parameter;
|
||||
function get_ripe_api_whois_data_json($ripe_data_param, $ripe_query_param) {
|
||||
$ripe_whois_url = 'https://stat.ripe.net/data/'. $ripe_data_param . '/data.json?resource=' . $ripe_query_param;
|
||||
return json_decode(file_get_contents($ripe_whois_url) , true);
|
||||
}//end get_ripe_api_whois_data_json()
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ else {
|
||||
<div class="collapse navbar-collapse" id="navHeaderCollapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="dropdown">
|
||||
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-lightbulb-o fa-fw fa-lg fa-nav-icons"></i> Overview</a>
|
||||
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-lightbulb-o fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Overview</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-lightbulb-o fa-fw fa-lg"></i> Overview</a></li>
|
||||
<li class="dropdown-submenu">
|
||||
@@ -113,7 +113,7 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) {
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="devices/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-server fa-fw fa-lg fa-nav-icons"></i> Devices</a>
|
||||
<a href="devices/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-server fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Devices</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-submenu">
|
||||
<a href="devices/"><i class="fa fa-server fa-fw fa-lg"></i> All Devices</a>
|
||||
@@ -187,7 +187,7 @@ if ($_SESSION['userlevel'] >= '10') {
|
||||
if ($config['show_services']) {
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="services/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cogs fa-fw fa-lg fa-nav-icons"></i> Services</a>
|
||||
<a href="services/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cogs fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Services</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="services/"><i class="fa fa-cogs fa-fw fa-lg"></i> All Services </a></li>
|
||||
|
||||
@@ -216,7 +216,7 @@ if ($_SESSION['userlevel'] >= '10') {
|
||||
|
||||
<!-- PORTS -->
|
||||
<li class="dropdown">
|
||||
<a href="ports/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-link fa-fw fa-lg fa-nav-icons"></i> Ports</a>
|
||||
<a href="ports/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-link fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Ports</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="ports/"><i class="fa fa-link fa-fw fa-lg"></i> All Ports</a></li>
|
||||
|
||||
@@ -322,7 +322,7 @@ $menu_sensors = $used_sensors;
|
||||
?>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="health/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-heartbeat fa-fw fa-lg fa-nav-icons"></i> Health</a>
|
||||
<a href="health/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-heartbeat fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Health</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="health/metric=mempool/"><i class="fa fa-gears fa-fw fa-lg"></i> Memory</a></li>
|
||||
<li><a href="health/metric=processor/"><i class="fa fa-desktop fa-fw fa-lg"></i> Processor</a></li>
|
||||
@@ -373,7 +373,7 @@ $app_list = dbFetchRows("SELECT DISTINCT(`app_type`) AS `app_type` FROM `applica
|
||||
if ($_SESSION['userlevel'] >= '5' && count($app_list) > "0") {
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="apps/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-tasks fa-fw fa-lg fa-nav-icons"></i> Apps</a>
|
||||
<a href="apps/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-tasks fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Apps</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<?php
|
||||
|
||||
@@ -411,7 +411,7 @@ if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf
|
||||
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="routing/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-arrows fa-fw fa-lg fa-nav-icons"></i> Routing</a>
|
||||
<a href="routing/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-arrows fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Routing</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<?php
|
||||
$separator = 0;
|
||||
@@ -458,7 +458,7 @@ if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf
|
||||
?>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-plug fa-fw fa-lg fa-nav-icons"></i> <span class="hidden-md hidden-sm">Plugins</span></a>
|
||||
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-plug fa-fw fa-lg fa-nav-icons hidden-md"></i> <span class="hidden-sm">Plugins</span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<?php
|
||||
Plugins::call('menu');
|
||||
@@ -488,6 +488,10 @@ if(is_file("includes/print-menubar-custom.inc.php")) {
|
||||
</div>
|
||||
</form>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<?php
|
||||
$notifications = new ObjCache('notifications');
|
||||
echo ' <li><a href="notifications/"><span class="badge count-notif">'.($notifications['sticky_count']+$notifications['count']).'</span></a></li>';
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cog fa-fw fa-lg fa-nav-icons"></i></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
@@ -194,14 +194,10 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
|
||||
|
||||
<span class="message" id="message"></span>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="gridster grid">
|
||||
<ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -237,9 +233,12 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
dashboard_collapse();
|
||||
gridster = $(".gridster ul").gridster({
|
||||
widget_base_dimensions: [100, 100],
|
||||
widget_base_dimensions: ['auto', 100],
|
||||
autogenerate_stylesheet: true,
|
||||
widget_margins: [5, 5],
|
||||
avoid_overlapped_widgets: true,
|
||||
min_cols: 1,
|
||||
max_cols: 20,
|
||||
draggable: {
|
||||
handle: 'header, span',
|
||||
stop: function(e, ui, $widget) {
|
||||
@@ -263,6 +262,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
|
||||
};
|
||||
}
|
||||
}).data('gridster');
|
||||
$('.gridster ul').css({'width': $(window).width()});
|
||||
|
||||
gridster.remove_all_widgets();
|
||||
gridster.disable();
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker, QuxLabs UG <[email protected]>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/**
|
||||
* Notification Page
|
||||
* @author Daniel Preussker
|
||||
* @copyright 2015 Daniel Preussker, QuxLabs UG
|
||||
* @license GPL
|
||||
* @package LibreNMS
|
||||
* @subpackage Notifications
|
||||
*/
|
||||
|
||||
$notifications = new ObjCache('notifications');
|
||||
?>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1><a href="/notifications">Notifications</a></h1>
|
||||
<h4><strong class="count-notif"><?php echo $notifications['count']; ?></strong> Unread Notifications <?php echo ($_SESSION['userlevel'] == 10 ? '<button class="btn btn-success pull-right new-notif" style="margin-top:-10px;">New</button>' : ''); ?></h4>
|
||||
<hr/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container new-notif-collapse">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<form class="form-horizontal new-notif-form">
|
||||
<div class="form-group">
|
||||
<label for="notif_title" class="col-sm-2 control-label">Title</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="notif_title" name="notif_title" placeholder="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="notif_body" class="col-sm-2 control-label">Message</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" id="notif_body" name="notif_body"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-success">Add Notification</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!isset($vars['archive'])) { ?>
|
||||
<div class="container">
|
||||
<?php
|
||||
foreach ($notifications['sticky'] as $notif) {
|
||||
if (is_numeric($notif['source'])) {
|
||||
$notif['source'] = dbFetchCell('select username from users where user_id =?',array($notif['source']));
|
||||
} ?>
|
||||
<div class="well">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4 class="text-warning" id="<?php echo $notif['notifications_id']; ?>"><strong><i class="fa fa-bell-o"></i> <?php echo $notif['title']; ?></strong> <span class="pull-right"><?php echo ($notif['user_id'] != $_SESSION['user_id'] ? '<code>Sticky by '.dbFetchCell('select username from users where user_id = ?',array($notif['user_id'])).'</code>' : '<button class="btn btn-primary fa fa-bell-slash-o unstick-notif" data-toggle="tooltip" data-placement="bottom" title="Remove Sticky" style="margin-top:-10px;"></button>'); ?></span></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<blockquote>
|
||||
<p><?php echo $notif['body']; ?></p>
|
||||
<footer>Source: <code><?php echo $notif['source']; ?></code></footer>
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($notifications['sticky_count'] != 0) { ?>
|
||||
<hr/>
|
||||
<?php } ?>
|
||||
<?php
|
||||
foreach ($notifications['unread'] as $notif) {
|
||||
if (is_numeric($notif['source'])) {
|
||||
$notif['source'] = dbFetchCell('select username from users where user_id =?',array($notif['source']));
|
||||
} ?>
|
||||
<div class="well">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4 class="text-success" id="<?php echo $notif['notifications_id']; ?>"><strong><?php echo $notif['title']; ?></strong><span class="pull-right">
|
||||
<?php echo ($_SESSION['userlevel'] == 10 ? '<button class="btn btn-primary fa fa-bell-o stick-notif" data-toggle="tooltip" data-placement="bottom" title="Mark as Sticky" style="margin-top:-10px;"></button>' : ''); ?>
|
||||
|
||||
<button class="btn btn-primary fa fa-eye read-notif" data-toggle="tooltip" data-placement="bottom" title="Mark as Read" style="margin-top:-10px;"></button>
|
||||
</span>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<blockquote>
|
||||
<p><?php echo $notif['body']; ?></p>
|
||||
<footer>Source: <code><?php echo $notif['source']; ?></code></footer>
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3><a class="btn btn-default" href="/notifications/archive">Show Archive</a></h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } else if (isset($vars['archive'])) { ?>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h2>Archive</h2>
|
||||
</div>
|
||||
</div>
|
||||
<?php foreach (array_reverse($notifications['read']) as $notif) { ?>
|
||||
<div class="well">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4 id="<?php echo $notif['notifications_id']; ?>"><?php echo $notif['title']; echo ($_SESSION['userlevel'] == 10 ? '<span class="pull-right"><button class="btn btn-primary fa fa-bell-o stick-notif" data-toggle="tooltip" data-placement="bottom" title="Mark as Sticky" style="margin-top:-10px;"></button></span>' : ''); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<blockquote>
|
||||
<p><?php echo $notif['body']; ?></p>
|
||||
<footer>Source: <code><?php echo $notif['source']; ?></code></footer>
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<script>
|
||||
$(function() {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
$('.new-notif-collapse').fadeOut(0);
|
||||
$(document).on( "click", ".new-notif", function() {
|
||||
$('.new-notif-collapse').fadeToggle();
|
||||
});
|
||||
|
||||
$(document).on( "submit", ".new-notif-form", function() {
|
||||
var notif = {};
|
||||
data = $(this).serializeArray();
|
||||
for( var field in data ) {
|
||||
notif[data[field].name] = data[field].value;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: {type: 'notifications', title: notif.notif_title, body: notif.notif_body, action: 'create'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if( data.status == "ok" ) {
|
||||
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
|
||||
window.location.href="/notifications";
|
||||
}
|
||||
else {
|
||||
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).on( "click", ".read-notif", function() {
|
||||
$(this).attr("disabled", true);
|
||||
var notif = $(this).parent().parent().attr('id');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: {type: 'notifications', notification_id: notif, action: 'read'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if( data.status == "ok" ) {
|
||||
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
|
||||
$("#"+notif).parent().parent().parent().fadeOut();
|
||||
$(".count-notif").each(function(){
|
||||
this.innerHTML = this.innerHTML-1;
|
||||
});
|
||||
}
|
||||
else {
|
||||
$(this).attr("disabled", false);
|
||||
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on( "click", ".stick-notif", function() {
|
||||
var notif = $(this).parent().parent().attr('id');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: {type: 'notifications', notification_id: notif, action: 'stick'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if( data.status == "ok" ) {
|
||||
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
|
||||
window.location.href="/notifications";
|
||||
}
|
||||
else {
|
||||
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on( "click", ".unstick-notif", function() {
|
||||
var notif = $(this).parent().parent().attr('id');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: {type: 'notifications', notification_id: notif, action: 'unstick'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if( data.status == "ok" ) {
|
||||
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
|
||||
window.location.href="/notifications";
|
||||
}
|
||||
else {
|
||||
$("#message").html('<div class="alert alert-info">' + data.message + '</div>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -13,39 +13,54 @@ $pagetitle[] = 'RIPE NCC - API Tools';
|
||||
?>
|
||||
<h3> RIPE NCC API Tools </h3>
|
||||
<hr>
|
||||
<h4> Whois </h4>
|
||||
<form class="form-horizontal" action="" method="post">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="input-parameter" placeholder="IP, ASN etc.">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" name="btn-query" id="btn-query" class="btn btn-primary">Query</button>
|
||||
</span>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label><input type="radio" name="data_radio" value="abuse-contact-finder">Abuse Contact Finder</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label><input type="radio" name="data_radio" value="whois">Whois</label>
|
||||
</div>
|
||||
<br />
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="input-parameter" placeholder="IP, ASN etc.">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" name="btn-query" id="btn-query" class="btn btn-primary">Query</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<br />
|
||||
<div id="ripe-output" style="font-family: Courier New; background-color: lightgray;"></div>
|
||||
<div id="ripe-output" class="alert alert-success" style="display: none;"></div>
|
||||
<br />
|
||||
<script>
|
||||
$("[name='btn-query']").on('click', function(event) {
|
||||
event.preventDefault();
|
||||
var $this = $(this);
|
||||
var parameter = $("#input-parameter").val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: { type: "query-ripenccapi", parameter: parameter},
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
$('#ripe-output').empty();
|
||||
if (data.output.data.records) {
|
||||
$.each(data.output.data.records[0], function (row,value) {
|
||||
$('#ripe-output').append(value['key'] + ' = ' + value['value'] +'<br />');
|
||||
});
|
||||
$("[name='btn-query']").on('click', function(event) {
|
||||
event.preventDefault();
|
||||
var $this = $(this);
|
||||
var data_param = $('input[name=data_radio]:checked').val();
|
||||
var query_param = $("#input-parameter").val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: {
|
||||
type: "query-ripenccapi",
|
||||
data_param: data_param,
|
||||
query_param: query_param
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
$('#ripe-output').empty();
|
||||
$("#ripe-output").show();
|
||||
if (data.output.data.records)
|
||||
$.each(data.output.data.records[0], function(row, value) {
|
||||
$('#ripe-output').append(value['key'] + ' = ' + value['value'] + '<br />');
|
||||
});
|
||||
else if (data.output.data.anti_abuse_contacts.abuse_c)
|
||||
$.each(data.output.data.anti_abuse_contacts.abuse_c, function(row, value) {
|
||||
$('#ripe-output').append(value['description'] + ' = ' + value['email'] + '<br />');
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
toastr.error('Error');
|
||||
}
|
||||
},
|
||||
error:function(){
|
||||
toastr.error('Error');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user