2
2
/**
3
3
* Roundcube Bookmarks Plugin
4
4
*
5
- * @version 2.2.3
5
+ * @version 2.2.4
6
6
* @author Offerel
7
7
* @copyright Copyright (c) 2020, Offerel
8
8
* @license GNU General Public License, version 3
@@ -90,19 +90,19 @@ function get_notifications() {
90
90
$ path = $ rcmail ->config ->get ('bookmarks_path ' , false );
91
91
$ filename = $ rcmail ->config ->get ('bookmarks_filename ' , false );
92
92
93
- $ ch = curl_init ();
94
- curl_setopt ($ ch , CURLOPT_URL , $ path .$ filename .'?gurls=1 ' );
95
- curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
96
- curl_setopt ($ ch , CURLOPT_REFERER , $ _SERVER ['REQUEST_URI ' ]);
97
- curl_setopt ($ ch , CURLOPT_VERBOSE , TRUE );
98
- curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , FALSE );
99
- curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , TRUE );
100
- curl_setopt ($ ch , CURLOPT_MAXREDIRS , 4 );
101
- curl_setopt ($ ch , CURLOPT_HTTPGET , TRUE );
93
+ $ data = array (
94
+ 'caction ' => 'gurls '
95
+ );
96
+
97
+ $ ch =curl_init ();
98
+ curl_setopt ($ ch , CURLOPT_URL , $ path .$ filename );
102
99
curl_setopt ($ ch , CURLOPT_USERPWD , $ rcmail ->user ->get_username ().": " .$ rcmail ->get_user_password ());
103
- $ data = curl_exec ($ ch );
104
- $ rcmail ->output ->command ('plugin.sendNotifications ' , $ data );
100
+ curl_setopt ($ ch , CURLOPT_POST , true );
101
+ curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ data );
102
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
103
+ $ response = curl_exec ($ ch );
105
104
curl_close ($ ch );
105
+ $ rcmail ->output ->command ('plugin.sendNotifications ' , $ response );
106
106
rcube_utils::setcookie ('sycmarks_n ' , '1 ' , 0 );
107
107
}
108
108
}
@@ -112,17 +112,18 @@ function del_not() {
112
112
$ this ->load_config ();
113
113
$ path = $ rcmail ->config ->get ('bookmarks_path ' , false );
114
114
$ filename = $ rcmail ->config ->get ('bookmarks_filename ' , false );
115
+
116
+ $ sdata = array (
117
+ 'caction ' => 'durl ' ,
118
+ 'durl ' => rcube_utils::get_input_value ('_nkey ' , rcube_utils::INPUT_GPC )
119
+ );
115
120
116
121
$ ch = curl_init ();
117
- curl_setopt ($ ch , CURLOPT_URL , $ path .$ filename .'?durl= ' .rcube_utils::get_input_value ('_nkey ' , rcube_utils::INPUT_GPC ));
118
- curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
119
- curl_setopt ($ ch , CURLOPT_REFERER , $ _SERVER ['REQUEST_URI ' ]);
120
- curl_setopt ($ ch , CURLOPT_VERBOSE , TRUE );
121
- curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , FALSE );
122
- curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , TRUE );
123
- curl_setopt ($ ch , CURLOPT_MAXREDIRS , 4 );
124
- curl_setopt ($ ch , CURLOPT_HTTPGET , TRUE );
122
+ curl_setopt ($ ch , CURLOPT_URL , $ path .$ filename );
125
123
curl_setopt ($ ch , CURLOPT_USERPWD , $ rcmail ->user ->get_username ().": " .$ rcmail ->get_user_password ());
124
+ curl_setopt ($ ch , CURLOPT_HTTPPOST , TRUE );
125
+ curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ sdata );
126
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
126
127
$ data = curl_exec ($ ch );
127
128
curl_close ($ ch );
128
129
}
@@ -136,15 +137,14 @@ function get_bookmarks() {
136
137
$ password = $ rcmail ->get_user_password ();
137
138
$ ext = pathinfo ($ filename , PATHINFO_EXTENSION );
138
139
$ remote_url = $ path ."/ " .$ filename ;
139
- $ opts = array ('http ' =>array (
140
- 'method ' =>"GET " ,
141
- 'header ' => "Authorization: Basic " .base64_encode ("$ username: $ password " )
142
- )
143
- );
144
-
145
- $ context = stream_context_create ($ opts );
146
140
147
141
if ($ ext === "json " ) {
142
+ $ opts = array ('http ' =>array (
143
+ 'method ' =>"GET " ,
144
+ 'header ' => "Authorization: Basic " .base64_encode ("$ username: $ password " )
145
+ )
146
+ );
147
+ $ context = stream_context_create ($ opts );
148
148
$ bms = file_get_contents ($ remote_url , false , $ context );
149
149
foreach ($ http_response_header as &$ value ) {
150
150
if (strpos ($ value , 'ast-Modified ' ) != 0 ) {
@@ -162,7 +162,10 @@ function get_bookmarks() {
162
162
}
163
163
}
164
164
elseif ($ ext === "php " ) {
165
- $ sdata = array ('export ' => 'html ' );
165
+ $ sdata = array (
166
+ 'caction ' => 'fexport ' ,
167
+ 'type ' => 'html '
168
+ );
166
169
$ ch = curl_init ();
167
170
curl_setopt ($ ch , CURLOPT_URL , $ path .$ filename );
168
171
curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
@@ -250,7 +253,7 @@ function del_url() {
250
253
$ rcmail ->output ->command ('syncmarks/urladded ' , array ('message ' => "Bookmark deleted " , 'data ' => $ cmarks ));
251
254
}
252
255
elseif ($ format == "php " ) {
253
- $ ddata = array ('mdel ' => true , 'id ' => $ bid , 'rc ' => true );
256
+ $ ddata = array ('caction ' => ' mdel ' , 'id ' => $ bid , 'rc ' => true );
254
257
$ path = $ rcmail ->config ->get ('bookmarks_path ' , false );
255
258
$ filename = $ rcmail ->config ->get ('bookmarks_filename ' , false );
256
259
$ username = $ rcmail ->user ->get_username ();
@@ -267,13 +270,14 @@ function del_url() {
267
270
curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ ddata );
268
271
curl_setopt ($ ch , CURLOPT_USERPWD , $ username .": " .$ password );
269
272
$ rdata = curl_exec ($ ch );
273
+ $ rcmail ->output ->command ('syncmarks/url_removed ' , array ('message ' => "URL removed " ));
270
274
curl_close ($ ch );
271
275
}
272
276
}
273
277
274
278
function get_title ($ url ) {
275
279
$ ch = curl_init ();
276
- curl_setopt ($ ch , CURLOPT_URL , $ new_url );
280
+ curl_setopt ($ ch , CURLOPT_URL , $ url );
277
281
curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
278
282
curl_setopt ($ ch , CURLOPT_REFERER , $ _SERVER ['REQUEST_URI ' ]);
279
283
curl_setopt ($ ch , CURLOPT_VERBOSE , TRUE );
@@ -370,7 +374,7 @@ function add_url() {
370
374
$ rcmail ->output ->command ('syncmarks/urladded ' , array ('message ' => 'URL is added. ' ,'data ' => $ cmarks ));
371
375
}
372
376
elseif ($ format == 'php ' ) {
373
- $ ddata = array ('madd ' => true , 'url ' => $ new_url , 'rc ' => true , 'folder ' => 'unfiled_____ ' );
377
+ $ ddata = array ('caction ' => ' madd ' , 'url ' => $ new_url , 'rc ' => true , 'folder ' => 'unfiled_____ ' );
374
378
$ path = $ rcmail ->config ->get ('bookmarks_path ' , false );
375
379
$ filename = $ rcmail ->config ->get ('bookmarks_filename ' , false );
376
380
$ username = $ rcmail ->user ->get_username ();
@@ -387,6 +391,7 @@ function add_url() {
387
391
curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ ddata );
388
392
curl_setopt ($ ch , CURLOPT_USERPWD , $ username .": " .$ password );
389
393
$ rdata = curl_exec ($ ch );
394
+ $ rcmail ->output ->command ('syncmarks/url_removed ' , array ('message ' => "URL added " ));
390
395
curl_close ($ ch );
391
396
}
392
397
}
0 commit comments