YaWK  24.1
Yet another WebKit
syslog.php
Go to the documentation of this file.
1 <script type="text/javascript">
2  $(document).ready(function() {
3  $('#table-sort').dataTable( {
4  "bPaginate": false,
5  "bLengthChange": false,
6  "bFilter": true,
7  "bSort": false,
8  "bInfo": true,
9  "bAutoWidth": true
10  } );
11  });
12 
13  // dismiss a single notification
14  // this function will be called by click on the envelope icon in the syslog table
15  function dismissNotification(id) {
16  $.ajax({ // do ajax request
17  url: 'js/dismiss-singleNotification.php',
18  type: 'POST',
19  data: {
20  "id": id
21  },
22  success: function (data) {
23  if (!data) {
24  alert('Something went wrong!');
25  return false;
26  }
27  else // dismiss notification(id) successful
28  { // ajax post-processing: update icons + bell label
29  // get current icon with this id
30  var currentIcon = '#envelope-'+id;
31  // get current with this id
32  var currentLink = '#link'+id;
33  // store bell label (the yellow flag on the notification box)
34  var bellLabel = '#bell-label';
35  // select notification menu counter span
36  var notificationCounterSpan = '#notificationsMenuCounter';
37  // select notification menu counter span
38  var notificationItem = '#note-'+id;
39  // remove closed envelope icon
40  $(currentIcon).removeClass('fa fa-envelope-o');
41  // add open envelope icon
42  $(currentIcon).addClass('fa fa-envelope-open-o text-gray');
43  // change onclick function call to reopen
44  $(currentLink).attr("onclick","reopenNotification("+id+")");
45  // get number of bell label notification counter
46  var notificationCounter = $(bellLabel).text();
47  // get number of bell label notification counter
48  var notificationCounterMenu = $(notificationCounterSpan).text();
49  // subtract -1 from counter
50  notificationCounter--;
51  notificationCounterMenu--;
52  // if notification counter is null
53  if (!notificationCounter)
54  { // fade away the orange label on top
55  $(bellLabel).fadeOut();
56  $(notificationCounterSpan).text(notificationCounterMenu);
57  $(notificationItem).fadeOut();
58  }
59  else
60  { // update bell label notification counter
61  $(bellLabel).text(notificationCounter);
62  $(notificationCounterSpan).text(notificationCounterMenu);
63  $(notificationItem).fadeOut();
64  }
65  }
66  }
67  });
68  }
69 
70  // re-open a single notification
71  // this function will be called by click on the envelope icon in the syslog table
72  function reopenNotification(id) {
73  $.ajax({ // do ajax request
74  url: 'js/reopen-singleNotification.php',
75  type: 'POST',
76  data: {
77  "id": id
78  },
79  success: function (data) {
80  if (!data) {
81  alert('Something went wrong!');
82  return false;
83  }
84  else
85  { // re-open notification(id) successful
86  // ajax post-processing: update icons + bell label
87  // get current icon with this id
88  var currentIcon = '#envelope-'+id;
89  // get current link with this id
90  var currentLink = '#link'+id;
91  // get current icon with this id
92  var bellLabel = '#bell-label';
93  // select notification menu counter span
94  var notificationCounterSpan = '#notificationsMenuCounter';
95  // update envelope class: remove open envelope
96  $(currentIcon).removeClass('fa fa-envelope-open-o text-gray');
97  // update envelope class to closed envelope
98  $(currentIcon).addClass('fa fa-envelope-o');
99  // change onclick function call to reopen
100  $(currentLink).attr("onclick","dismissNotification("+id+")");
101  // uget bell label notification number
102  var notificationCounter = $(bellLabel).text();
103  // get number of bell label notification counter
104  var notificationCounterMenu = $(notificationCounterSpan).text();
105  // add +1 to notification counter
106  notificationCounter++;
107  notificationCounterMenu++;
108  // update bell label notification counter
109  $(bellLabel).text(notificationCounter);
110  $(notificationCounterSpan).text(notificationCounterMenu);
111  }
112  }
113  });
114  }
115 </script>
116 <?php
117 
118 use YAWK\alert;
119 use YAWK\backend;
120 use YAWK\db;
121 use YAWK\language;
122 use YAWK\settings;
123 use YAWK\sys;
124 use YAWK\user;
125 
126 /** @var $db db */
127 /** @var $lang language */
128 
129 
130 // check if syslog is enabled
131 if (settings::getSetting($db, "syslogEnable") == false)
132 { // if not, throw a warning message
133  echo alert::draw("danger", $lang['SYSLOG_DISABLED'], $lang['SYSLOG_DISABLED_MSG'], "", 0);
134 }
135 
136 // TEMPLATE WRAPPER - HEADER & breadcrumbs
137 echo "
138  <!-- Content Wrapper. Contains page content -->
139  <div class=\"content-wrapper\" id=\"content-FX\">
140  <!-- Content Header (Page header) -->
141  <section class=\"content-header\">";
142 /* draw Title on top */
143 echo backend::getTitle($lang['SYSLOG'], $lang['SYSLOG_SUBTEXT']);
144 echo"<ol class=\"breadcrumb\">
145  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
146  <li><a href=\"index.php?page=syslog\" class=\"active\" title=\"$lang[SYSLOG]\"> $lang[SYSLOG]</a></li>
147  </ol>
148  </section>
149  <!-- Main content -->
150  <section class=\"content\">";
151 /* page content start here */
152 
153 if (isset($_GET['clear']) && $_GET['clear'] === '1')
154  { // delete all syslog entries
155  if ($sql = $db->query("TRUNCATE TABLE {syslog}"))
156  { // delete all user notifications
157  if ($db->query("TRUNCATE TABLE {notifications}"))
158  { // success, reload page
159  alert::draw("success", "$lang[SYSLOG_DATA_DEL]", "$lang[SYSLOG_DATA_DEL_SUBTEXT]","",3600);
160  }
161  }
162  else
163  { // q failed...
164  alert::draw("warning", "$lang[WARNING]", "$lang[SYSLOG_DATA_DEL_SUBTEXT]", "",4200);
165  }
166  }
167 ?>
168 
169 <div class="box box-default">
170  <div class="box-header with-border">
171  <h3 class="box-title"><?php echo "$lang[SYSTEM_LOGFILES]"; ?></h3>
172  </div>
173  <div class="box-body">
174 
175  <!-- btn clear log -->
176  <a class="btn btn-danger pull-right" role="dialog" title="<?php echo $lang['SYSLOG_CLEAR'];?>" data-confirm="<?php echo $lang['SYSLOG_DEL_CONFIRM']; ?>" href="index.php?page=syslog&clear=1">
177  <i class="fa fa-trash-o"></i> &nbsp;<?php print $lang['SYSLOG_CLEAR']; ?>
178  </a>
179  <!-- btn syslog settings -->
180  <a class="btn btn-default pull-right" title="<?php echo $lang['SETTINGS'];?>" href="index.php?page=syslog-config">
181  <i class="fa fa-cog"></i> &nbsp;<?php print $lang['SETTINGS']; ?>
182  </a>
183 
184 <table style="width:100%;" class="table table-striped table-hover table-responsive" id="table-sort">
185  <thead>
186  <tr>
187  <td style="width:3%;" class="text-center"><strong><small><i class="fa fa-bell-o"></i></small></strong></td>
188  <td style="width:8%;" class="text-center"><strong><?php echo $lang['TYPE']; ?></strong></td>
189  <td style="width:10%;" class="text-center"><strong><?php echo $lang['TIMESTAMP']; ?></strong></td>
190  <td style="width:8%;" class="text-center"><strong><?php echo $lang['USER']; ?></strong></td>
191  <td style="width:61%;"><strong><?php echo $lang['ENTRY']; ?></strong></td>
192  <td style="width:10%;" class="text-center"><strong><?php // echo $lang['AFFECTED']; ?></strong></td>
193  </tr>
194  </thead>
195  <tbody>
196  <?php
197  /* load complete syslog, get all notifications */
198  $syslog = sys::getSyslog($db);
199  if (is_array($syslog))
200  {
201  foreach ($syslog AS $log)
202  { // get username for affected uid
203  $affected_user = user::getUserNameFromID($db, $log['toUID']);
204  // improve view of category title (cpt. caps + remove post tags -warning -success and -error)
205  $log['property'] = strtoupper(substr($log['property'], 0, strpos($log['property'], '-')));
206  // calculate time ago view
207  $time_ago = sys::time_ago($log['log_date'], $lang);
208  // 1 tbl row per syslog line
209  if ($log['log_type'] == 0)
210  {
211  $textMarkup = "";
212  $category = "<b>".$log['property']."</b><br><span class=\"label label-default\">Info</span>";
213  }
214 
215  elseif ($log['log_type'] == 1)
216  {
217  $textMarkup = "";
218  $category = "<b>".$log['property']."</b><br><span class=\"label label-warning\">WARNING</span>";
219  }
220  elseif ($log['log_type'] == 2)
221  {
222  $textMarkup = " class=\"text-red\"";
223  $category = "<b>".$log['property']."</b><br><span class=\"label label-danger\">ERROR</span>";
224  }
225  elseif ($log['log_type'] == 3)
226  {
227  $textMarkup = "";
228  $category = "<b>".$log['property']."</b><br><span class=\"label label-success\">SUCCESS</span>";
229  }
230  else
231  {
232  $textMarkup = "";
233  $category = "<b>".$log['property']."</b><br><span class=\"label label-default\">LOG</span>";
234  }
235 
236  if ($log['seen'] == 0)
237  {
238  $labelMarkup = "<a href=\"#\" onclick=\"dismissNotification('".$log['log_id']."')\" id=\"link".$log['log_id']."\" data-id=\"$log[log_id]\"><i class=\"fa fa-envelope-o\" id=\"envelope-$log[log_id]\" title=\"$lang[ID]: $log[log_id]\"></i></a>";
239  }
240  else
241  {
242  $labelMarkup = "<a href=\"#\" onclick=\"reopenNotification('".$log['log_id']."')\" id=\"link".$log['log_id']."\" data-id=\"$log[log_id]\"><i class=\"fa fa-envelope-open-o text-gray\" id=\"envelope-$log[log_id]\" title=\"$lang[ID]: $log[log_id]\"></i></a>";
243  }
244 
245  echo "<tr class=\"".$log['type']."\">
246  <td class=\"text-center\">$labelMarkup</td>
247  <td class=\"text-center\">".$category."</td>
248  <td class=\"text-center\"><small>$log[log_date]<br><small>".$time_ago."</small></td>
249  <td class=\"text-center\"><a href=\"index.php?page=user-edit&user=$log[username]\" title=\"$log[username] ($lang[IN_NEW_WINDOW])\" target=\"_blank\"$textMarkup>".$log['username']."</a></td>
250  <td$textMarkup><i class=\"".$log['icon']."\"></i> &nbsp;&nbsp;".$log['message']."</td>
251  <td class=\"text-center\"><span$textMarkup>".$affected_user."</span></td>
252  </tr>";
253  }
254  }
255  ?>
256  </tbody>
257 </table>
258 </div>
259 </div>
Throws a fancy Bootstrap Alert (success, info, warning or danger)
Definition: alert.php:19
Backend class serves a few useful functions for the admin backend.
Definition: backend.php:27
Mysqli database class; returns db connection object.
Definition: db.php:16
The language class - support multilingual backend.
Definition: language.php:17
Settings class: get and set YaWK system settings.
Definition: settings.php:9
The sys class - handles yawk's system core functions.
Definition: sys.php:17
The default user class. Provide all functions to handle the user object.
Definition: user.php:17
function a
Definition: browser.js:14
type
Definition: menu-new.php:35
$sql
Definition: message-new.php:32
print $page title
Definition: page-edit.php:377
print $_GET['id']
Definition: page-edit.php:357
function i(e, t)
Definition: plyr.js:1
<!-- backend language -->< h3 >< i class="fa fa-language"></i > & nbsp
</tr ></thead >< tbody > $syslog
Definition: syslog.php:198
print $lang['SYSLOG_CLEAR']
Definition: syslog.php:176
if(!isset($template)) if(!isset($user)) $template id
document ready(function() { $('a[data-confirm]').click(function(ev) { modal='#dataConfirmModal';var href=$(this).attr('href');var title=$(this).attr('title');var icon=$(this).attr('data-icon');if(!icon) { icon='fa fa-trash-o';} if(!$(modal).length) { $('body').append('< div id="dataConfirmModal" class="modal fade" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true">< div class="modal-dialog">< div class="modal-content">< div class="modal-header">< button type="button" class="close" data-dismiss="modal" aria-hidden="true">< i class="fa fa-times"></i ></button >< br >< div class="col-md-1">< h3 class="modal-title">< i class="'+icon+'"></i ></h3 ></div >< div class="col-md-11">< h3 class="modal-title" id="dataConfirmLabel">'+title+'</h3 ></div ></h3 ></div >< div class="modal-body"></div >< div class="modal-footer">< button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">Abbrechen</button >< a type="button" class="btn btn-danger" id="dataConfirmOK">< i class="'+icon+'"></i > L &ouml;schen</a ></div ></div ></div ></div >');} $(modal).find('.modal-body').text($(this).attr('data-confirm'));$('#dataConfirmOK').attr('href', href);$(modal).modal({show:true});return false;});$('#terminateUser').click(function() { var terminate=window.confirm("ACHTUNG!\nDas wird Deinen Account permanent deaktivieren.\n"+"Bist Du Dir sicher, dass Du das tun willst?");if(terminate===true) { var terminateUser=window.confirm("Bist Du Dir wirklich ganz sicher?\n"+"Diese Aktion kann nicht rueckgaengig gemacht werden.");if(terminateUser===true) { $.get('system/templates/YaWK-bootstrap3/js/terminate-user.php', function(data) { if(data==="true") { setTimeout("window.location='logout.html'", 0);} else { alert("Fehler: "+data);} });} } });function dismissNotifications() { $.ajax({ url:'js/dismiss-notifications.php', type:'POST', success:function(data) { if(!data) { alert('Something went wrong!');return false;} } });$("#bell-label").fadeOut();$('#notification-header').html('You have 0 notifications');$('#notification-menu').fadeOut();} $("#dismiss").click(function() { dismissNotifications();});function disableButtons(delay) { $('#loginButton').removeClass().addClass('btn btn-success disabled').attr('id', 'LOGIN_FORBIDDEN');$('#resetPasswordButton').removeClass().addClass('btn btn-danger disabled');setTimeout(function() { $('#LOGIN_FORBIDDEN').attr('id', 'loginButton').removeClass().addClass('btn btn-success');$('#resetPasswordButton').removeClass().addClass('btn btn-danger');}, delay);} $("#loginButton").click(function(){ if($('#loginButton').length > 0) { if($('#loginButton').hasClass('btn') &&$('#loginButton').hasClass('btn-success') &&$('#loginButton').hasClass('disabled')) { } else { $("#loginForm").submit();disableButtons(10000);} } else if($('#LOGIN_FORBIDDEN').length > 0) { if($('#LOGIN_FORBIDDEN').hasClass('btn') &&$('#LOGIN_FORBIDDEN').hasClass('btn-success') &&$('#LOGIN_FORBIDDEN').hasClass('disabled')) { } else { } } });$("#blockedBtn").hover(function() { $("#blockedBtn").hide();$("#askBtn").fadeIn(820);});})