Esempio n. 1
0
    $category = pg_escape_string($_REQUEST['category']);
    $CategoryID = $Category->FetchByName($category);
    if (!$CategoryID) {
        $msg = "category '{$category}' not found";
        syslog(LOG_ERR, $msg . " User = '******' in " . __FILE__ . ':' . __LINE__);
        die($msg);
    }
} else {
    $msg = "category not supplied";
    syslog(LOG_ERR, $msg . " User = '******' in " . __FILE__ . ':' . __LINE__);
    die($msg);
}
if ($submit) {
    pg_exec($db, "BEGIN");
    $WatchList = new WatchList($db);
    $WatchList->EmptyTheListCategory($User->id, $wlid, $Category->id);
    $ports = $_POST["ports"];
    if ($ports) {
        $WatchListElement = new WatchListElement($db);
        // make sure we are pointing at the start of the array.
        reset($ports);
        while (list($key, $value) = each($ports)) {
            $WatchListElement->Add($User->id, $wlid, $value);
            $result = pg_exec($db, $sql);
            ${"port_" . $value} = 1;
            if (!$result) {
                syslog(LOG_ERR, $_SERVER["PHP_SELF"] . ": could not clear watch list '{$wlid}' owned by '{$User->id}' of element '{$value}' in " . __FILE__ . ':' . __LINE__);
                die("error clear list before saving");
            }
        }
    }