* @version 0.1 * * Requires WordPress >=1.5 and PHP >=4.3 * * Inspired by dailydelicious by Stephen Eyre * http://www.dot-totally.co.uk/dailydelicious.txt * *
 * USAGE:
 * 
 * 1) Edit the section below.  At the very least use your Furl userid.
 * 
 * 2) Put there file somewhere on the server where you run WordPress.
 * 
 * 3) Run this script to get a posting
 *
 * 4) See the 
classes and customize your CSS how you like * * 5) Set up a cronjob or somesuch to run this script regularly * (probably every $furl['maxdays']) * *
* */ // Configure these: /** absolute path to WP installation, no trailing */ $wp_path = '/var/www/wordpress'; /** furl userid number */ $furl['userid'] = 3694; /* * these options are all described here * http: 8www.furl.net/shareSiteAdvanced.jsp * from which you'll get a query like this: * userid=3694&maxitems=99&maxdays=10&spawn=y&furl=n&comments=y&date=n&clippings=y&ratings=y&html=y */ $furl['maxitems'] = 99; $furl['maxdays'] = 1; $furl['spawn'] = 'y'; $furl['furl'] = 'n'; $furl['comments'] = 'y'; $furl['date'] = 'n'; $furl['clippings'] = 'y'; $furl['ratings'] = 'y'; $furl['html'] = 'y'; /** anything you want to precede the Furl-generated content */ $furl_header = '

Grabbed from my furl.

'; /** anything you want to follow the Furl-generated content */ $furl_footer = ''; $wp_userid = 2; // User ID to post in $wp_catid = 1; // Category in which to put Furl post $wp_allowcomments = 'open'; // Allow comments on all links? (open or closed) $wp_allowpings = 'open'; // Allow pingbacks on all links? (open or closed) $wp_posttitle = 'Today\'s bookmarks'; // Title for your post $wp_postname = 'furl'; // Post name (for permalinks, etc) // BELOW HERE LEAVE ALONE require_once($wp_path . '/wp-config.php'); define("FURL_SITELATEST_BASE", "http://www.furl.net/siteLatest.jsp?"); // http_build_query was introduced in PHP 5 // so hack in a replacement for earlier versions if (!function_exists('http_build_query')) { function http_build_query($formdata) { $pairs = array(); foreach ($formdata as $key => $value) { $pairs[] = "$key=$value"; } return implode($pairs, '&'); } } $data_source = FURL_SITELATEST_BASE.http_build_query($furl); $today = getdate(); $date = mktime(0,0,0,$today['mon'], $today['mday'], $today['year']); $now = current_time('mysql'); $now_gmt = current_time('mysql', 1); $dt = date("Y-m-d"); $data = file_get_contents($data_source); furl_post_entry($data); function furl_post_entry ($body) { global $furl_header, $furl_footer, $wpdb, $wp_userid, $wp_catid, $wp_posttitle, $wp_allowcomments, $wp_allowpings, $wp_postname, $now, $now_gmt; $content = $furl_header.$body.$furl_footer; // convert newlines to spaces so WordPress doesn't make the
's $content = strtr($content, "\r\n", ' '); // Build Query $query = "INSERT INTO $wpdb->posts " . "(`post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_status`, `comment_status`, `ping_status`, `post_name`, `post_modified`, `post_modified_gmt`) " . "VALUES " . "(" . $wp_userid . ", '" . $now . "', '" . $now_gmt . "', '" . addslashes($content) . "', '" . addslashes($wp_posttitle) . "', 'publish', '" . $wp_allowcomments . "', '" . $wp_allowpings . "', '" . $wp_postname . "', '" . $now . "', '" . $now_gmt . "');"; // Run Query $wpdb->query($query); // Get ID for category $post_ID = $wpdb->get_var("SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1"); // Build category query $query = "INSERT INTO $wpdb->post2cat " . "(`post_id`, `category_id`) " . "VALUES " . "('" . $post_ID . "', '" . $wp_catid . "');"; // Run Category Query $wpdb->query($query); } /* * License * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ?>