Changeset 3875
- Timestamp:
- 06/15/06 08:18:04 (2 years ago)
- Files:
-
- trunk/wp-links-opml.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-links-opml.php
r3470 r3875 1 <?php 2 $doing_rss = 1; 1 <?php 3 2 4 require('wp-blog-header.php'); 3 if (empty($wp)) { 4 require_once('./wp-config.php'); 5 wp(); 6 } 7 5 8 header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true); 6 9 $link_cat = $_GET['link_cat']; 7 if ((empty ($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {8 $sql_cat = '';10 if ((empty ($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) { 11 $link_cat = ''; 9 12 } else { // be safe 10 $link_cat = ''.urldecode($link_cat).''; 11 $link_cat = addslashes_gpc($link_cat); 12 $link_cat = intval($link_cat); 13 if ($link_cat != 0) { 14 $sql_cat = "AND $wpdb->links.link_category = $link_cat"; 15 $cat_name = $wpdb->get_var("SELECT $wpdb->linkcategories.cat_name FROM $wpdb->linkcategories WHERE $wpdb->linkcategories.cat_id = $link_cat"); 16 if (!empty($cat_name)) { 17 $cat_name = ": category $cat_name"; 18 } 19 } 13 $link_cat = '' . urldecode($link_cat) . ''; 14 $link_cat = intval($link_cat); 20 15 } 21 16 ?><?php echo '<?xml version="1.0"?'.">\n"; ?> 22 <!-- generator="wordpress/<?php echo $wp_version?>" -->17 <!-- generator="wordpress/<?php bloginfo_rss('version') ?>" --> 23 18 <opml version="1.0"> 24 19 <head> … … 27 22 </head> 28 23 <body> 29 <?php $sql = "SELECT $wpdb->links.link_url, link_rss, $wpdb->links.link_name, $wpdb->links.link_category, $wpdb->linkcategories.cat_name, link_updated 30 FROM $wpdb->links 31 JOIN $wpdb->linkcategories on $wpdb->links.link_category = $wpdb->linkcategories.cat_id 32 AND $wpdb->links.link_visible = 'Y' 33 $sql_cat 34 ORDER BY $wpdb->linkcategories.cat_name, $wpdb->links.link_name \n"; 35 //echo("<!-- $sql -->"); 36 $prev_cat_id = 0; 37 $results = $wpdb->get_results($sql); 38 if ($results) { 39 foreach ($results as $result) { 40 if ($result->link_category != $prev_cat_id) { // new category 41 if ($prev_cat_id != 0) { // not first time 24 <?php 25 26 if (empty ($link_cat)) 27 $cats = get_categories("type=link&hierarchical=0"); 28 else 29 $cats = array (get_category($link_cat)); 30 31 foreach ((array) $cats as $cat) { 42 32 ?> 43 </outline>33 <outline type="category" title="<?php echo wp_specialchars($cat->cat_name); ?>"> 44 34 <?php 45 } // end if not first time 35 36 $bookmarks = get_bookmarks("category={$cat->cat_ID}"); 37 foreach ((array) $bookmarks as $bookmark) { 46 38 ?> 47 <outline type="category" title="<?php echo wp_specialchars($result->cat_name); ?>">39 <outline text="<?php echo wp_specialchars($bookmark->link_name); ?>" type="link" xmlUrl="<?php echo wp_specialchars($bookmark->link_rss); ?>" htmlUrl="<?php echo wp_specialchars($bookmark->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $bookmark->link_updated) echo $bookmark->link_updated; ?>" /> 48 40 <?php 49 $prev_cat_id = $result->link_category; 50 } // end if new category 41 42 } 51 43 ?> 52 <outline text="<?php echo wp_specialchars($result->link_name); ?>" type="link" xmlUrl="<?php echo wp_specialchars($result->link_rss); ?>" htmlUrl="<?php echo wp_specialchars($result->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $result->link_updated) echo $result->link_updated; ?>" />44 </outline> 53 45 <?php 54 } // end foreach 55 ?> 56 </outline> 57 <?php 58 } // end if 46 47 } 59 48 ?> 60 49 </body>
