YaWK  24.1
Yet another WebKit
syslog-config.php
Go to the documentation of this file.
1 <?php
2 
3 use YAWK\alert;
4 use YAWK\backend;
5 use YAWK\db;
6 use YAWK\language;
7 use YAWK\settings;
8 use YAWK\sys;
9 
10 /** @var $db db */
11 /** @var $lang language */
12 
13 if(isset($_POST))
14 { // log checkboxes
15  if (isset($_POST['active']))
16  {
17  foreach ($_POST['active'] as $property => $value)
18  { // check checkbox value
19  if ($value == "on")
20  { // set to numeric value
21  $value = 1;
22  }
23  else
24  { // checkbox off
25  $value = 0;
26  }
27  // update syslog_categories log (active) values
28  if (!$db->query("UPDATE {syslog_categories} SET active = '".$value."' WHERE id = '".$property."' "))
29  { // make syslog entry on error
30  sys::setSyslog($db, 3, 1, "Unable to update syslog configuration - unable to set state of field: $property to value: $value", "", 0, 0, 0);
31  }
32  }
33  }
34  // notification checkboxes
35  if (isset($_POST['notify']))
36  {
37  foreach ($_POST['notify'] as $property => $value)
38  { // check checkbox values
39  if ($value == "on")
40  { // set to numeric value
41  $value = 1;
42  }
43  else
44  { // checkbox off
45  $value = 0;
46  }
47  // update syslog_categories notify values
48  if (!$db->query("UPDATE {syslog_categories} SET notify = '".$value."' WHERE id = '".$property."' "))
49  { // make syslog entry on error
50  sys::setSyslog($db, 3, 1, "Unable to update syslog configuration - unable to set state of field: $property to value: $value", "", 0, 0, 0);
51  }
52  }
53  }
54 }
55 ?>
56 <script type="text/javascript">
57  $(document).ready(function() {
58  $('#table-sort').dataTable( {
59  "bPaginate": false,
60  "bLengthChange": false,
61  "bFilter": true,
62  "bSort": false,
63  "bInfo": true,
64  "bAutoWidth": true
65  } );
66  } );
67 </script>
68 <script type="text/javascript">
69  $(document).ready(function() {
70  // TRY TO DISABLE CTRL-S browser hotkey
71  function saveHotkey() {
72  // simply disables save event for chrome
73  $(window).keypress(function (event) {
74  if (!(event.which === 115 && (navigator.platform.match("Mac") ? event.metaKey : event.ctrlKey)) && !(event.which === 19)) return true;
75  event.preventDefault();
76  formmodified=0; // do not warn user, just save.
77  return false;
78  });
79  // used to process the cmd+s and ctrl+s events
80  $(document).keydown(function (event) {
81  if (event.which === 83 && (navigator.platform.match("Mac") ? event.metaKey : event.ctrlKey)) {
82  event.preventDefault();
83  $('#savebutton').click(); // SAVE FORM AFTER PRESSING STRG-S hotkey
84  formmodified=0; // do not warn user, just save.
85  // save(event);
86  return false;
87  }
88  });
89  }
90  saveHotkey();
91 
92 
93  var savebutton = ('#savebutton');
94  var savebuttonIcon = ('#savebuttonIcon');
95  // ok, lets go...
96  // we need to check if user clicked on save button
97  $(savebutton).click(function() {
98  $(savebutton).removeClass('btn btn-success').addClass('btn btn-warning disabled');
99  $(savebuttonIcon).removeClass('fa fa-save').addClass('fa fa-spinner fa-spin fa-fw');
100  });
101 
102 
103  // automatically turn off notifications if loggin is turned of for this category
104  // check if any checkbox has changed
105  $(':checkbox').change(function()
106  { // $this is reference to the clicked checkbox
107  var $this = $(this);
108  // get ID attribute from this checkbox
109  var id = $(this).attr('id');
110  // the corresponding notify checkbox to the logging checkbox
111  var notifyCheckbox = '#notify'+id;
112  // check if clicked checkbox is currently checked
113  if ($this.is(':checked'))
114  { // toggle corresponding notify checkbox ON
115  $(notifyCheckbox).bootstrapToggle('enable');
116  $(notifyCheckbox).bootstrapToggle('on');
117  // alert('checkbox '+id+ ' is now ON');
118  } else {
119  // toggle corresponding notify checkbox OFF
120  $(notifyCheckbox).bootstrapToggle('off');
121  $(notifyCheckbox).bootstrapToggle('disable');
122  // $(notifyCheckbox).bootstrapToggle.off;
123  }
124  });
125 
126  // Toggle all syslog categories on / off
127  $('#toggleAllBtn').click(function(e)
128  {
129  // prevent page reload
130  e.preventDefault();
131  // select table
132  var table = $("#table-sort");
133  // select all checkboxes in this table
134  var selected = $('td input:checkbox',table);
135  // on each selected checkbox
136  $(selected).each(function()
137  {
138  // $this reference to the clicked checkbox
139  var $this = $(this);
140  // store current checkbox selector
141  var currentCheckbox = '#'+this.id;
142  // check if checkbox is checked
143  if ($this.is(':checked'))
144  { // toggle current checkbox (all)
145  $(currentCheckbox).bootstrapToggle('toggle');
146  // console.log(this.id+' is checked');
147  }
148  else
149  { // toggle not checked checkboxes
150  $(currentCheckbox).bootstrapToggle('toggle');
151  // console.log(this.name+' unchecked');
152  }
153  });
154  });
155 
156  }); // end document ready
157 </script>
158 <!-- Bootstrap toggle css -->
159 <link rel="stylesheet" href="../system/engines/bootstrap-toggle/css/bootstrap-toggle.css">
160 <!-- Bootstrap toggle js -->
161 <script type="text/javascript" src="../system/engines/bootstrap-toggle/js/bootstrap-toggle.min.js"></script>
162 <?php
163 // check if syslog is enabled
164 $syslogEnabled = settings::getSetting($db, "syslogEnable");
165 if ($syslogEnabled == false)
166 { // if not, throw a warning message
167  echo alert::draw("danger", $lang['SYSLOG_DISABLED'], $lang['SYSLOG_DISABLED_MSG'], "", 0);
168 }
169 
170 // TEMPLATE WRAPPER - HEADER & breadcrumbs
171 echo "
172  <!-- Content Wrapper. Contains page content -->
173  <div class=\"content-wrapper\" id=\"content-FX\">
174  <!-- Content Header (Page header) -->
175  <section class=\"content-header\">";
176 /* draw Title on top */
177 echo backend::getTitle($lang['SYSLOG'], $lang['SYSLOG_CONFIG']);
178 echo"<ol class=\"breadcrumb\">
179  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
180  <li><a href=\"index.php?page=syslog\" class=\"active\" title=\"$lang[SYSLOG]\"> $lang[SYSLOG]</a></li>
181  <li><a href=\"index.php?page=syslog-config\" class=\"active\" title=\"$lang[CONFIGURATION]\"> $lang[CONFIGURATION]</a></li>
182  </ol>
183  </section>
184  <!-- Main content -->
185  <section class=\"content\">";
186 /* page content start here */
187 
188 if (isset($_GET['clear']) && $_GET['clear'] === '1')
189 { // delete all syslog entries
190  if ($sql = $db->query("TRUNCATE TABLE {syslog}"))
191  { // delete all user notifications
192  if ($db->query("TRUNCATE TABLE {notifications}"))
193  { // success, reload page
194  alert::draw("success", "$lang[SYSLOG_DATA_DEL]", "$lang[SYSLOG_DATA_DEL_SUBTEXT]","",3600);
195  }
196  }
197  else
198  { // q failed...
199  alert::draw("warning", "$lang[WARNING]", "$lang[SYSLOG_DATA_DEL_SUBTEXT]", "",4200);
200  }
201 }
202 ?>
203 
204 <div class="box box-default">
205  <div class="box-header with-border">
206  <h3 class="box-title"><?php echo "$lang[SETTINGS]"; ?></h3>
207  </div>
208  <div class="box-body">
209 
210 
211  <form name="form" id="form" role="form" action="index.php?page=syslog-config" method="post">
212 
213  <!-- savebutton -->
214  <button class="btn btn-success pull-right" type="submit" title="<?php echo $lang['SAVE'];?>" id="savebutton">
215  <i class="fa fa-save" id="savebuttonIcon"></i> &nbsp;&nbsp;<?php print $lang['SAVE']; ?>
216  </button>
217 
218  <!-- link to syslog -->
219  <a href="index.php?page=syslog" class="btn btn-default pull-right">
220  <i class="fa fa-angle-double-left"></i>&nbsp;&nbsp; <?php print $lang['SYSLOG']; ?>
221  </a>
222  <!-- toggle all -->
223  <button class="btn btn-default pull-right" id="toggleAllBtn" href="#" title="<?php print $lang['TOGGLE_ALL']; ?>">
224  <i class="fa fa-toggle-on"></i>
225  </button>
226 
227  <table style="width:100%;" class="table table-striped table-hover table-responsive" id="table-sort">
228  <thead>
229  <tr>
230  <td style="width:35%;" class="text-left"><strong><?php echo $lang['CATEGORY']; ?></strong></td>
231  <td style="width:20%;" class="text-center"><i class="fa fa-code"></i> &nbsp;<strong><?php echo $lang['LOG']; ?></strong></td>
232  <td style="width:25%;" class="text-center"><i class="fa fa-bell-o"></i> &nbsp;<strong><?php echo $lang['NOTIFY']; ?></strong></td>
233  <td style="width:10%;" class="text-center">&nbsp;</td>
234  </tr>
235  </thead>
236  <tbody>
237  <?php
238  /* load complete syslog, get all notifications */
239  $syslogCategories = sys::getSyslogCategories($db);
240  if (is_array($syslogCategories))
241  {
242  foreach ($syslogCategories AS $category)
243  {
244  if (strstr($category['property'], "success"))
245  {
246  $color = " text-green";
247  }
248  elseif (strstr($category['property'], "warning"))
249  {
250  $color = " text-orange";
251  }
252  elseif (strstr($category['property'], "error"))
253  {
254  $color = " text-red";
255  }
256  else
257  {
258  $color = " text-gray";
259  }
260 
261  if ($syslogEnabled == false)
262  {
263  $disabled = " disabled readonly";
264  }
265  else
266  {
267  $disabled = '';
268  }
269 
270 
271  if ($category['active'] == 1)
272  {
273  $log_active = " checked".$disabled;
274  }
275  else
276  {
277  $log_active = "";
278  }
279 
280  if ($category['notify'] == 1)
281  {
282  $notify_active = " checked".$disabled;
283  }
284  else
285  {
286  $notify_active = "";
287  }
288  echo "<tr>
289  <td class=\"text-left\"><i class=\"".$category['icon']."$color\"></i>&nbsp;&nbsp;&nbsp;&nbsp; <b>".ucfirst($category['property'])."</b></td>
290  <td class=\"text-center\">
291  <input type=\"hidden\" name=\"active[".$category['id']."]\" id=\"hidden-".$category['id']."\" value=\"off\">
292  <input type=\"checkbox\" data-on=\"$lang[ON_]\" data-off=\"$lang[OFF_]\" data-toggle=\"toggle\" data-onstyle=\"success\" data-offstyle=\"danger\" class=\"checkbox\" data-activeID=\"".$category['id']."\" name=\"active[".$category['id']."]\" id=\"".$category['id']."\"$log_active>
293  </td>
294  <td class=\"text-center\">
295  <input type=\"hidden\" name=\"notify[".$category['id']."]\" id=\"hidden-".$category['id']."\" value=\"off\">
296  <input type=\"checkbox\" data-on=\"<i class='fa fa-bell-o'>\" data-off=\"<i class='fa fa-bell-slash-o'>\" data-toggle=\"toggle\" data-onstyle=\"success\" data-offstyle=\"danger\" data-notifyID=\"".$category['id']."\" class=\"checkbox\" name=\"notify[".$category['id']."]\" id=\"notify".$category['id']."\"$notify_active>
297  </td>
298  <td class=\"text-center\">&nbsp;</td>
299  </tr>";
300  }
301  }
302  ?>
303  </tbody>
304  </table>
305  </form>
306  </div>
307 </div>
308 
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
function window
Definition: fuckAdBlock.js:8
function a
Definition: browser.js:14
c jPlayer event
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 e
Definition: plyr.js:1
function i(e, t)
Definition: plyr.js:1
<!-- backend language -->< h3 >< i class="fa fa-language"></i > & nbsp
$syslogCategories
print $lang['SAVE']
if(isset($_POST)) $syslogEnabled
$template name
if(!isset($template)) if(!isset($user)) $template id
$value
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);});})