123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
- $shortoptions = 'i:n:f:';
- $longoptions = array('id=', 'nickname=', 'file=');
- $helptext = <<<END_OF_IMPORTBOOKMARKS_HELP
- importbookmarks.php [options]
- Restore a backed-up Delicious.com bookmark file
- -i --id ID of user to import bookmarks for
- -n --nickname nickname of the user to import for
- -f --file file to read from (STDIN by default)
- END_OF_IMPORTBOOKMARKS_HELP;
- require_once INSTALLDIR.'/scripts/commandline.inc';
- function getBookmarksFile()
- {
- $filename = get_option_value('f', 'file');
- if (empty($filename)) {
- show_help();
- exit(1);
- }
- if (!file_exists($filename)) {
-
-
- throw new Exception(sprintf(_m('No such file "%s".'),$filename));
- }
- if (!is_file($filename)) {
-
-
- throw new Exception(sprintf(_m('Not a regular file: "%s".'),$filename));
- }
- if (!is_readable($filename)) {
-
-
- throw new Exception(sprintf(_m('File "%s" not readable.'),$filename));
- }
-
- printfv(_m('Getting backup from file "%s".')."\n", $filename);
- $html = file_get_contents($filename);
- return $html;
- }
- try {
- $user = getUser();
- $html = getBookmarksFile();
- $qm = QueueManager::get();
- $qm->enqueue(array($user, $html), 'dlcsback');
- } catch (Exception $e) {
- print $e->getMessage()."\n";
- exit(1);
- }
|