* @version 0.1 - Aug 25 2006 */ //error_reporting(E_ALL); require_once('../../../../wp-config.php'); require_once('clsParseXML.php'); array('•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•', '•'); array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'ETH', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 'ss', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'e', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'eth', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y'); class Scrib_importer{ private function prep_xml($xmlsrc, $is_string = NULL) { if ($is_string) { $xmlraw = $xmlsrc; } else { $xmlraw = utf8_encode(file_get_contents($xmlsrc)); } // This is where we compensate for stoned XML $xmlraw = preg_replace('%>[#&\x80-\xFF](.*?)<\/%s', '>GarbageDataget_var("SELECT post_id FROM $btaggy->meta_table WHERE tag_type = 'sourceid' AND tag_small = '$sourceid'"); } public function insertharvest($bibr) { global $wpdb, $scrib; $wpdb->get_results("REPLACE INTO $scrib->harvest_table (source_id, harvest_date, imported, content) VALUES ('". $wpdb->escape($bibr['the_sourceid']) ."', NOW(), 0, '". $wpdb->escape(serialize($bibr)) ."')"); echo "

harvested source_id {$bibr['the_sourceid']}

"; return; } public function insertpost($bibr){ global $bsuite, $btaggy, $wpdb; if($this->post_exists($bibr['the_sourceid'])) $postdata['ID'] = self::post_exists($bibr['the_sourceid']); $postdata['post_title'] = $wpdb->escape(str_replace('\"', '"', $bibr['the_title'])); $postdata['post_date'] = $bibr['the_pubdate']; $postdata['post_date_gmt'] = $bibr['the_acqdate']; $postdata['comment_status'] = get_option('default_comment_status'); $postdata['ping_status'] = get_option('default_pingback_flag'); $postdata['post_status'] = 'publish'; $postdata['post_type'] = 'scrib'; $postdata['post_content'] = $wpdb->escape(str_replace('\"', '"', $bibr['the_content'])); $postdata['post_excerpt'] = $wpdb->escape(str_replace('\"', '"', $bibr['the_excerpt'])); $postdata['post_author'] = 0; $post_id = wp_insert_post($postdata); $btaggy->taggy_update($post_id, $bibr['the_content']); $bsuite->searchsmart_upindex($post_id, $wpdb->escape($bibr['the_content'])); if($postdata['ID']){ echo "Updated post_id $post_id / source_id {$bibr['the_sourceid']} · "; }else{ echo "Inserted post_id $post_id / source_id {$bibr['the_sourceid']} · "; } /* if(SCRIB_DEBUG){ echo '


';
			print_r($bibr);
			echo '
'; } */ return($post_id); } public function get_altisbn($isbn) { $result = array(); // OCLC's xISBN // http://www.oclc.org/research/projects/xisbn/ $xmlopacurl = 'http://labs.oclc.org/xisbn/' . $isbn; $xml = self::prep_xml($xmlopacurl); foreach ($xml->xpath('/idlist/isbn') as $temp) { $result[] = (string) $temp; } // the first element of the array is always the same as the query ISBN, delete it array_shift($result); /* // LibraryThing's thingISBN // http://www.librarything.com/thingology/2006/06/introducing-thingisbn_14.php $xmlopacurl = 'http://www.librarything.com/api/thingISBN/' . $isbn; $xml = self::prep_xml($xmlopacurl); foreach ($xml->xpath('/idlist/isbn') as $temp) { $result[] = (string) $temp; } */ return($result); } public function enrich($isbn_list){ foreach($isbn_list as $isbn){ //echo $isbn . "
\n"; // there's an ugly hack/work around below. For some reason the API server is returning crunk at the head of the serialized result. I'm removing it with substring, but i should fix it at the source. $record = unserialize(substr(file_get_contents('http://api.scriblio.net/v01a/enrich/?isbn='. $isbn),3)); if($record['status']){ return($record); } } } } ?>