1<HTML>
2<style>
3    .buttonblock {
4  display: block;
5  width: 100%;
6  border: none;
7  background-color: #04AA6D;
8  padding: 14px 28px;
9  font-size: 16px;
10  cursor: pointer;
11  text-align: center;
12}
13
14</style>
15<HEAD>
16<?php
17        /**
18     * bookmark2wiki
19	 * forked from post2wiki.php by riny [at] bk [dot] ru
20	 * To bookmark webpage using bookmarklet
21     * The app will add the url, title and hightlighed text you want to the end of the content of the targeted namespace. It does not directly read/white the dokuwiki page folder.
22	 * Version 0.1
23	 * todo : check security of input
24         * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
25         * @author     edwardcodelab https://github.com/edwardcodelab
26         **/
27
28	// TYPICAL USAGE :
29        //                 Create bookmarklet as shown in the bookmarklet part below:
30        //                 Change the window.open statement to reflect the location of the bookmark2wiki.php script.
31        //                 Drag bookmarklet to your toolbar.
32        //  BOOKMARKLET :
33	//  javascript:Q=document.selection?document.selection.createRange().text:document.getSelection(); void(window.open('https://myserver/bookmark2wiki.php?te='+escape(Q)+'&ur='+ escape(location.href)+'&ti='+escape(document.title),'dokuwikiadd','scrollbars=yes,resizable=yes,toolbars=yes,width=200,height=100,left=200,top=200,status=yes'));
34
35	// SETUP SECTION
36	$namespace="new_bookmarks";  // default namespace for weblog
37	$host="https://yourhost.com";    // servername where your dokuwiki is
38	$dokuwikipath="/dokuwiki/doku.php"; //path to your dokuwiki
39
40	// POST TO WIKI
41	$timestamp = date("Y:m:d:H:i:s"); //Group blogged items per year
42	$wikitext=$_GET['te'];  // things to log : Selected text
43	$url=$_GET['ur'];       // things to log : URL
44	$title=$_GET['ti'];     // things to log : title
45	$string = preg_replace('/%u([0-9A-F]+)/', '&#x$1;', $title); // convert the unicode
46    $title = html_entity_decode($string, ENT_COMPAT, 'UTF-8');
47    $string = preg_replace('/%u([0-9A-F]+)/', '&#x$1;', $wikitext); // convert the unicode
48    $wikitext = html_entity_decode($string, ENT_COMPAT, 'UTF-8');
49	$targeturl="https://$host$dokuwikipath?id=$namespace&do=edit";
50
51	      echo '<script>';
52          echo 'function loadFunc(){';
53          echo 'document.getElementById("top").contentWindow.document.getElementsByTagName("textarea")[0].innerHTML += "    * [['.$url.'|'.$title.']] \\\\\\\\ '.$wikitext.' -- '.$timestamp.'\r\n";';
54
55          echo '};';
56          echo '</script>';
57
58  ?>
59
60</HEAD>
61<BODY onload="loadFunc();">
62<button id="close_button" class="buttonblock" onclick='window.close();'>CLOSE</button>
63 <?php
64echo '<iframe src="'.$targeturl.'" id="top" width="100%" height="100%"></iframe>';
65    ?>
66</BODY>
67
68</HTML>