|
@@ -7,25 +7,30 @@ require('include/muoribenejson.php');
|
|
|
require('include/sessionstart.php');
|
|
|
require('include/myconn.php');
|
|
|
require('include/getadmacc.php');
|
|
|
-if ($account['Level']=='guest')
|
|
|
- muoribene('Sorry, you are not authorized.',true);
|
|
|
+if ($account['Level'] == 'guest')
|
|
|
+ muoribene('Sorry, you are not authorized.', true);
|
|
|
|
|
|
-if (array_key_exists('act',$_GET) && $_GET['act']=='markread' && array_key_exists('id',$_GET) && preg_match('/^[0-9]+$/',$_GET['id'])===1) {
|
|
|
- $_GET['id']+=0;
|
|
|
- mysqli_query($link,'UPDATE Notifications SET Seen=1 WHERE ID='.$_GET['id'])
|
|
|
- or muoribene(mysqli_error($link),true);
|
|
|
- $res=mysqli_query($link,'SELECT ID FROM Notifications WHERE Seen=0')
|
|
|
- or muoribene(mysqli_error($link),true);
|
|
|
- echo('{"hmunseen":'.mysqli_num_rows($res).'}'.N);
|
|
|
-} elseif (array_key_exists('act',$_GET) && $_GET['act']=='loadchunk' && array_key_exists('chunk',$_GET) && preg_match('/^[0-9]+$/',$_GET['chunk'])===1) {
|
|
|
- $_GET['chunk']+=0;
|
|
|
- $chunksize=20; // questo dev'essere uguale in include/notifs.php
|
|
|
- $res=mysqli_query($link,'SELECT * FROM Notifications ORDER BY Microtime DESC LIMIT '.($_GET['chunk']*$chunksize).','.$chunksize)
|
|
|
- or muoribene(mysqli_error($link),true);
|
|
|
- $buf=array();
|
|
|
- while ($row=mysqli_fetch_assoc($res)) {
|
|
|
- ($row['Seen']==0) ? $notifclass='notifunseen' : $notifclass='notifseen';
|
|
|
- $buf[]='<div id="notif-'.$row['ID'].'" class="'.$notifclass.'" onclick="markread(this)">'.strftime('%d/%m/%y %T',$row['Microtime']).': '.$row['Notification'].'</div>';
|
|
|
+if (array_key_exists('act', $_GET) && $_GET['act'] == 'markread' && array_key_exists('id', $_GET) && preg_match('/^[0-9]+$/', $_GET['id']) === 1) {
|
|
|
+ $_GET['id'] += 0;
|
|
|
+ mysqli_query($link, 'UPDATE Notifications SET Seen=1 WHERE ID=' . $_GET['id'])
|
|
|
+ or muoribene(mysqli_error($link), true);
|
|
|
+ $res = mysqli_query($link, 'SELECT ID FROM Notifications WHERE Seen=0')
|
|
|
+ or muoribene(mysqli_error($link), true);
|
|
|
+ echo('{"hmunseen":' . mysqli_num_rows($res) . '}' . N);
|
|
|
+} elseif (array_key_exists('act', $_GET) && $_GET['act'] == 'delete' && array_key_exists('id', $_GET) && preg_match('/^[0-9]+$/', $_GET['id']) === 1) {
|
|
|
+ $_GET['id'] += 0;
|
|
|
+ mysqli_query($link, 'DELETE FROM Notifications WHERE ID=' . $_GET['id'])
|
|
|
+ or muoribene(mysqli_error($link), true);
|
|
|
+ echo('{"deleted":' . true . '}' . N);
|
|
|
+} elseif (array_key_exists('act', $_GET) && $_GET['act'] == 'loadchunk' && array_key_exists('chunk', $_GET) && preg_match('/^[0-9]+$/', $_GET['chunk']) === 1) {
|
|
|
+ $_GET['chunk'] += 0;
|
|
|
+ $chunksize = 20; // questo dev'essere uguale in include/notifs.php
|
|
|
+ $res = mysqli_query($link, 'SELECT * FROM Notifications ORDER BY Microtime DESC LIMIT ' . ($_GET['chunk'] * $chunksize) . ',' . $chunksize)
|
|
|
+ or muoribene(mysqli_error($link), true);
|
|
|
+ $buf = array();
|
|
|
+ while ($row = mysqli_fetch_assoc($res)) {
|
|
|
+ ($row['Seen'] == 0) ? $notifclass = 'notifunseen' : $notifclass = 'notifseen';
|
|
|
+ $buf[] = '<div id="notif-' . $row['ID'] . '" class="' . $notifclass . '" onclick="markread(this)">' . strftime('%d/%m/%y %T', $row['Microtime']) . ': ' . $row['Notification'] . '</div>';
|
|
|
}
|
|
|
echo(json_encode($buf));
|
|
|
} elseif (array_key_exists('act',$_GET) && $_GET['act']=='loadnew' && array_key_exists('lmt',$_GET) && preg_match('/^[0-9]+(\.[0-9]+)?$/',$_GET['lmt'])===1) {
|