$id, 'notice' => $notice, 'url' => $url, 'category' => $category, 'priority' => $priority, ); $queue[$queuekey] = $toqueue; $queueout = fopen($notice_path, "w"); if(!$queueout) { log_error("Could not open {$notice_path} for writing"); return; } fwrite($queueout, serialize($queue)); fclose($queueout); log_error("New alert found: {$notice}"); /* soekris */ if(file_exists("/dev/led/error")) exec("/bin/echo 1 > /dev/led/error"); /* wrap */ if(file_exists("/dev/led/led2")) exec("/bin/echo f5 > /dev/led/led2"); return $queuekey; } function get_notices($category = "all") { if(file_exists('/tmp/notices')) { $queue = unserialize(file_get_contents('/tmp/notices')); if(!$queue) return false; if($category != 'all') { foreach($queue as $time => $notice) { if(strtolower($notice['category']) == strtolower($category)) $toreturn[$time] = $notice; } return $toreturn; } else { return $queue; } } else { return false; } } function close_notice($id) { global $notice_path; require_once("util.inc"); /* soekris */ if(file_exists("/dev/led/error")) exec("/bin/echo 0 > /dev/led/error"); /* wrap */ if(file_exists("/dev/led/led2")) exec("/bin/echo 0 > /dev/led/led2"); $ids = array(); if(!$notices = get_notices()) return; if($id == "all") { unlink_if_exists($notice_path); return; } foreach(array_keys($notices) as $time) { if($id == $time) { unset($notices[$id]); break; } } foreach($notices as $key => $notice) { $ids[$key] = $notice['id']; } foreach($ids as $time => $tocheck) { if($id == $tocheck) { unset($notices[$time]); break; } } if(count($notices) != 0) { $queueout = fopen($notice_path, "w"); fwrite($queueout, serialize($notices)); fclose($queueout); } else { unlink_if_exists($notice_path); } return; } function dump_xml_notices() { require_once("xmlparse.inc"); global $notice_path, $listtags; $listtags[] = 'notice'; if(!$notices = get_notices()) return; foreach($notices as $time => $notice) { $notice['time'] = $time; $toput['notice'][] = $notice; } $xml = dump_xml_config($toput, 'notices'); return $xml; } function print_notices($notices, $category = "all") { foreach($notices as $notice) { if($category != "all") { if(in_array($notice['category'], $category)) $categories[] = $notice['category']; } else { $categories[] = $notice['category']; } } $categories = array_unique($categories); sort($categories); foreach($categories as $category) { $toreturn .= "