From aad95d87b39daf8d78dead7ab014dffeec0e8380 Mon Sep 17 00:00:00 2001 From: Offerel <14041522+Offerel@users.noreply.github.com> Date: Thu, 16 Jul 2020 20:35:56 +0200 Subject: [PATCH] Added options page --- composer.json | 2 +- localization/de_DE.inc | 3 +- localization/en_US.inc | 3 +- skins/elastic/plugin.css | 23 +++-- skins/elastic/plugin.min.css | 2 +- syncmarks.js | 59 +++++++------ syncmarks.min.js | 4 +- syncmarks.php | 165 +++++++++++++++++++++++++++-------- 8 files changed, 184 insertions(+), 77 deletions(-) diff --git a/composer.json b/composer.json index 516838c..dac634b 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "role": "Developer" } ], - "version": "2.2.0", + "version": "2.2.1", "repositories": [ { "type": "composer", diff --git a/localization/de_DE.inc b/localization/de_DE.inc index d196558..56e83c1 100644 --- a/localization/de_DE.inc +++ b/localization/de_DE.inc @@ -1,7 +1,8 @@ \ No newline at end of file diff --git a/localization/en_US.inc b/localization/en_US.inc index 26748a6..3a890c9 100644 --- a/localization/en_US.inc +++ b/localization/en_US.inc @@ -1,7 +1,8 @@ \ No newline at end of file diff --git a/skins/elastic/plugin.css b/skins/elastic/plugin.css index db810d2..bca309a 100644 --- a/skins/elastic/plugin.css +++ b/skins/elastic/plugin.css @@ -33,15 +33,16 @@ background: #f4f4f4; top: 0; position: absolute; - height: 18px; + height: 25px; width: 100%; border: thin solid #d4dbde; right: 0; border-right: unset; text-align: center; vertical-align: middle; - line-height: 15px; + line-height: 25px; overflow: hidden; + border-top: unset; } #bookmarks { display: block; @@ -50,9 +51,9 @@ bottom: 15px; transition: 1s; overflow: auto; - top: 15px; + top: 24px; background-color: #EEF3FA; - padding-top: 10px; + padding-top: 0; margin-bottom: 10px!important; right: 0; white-space: nowrap; @@ -75,6 +76,9 @@ color: #000; margin: 0; } +#bookmarks h1 { + display: none; +} #bookmarks dd { display: none; } @@ -103,10 +107,10 @@ margin-left: -1px!important; } #bookmarks li.file a { - background: url(images/globe.png) 0 0 no-repeat; + background: url(images/globe.png) 2px 2px no-repeat; background-size: 13px; color: #000; - padding-left: 21px; + padding-left: 20px; text-decoration: none; display: block; white-space: nowrap; @@ -137,13 +141,13 @@ padding-left: 1px; } #bookmarks li label { - background: url(images/folder-horizontal.png) 12px 2px no-repeat; + background: url(images/folder-horizontal.png) 12px 0 no-repeat; cursor: pointer; display: block; padding-left: 35px; } #bookmarks li input:checked+ol { - background: url(images/toggle-small.png) 40px 3px no-repeat; + background: url(images/toggle-small.png) 39px 3px no-repeat; margin: -2em 0 0 -44px; padding: 1.563em 0 0 80px; height: auto; @@ -154,4 +158,7 @@ } #bookmarks li input:checked+ol>li:last-child { margin: 0 0 .063em; +} +.listing.iconized tr.syncmarks > td.section::before { + content: "\f02e"; } \ No newline at end of file diff --git a/skins/elastic/plugin.min.css b/skins/elastic/plugin.min.css index 78b1b67..8dcb0c0 100644 --- a/skins/elastic/plugin.min.css +++ b/skins/elastic/plugin.min.css @@ -1 +1 @@ -#bmframe{height: 100%;border: 1px solid #bbb;border-top-left-radius: 5px;border-bottom-left-radius: 5px;width: 100%;}#add,#bookmarkpane{bottom:0;z-index:100}#add,#bheader{text-align:center;vertical-align:middle;overflow:hidden}#add,#bheader,#bookmarks{width:100%;right:0;border:thin solid #d4dbde;position:absolute}#add,#bheader,#bookmarkpane,#bookmarks{position:absolute}#taskmenu a.bookmarks::before{content:"\f02e"}#bookmarkpane{transition:1s;top:58px;right:0;width:0}#add{background:#e1e1e1;height:25px;border-right:unset;line-height:23px;cursor:pointer}#add:hover{background:#b7b7b7}#bheader{background:#f4f4f4;top:0;height:18px;border-right:unset;line-height:15px}#bookmarks{display:block;bottom:15px;transition:1s;overflow:auto;top:15px;background-color:#EEF3FA;padding-top:10px;margin-bottom:10px!important;white-space:nowrap;border-right:unset;border-bottom:unset;font-family:"Lucida Grande",Verdana,Arial,Helvetica,sans-serif;font-size:12px;line-height:16px}#bookmarks html{font-family:Verdana,Arial,Helvetica,sans-serif}#bookmarks body,#bookmarks h1,#bookmarks h2,#bookmarks h3,#bookmarks h4,#bookmarks h5,#bookmarks li,#bookmarks p,#bookmarks ul{margin:0;padding:0;background-color:#EEF3FA}#bookmarks dd,#bookmarks hr{display:none}#bookmarks p{font-size:1em;margin:0 0 1em}#bookmarks body{color:#000;margin:0;font-size:.8em}#bookmarks ol.tree{padding:0 0 0 20px;width:90%}#bookmarks>li.file{margin-left:29px!important}#bookmarks li{position:relative;margin-left:15px;list-style:none}#bookmarks li.file{margin-left:-1px!important}#bookmarks li.file a{background:url(images/globe.png) no-repeat;background-size:13px;color:#000;padding-left:21px;text-decoration:none;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:.9em}#bookmarks li input{position:absolute;left:0;margin-left:0;opacity:0;z-index:2;cursor:pointer;height:1em;width:1em;top:0}#bookmarks li input+ol{background:url(images/toggle-small-expand.png) 40px -2px no-repeat;margin:-1.5em 0 0 -44px;height:1em;text-overflow:ellipsis}#bookmarks li input+ol>li{display:none;margin-left:-14px!important;padding-left:1px}#bookmarks li label{background:url(images/folder-horizontal.png) 12px 2px no-repeat;cursor:pointer;display:block;padding-left:35px}#bookmarks li input:checked+ol{background:url(images/toggle-small.png) 40px 3px no-repeat;margin:-2em 0 0 -44px;padding:1.563em 0 0 80px;height:auto}#bookmarks li input:checked+ol>li{display:block;margin:0 0 .125em}#bookmarks li input:checked+ol>li:last-child{margin:0 0 .063em} \ No newline at end of file +#bmframe{height:100%;border:1px solid #bbb;border-top-left-radius:5px;border-bottom-left-radius:5px;width:100%}#taskmenu a.bookmarks::before{content:"\f02e"}#bookmarkpane{position:absolute;transition:1s;top:58px;right:0;bottom:0;width:0;z-index:100}#add{background:#e1e1e1;bottom:0;position:absolute;height:25px;width:100%;border:thin solid #d4dbde;right:0;z-index:100;border-right:unset;overflow:hidden;text-align:center;vertical-align:middle;line-height:23px;cursor:pointer}#add:hover{background:#b7b7b7}#bheader{background:#f4f4f4;top:0;position:absolute;height:25px;width:100%;border:thin solid #d4dbde;right:0;border-right:unset;text-align:center;vertical-align:middle;line-height:25px;overflow:hidden;border-top:unset}#bookmarks{display:block;position:absolute;width:100%;bottom:15px;transition:1s;overflow:auto;top:24px;background-color:#eef3fa;padding-top:0;margin-bottom:10px!important;right:0;white-space:nowrap;border:thin solid #d4dbde;border-right:unset;border-bottom:unset;font-family:"Lucida Grande",Verdana,Arial,Helvetica,sans-serif;font-size:12px;line-height:16px}#bookmarks html{font-family:Verdana,Arial,Helvetica,sans-serif}#bookmarks body,#bookmarks h1,#bookmarks h2,#bookmarks h3,#bookmarks h4,#bookmarks h5,#bookmarks li,#bookmarks p,#bookmarks ul{margin:0;padding:0;background-color:#eef3fa}#bookmarks body{color:#000;margin:0}#bookmarks h1{display:none}#bookmarks dd{display:none}#bookmarks p{font-size:1em;margin:0 0 1em}#bookmarks hr{display:none}#bookmarks body{font-size:.8em}#bookmarks ol.tree{padding:0 0 0 20px;width:90%}#bookmarks>li.file{margin-left:29px!important}#bookmarks li{position:relative;margin-left:15px;list-style:none}#bookmarks li.file{margin-left:-1px!important}#bookmarks li.file a{background:url(images/globe.png) 2px 2px no-repeat;background-size:13px;color:#000;padding-left:20px;text-decoration:none;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:.9em}#bookmarks li input{position:absolute;left:0;margin-left:0;opacity:0;z-index:2;cursor:pointer;height:1em;width:1em;top:0}#bookmarks li input+ol{background:url(images/toggle-small-expand.png) 40px -2px no-repeat;margin:-1.5em 0 0 -44px;height:1em;text-overflow:ellipsis}#bookmarks li input+ol>li{display:none;margin-left:-14px!important;padding-left:1px}#bookmarks li label{background:url(images/folder-horizontal.png) 12px 0 no-repeat;cursor:pointer;display:block;padding-left:35px}#bookmarks li input:checked+ol{background:url(images/toggle-small.png) 39px 3px no-repeat;margin:-2em 0 0 -44px;padding:1.563em 0 0 80px;height:auto}#bookmarks li input:checked+ol>li{display:block;margin:0 0 .125em}#bookmarks li input:checked+ol>li:last-child{margin:0 0 .063em}.listing.iconized tr.syncmarks>td.section::before{content:"\f02e"} \ No newline at end of file diff --git a/syncmarks.js b/syncmarks.js index ca51072..4396a2a 100644 --- a/syncmarks.js +++ b/syncmarks.js @@ -1,26 +1,18 @@ /** * Roundcube Bookmarks Plugin * - * @version 2.2.0 + * @version 2.2.1 * @author Offerel * @copyright Copyright (c) 2020, Offerel * @license GNU General Public License, version 3 */ -function h_del(t, o) { +function h_del(t, o, format) { t.preventDefault(); - var e = rcmail.gettext("bookmarks_del", "syncmarks").replace("%b%", o.innerHTML); + var e = rcmail.gettext("bookmarks_del", "syncmarks").replace("%b%", o.innerHTML); if (1 == confirm(e)) { - var r = encodeURIComponent(o.href); - rcmail.http_post("syncmarks/del_url", "_url=" + r + "&_format=html") - } -} - -function j_del(t, o) { - t.preventDefault(); - var e = rcmail.gettext("bookmarks_del", "syncmarks").replace("%b%", o.innerHTML); - if (1 == confirm(e)) { - var r = encodeURIComponent(o.href); - rcmail.http_post("syncmarks/del_url", "_url=" + r + "&_format=json") + let r = encodeURIComponent(o.href); + let i = o.attributes['bid']['value']; + rcmail.http_post("syncmarks/del_url", "_url=" + r + "&_format=" + format + "&_bid=" + i) } } @@ -33,14 +25,9 @@ function bookmarks_cmd() { } } -function add_url() { - var t = encodeURIComponent(prompt(rcmail.gettext("bookmarks_url", "syncmarks"))); - 0 < t.length && (t.startsWith("http") || t.startsWith("ftp")) && rcmail.http_post("syncmarks/add_url", "_url=" + t + "&_format=html") -} - -function jadd_url() { - var t = encodeURIComponent(prompt(rcmail.gettext("bookmarks_url", "syncmarks"))); - 0 < t.length && (t.startsWith("http") || t.startsWith("ftp")) && rcmail.http_post("syncmarks/add_url", "_url=" + t + "&_format=json") +function add_url(format) { + var t = encodeURIComponent(prompt(rcmail.gettext("bookmarks_url", "syncmarks"))); + 0 < t.length && (t.startsWith("http") || t.startsWith("ftp")) && rcmail.http_post("syncmarks/add_url", "_url=" + t + "&_format=" + format) } function urladded(t) { @@ -50,13 +37,29 @@ function urladded(t) { function get_bookmarks(response) { bookmarks = JSON.parse(response.data); - if(response.message == 'php') { - $('#bmframe').attr('srcdoc',bookmarks); - document.getElementById("bookmarkpane").style.width = "300px"; + $('#bookmarkpane').html(bookmarks); + document.getElementById("bookmarkpane").style.width = "300px"; +} + +function en_noti() { + if (!("Notification" in window)) { + alert("This browser does not support desktop notification"); } - else { - $('#bookmarkpane').html(bookmarks); - document.getElementById("bookmarkpane").style.width = "300px"; + else if (Notification.permission === "granted") { + var notification = new Notification("Syncmarks", { + body: "Notifications are now enabled for Syncmarks.", + icon: './plugins/syncmarks/bookmarks.png' + }); + } + else if (Notification.permission !== "denied") { + Notification.requestPermission().then(function (permission) { + if (permission === "granted") { + var notification = new Notification("Syncmarks", { + body: "Notifications are now enabled for Syncmarks.", + icon: './plugins/syncmarks/bookmarks.png' + }); + } + }); } } diff --git a/syncmarks.min.js b/syncmarks.min.js index 18749e8..3102ea5 100644 --- a/syncmarks.min.js +++ b/syncmarks.min.js @@ -1,9 +1,9 @@ /** * Roundcube Bookmarks Plugin * - * @version 2.2.0 + * @version 2.2.1 * @author Offerel * @copyright Copyright (c) 2020, Offerel * @license GNU General Public License, version 3 */ -function h_del(t,o){t.preventDefault();var e=rcmail.gettext("bookmarks_del","syncmarks").replace("%b%",o.innerHTML);if(1==confirm(e)){var r=encodeURIComponent(o.href);rcmail.http_post("syncmarks/del_url","_url="+r+"&_format=html")}}function j_del(t,o){t.preventDefault();var e=rcmail.gettext("bookmarks_del","syncmarks").replace("%b%",o.innerHTML);if(1==confirm(e)){var r=encodeURIComponent(o.href);rcmail.http_post("syncmarks/del_url","_url="+r+"&_format=json")}}function bookmarks_cmd(){"300"!=document.getElementById("bookmarkpane").clientWidth?rcmail.http_post("syncmarks/get_bookmarks","_url=2"):document.getElementById("bookmarkpane").style.width="0"}function add_url(){var t=encodeURIComponent(prompt(rcmail.gettext("bookmarks_url","syncmarks")));0add_texts('localization/', true); $this->register_task('syncmarks'); - $this->include_stylesheet($this->local_skin_path().'/plugin.min.css'); - $this->include_script('syncmarks.js'); + $this->include_stylesheet($this->local_skin_path().'/plugin.css'); $this->add_button(array( 'label' => 'syncmarks.bookmarks', @@ -25,6 +26,14 @@ public function init() { 'innerclass'=> 'button-inner', 'type' => 'link' ), 'taskbar'); + + if($rcmail->task == 'settings') { + $this->add_hook('preferences_sections_list', array($this, 'bms_preferences_sections_list')); + $this->add_hook('preferences_list', array($this, 'bms_preferences_list')); + $this->add_hook('preferences_save', array($this, 'bms_preferences_save')); + } + + $bms_notifications = $rcmail->config->get('bms_notifications'); $this->add_hook('render_page', array($this, 'add_bookmarks')); $this->add_hook('refresh', array($this, 'get_notifications')); @@ -35,15 +44,44 @@ public function init() { $this->register_action('get_bookmarks', array($this, 'get_bookmarks')); $this->register_action('del_not', array($this, 'del_not')); } - + + function bms_preferences_sections_list($p) { + $p['list']['syncmarks'] = array('id' => 'syncmarks', 'section' => $this->gettext('bookmarks')); + return($p); + } + + function bms_preferences_list($p) { + if ($p['section'] != 'syncmarks') { + return $p; + } + $rcmail = rcmail::get_instance(); + $p['blocks']['main']['name']=$this->gettext('mainoptions'); + $field_id='bms_notifications'; + $input = new html_checkbox(array( 'name' => 'bms_notifications', + 'onchange' => 'en_noti()', + 'id' => 'bms_notifications', + 'value' => 1)); + return $p; + } + + function bms_preferences_save($p) { + if ($p['section'] == 'syncmarks') { + $p['prefs'] = array( + 'bms_notifications' => intval(rcube_utils::get_input_value('bms_notifications', rcube_utils::INPUT_POST)), + ); + } + + return $p; + } + function unset_cookie() { rcube_utils::setcookie('sycmarks_n', '0', time() - 60); } function get_notifications() { - if($_COOKIE['sycmarks_n'] != '1') { - $rcmail = rcmail::get_instance(); - $this->load_config(); + $rcmail = rcmail::get_instance(); + if($_COOKIE['sycmarks_n'] != '1' && $rcmail->config->get('bms_notifications') == "1") { + //$this->load_config(); $path = $rcmail->config->get('bookmarks_path', false); $filename = $rcmail->config->get('bookmarks_filename', false); @@ -91,7 +129,7 @@ function get_bookmarks() { $filename = $rcmail->config->get('bookmarks_filename', false); $username = $rcmail->user->get_username(); $password = $rcmail->get_user_password(); - $ext = pathinfo($filename, PATHINFO_EXTENSION); + $ext = pathinfo($filename, PATHINFO_EXTENSION); $remote_url = $path."/".$filename; $opts = array('http'=>array( 'method'=>"GET", @@ -100,9 +138,9 @@ function get_bookmarks() { ); $context = stream_context_create($opts); - $bms = file_get_contents($remote_url, false, $context); if($ext === "json") { + $bms = file_get_contents($remote_url, false, $context); foreach ($http_response_header as &$value) { if (strpos($value, 'ast-Modified') != 0) { $modified = strtotime(substr($value, 15)); @@ -118,6 +156,26 @@ function get_bookmarks() { $bms = parseHTMLMarks($bms, filemtime($bmfile), $this->gettext('bookmarks_new')); } } + elseif($ext === "php") { + $sdata = array('export' => 'html'); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $path.$filename); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']); + curl_setopt($ch, CURLOPT_VERBOSE, TRUE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); + curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_POSTFIELDS, $sdata); + curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password); + $rdata = curl_exec($ch); + $lsnc = array('caction' => 'lsnc'); + curl_setopt($ch, CURLOPT_POSTFIELDS, $lsnc); + $tdata = curl_exec($ch); + curl_close($ch); + + $bms = parseHTMLMarks($rdata, round($tdata / 1000), $this->gettext('bookmarks_new'), 'php'); + } $rcmail->output->command('syncmarks/get_bookmarks', array('message' => $ext, 'data' => json_encode($bms))); } @@ -128,6 +186,7 @@ function del_url() { $bmfile = str_replace("%u", $rcmail->user->get_username(), $rcmail->config->get('bookmarks_path', false).$rcmail->config->get('bookmarks_filename', false)); $del_url = rcube_utils::get_input_value('_url', rcube_utils::INPUT_POST); $format = rcube_utils::get_input_value('_format', rcube_utils::INPUT_POST); + $bid = rcube_utils::get_input_value('_bid', rcube_utils::INPUT_POST); if($format == "html") { if(file_exists($bmfile)) { @@ -185,16 +244,29 @@ function del_url() { $cmarks = parseJSONMarks($nBookmarks, time(), $this->gettext('bookmarks_new')); $rcmail->output->command('syncmarks/urladded', array('message' => "Bookmark deleted", 'data' => $cmarks)); } + elseif($format == "php") { + $ddata = array('mdel' => true, 'id' => $bid, 'rc' => true); + $path = $rcmail->config->get('bookmarks_path', false); + $filename = $rcmail->config->get('bookmarks_filename', false); + $username = $rcmail->user->get_username(); + $password = $rcmail->get_user_password(); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $path.$filename); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']); + curl_setopt($ch, CURLOPT_VERBOSE, TRUE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); + curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_POSTFIELDS, $ddata); + curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password); + $rdata = curl_exec($ch); + curl_close($ch); + } } - - function add_url() { - $rcmail = rcmail::get_instance(); - $this->load_config(); - $new_url = rcube_utils::get_input_value('_url', rcube_utils::INPUT_POST); - $format = rcube_utils::get_input_value('_format', rcube_utils::INPUT_POST); - $path = $rcmail->config->get('bookmarks_path', false); - $filename = $rcmail->config->get('bookmarks_filename', false); - + + function get_title($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $new_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -204,8 +276,6 @@ function add_url() { curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_MAXREDIRS, 4); curl_setopt($ch, CURLOPT_HTTPGET, TRUE); - curl_setopt($ch, CURLOPT_USERPWD, $rcmail->user->get_username().":".$rcmail->get_user_password()); - $data = curl_exec($ch); curl_close($ch); @@ -213,8 +283,18 @@ function add_url() { @$doc->loadHTML($data); $nodes = $doc->getElementsByTagName('title'); $title = $nodes->item(0)->nodeValue; + return $title; + } + + function add_url() { + $rcmail = rcmail::get_instance(); + $new_url = rcube_utils::get_input_value('_url', rcube_utils::INPUT_POST); + $format = rcube_utils::get_input_value('_format', rcube_utils::INPUT_POST); + $path = $rcmail->config->get('bookmarks_path', false); + $filename = $rcmail->config->get('bookmarks_filename', false); if($format == 'html') { + $title = get_title($url); $bmfile = str_replace("%u", $rcmail->user->get_username(), $rcmail->config->get('bookmarks_path', false).$rcmail->config->get('bookmarks_filename', false)); if(file_exists($bmfile)) { @@ -249,6 +329,7 @@ function add_url() { } } elseif($format == 'json') { + $title = get_title($url); $url = $path."/".$filename; $context = stream_context_create(array ('http' => array ('header' => 'Authorization: Basic '.base64_encode($rcmail->user->get_username().":".$rcmail->get_user_password())))); $bookmarks = file_get_contents($url, false, $context); @@ -282,30 +363,44 @@ function add_url() { $cmarks = parseJSONMarks($bookmarks, time(), $this->gettext('bookmarks_new')); $rcmail->output->command('syncmarks/urladded', array('message' => 'URL is added.','data' => $cmarks)); } + elseif($format == 'php') { + $ddata = array('madd' => true, 'url' => $new_url, 'rc' => true, 'folder' => 'unfiled_____'); + $path = $rcmail->config->get('bookmarks_path', false); + $filename = $rcmail->config->get('bookmarks_filename', false); + $username = $rcmail->user->get_username(); + $password = $rcmail->get_user_password(); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $path.$filename); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']); + curl_setopt($ch, CURLOPT_VERBOSE, TRUE); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); + curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_POSTFIELDS, $ddata); + curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password); + $rdata = curl_exec($ch); + curl_close($ch); + } } function add_bookmarks() { $rcmail = rcmail::get_instance(); + $this->include_script('syncmarks.js'); $exctasks = array("login","logout"); if(!in_array($rcmail->task,$exctasks)) { $this->load_config(); $filename = $rcmail->config->get('bookmarks_filename', false); $ext = pathinfo($filename, PATHINFO_EXTENSION); - - if($ext === "php") { - $rcmail->output->add_footer("
"); - return $args; - } - else { - $rcmail->output->add_footer("
"); - return $args; - } + $rcmail->output->add_footer("
"); + return $args; } } function bookmarks_cmd() { - $this->include_script('plugin.js'); + $this->include_script('syncmarks.js'); } } @@ -323,7 +418,7 @@ function parseJSONMarks($bookmarks, $bdate, $button) { $bookmarks = str_replace("
    1. ","",$bookmarks); $bookmarks = substr($bookmarks,2,strlen($bookmarks)-12); - $bookmarks = "
      Date: ".date("d.m.Y H:i:s", $bdate)."
      ".$bookmarks."\n
      ".$button."
      "; + $bookmarks = "
      Date: ".date("d.m.Y H:i:s", $bdate)."
      ".$bookmarks."\n
      ".$button."
      "; return $bookmarks; } @@ -331,7 +426,7 @@ function makeHTMLTree($arr) { static $bookmarks = ""; if(is_array($arr) && array_key_exists("url", $arr)) { - $bookmark = "\t
    2. ".$arr['title']."
    3. \n%ID".$arr['parentId']; + $bookmark = "\t
    4. ".$arr['title']."
    5. \n%ID".$arr['parentId']; $bookmarks = str_replace("%ID".$arr['parentId'], $bookmark, $bookmarks); } elseif(is_array($arr) && !array_key_exists("url", $arr) && $arr['id'] != "") { @@ -354,20 +449,20 @@ function makeHTMLTree($arr) { return $bookmarks; } -function parseHTMLMarks($bookmarks, $bdate, $button) { +function parseHTMLMarks($bookmarks, $bdate, $button, $format='html') { $rcmail = rcmail::get_instance(); $bookmarks = preg_replace("/
      [^>]*?

      ]*? PERSONAL_TOOLBAR_FOLDER=\"true\">(.+?)<\/H3>/is", "

    $1

    ", $bookmarks); $bookmarks = preg_replace("/

    ]*? UNFILED_BOOKMARKS_FOLDER=\"true\">(.+?)<\/H3>/is", "

    $1

    ", $bookmarks); $bookmarks = preg_replace("/

    (.+?)<\/H1>/is", "
  • \n", $bookmarks); $bookmarks = preg_replace("/
    (.+?)<\/H3>/is", "
  • ", $bookmarks); - $bookmarks = str_replace("
    ","
  • ",$bookmarks); $bookmarks = preg_replace("/(.+?)<\/A>/is", "$2", $bookmarks); $bookmarks = str_replace("

    ","

      ",$bookmarks); $bookmarks = str_replace("

    ","",$bookmarks); $bookmarks = str_replace("","",$bookmarks); - $bookmarks = "

    Date: ".date("d.m.Y H:i:s", $bdate)."
    ".$bookmarks."
    ".$button."
    "; + $bookmarks = "
    Date: ".date("d.m.Y H:i:s", $bdate)."
    ".$bookmarks."
    ".$button."
    "; return $bookmarks; }