function remove_status($id, $checkuser = false) { $dataitem = "status/post_{$id}"; if (!data_exists($dataitem)) { return; } if ($checkuser) { if (!user()) { return; } $data = json_decode(data_read($dataitem), true); if ($data['user'] !== user('id')) { return; } } data_remove($dataitem); sync_begin(); $lastidO = last_post_id(); $lastid = $lastidO; while ($lastid > 0 && !data_exists("status/post_{$lastid}")) { $lastid--; } if ($lastidO != $lastid) { data_save('status/id', $lastid); } sync_end(); }
function form_actions() { global $di_actions; /* ================= input validation ================= */ input_validate_input_regex(get_request_var_post('drp_action'), '^([a-zA-Z0-9_]+)$'); /* ==================================================== */ /* if we are to save this form, instead of display it */ if (isset($_POST['selected_items'])) { $selected_items = unserialize(stripslashes($_POST['selected_items'])); if ($_POST['drp_action'] == '1') { /* delete */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ data_remove($selected_items[$i]); } } header('Location: data_input.php'); exit; } /* setup some variables */ $di_list = ''; $i = 0; /* loop through each of the data queries and process them */ while (list($var, $val) = each($_POST)) { if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $di_list .= '<li>' . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM data_input WHERE id = ?', array($matches[1]))) . '</li>'; $di_array[$i] = $matches[1]; $i++; } } top_header(); html_start_box('<strong>' . $di_actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', ''); print "<form action='data_input.php' method='post'>\n"; if (isset($di_array) && sizeof($di_array)) { if ($_POST['drp_action'] == '1') { /* delete */ $graphs = array(); print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea' class='odd'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Data Input Method(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>{$di_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; } $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete Data Input Method(s)'>"; } else { print "<tr><td class='odd'><span class='textError'>You must select at least one data input method.</span></td></tr>\n"; $save_html = "<input type='button' value='Return' onClick='window.history.back()'>"; } print "\t<tr>\n\t\t\t<td align='right' class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($di_array) ? serialize($di_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST['drp_action'] . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n\t\t"; html_end_box(); bottom_footer(); }
function form_actions() { global $colors, $di_actions; /* if we are to save this form, instead of display it */ if (isset($_POST["selected_items"])) { $selected_items = unserialize(stripslashes($_POST["selected_items"])); if (get_request_var_post("drp_action") === "1") { /* delete */ /* do a referential integrity check */ if (sizeof($selected_items)) { foreach($selected_items as $data_input_id) { /* ================= input validation ================= */ input_validate_input_number($data_input_id); /* ==================================================== */ if (sizeof(db_fetch_assoc("SELECT * FROM data_template_data WHERE data_input_id=$data_input_id LIMIT 1"))) { $bad_ids[] = $data_input_id; }else{ $data_input_ids[] = $data_input_id; } } } if (isset($bad_ids)) { $message = ""; foreach($bad_ids as $data_input_id) { $message .= (strlen($message) ? "<br>":"") . "<i>Data Input Method " . $data_input_id . " is in use and can not be removed</i>\n"; } $_SESSION['sess_message_data_input_ref_int'] = array('message' => "<font size=-2>$message</font>", 'type' => 'info'); raise_message('data_input_ref_int'); } if (isset($data_input_ids)) { foreach($data_input_ids as $data_input_id) { data_remove($data_input_id); } } } header("Location: data_input.php"); exit; } /* setup some variables */ $di_list = ""; $i = 0; $di_array = array(); /* loop through each of the data queries and process them */ while (list($var,$val) = each($_POST)) { if (preg_match("/^chk_([0-9]+)$/", $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $di_list .= "<li>" . db_fetch_cell("SELECT name FROM data_input WHERE id='" . $matches[1] . "'") . "<br>"; $di_array[$i] = $matches[1]; } $i++; } include_once(CACTI_BASE_PATH . "/include/top_header.php"); html_start_box("<strong>" . $di_actions{get_request_var_post("drp_action")} . "</strong>", "60", $colors["header_panel"], "3", "center", ""); print "<form action='data_input.php' method='post'>\n"; if (sizeof($di_array)) { if (get_request_var_post("drp_action") === ACTION_NONE) { /* NONE */ print " <tr> <td class='textArea'> <p>" . __("You did not select a valid action. Please select 'Return' to return to the previous menu.") . "</p> </td> </tr>\n"; }elseif (get_request_var_post("drp_action") === "1") { /* delete */ $graphs = array(); print " <tr> <td class='textArea'> <p>" . __("Are you sure you want to delete the following data input methods?") . "</p> <p>$di_list</p> </td> </tr>\n"; } } else { print " <tr> <td class='textArea'> <p>" . __("You must first select a Data Input Method. Please select 'Return' to return to the previous menu.") . "</p> </td> </tr>\n"; } if (!sizeof($di_array) || get_request_var_post("drp_action") === ACTION_NONE) { form_return_button_alt(); }else{ form_yesno_button_alt(serialize($di_array), get_request_var_post("drp_action")); } html_end_box(); include_once(CACTI_BASE_PATH . "/include/bottom_footer.php"); }
function form_actions() { global $colors, $di_actions; /* if we are to save this form, instead of display it */ if (isset($_POST["selected_items"])) { $selected_items = unserialize(stripslashes($_POST["selected_items"])); if ($_POST["drp_action"] == "1") { /* delete */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ data_remove($selected_items[$i]); } } header("Location: data_input.php"); exit; } /* setup some variables */ $di_list = ""; $i = 0; /* loop through each of the data queries and process them */ while (list($var, $val) = each($_POST)) { if (ereg("^chk_([0-9]+)\$", $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $di_list .= "<li>" . db_fetch_cell("SELECT name FROM data_input WHERE id='" . $matches[1] . "'") . "<br>"; $di_array[$i] = $matches[1]; } $i++; } include_once "./include/top_header.php"; html_start_box("<strong>" . $di_actions[$_POST["drp_action"]] . "</strong>", "60%", $colors["header_panel"], "3", "center", ""); print "<form action='data_input.php' method='post'>\n"; if ($_POST["drp_action"] == "1") { /* delete */ $graphs = array(); print "\n\t\t\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>Are you sure you want to delete the following data input methods?</p>\n\t\t\t\t\t<p>{$di_list}</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n"; } if (!isset($di_array)) { print "<tr><td bgcolor='#" . $colors["form_alternate1"] . "'><span class='textError'>You must select at least one data input method.</span></td></tr>\n"; $save_html = ""; } else { $save_html = "<input type='image' src='images/button_yes.gif' alt='Save' align='absmiddle'>"; } print "\t<tr>\n\t\t\t<td align='right' bgcolor='#eaeaea'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($di_array) ? serialize($di_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>\n\t\t\t\t<a href='data_input.php'><img src='images/button_no.gif' alt='Cancel' align='absmiddle' border='0'></a>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n\t\t"; html_end_box(); include_once "./include/bottom_footer.php"; }
$v *= 1; if ($v >= $max) { continue; } $item = json_decode(data_read($k), true); $item['content'] = $item['content'][0]; $item['id'] = $v; $ret[] = $item; $c++; if ($c >= 10) { break; } } die(json_encode($ret)); } elseif (isset($_POST['rmtag'])) { data_remove('ticket/tag/' . base64_encode($_POST['rmtag'])); die; } elseif (isset($_GET['id'])) { if (!data_exists('ticket/t_' . $_GET['id'])) { die(tpl('404', array('hehe' => '123'))); } $tags = data_list('ticket/tag'); foreach ($tags as &$v) { $v = base64_decode($v); } $item = json_decode(data_read('ticket/t_' . $_GET['id']), true); $item['id'] = $_GET['id']; die(tpl('show-ticket', array('tags' => $tags, 'ticket' => $item))); } else { $tags = data_list('ticket/tag'); foreach ($tags as &$v) {
break; case 'field_remove': field_remove(); header("Location: data_input.php?action=edit&id=" . $_GET["data_input_id"]); break; case 'field_edit': include_once("./include/top_header.php"); field_edit(); include_once("./include/bottom_footer.php"); break; case 'remove': data_remove(); header("Location: data_input.php"); break; case 'edit': include_once("./include/top_header.php"); data_edit(); include_once("./include/bottom_footer.php"); break; default: include_once("./include/top_header.php"); data();
} else { $o = array(); } $c = iescape($_POST['content']); $lines = explode("\n", $c); $t = $lines[0]; unset($lines[0]); $c = implode('</br>', $lines); $o[] = array('title' => $t, 'content' => $c, 'user' => user('id')); data_save($dataitem, json_encode($o)); post_status(LANG('modify the calendar at %%', $_POST['date'])); } } elseif ($_GET['action'] == 'delete') { if (user() && user('verified') && posted('date', 'key')) { $dataitem = 'calendar/' . $_POST['date']; if (data_exists($dataitem)) { $o = json_decode(data_read($dataitem), true); } else { $o = array(); } if (isset($o[$_POST['key']])) { unset($o[$_POST['key']]); } if (count($o) <= 0) { data_remove($dataitem); } else { data_save($dataitem, json_encode($o)); } post_status(LANG('modify the calendar at %%', $_POST['date'])); } }
function form_actions() { global $colors, $di_actions; /* if we are to save this form, instead of display it */ if (isset($_POST["selected_items"])) { $selected_items = unserialize(stripslashes($_POST["selected_items"])); if ($_POST["drp_action"] == "1") { /* delete */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ data_remove($selected_items[$i]); } } header("Location: data_input.php"); exit; } /* setup some variables */ $di_list = ""; $i = 0; /* loop through each of the data queries and process them */ while (list($var, $val) = each($_POST)) { if (preg_match("/^chk_([0-9]+)\$/", $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $di_list .= "<li>" . db_fetch_cell("SELECT name FROM data_input WHERE id='" . $matches[1] . "'") . "</li>"; $di_array[$i] = $matches[1]; $i++; } } include_once "./include/top_header.php"; html_start_box("<strong>" . $di_actions[$_POST["drp_action"]] . "</strong>", "60%", $colors["header_panel"], "3", "center", ""); print "<form action='data_input.php' method='post'>\n"; if (isset($di_array) && sizeof($di_array)) { if ($_POST["drp_action"] == "1") { /* delete */ $graphs = array(); print "\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\r\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Data Input Method(s) will be deleted.</p>\r\n\t\t\t\t\t\t<p><ul>{$di_list}</ul></p>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\n"; } $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete Data Input Method(s)'>"; } else { print "<tr><td bgcolor='#" . $colors["form_alternate1"] . "'><span class='textError'>You must select at least one data input method.</span></td></tr>\n"; $save_html = "<input type='button' value='Return' onClick='window.history.back()'>"; } print "\t<tr>\r\n\t\t\t<td align='right' bgcolor='#eaeaea'>\r\n\t\t\t\t<input type='hidden' name='action' value='actions'>\r\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($di_array) ? serialize($di_array) : '') . "'>\r\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>\r\n\t\t\t\t{$save_html}\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t"; html_end_box(); include_once "./include/bottom_footer.php"; }
/***************** * Save wiki page *****************/ if (isset($_GET['save']) && user('verified')) { data_save("wiki/{$query}/content", $_POST['content']); $stat = LANG('updated wiki page') . ' : '; $stat .= '<a href="' . BASE . 'wiki?p=' . urlencode($pquery) . '">' . $pquery . '</a>'; post_status($stat, 'did', false); die; } /******************* * Delete wiki page *******************/ if (isset($_GET['delete']) && user('verified')) { data_remove("wiki/{$query}/content"); data_remove("wiki/{$query}/attachments"); foreach (scandir("data/wiki/{$query}") as $f) { if (substr($f, 0, 4) == 'att_') { $f = "data/wiki/{$query}/{$f}"; if (!is_dir($f)) { unlink($f); } } } delEmptyTree("data/wiki/{$query}"); redirect('/wiki?p=' . urlencode($pquery)); die; } /******************** * Delete attachment ********************/