Exemplo n.º 1
0
         save_export_files($total_files_array);
         $display_files_array = array_slice($total_files_array, $from, $limit);
         $display_files = join(",", $display_files_array);
         $display_files = "id IN ({$display_files})";
         $result = $dbHandle->query("SELECT id,file,authors,title,journal,secondary_title,year,volume,pages,abstract,uid,doi,url,addition_date,rating,bibtex\r\n                                                FROM library WHERE {$display_files}");
     }
 } else {
     if (!isset($total_files_array)) {
         if (!empty($category_sql)) {
             $result = $dbHandle->query("SELECT id FROM library {$all_in} {$where} id IN (" . $category_sql . ") ORDER BY {$orderby} COLLATE NOCASE {$ordering}");
         } else {
             $result = $dbHandle->query("SELECT id FROM library {$all_in} {$where} {$browse_string} ORDER BY {$orderby} COLLATE NOCASE {$ordering}");
         }
         $total_files_array = $result->fetchAll(PDO::FETCH_COLUMN);
         $result = null;
         save_export_files($total_files_array);
     }
     $display_files_array = array_slice($total_files_array, $from, $limit);
     $display_files = join(",", $display_files_array);
     $display_files = "id IN ({$display_files})";
     $result = $dbHandle->query("SELECT id,file,authors,title,journal,secondary_title,year,volume,pages,abstract,uid,doi,url,addition_date,rating,bibtex\r\n                                    FROM library WHERE {$display_files}");
 }
 $rows = count($total_files_array);
 $total_files_array = null;
 if ($rows > 0) {
     $result = $result->fetchAll(PDO::FETCH_ASSOC);
     $dbHandle = null;
     //SORT QUERY RESULTS
     $tempresult = array();
     foreach ($result as $row) {
         $key = array_search($row['id'], $display_files_array);
Exemplo n.º 2
0
        $result = $dbHandle->query("SELECT COUNT(*) FROM library WHERE id={$file_query}");
        $exists = $result->fetchColumn();
        $result = null;
        $dbHandle = null;
        if ($exists == 1) {
            $_SESSION['session_clipboard'][] = $_GET['file'];
            echo "added";
        } else {
            echo 'Error! This item does not exist anymore.';
        }
    } else {
        if (!in_array($_GET['file'], $_SESSION['session_clipboard'])) {
            $_SESSION['session_clipboard'][] = $_GET['file'];
            $_SESSION['session_clipboard'] = array_unique($_SESSION['session_clipboard']);
            echo "added";
        } else {
            $key = array_search($_GET['file'], $_SESSION['session_clipboard']);
            unset($_SESSION['session_clipboard'][$key]);
            if (isset($_GET['selection']) && $_GET['selection'] == 'clipboard') {
                $export_files = read_export_files(0);
                $id = array_search($_GET['file'], $export_files);
                if ($id !== false) {
                    unset($export_files[$id]);
                    $export_files = array_values($export_files);
                    save_export_files($export_files);
                }
            }
            echo "removed";
        }
    }
}
Exemplo n.º 3
0
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;
    }
}
Exemplo n.º 4
0
<?php

include_once 'data.php';
include_once '../functions.php';
$export_files = array();
$export_files = read_export_files(0);
if (isset($_GET['action']) && $_GET['action'] == 'add') {
    $_SESSION['session_clipboard'] = array();
    $_SESSION['session_clipboard'] = $export_files;
} else {
    $_SESSION['session_clipboard'] = array();
    if (isset($_GET['selection']) && $_GET['selection'] == 'clipboard') {
        save_export_files(array());
    }
}
Exemplo n.º 5
0
         $result_ids = $result->fetchAll(PDO::FETCH_COLUMN);
     }
     $result = null;
     $dbHandle = null;
     $result_string = join(",", $result_ids);
     $result_string = "id IN ({$result_string})";
     database_connect($database_path, 'library');
     $result = $dbHandle->query("SELECT id FROM library {$where} {$in} {$result_string} ORDER BY {$orderby} COLLATE NOCASE {$ordering}");
     $result_array = $result->fetchAll(PDO::FETCH_COLUMN);
     $rows = count($result_array);
     $result = null;
 }
 //PULL DATA FOR ITEMS TO DISPLAY FROM DATABASE
 $limited_result = array();
 if (!empty($result_array)) {
     save_export_files($result_array);
     $limited_result = array_slice($result_array, $from, $limit);
     $result_string = join(",", $limited_result);
     $result_string = "id IN ({$result_string})";
     $result = $dbHandle->query("SELECT id,file,authors,title,journal,secondary_title,year,volume,pages,abstract,uid,doi,url,addition_date,rating FROM library WHERE {$result_string} ORDER BY {$orderby} COLLATE NOCASE {$ordering}");
     $result = $result->fetchAll(PDO::FETCH_ASSOC);
     $dbHandle = null;
 }
 //SAVE SEARCH IN CACHE
 if ($_GET['select'] != 'clipboard' && !isset($searches[$md5_query])) {
     $searches[$md5_query]['result'] = $result_array;
     $searches[$md5_query]['query_time'] = time();
     save_search($searches_file, $searches);
 }
 //TRUNCATE SHELF FILES ARRAY TO ONLY DISPLAYED FILES IMPROVES PERFROMANCE FOR LARGE SHELVES
 if (count($shelf_files) > 5000) {