function Modified($what, $message = '') { // plog('Modified('.$what.','.$message.')'); global $auth, $database; $m = new Modification($database); $mods = $m->Select('r_Auth = ' . $auth['ID'] . ' ORDER BY Timestamp DESC LIMIT 50'); $now = strtotime('now'); $what_json = json_encode($what); // Messages are not saved if they are a duplicate of a recent event. if (!false_or_null($mods)) { foreach ($mods as $a) { if ($now - intval($a['Timestamp']) > 30) { continue; } if (strlen($a['What']) === strlen($what_json) && matches($what_json, $a['What']) && matches($message, $a['Message'])) { /*plog("Modified matched previous message");*/ return FALSE; } } } RemoveOldModifications(); return $m->Insert(array('r_Auth' => $auth['ID'], 'What' => $what_json, 'Message' => $message, 'Timestamp' => $now)); }
$p = new Page(); if (!$p->ajax) { $p->HTML('header.html', array("###MENU###" => Dropdown_menu($p))); } $p->title = "Your Website"; $p->CSS("main.css"); $p->Jquery(); $getpost = getpost(); $p->HTML('<BR>'); $p->HTML('groundrules.html'); ///// Show recent activity // Show edit activity global $auth_database; plog("Get mods!"); $m = new Modification($auth_database); $mods = $m->Select(' Timestamp > ' . strtotime('-1 days') . ' ORDER BY Timestamp DESC'); $m_auth = new Auth($auth_database); if (!false_or_null($mods)) { $data = array(); foreach ($mods as $mod) { $user = $m_auth->Get($mod['r_Auth']); $what = ''; $w = json_decode($mod['What'], true); foreach ($w as $dataset) { foreach ($dataset as $table => $change) { $edit = strtolower($table) . ".edit"; if ($edit == "catalogcategory.edit") { $edit = "category.edit"; } else { if ($edit == "catalogexport.edit") { $edit = "export.inspect";
$a = $m_auth->Get($s['r_Auth']); if (false_or_null($a)) { continue; } $found = FALSE; foreach ($was as $u) { if (matches($u, $a['username'])) { $found = TRUE; break; } } if ($found === TRUE) { continue; } $was[] = $a['username']; $mod = $mod_model->Select(array('r_Auth' => $a['ID']), '*', "", 'ORDER BY Timestamp DESC', 1); if (!false_or_null($mod)) { $lastmod = (strtotime('now') - intval($mod[0]['Timestamp'])) / 60; if (intval($lastmod) > 0) { $lastmod = intval($lastmod) . 'm'; } else { $lastmod = ''; } } else { $lastmod = ''; } if (strlen(trim($activity)) == 0) { $activity = ' <span class="fi-skull"></span> ' . (strtotime('now') - $s['refreshed']) . 's' . ' ' . $lastmod . '</small>'; } else { $activity = '<small>' . '<span class="bottomtinytag">' . $activity . '</span> ' . (strtotime('now') - $s['refreshed']) . 's' . ' ' . $lastmod . '</small>'; }