MastodonHelp/web/mustard/notifs.php

334 lines
12 KiB
PHP
Raw Normal View History

<?php
require('include/glob.php');
require('include/muoribene.php');
require('include/sessionstart.php');
require('include/myconn.php');
require('include/getadmacc.php');
if ($account['Level'] == 'guest')
muoribene('Sorry, you are not authorized.', true);
require('include/menu.php');
$menu['menu']['selected'] = true;
$menu['menu']['submenu']['notifs']['selected'] = true;
buildmenu($menu);
$dbg = '';
// praticamente una macro
function hspech($str)
{
return (htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8'));
}
$dbg .= $dlang . '<br>' . N;
$dbg .= '<pre>' . print_r($_GET, 1) . '</pre>';
$dbg .= '<pre>' . print_r($inst, 1) . '</pre>' . N;
if ($account['Level'] != 'guest') {
require('include/notifs.php');
$notifs = notifs($link);
} else {
muoribene("Non hai i permessi per vedere questa pagina", true);
}
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Mustard - Notifs</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Admin pages for Mastodon Startpage">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="icon" type="image/png" href="imgs/icona-32.png" sizes="32x32">
<link rel="icon" type="image/png" href="imgs/icona-192.png" sizes="192x192">
<link rel="icon" type="image/png" href="imgs/icona-512.png" sizes="512x512">
<link rel="apple-touch-icon-precomposed" href="imgs/icona-180.png">
<script language="JavaScript" src="js/menu.js?v=<?php echo($cjrand); ?>"></script>
<script language="JavaScript" src="js/confirma.js?v=<?php echo($cjrand); ?>"></script>
<script language="JavaScript" src="js/alerta.js?v=<?php echo($cjrand); ?>"></script>
<link rel="stylesheet" type="text/css" href="theme.css?v=<?php echo($cjrand); ?>">
<script language="JavaScript">
<!--
<?php if ($account['Level'] != 'guest') require('js/notifs.js.php'); ?>
function deselect(selid) {
var sel = document.getElementById(selid);
sel.selectedIndex = -1;
}
function getselarr(selid) {
var sel = document.getElementById(selid), selc = sel.length, i, arr = [];
for (i = 0; i < selc; i++)
arr.push([sel.options[i].text, sel.options[i].value, sel.options[i].selected]);
return arr;
}
function updselarr(selid, selarr) {
var sel = document.getElementById(selid), selc = sel.length, selarrc = selarr.length, i, ii;
sel = sel.options;
ii = 0;
for (i = 0; i < selc; i++) {
while (ii < selarrc) {
if (selarr[ii][1] == sel[i].value) {
(sel[i].selected) ? selarr[ii][2] = true : selarr[ii][2] = false;
break;
}
ii++;
}
}
return selarr;
}
function filtsel(selarr, filt, selid, recbid, inpid, ocol, ecol) {
var sel = document.getElementById(selid), selarrc = selarr.length, i, ii, go = true;
if (!document.getElementById(recbid).checked) {
filt = filt.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
} else {
try {
(RegExp(filt));
} catch (e) {
go = false;
}
}
if (go) {
sel.length = 0;
for (i = 0; i < selarrc; i++) {
if (RegExp(filt, 'i').test(selarr[i][0]))
sel.options.add(new Option(selarr[i][0], selarr[i][1], false, selarr[i][2]));
}
if (ocol != null)
document.getElementById(inpid).style.backgroundColor = ocol;
} else if (ecol != null) {
document.getElementById(inpid).style.backgroundColor = ecol;
}
}
function selup(selid) {
var sel = document.getElementById(selid), len = sel.length, i, prevopt, curopt;
if (sel.selectedIndex > 0) {
for (i = 0; i < len; i++) {
if (sel.options[i].selected) {
prevopt = sel.options[i - 1];
curopt = sel.options[i];
sel.remove(i - 1);
sel.remove(i - 1);
sel.add(curopt, i - 1);
sel.add(prevopt, i);
}
}
}
}
function seltop(selid) {
var sel = document.getElementById(selid);
while (sel.selectedIndex > 0)
selup(selid);
}
function seldown(selid) {
var sel = document.getElementById(selid), len = sel.length, i, nextopt, curopt;
if (!sel.options[len - 1].selected) {
for (i = len - 1; i > -1; i--) {
if (sel.options[i].selected) {
curopt = sel.options[i];
nextopt = sel.options[i + 1];
sel.remove(i);
sel.remove(i);
sel.add(curopt, i);
sel.add(nextopt, i);
}
}
}
}
function selbot(selid) {
var sel = document.getElementById(selid), len = sel.length;
if (sel.selectedIndex >= 0) {
while (!sel.options[len - 1].selected)
seldown(selid);
}
}
function selonebyval(refarr, val) {
var len = refarr.length, i;
for (i = len - 1; i > -1; i--)
(refarr[i][1] == val) ? refarr[i][2] = true : refarr[i][2] = false;
return refarr;
}
function rmelbyval(refarr, val) {
var len = refarr.length, i;
for (i = len - 1; i > -1; i--) {
if (refarr[i][1] == val) {
refarr.splice(i, 1);
break;
}
}
return refarr;
}
// usato da edinsth.php
function cheltxtbyval(refarr, val, ntxt) {
var len = refarr.length, i;
for (i = len - 1; i > -1; i--) {
if (refarr[i][1] == val) {
refarr[i][0] = ntxt;
break;
}
}
return refarr;
}
// usato da edinsth.php
function chelvalbyval(refarr, val, nval) {
var len = refarr.length, i;
for (i = len - 1; i > -1; i--) {
if (refarr[i][1] == val) {
refarr[i][1] = nval;
break;
}
}
return refarr;
}
function seladd(fromselid, toselid, refarr) {
var fromsel = document.getElementById(fromselid), fslen = fromsel.length,
tosel = document.getElementById(toselid), i;
// farlo a scalare invece che a crescere inverte nella select di destinazione l'ordine delle opzioni scelte in quella di origine, perciò lo faccio a crescere
for (i = 0; i < fslen; i++) {
if (fromsel.options[i].selected) {
refarr = rmelbyval(refarr, fromsel.options[i].value);
tosel.add(fromsel.options[i]);
fslen--;
i--;
}
}
return refarr;
}
function sortByKey(array, key) {
return array.sort(function (a, b) {
var x = a[key].toLowerCase();
var y = b[key].toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
});
}
function selrem(fromselid, toselid, refarr, searchid, regexcbid) {
var fromsel = document.getElementById(fromselid), fslen = fromsel.length,
tosel = document.getElementById(toselid), i;
for (i = fslen - 1; i > -1; i--) {
if (fromsel.options[i].selected) {
refarr.push([fromsel.options[i].text, fromsel.options[i].value, true]);
fromsel.remove(i);
}
}
refarr = sortByKey(refarr, 0);
filtsel(refarr, document.getElementById(searchid).value, toselid, regexcbid, searchid, 'white', '#ff8080');
return refarr;
}
function selordalf(selid) {
var sel = document.getElementById(selid), len = sel.length, arr = [], i;
for (i = 0; i < len; i++)
arr.push([sel.options[i].text, sel.options[i].value, sel.options[i].selected]);
arr = sortByKey(arr, 0);
sel.length = 0;
for (i = 0; i < len; i++)
sel.add(new Option(arr[i][0], arr[i][1], false, arr[i][2]));
}
function selordinv(selid) {
var sel = document.getElementById(selid), len = sel.length, arr = [], i;
for (i = 0; i < len; i++)
arr.push([sel.options[i].text, sel.options[i].value, sel.options[i].selected]);
arr = arr.reverse();
sel.length = 0;
for (i = 0; i < len; i++)
sel.add(new Option(arr[i][0], arr[i][1], false, arr[i][2]));
}
function closeinpup() {
document.getElementById('inpopup').innerHTML = '<div id="popupcont">...</div>';
document.getElementById('popup').style.display = 'none';
}
function edit(selid, what, mode) {
var act = '', id = 0;
if (mode == 'edit')
act = {0: 'Editing', 1: 'edit'};
else if (mode == 'add')
act = {0: 'Adding', 1: 'add'};
else if (mode == 'remove')
act = {0: 'Removing', 1: 'remove'};
var sel = document.getElementById(selid);
if ((mode == 'edit' || mode == 'remove') && sel.selectedIndex < 0) {
alerta('Error', '<p>You have to select an entry to ' + act[1] + ' ;-)</p>');
} else {
if (mode == 'edit' || mode == 'remove')
id = sel.options[sel.selectedIndex].value;
document.getElementById('inpopup').innerHTML = '<div class="hiftit"><img src="imgs/p.png" style="float:left;width:24px;height:24px">' + act[0] + ' «' + what + '» entry<img src="imgs/close.svg" class="imgbut" style="float:right;" onclick="closeinpup()"></div><iframe src="edinsth.php?w=' + selid + '&i=' + id + '&m=' + mode + '" class="hiframe"></iframe>';
document.getElementById('popup').style.display = 'table';
}
}
function ckf() {
// questo qua sotto resetta eventuale filtro su LocalityID in modo che se c'è valore selezionato ma non mostrato viene passato
filtsel(locselarr, '', 'LocalityID', 'locselre', 'locsearch', 'white', '#ff8080');
var selids = ['ChosenLangs[]', 'ChosenFinModes[]', 'ChosenPolicies[]', 'ChosenTags[]'], len = selids.length,
i, sel, ii;
for (i = 0; i < len; i++) {
sel = document.getElementById(selids[i]).options;
for (ii = 0; ii < sel.length; ii++)
sel[ii].selected = true;
}
document.getElementById('f').submit();
}
//-->
</script>
</head>
<body>
<nav>
<div id="hmenu">
<ul>
<?php echo($menuout); ?>
</ul>
<div class="mtit">Notifiche</div>
<div id="rightdiv">
<?php if ($account['Level'] != 'guest') echo('<img src="' . $notifs['imgoff'] . '" id="bell" class="rlinks" title="Show notifications" onclick="shidenotifs();">' . N); ?>
<img src="imgs/esci.svg" class="rlinks" title="Logout" onclick="document.location.href='logout.php';">
</div>
</div>
</nav>
<div id="fullscreen">
<div id="middlerow">
<div id="notifs-list">
<?php
if ($account['Level'] != 'guest') {
$sev_classes = array(
1 => "sev-normal",
2 => "sev-warning",
3 => "sev-error"
);
foreach ($notifs['notifs'] as $n) {
echo("<div id=\"notif-" . $n["ID"] . "\" class=\"" . $sev_classes[$n["Severity"]] . "\">" . $n["Notification"] . "</div>\n");
}
} ?>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
mysqli_close($link);
?>