コード例 #1
0
ファイル: refresh.php プロジェクト: jmorwick/mypdfdb
            $path = null;
            $dupe_paths = array();
            foreach ($dupes as $dupe_id) {
                $dupe_info = get_pdf_info($dupe_id);
                if ($path == null) {
                    $path = $dupe_info['path'];
                } else {
                    $dupe_paths[] = $dupe_info['path'];
                }
            }
            echo "merging metadata: ";
            print_r($dupes);
            $new_id = merge_pdf_metadata($dupes, $path);
            if ($new_id) {
                echo "new pdf id: {$new_id}\n";
                foreach ($dupe_paths as $dupe_path) {
                    delete_pdf_file($dupe_path);
                }
            } else {
                echo "merge failed\n";
            }
        }
    }
}
echo "Total records: " . count(find_pdfs_all()) . "\n";
echo "orphans: \n";
foreach ($orphans as $pdf_id) {
    print_r(get_pdf_info($pdf_id));
    echo "deleting path info (making this pdf an orphan)...";
    orphan_pdf($pdf_id);
}
コード例 #2
0
ファイル: lib.php プロジェクト: jmorwick/mypdfdb
function merge_pdfs($pdf_ids)
{
    // TODO: this entire function should be gaurded by some sort of mutex
    if (count($pdf_ids) < 2) {
        err_bad_input_format("expected at least 2 pdf ids");
    }
    // validate pdf arguments and gather merged pdf attributes
    $paths = array();
    foreach ($pdf_ids as $pdf_id) {
        $pdf = get_pdf_info($pdf_id);
        if (!$pdf) {
            err_bad_input_data('pdfid', $pdf_id, 'not a valid pdf id');
        }
        $paths[] = $pdf['path'];
    }
    $new_path = merge_pdf_files($paths);
    $new_id = merge_pdf_metadata($pdf_ids, $new_path);
    if (!$new_id) {
        err_internal("could not merge pdfs");
    }
}
コード例 #3
0
ファイル: weblib.php プロジェクト: jmorwick/mypdfdb
function service_delete_pdfs($args)
{
    if (count($args) == 0) {
        err_bad_input_format("expected at least 1 argument in URL (one or more pdf ids)");
    }
    // validate pdf arguments
    foreach ($args as $pdf_id) {
        if (!get_pdf_info($pdf_id)) {
            err_bad_input_data('pdfid', $pdf_id, 'not a valid pdf id');
        }
    }
    // delete pdfs
    foreach ($args as $pdf_id) {
        delete_pdf($pdf_id);
    }
}