<hr class="line-stroke"> <div class="clearfix"></div> <?php if (have_posts()) { while (have_posts()) { the_post(); the_content(); } } ?> <div class="clearfix"></div> <?php $research_pdf = get_post_meta($post->ID, 'authors_section_pdf', true); $pdf_id = get_pdf_id($research_pdf); $file_path = filesize(get_attached_file($pdf_id)); $pdf_size = $file_path; if (!empty($research_pdf)) { echo '<a class="button float-right bottom-spacing" target="_blank" href="' . $research_pdf . '">View (PDF, ' . formatSizeUnits($pdf_size) . ')</a>'; } ?> </div> <!-- Research ends here--> </div> <?php //sidebar comes here get_sidebar(); ?> </div>
$orphans = array(); // check every existing db record foreach (find_pdfs_all() as $pdf_id) { $pdf = get_pdf_info($pdf_id); if ($pdf) { $path = $pdf['path']; $cpath = canonicalize_path($path); if (!file_exists(get_full_path($path))) { // the file was deleted. keep the data, but make it an orphan (no path) echo "*** file {$cpath} doesn't exist! adding to orphans list\n"; $orphans[] = $pdf_id; } else { if ($path != $cpath) { // the path is not a cannonical path... fix it echo "path not canoncial: {$path} -> {$cpath}\n"; $other_pdf_id = get_pdf_id($cpath); if ($other_pdf_id) { // another record is using this file with an alternative path name... merge the records only // TODO: merge metadata only -- they're using the same file echo "redundant path with {$other_pdf_id}: merge with {$pdf_id} \n"; merge_pdf_metadata(array($pdf_id, $other_pdf_id), $cpath); } else { echo "update path to be canonical...\n"; $pdf['path'] = $cpath; unset($pdf['id']); update_pdf_info($pdf_id, $pdf); } } } // check for duplicates of this file and merge if necessary $dupes = get_pdf_ids_with_hash($pdf['md5']);