function nel_clean_exit($dataforce, $die) { $dataforce['post_links'] = nel_cache_links($dataforce['post_links']); nel_write_multi_cache($dataforce); if ($die) { die; } if (STUFF_DONE) { echo '<meta http-equiv="refresh" content="10;URL=' . PHP_SELF2 . PHP_EXT . '">'; } else { echo '<meta http-equiv="refresh" content="1;URL=' . PHP_SELF2 . PHP_EXT . '">'; } die; }
function nel_delete_content($dataforce, $sub, $type, $plugins, $dbh) { $id = $sub[1]; if (!is_numeric($id)) { nel_derp(13, array('origin' => 'DELETE')); } $flag = FALSE; $hashed_pass = nel_hash($dataforce['pass'], $plugins); $hashed_pass = utf8_substr($hashed_pass, 0, 16); $result = $dbh->query('SELECT post_number,password,response_to,mod_post FROM ' . POSTTABLE . ' WHERE post_number=' . $id . ''); $post_data = $result->fetch(PDO::FETCH_ASSOC); unset($result); if (!empty($_SESSION) && !$_SESSION['ignore_login']) { $temp = $_SESSION['ignore_login']; if ($_SESSION['perms']['perm_delete']) { if ($post_data['mod_post'] === '0') { $flag = TRUE; } else { $staff_type = $_SESSION['settings']['staff_type']; if ($post_data['mod_post'] === '3' && $staff_type === 'admin') { $flag = TRUE; } else { if ($post_data['mod_post'] === '2' && $staff_type === 'admin' || $staff_type === 'moderator') { $flag = TRUE; } else { if ($flag = $post_data['mod_post'] === '1' && $staff_type === 'admin' || $staff_type === 'moderator' || $staff_type === 'janitor') { $flag = TRUE; } } } } } $_SESSION['ignore_login'] = $flag ? TRUE : $temp; } else { $flag = $hashed_pass === $post_data['password'] ? TRUE : FALSE; $temp = TRUE; } if ($flag) { if ($type === 'THREAD') { $result = $dbh->query('SELECT post_number FROM ' . POSTTABLE . ' WHERE response_to=' . $id . ' OR post_number=' . $id . ''); $content_refs = $result->fetchALL(PDO::FETCH_COLUMN, 0); unset($result); foreach ($content_refs as $ref) { $dbh->query('DELETE FROM ' . FILETABLE . ' WHERE post_ref=' . $ref . ''); $dbh->query('DELETE FROM ' . POSTTABLE . ' WHERE post_number=' . $ref . ''); preg_replace('#p([0-9]+)t' . $ref . '#', '', $dataforce['post_links']); } nel_eraser_gun(PAGE_PATH . $id, NULL, TRUE); nel_eraser_gun(SRC_PATH . $id, NULL, TRUE); nel_eraser_gun(THUMB_PATH . $id, NULL, TRUE); nel_update_archive_status($dataforce, $dbh); } else { if ($type === 'POST') { $result = $dbh->query('SELECT filename,extension,preview_name FROM ' . FILETABLE . ' WHERE post_ref=' . $id . ''); $file_data = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); $dbh->query('DELETE FROM ' . FILETABLE . ' WHERE post_ref=' . $id . ''); foreach ($file_data as $refs) { nel_eraser_gun(SRC_PATH . $post_data['response_to'], $refs['filename'] . $refs['extension'], FALSE); if ($refs['preview_name']) { nel_eraser_gun(THUMB_PATH . $post_data['response_to'], $refs['preview_name'], FALSE); } } if ($dataforce['only_delete_file']) { $dbh->query('UPDATE ' . POSTTABLE . ' SET has_file=0 WHERE post_number=' . $id . ''); } else { $dbh->query('DELETE FROM ' . POSTTABLE . ' WHERE post_number=' . $id . ''); $result = $dbh->query('SELECT post_count FROM ' . POSTTABLE . ' WHERE post_number=' . $post_data['response_to'] . ''); $pcount = $result->fetch(PDO::FETCH_ASSOC); unset($result); $result = $dbh->query('SELECT post_number,post_time FROM ' . POSTTABLE . ' WHERE response_to=' . $post_data['response_to'] . ' ORDER BY post_number desc'); $ptimes = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); $dbh->query('UPDATE ' . POSTTABLE . ' SET post_count=' . ($pcount['post_count'] - 1) . ', last_update=' . $ptimes[0]['post_time'] . ', last_response=' . $ptimes[0]['post_number'] . ' WHERE post_number=' . $post_data['response_to'] . ''); preg_replace('#p' . $id . 't([0-9]+)#', '', $dataforce['post_links']); } } else { if ($type === 'FILE') { // add check for updating post as no files if they're all gone $fnum = $sub[2]; $result = $dbh->query('SELECT filename,extension,preview_name FROM ' . FILETABLE . ' WHERE post_ref=' . $id . ' AND file_order=' . $fnum . ''); $file_data = $result->fetch(PDO::FETCH_ASSOC); unset($result); if ($file_data !== FALSE) { $dbh->query('DELETE FROM ' . FILETABLE . ' WHERE post_ref=' . $id . ' AND file_order=' . $fnum . ''); if ($post_data['response_to'] == 0) { nel_eraser_gun(SRC_PATH . $post_data['post_number'], $file_data['filename'] . $file_data['extension'], FALSE); if ($file_data['preview_name']) { nel_eraser_gun(THUMB_PATH . $post_data['post_number'], $file_data['preview_name'], FALSE); } } else { nel_eraser_gun(SRC_PATH . $post_data['response_to'], $file_data['filename'] . $file_data['extension'], FALSE); if ($file_data['preview_name']) { nel_eraser_gun(THUMB_PATH . $post_data['response_to'], $file_data['preview_name'], FALSE); } } } } } } nel_cache_links(); } else { nel_derp(20, array('origin' => 'DELETE')); } if (!empty($_SESSION)) { $_SESSION['ignore_login'] = $temp; } }