"; $owner_uid = $_SESSION["uid"]; db_query($link, "BEGIN"); $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE feed_url = '". $data["feed_url"] . "' AND owner_uid = '$owner_uid'"); if (db_num_rows($result) == 0) { return false; } $feed_id = db_fetch_result($result, 0, "id"); $result = db_query($link, "SELECT id FROM ttrss_entries WHERE guid = '".$data["guid"]."'"); if (db_num_rows($result) == 0) { print "Not found, adding base entry...
"; $entry_title = $data["title"]; $entry_guid = $data["guid"]; $entry_link = $data["link"]; $updated = $data["updated"]; $date_entered = $data["date_entered"]; $entry_content = $data["content"]; $content_hash = "SHA1:" . sha1(strip_tags($entry_content)); $entry_comments = $data["comments"]; $result = db_query($link, "INSERT INTO ttrss_entries (title, guid, link, updated, content, content_hash, no_orig_date, date_entered, comments) VALUES ('$entry_title', '$entry_guid', '$entry_link', '$updated', '$entry_content', '$content_hash', false, '$date_entered', '$entry_comments')"); } $result = db_query($link, "SELECT id FROM ttrss_entries WHERE guid = '".$data["guid"]."'"); if (db_num_rows($result) == 0) { return false; } $entry_id = db_fetch_result($result, 0, "id"); print "Found base ID: $entry_id
"; $result = db_query($link, "SELECT int_id FROM ttrss_user_entries WHERE ref_id = '$entry_id'"); if (db_num_rows($result) == 0) { print "User table entry not found, creating...
"; $unread = $data["unread"]; $marked = $data["marked"]; $last_read = $data["last_read"]; if (!$last_read) { $last_read_qpart = 'NULL'; } else { $last_read_qpart = "'$last_read'"; } $result = db_query($link, "INSERT INTO ttrss_user_entries (ref_id, owner_uid, feed_id, unread, marked, last_read) VALUES ('$entry_id', '$owner_uid', '$feed_id', '$unread', '$marked', $last_read_qpart)"); } else { print "User table entry already exists, nothing to do.
"; } db_query($link, "COMMIT"); } ?>

Import XMLDB (your login is )

File:  
Importing data (your login is ".$_SESSION["name"].")"; if (is_file($_FILES['xmldb']['tmp_name'])) { $dom = domxml_open_file($_FILES['xmldb']['tmp_name']); // $dom = domxml_open_file('xmldb.xml'); if ($dom) { $root = $dom->document_element(); $schema_version = $root->get_elements_by_tagname('schema_version'); $schema_version = $schema_version[0]->get_content(); if ($schema_version != SOURCE_SCHEMA_VERSION) { die("Incorrect source schema version"); } $articles = $root->get_elements_by_tagname("article"); foreach ($articles as $article) { $child_nodes = $article->child_nodes(); $article_data = array(); foreach ($child_nodes as $child) { $article_data[$child->tagname()] = $child->get_content(); } import_article($link, $article_data); } } else { print "Error: could not parse document."; } } else { print "

Error: please upload XMLDB.

"; } } ?>