'); # What string denotes a tear?
define('MAX_BEFORE_TEAR',2); # How many items do we allow on the home-page before adding a tearline?
$initialPublishState=$wfPublish[$automatic_publish];
# Stop configuring now!
require_once($wp_path . '/wp-config.php');
# A counter, counts the number of items we have seen so far
$counter=0;
function startElement($parser, $name, $attrs)
{
global $content;
if ($name == "POSTS") {
$content = $content . 'Shared bookmarks for del.icio.us user '
. FULLNAME
. " on " . $attrs["DT"] . "\n\n";
}
else {
# Increment the counter. We are counting using normal counting numbers (1 biased) the number of items that have been processed.
global $empty;
global $counter;
$empty = false;
if ($counter == MAX_BEFORE_TEAR)
{
# Add in the tearstring if we have hit the required number of items.
$content = $content . TEARSTRING;
}
# We increment the counter with each iteration.
$counter ++;
$keywords=split(' ',$attrs['TAG']);
$kwString='';
$urls=array();
foreach ($keywords as $keyword)
{
$url='http://del.icio.us/'.DEL_USER.'/'.htmlspecialchars($keyword);
$tag=''.htmlspecialchars($keyword).'';
$urls[]=$tag;
}
# Form a string of Keyword links.
$kwString=implode(', ', $urls);
$content = $content . "\n" .' - '
. htmlspecialchars($attrs['DESCRIPTION'])
. ":\n"
. htmlspecialchars($attrs['EXTENDED'])
. ' Keywords: ' . $kwString . "
\n";
}
}
function endElement($parser, $name)
{
global $content;
if ($name == "POSTS") {
$content = $content . "
";
}
}
# Get Dates for Post
$now = current_time('mysql');
$now_gmt = current_time('mysql', 1);
$empty = true;
$dt = date("Y-m-d");
$fp = fopen("http://$del_user:$del_password@del.icio.us/api/posts/get?dt=$dt", "r");
$content = "";
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
if($empty)
return;
# Build Query
$query = "INSERT INTO $tableposts "
. "(`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) . "', '".$initialPublishState."', '" . $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 $tableposts ORDER BY ID DESC LIMIT 1");
# Build category query
$query = "INSERT INTO $tablepost2cat "
. "(`post_id`, `category_id`) "
. "VALUES "
. "('" . $post_ID . "', '" . $wp_catid . "');";
# Run Category Query
$wpdb->query($query);
?>