forked from brablc/sitebar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
integrator.php
630 lines (540 loc) · 18.8 KB
/
integrator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
<?php
/******************************************************************************
* SiteBar 3 - The Bookmark Server for Personal and Team Use. *
* Copyright (C) 2003-2008 Ondrej Brablc <http://brablc.com/mailto?o> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************/
require_once('./inc/errorhandler.inc.php');
require_once('./inc/page.inc.php');
require_once('./inc/usermanager.inc.php');
$um = SB_UserManager::staticInstance();
// If we are called the first time, without params and without cookies
if (!isset($_GET['url']) && !isset($_GET['lang']))
{
SB_Skin::set($um->getParam('user','skin'));
$url = $um->getParamB64('config','integrator_url');
$url .= '?lang=' . $um->getParam('user','lang');
$url .= '&skin=' . SB_Skin::get();
$url .= '&version='. SB_CURRENT_RELEASE;
$url .= '&url='. SB_Page::absBaseUrl();
$url .= '&popup_params='. $um->getParam('user','popup_params');
// Redirect to the central URL, or to the own URL with the information
header('Location: ' . $url);
exit;
}
// Now we have the information, we are on the right page and we will use cookies
// We will redirect using META tag later on to support all browsers
if (isset($_GET['url']))
{
foreach (array('skin','version','url','popup_params') as $key)
{
$cookieName = 'sbi_'.$key;
$_COOKIE[$cookieName] = $_REQUEST[$key];
setcookie($cookieName, $_REQUEST[$key]);
}
}
SB_Page::absBaseUrl($_COOKIE['sbi_url']);
SB_Skin::set($_COOKIE['sbi_skin']);
if (preg_match('/^\w+/', $_GET['lang']))
{
SB_SetLanguage($_GET['lang']);
}
$um->setParam('user',$_COOKIE['popup_params']);
if (isset($_REQUEST['install']))
{
IEInstall();
exit;
}
if (isset($_REQUEST['search_engine']))
{
SearchEngine();
exit;
}
// Redirect and keep cookies
$meta = null;
if (isset($_GET['url']))
{
$meta = '<meta http-equiv="refresh" content="0;url=integrator.php?lang='.SB_GetLanguage().'">';
}
SB_Page::head('Integrator', 'siteBarIndex', null, null, $meta);
if (isset($_GET['url']))
{
exit;
}
// Include skin hook file
include_once(SB_Skin::path().'/hook.inc.php');
$hook = new SB_Hook();
$sponsor = new SB_SponsorInterface($hook);
$file = './inc/sponsor.inc.php';
if (is_file($file))
{
include_once($file);
$sponsor = new SB_Sponsor($hook);
}
$browser = SB_reqVal('browser');
$browsers = array
(
'firefox' => array
(
'label' =>'Mozilla Firefox',
'homepage' =>'http://www.mozilla.org/products/firefox/',
'platforms'=>'9.0/All',
'usage' => '',
'exclude' =>array(),
'extra' =>array('sitebar_client','sitebar','sidebar','livebookmarks','search_engine','iframe','google'),
),
'konqueror' => array
(
'label' =>'Konqueror',
'homepage' =>'http://www.konqueror.org/',
'platforms'=>'3.x/Linux',
'usage' => '',
'exclude' =>array(),
'extra' =>array('sidebar_konqueror','iframe','google'),
),
'opera' => array
(
'label' =>'Opera Web Browser',
'homepage' =>'http://www.opera.com/',
'platforms'=>'9.5/WinXP',
'usage' => SB_P('integrator::usage_opera'),
'exclude' =>array('dir'),
'extra' =>array('hotlist','iframe','google'),
),
'msie' => array
(
'label' =>'Microsoft Internet Explorer',
'homepage' =>'http://www.microsoft.com/windows/ie/default.mspx',
'platforms'=>'8.0/Windows',
'usage' => '',
'exclude' =>array(),
'extra' =>array('install', 'uninstall', 'searchbar','iframe','google'),
),
'maxthon' => array
(
'label' =>'Maxthon Tabbed Browser',
'homepage' =>'http://www.maxthon.com/',
'platforms'=>'1.1.120/WinXP',
'usage' => '',
'exclude' =>array(),
'extra' =>array('maxthon_sidebar','maxthon_toolbar','iframe','google'),
),
'other' => array
(
'label' =>'Linux Distro/Other Tools',
'homepage' =>'',
'platforms'=>'Gentoo,Debian/PHP Layers Menu',
'usage' => '',
'exclude' =>array('dir','window','popup','addpage'),
'extra' =>array('gentoo','debian','phplm'),
),
);
$bookmarklet = "javascript:var w=window;var d=w.document;var cp=d.characterSet?d.characterSet:d.charset;".
"w.open('" . SB_Page::absBaseUrl() . "command.php?command=Add%20Bookmark".
"&url='+escape(w.location.href)+'".
"&name='+escape(d.title)+".
"(cp?'&cp='+cp:''),'sbBmkWin','".
$um->getParamB64('user','popup_params')."');void(0)";
$popup = "javascript:window.open('".SB_Page::absBaseUrl()."index.php" .
"?target=_blank','sbPopWin',".
"'directories=no,width=220,height=600,left=0,top=0,scrollbars=yes,location=no,menubar=no, status=no, toolbar=no');void(0)";
$urlParts = parse_url(SB_Page::absBaseUrl());
$uniqName = preg_replace("/[^\w]*/", "", $urlParts['host']);
$extra = array
(
'sitebar_client' => array
(
'label' => 'SiteBar Client',
'url' => 'https://addons.mozilla.org/firefox/3605/',
'desc' => SB_P('integrator::hint_sitebar'),
),
'livebookmarks' => array
(
'label' => 'Live Bookmarks',
'url' => sprintf('%sindex.php?w=firefox&mode=download', SB_Page::absBaseUrl()),
'desc' => SB_P('integrator::hint_livebookmarks'),
),
'sidebar' => array
(
'label' => 'Sidebar',
'url' => sprintf("javascript:sidebar.addPanel('SiteBar','%sindex.php','')",SB_Page::absBaseUrl()),
'desc' => SB_P('integrator::hint_sidebar'),
),
'search_engine' => array
(
'label' => 'Add Search Engine',
'url' => sprintf("javascript:void(window.sidebar.addSearchEngine('%s', '%s', '%s', '%s'))",
SB_Page::absBaseUrl().'integrator.php?lang='.SB_GetLanguage() . '&search_engine=/sitebar'.$uniqName.'.src',
SB_Page::absBaseUrl().''.SB_Skin::imgsrc('root_transparent').'?rename=/sitebar'.$uniqName.'.png',
strlen($um->getParamB64('config','feed_root_name'))?$um->getParamB64('config','feed_root_name'):'SiteBar',
SB_T("Bookmarks")),
'desc' => SB_P('integrator::hint_search_engine'),
),
'sidebar_mozilla' => array
(
'label' => 'Sidebar',
'url' => sprintf("javascript:sidebar.addPanel('SiteBar','%sindex.php','')",SB_Page::absBaseUrl()),
'desc' => SB_P('integrator::hint_sidebar_mozilla'),
),
'sidebar_konqueror' => array
(
'label' => 'Sidebar',
'url' => null,
'desc' => SB_P('integrator::hint_sidebar_konqueror', SB_Page::absBaseUrl()),
),
'hotlist' => array
(
'label' => 'Add to Panel',
'url' => SB_Page::absBaseUrl().'index.php',
'params' => array('title'=>'SiteBar', 'rel'=>'sidebar'),
'desc' => SB_P('integrator::hint_hotlist'),
),
'install' => array
(
'label' => 'Install',
'url' => 'integrator.php?lang='.SB_GetLanguage() . '&install=1',
'desc' => SB_P('integrator::hint_install'),
),
'uninstall' => array
(
'label' => 'Uninstall',
'url' => 'integrator.php?lang='.SB_GetLanguage() . '&install=0',
'desc' => SB_P('integrator::hint_uninstall'),
),
'searchbar' => array
(
'label' => 'Show in Search Bar',
'url' => sprintf("javascript:void(_search=open('%sindex.php','_search'))", SB_Page::absBaseUrl()),
'desc' => SB_P('integrator::hint_searchbar'),
),
'maxthon_sidebar' => array
(
'label' => 'Sidebar Plugin',
'url' => sprintf("http://sitebar.org/plugin/maxthon/?sidebar=%s", SB_Page::absBaseUrlShort()),
'desc' => SB_P('integrator::hint_maxthon_sidebar'),
),
'maxthon_toolbar' => array
(
'label' => 'Toolbar Plugin',
'url' => sprintf("http://sitebar.org/plugin/maxthon/?toolbar=%s", SB_Page::absBaseUrlShort()),
'desc' => SB_P('integrator::hint_maxthon_toolbar'),
),
'gentoo' => array
(
'label' => 'Gentoo Ebuild',
'url' => 'http://www.gentoo-portage.com/www-apps/sitebar',
'desc' => SB_P('integrator::hint_gentoo'),
),
'debian' => array
(
'label' => 'Debian',
'url' => 'http://packages.debian.org/unstable/web/sitebar',
'desc' => SB_P('integrator::hint_debian'),
),
'phplm' => array
(
'label' => 'PHP Layers Menu',
'url' => 'http://phplayersmenu.sourceforge.net/',
'desc' => SB_P('integrator::hint_phplm', sprintf('%sindex.php?w=phplm', SB_Page::absBaseUrl())),
),
);
$general = array
(
'addpage' => array
(
'label' => 'Add Page to SiteBar',
'url' => $bookmarklet,
'desc' => SB_P('integrator::hint_addpage'),
),
'window' => array
(
'label' => 'SiteBar',
'url' => SB_Page::absBaseUrl().'index.php',
'desc' => SB_P('integrator::hint_window'),
),
'dir' => array
(
'label' => 'SiteBar Directory',
'url' => SB_Page::absBaseUrl().'index.php?w=dir',
'desc' => SB_P('integrator::hint_dir'),
),
'popup' => array
(
'label' => 'SiteBar Pop-up',
'url' => $popup,
'desc' => SB_P('integrator::hint_popup'),
),
'iframe' => array
(
'label' => 'SiteBar iframe',
'url' => SB_Page::absBaseUrl().'iframe.php',
'desc' => str_replace('<IFRAME>','<IFRAME>',
SB_P('integrator::hint_iframe', array(SB_Page::absBaseUrl().'iframe.php'))),
),
'google' => array
(
'label' => 'Google Widget',
'url' => SB_Page::absBaseUrl().'google.php',
'desc' => SB_P('integrator::hint_google', array(SB_Page::absBaseUrl().'google.php')),
),
);
?>
<div id="main">
<div id="launcher">
<div>
<div id="home">
<a href="http://sitebar.org/"><img alt="" title="<?php echo SB_T('SiteBar Homepage')?>" src="<?php echo SB_Skin::imgsrc('logo')?>"></a>
<br>
[<a href="http://sitebar.org/"><?php echo SB_T('SiteBar Homepage')?></a>]
</div>
<div id="tip"><?php echo SB_P('integrator::welcome')?></div>
</div>
<div>
<h2><?php echo SB_T('SiteBar Integrator')?></h2>
<p>
<?php
echo SB_P('integrator::header');
?>
</p>
<table>
<tr>
<th><?php echo SB_T('Browser/Category')?></th>
<th colspan="2"><?php echo SB_T('Version/Platform')?></th>
</tr>
<?php
$lang = SB_GetLanguage();
foreach ($browsers as $id => $param)
{
echo "<tr>\r";
echo "<td><a".($browser == $id?" class=\"selected\"":"")." href=\"integrator.php?lang=$lang&browser=$id\" title=\"".SB_T('Integration Instructions')."\">".SB_T($param['label'])."</a></td>\r";
echo "<td>${param['platforms']}</td>\n";
echo "<td>";
if (isset($param['homepage']) && $param['homepage']!='')
{
echo "[<a href=\"${param['homepage']}\">Homepage</a>]";
}
else
{
echo " ";
}
echo "</td>\r";
echo "</tr>\r";
}
?>
</table>
<p class="comment">
<?php
if ($browser == '')
{
echo SB_P('integrator::hint');
}
else
{
echo '<a href="integrator.php?lang='.SB_GetLanguage().'">'.SB_T('Usage Tips for All Browsers').'</a>';
}
?>
</p>
<h2>
<?php
if ($browser == '')
{
echo SB_T('Usage Tips for All Browsers');
}
else
{
echo SB_T('Usage/Integration Tips for %s', array($browsers[$browser]['label']));
}
?>
</h2>
<?php
if ($browser != '')
{
if ( $browsers[$browser]['usage'] != '')
{
echo '<p class="browsertip">'."\r".
$browsers[$browser]['usage'].
"</p>\r";
}
}
?>
<table id="tips">
<tr>
<th class="tip"><?php echo SB_T('Tip')?></th>
<th class="desc"><?php echo SB_T('Description')?></th>
</tr>
<?php
foreach ($extra as $id => $params)
{
if (!isset($browsers[$browser]['extra']) || !in_array($id, $browsers[$browser]['extra']))
{
continue;
}
$urlparams = '';
if (isset($params['params']))
{
foreach ($params['params'] as $att => $val)
{
$urlparams .= " $att='" . $val . "'";
}
}
echo "<tr>\n";
if ($params['url'])
{
echo "<td class='extra'><a $urlparams href=\"${params['url']}\">".SB_T($params['label'])."</a></td>\n";
}
else
{
echo "<td class='extra'>".SB_T($params['label'])."</td>\n";
}
echo "<td class='desc'>${params['desc']}</td>\n";
echo "</tr>\n";
}
foreach ($general as $id => $params)
{
if (isset($browsers[$browser])
&& isset($browsers[$browser]['exclude'])
&& in_array($id, $browsers[$browser]['exclude']))
{
continue;
}
echo "<tr>\r";
if ($params['url'])
{
echo "<td class=\"general\"><a href=\"${params['url']}\">".SB_T($params['label'])."</a></td>\r";
}
else
{
echo "<td class=\"general\">".SB_T($params['label'])."</td>\r";
}
echo "<td class=\"desc\">${params['desc']}</td>\r";
echo "</tr>\r";
}
?>
</table>
<p class="comment">
<?php
echo SB_P('integrator::hint_bookmarklet');
?>
</p>
</div>
</div>
<div id="trailer">
<?php echo SB_P('integrator::copyright3') ?>
</div>
</div>
<div id="sponsorIntegratorVerticalRight"><?php $sponsor->integratorVerticalRight(); ?></div>
<?php
SB_Page::foot();
function IEInstall()
{
$install = $_REQUEST['install'];
$code = '{3F218DFB-00FF-297C-4D54-57696C4A6F6F}';
$title = 'SiteBar';
$url = SB_Page::absBaseUrl().'index.php';
$reg = '';
$filename = '';
$ctxUrl = SB_Page::absBaseUrl().'ctxmenu.php';
require_once('./inc/converter.inc.php');
$charsetKey = 'Charset in MS Windows';
$c = new SB_Converter(!$um || $um->getParam('config','use_conv_engine'),
(SB_T($charsetKey)==$charsetKey?null:SB_T($charsetKey)));
$addLink = $c->fromUTF8(SB_T('Add Link to SiteBar'));
$addPage = $c->fromUTF8(SB_T('Add Page to SiteBar'));
if ($install)
{
$filename = "InstallSiteBar.reg";
// See http://msdn.microsoft.com/workshop/browser/ext/tutorials/explorer.asp
$reg = <<<__INSTALL
REGEDIT4
[HKEY_CURRENT_USER\\Software\\Classes\\CLSID\\$code]
@="$title"
[HKEY_CURRENT_USER\\Software\\Classes\\CLSID\\$code\\Implemented Categories]
[HKEY_CURRENT_USER\\Software\\Classes\\CLSID\\$code\\Implemented Categories\\{00021493-0000-0000-C000-000000000046}]
[HKEY_CURRENT_USER\\Software\\Classes\\CLSID\\$code\\InProcServer32]
@="shdocvw.dll"
"ThreadingModel"="Apartment"
[HKEY_CURRENT_USER\\Software\\Classes\\CLSID\\$code\\Instance]
"CLSID"="{4D5C8C2A-D075-11d0-B416-00C04FB90376}"
[HKEY_CURRENT_USER\\Software\\Classes\\CLSID\\$code\\Instance\\InitPropertyBag]
"Url"="$url"
[-HKEY_CURRENT_USER\\Software\\Classes\\Component Categories\\{00021493-0000-0000-C000-000000000046}\\Enum]
[-HKEY_CURRENT_USER\\Software\\Classes\\Component Categories\\{00021494-0000-0000-C000-000000000046}\\Enum]
[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\$addLink]
"Contexts"=hex:22
"Flags"=hex:01
@="$ctxUrl?add=link"
[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\$addPage]
"Contexts"=hex:01
"Flags"=hex:01
@="$ctxUrl?add=page"
[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer\\Explorer Bars\\$code]
"BarSize"=hex:B4
"Name"="$title"
[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer\\Extensions\\{23F5C49C-74DF-42BA-A194-FF92A3B59FED}]
"ButtonText" = "SiteBar"
"MenuText" = "SiteBar Panel"
"MenuStatusBar"="Display SiteBar Panel"
"Icon" = hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,73,79,73,74,65,6d,33,32,5c,73,68,65,6c,6c,33,32,2e,64,6c,6c,2c,31,37,33,00
"HotIcon" = hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,73,79,73,74,65,6d,33,32,5c,73,68,65,6c,6c,33,32,2e,64,6c,6c,2c,31,37,33,00
"CLSID" = "{E0DD6CAB-2D10-11D2-8F1A-0000F87ABD16}"
"BandCLSID" = "$code"
"Default Visible"="Yes"
__INSTALL;
}
else
{
$filename = 'UnInstallSiteBar.reg';
$reg = <<<__UNINSTALL
REGEDIT4
[-HKEY_CURRENT_USER\\Software\\Classes\\CLSID\\$code]
[-HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer\\Explorer Bars\\$code]
[-HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer\\Extensions\\{23F5C49C-74DF-42BA-A194-FF92A3B59FED}]
[-HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\Add Link to SiteBar]
[-HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\Add Page to SiteBar]
[-HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\$addLink]
[-HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\$addPage]
__UNINSTALL;
}
header('Content-Type: application/octet-stream'."\r");
header('Content-Disposition: attachment; filename="'.$filename."\"\r");
header('Content-Transfer-Encoding: binary'."\r");
header('Content-Length: ' . strlen($reg)."\r");
echo $reg;
exit;
}
function SearchEngine()
{
$um = SB_UserManager::staticInstance();
$name = $um->getParamB64('config','feed_root_name');
if (!strlen($name))
{
$name = 'SiteBar';
}
?>
# SiteBar plug-in
<search
name="<?php echo $name ?>"
description="<?php echo SB_T('Search in SiteBar Bookmarks') ?>"
method="GET"
action="<?php echo SB_Page::absBaseUrl() ?>search.php"
searchForm="<?php echo SB_Page::absBaseUrl() ?>index.php"
>
<input name="q" user>
<input name="sourceid" value="sitebar-search">
</search>
<?php
exit;
}
?>