diff --git a/plugins/googlereaderimport/init.js b/plugins/googlereaderimport/init.js deleted file mode 100644 index 043952c75..000000000 --- a/plugins/googlereaderimport/init.js +++ /dev/null @@ -1,53 +0,0 @@ -function starredImportComplete(iframe) { - try { - if (!iframe.contentDocument.body.innerHTML) return false; - - Element.show(iframe); - - notify(''); - - if (dijit.byId('starredImportDlg')) - dijit.byId('starredImportDlg').destroyRecursive(); - - var content = iframe.contentDocument.body.innerHTML; - - if (content) Element.hide(iframe); - - dialog = new dijit.Dialog({ - id: "starredImportDlg", - title: __("Google Reader Import"), - style: "width: 600px", - onCancel: function() { - Element.hide(iframe); - this.hide(); - }, - execute: function() { - Element.hide(iframe); - this.hide(); - }, - content: content}); - - dialog.show(); - - } catch (e) { - exception_error("starredImportComplete", e); - } -} - -function starredImport() { - - var starred_file = $("starred_file"); - - if (starred_file.value.length == 0) { - alert(__("Please choose a file first.")); - return false; - } else { - notify_progress("Importing, please wait...", true); - - Element.show("starred_upload_iframe"); - - return true; - } -} - - diff --git a/plugins/googlereaderimport/init.php b/plugins/googlereaderimport/init.php deleted file mode 100644 index dcb335a0d..000000000 --- a/plugins/googlereaderimport/init.php +++ /dev/null @@ -1,384 +0,0 @@ -host = $host; - - $host->add_command("greader-import", - "import data in Google Reader JSON format", - $this, ":", "FILE"); - - $host->add_hook($host::HOOK_PREFS_TAB, $this); - } - - function greader_import($args) { - $file = $args['greader_import']; - - if (!file_exists($file)) { - _debug("file not found: $file"); - return; - } - - _debug("please enter your username:"); - - $username = db_escape_string(trim(read_stdin())); - - _debug("looking up user: $username..."); - - $result = db_query("SELECT id FROM ttrss_users - WHERE login = '$username'"); - - if (db_num_rows($result) == 0) { - _debug("user not found."); - return; - } - - $owner_uid = db_fetch_result($result, 0, "id"); - - _debug("processing: $file (owner_uid: $owner_uid)"); - - $this->import($file, $owner_uid); - } - - function get_prefs_js() { - return file_get_contents(dirname(__FILE__) . "/init.js"); - } - - function import($file = false, $owner_uid = 0) { - - purge_orphans(); - - if (!$file) { - header("Content-Type: text/html"); - - $owner_uid = $_SESSION["uid"]; - - if ($_FILES['starred_file']['error'] != 0) { - print_error(T_sprintf("Upload failed with error code %d", - $_FILES['starred_file']['error'])); - return; - } - - $tmp_file = false; - - if (is_uploaded_file($_FILES['starred_file']['tmp_name'])) { - $tmp_file = tempnam(CACHE_DIR . '/upload', 'starred'); - - $result = move_uploaded_file($_FILES['starred_file']['tmp_name'], - $tmp_file); - - if (!$result) { - print_error(__("Unable to move uploaded file.")); - return; - } - } else { - print_error(__('Error: please upload OPML file.')); - return; - } - - if (is_file($tmp_file)) { - $doc = json_decode(file_get_contents($tmp_file), true); - unlink($tmp_file); - } else { - print_error(__('No file uploaded.')); - return; - } - } else { - $doc = json_decode(file_get_contents($file), true); - } - - if ($file) { - $sql_set_marked = strtolower(basename($file)) == 'starred.json' ? 'true' : 'false'; - _debug("will set articles as starred: $sql_set_marked"); - - } else { - $sql_set_marked = strtolower($_FILES['starred_file']['name']) == 'starred.json' ? 'true' : 'false'; - } - - if ($doc) { - if (isset($doc['items'])) { - $processed = 0; - - foreach ($doc['items'] as $item) { -// print_r($item); - - $guid = db_escape_string(mb_substr($item['id'], 0, 250)); - $title = db_escape_string($item['title']); - $updated = date('Y-m-d h:i:s', $item['updated']); - $last_marked = date('Y-m-d h:i:s', mb_substr($item['crawlTimeMsec'], 0, 10)); - $link = ''; - $content = ''; - $author = db_escape_string($item['author']); - $tags = array(); - $orig_feed_data = array(); - - if (is_array($item['alternate'])) { - foreach ($item['alternate'] as $alt) { - if (isset($alt['type']) && $alt['type'] == 'text/html') { - $link = db_escape_string($alt['href']); - } - } - } - - if (is_array($item['summary'])) { - $content = db_escape_string( - $item['summary']['content'], false); - } - - if (is_array($item['content'])) { - $content = db_escape_string( - $item['content']['content'], false); - } - - if (is_array($item['categories'])) { - foreach ($item['categories'] as $cat) { - if (strstr($cat, "com.google/") === FALSE) { - array_push($tags, sanitize_tag($cat)); - } - } - } - - if (is_array($item['origin'])) { - if (strpos($item['origin']['streamId'], 'feed/') === 0) { - - $orig_feed_data['feed_url'] = db_escape_string( - mb_substr(preg_replace("/^feed\//", - "", $item['origin']['streamId']), 0, 200)); - - $orig_feed_data['title'] = db_escape_string( - mb_substr($item['origin']['title'], 0, 200)); - - $orig_feed_data['site_url'] = db_escape_string( - mb_substr($item['origin']['htmlUrl'], 0, 200)); - } - } - - $processed++; - - $imported += (int) $this->create_article($owner_uid, $guid, $title, - $link, $updated, $content, $author, $sql_set_marked, $tags, - $orig_feed_data, $last_marked); - - if ($file && $processed % 25 == 0) { - _debug("processed $processed articles..."); - } - } - - if ($file) { - _debug(sprintf("All done. %d of %d articles imported.", $imported, $processed)); - } else { - print "
" . T_sprintf("All done. %d out of %d articles imported.", $imported, $processed) . "
"; - } - - } else { - print_error(__('The document has incorrect format.')); - } - - } else { - print_error(__('Error while parsing document.')); - } - - if (!$file) { - print "".__("Paste your starred.json or shared.json into the form below."). "
"; - - print ""; - - print ""; - - print "