<?php include_once 'data.php'; include_once 'functions.php'; $export_files = read_export_files(0); if (!empty($_POST['omnitool']) && !empty($export_files)) { database_connect($database_path, 'library'); $user_query = $dbHandle->quote($_SESSION['user_id']); $dbHandle->beginTransaction(); // SAVE TO SHELF if ($_POST['omnitool'] == '1') { while (list(, $value) = each($export_files)) { $file_query = $dbHandle->quote($value); $result = $dbHandle->query("SELECT COUNT(*) FROM library WHERE id={$file_query}"); $exists = $result->fetchColumn(); $result = null; if ($exists == 1) { $dbHandle->exec("INSERT OR IGNORE INTO shelves (userID,fileID) VALUES ({$user_query},{$file_query})"); } } @unlink($temp_dir . DIRECTORY_SEPARATOR . 'lib_' . session_id() . DIRECTORY_SEPARATOR . 'shelf_files'); } // REMOVE FROM SHELF if ($_POST['omnitool'] == '2') { while (list(, $value) = each($export_files)) { $file_query = $dbHandle->quote($value); $dbHandle->exec("DELETE FROM shelves WHERE fileID={$file_query} AND userID={$user_query}"); } @unlink($temp_dir . DIRECTORY_SEPARATOR . 'lib_' . session_id() . DIRECTORY_SEPARATOR . 'shelf_files'); } // SAVE TO PROJECT
function delete_record($dbHandle, $files) { global $database_path; settype($files, "array"); // get PDF filenames of deleted items $result = $dbHandle->query("SELECT file FROM library WHERE id IN (" . join(',', $files) . ")"); $filenames = $result->fetchAll(PDO::FETCH_COLUMN); $result = null; // delete PDFs, supplementary files and PNGs while (list(, $filename) = each($filenames)) { if (is_file('library' . DIRECTORY_SEPARATOR . $filename)) { unlink('library' . DIRECTORY_SEPARATOR . $filename); } $integer1 = sprintf("%05d", intval($filename)); $supplementary_files = glob('library/supplement/' . $integer1 . '*', GLOB_NOSORT); if (is_array($supplementary_files)) { foreach ($supplementary_files as $supplementary_file) { @unlink($supplementary_file); } } $png_files = glob('library/pngs/' . $integer1 . '*.png', GLOB_NOSORT); if (is_array($png_files)) { foreach ($png_files as $png_file) { @unlink($png_file); } } } // delete from clipboard, make sure session_write_close was not called before this if (!empty($_SESSION['session_clipboard'])) { $_SESSION['session_clipboard'] = array_diff($_SESSION['session_clipboard'], $files); } // delete from main database $dbHandle->beginTransaction(); $dbHandle->exec("DELETE FROM library WHERE id IN (" . join(',', $files) . ")"); $dbHandle->exec("DELETE FROM shelves WHERE fileID IN (" . join(',', $files) . ")"); $dbHandle->exec("DELETE FROM filescategories WHERE fileID IN (" . join(',', $files) . ")"); $dbHandle->exec("DELETE FROM projectsfiles WHERE fileID IN (" . join(',', $files) . ")"); $dbHandle->exec("DELETE FROM notes WHERE fileID IN (" . join(',', $files) . ")"); $dbHandle->exec("DELETE FROM yellowmarkers WHERE filename IN ('" . join("','", $filenames) . "')"); $dbHandle->exec("DELETE FROM annotations WHERE filename IN ('" . join("','", $filenames) . "')"); $dbHandle->commit(); $dbHandle = null; // delete full texts $fdbHandle = database_connect($database_path, 'fulltext'); $fdbHandle->exec("DELETE FROM full_text WHERE fileID IN (" . join(',', $files) . ")"); $fdbHandle = null; // delete discussions if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'database' . DIRECTORY_SEPARATOR . 'discussions.sq3')) { $fdbHandle = database_connect($database_path, 'discussions'); $fdbHandle->exec("DELETE FROM filediscussion WHERE fileID IN (" . join(',', $files) . ")"); $fdbHandle = null; } // delete PDF bookmarks and history if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'database' . DIRECTORY_SEPARATOR . 'history.sq3')) { $fdbHandle = database_connect($database_path, 'history'); $fdbHandle->beginTransaction(); $fdbHandle->exec("DELETE FROM usersfiles WHERE fileID IN (" . join(',', $files) . ")"); $fdbHandle->exec("DELETE FROM bookmarks WHERE file IN ('" . join("','", $filenames) . "')"); $fdbHandle->commit(); $fdbHandle = null; } // update export files cache $export_files = read_export_files(0); $export_files = array_diff($export_files, $files); $export_files = array_values($export_files); cache_clear(); save_export_files($export_files); if (!empty($error)) { return $error; } }
include_once 'data.php'; include_once 'functions.php'; session_write_close(); if (!isset($_GET['from'])) { $from = '0'; } else { settype($_GET['from'], "integer"); $from = $_GET['from']; } // CACHING if (isset($_GET['from']) && !isset($_GET['browse']['No PDF']) && !isset($_GET['browse']['Not Indexed'])) { $cache_name = cache_name(); $db_change = database_change(array('library', 'shelves', 'projects', 'projectsusers', 'projectsfiles', 'filescategories', 'notes')); cache_start($db_change); $total_files_array = read_export_files($db_change); } if (!isset($_GET['project'])) { $project = ''; } else { $project = $_GET['project']; } if (!isset($_SESSION['limit'])) { $limit = 10; } else { settype($_SESSION['limit'], "integer"); $limit = $_SESSION['limit']; } if (!isset($_SESSION['orderby'])) { $orderby = 'id'; } else {
include_once 'data.php'; include_once '../functions.php'; session_write_close(); if (!isset($_GET['from'])) { $from = '0'; } else { settype($_GET['from'], "integer"); $from = $_GET['from']; } // CACHING if (isset($_GET['from']) && $_GET['from'] > 0 && !isset($_GET['browse']['No PDF']) && !isset($_GET['browse']['Not Indexed'])) { $cache_name = cache_name(); $db_change = database_change(array('library', 'shelves', 'projects', 'projectsusers', 'projectsfiles', 'filescategories', 'notes')); cache_start($db_change); $export_files = read_export_files($db_change); } if (!isset($_GET['project'])) { $project = ''; } else { $project = $_GET['project']; } $limit = 10; if (!isset($_SESSION['orderby'])) { $orderby = 'id'; } else { $orderby = $_SESSION['orderby']; } if (!isset($_SESSION['display'])) { $display = 'brief'; } else {