• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-jp-ancient: Commit

Nucleus CMS日本語版SVNをgit-svnしたもの。リポジトリの変換作業用


Commit MetaInfo

Revisionf957a0e44a7734e5199eaf09e5de7b002c771d14 (tree)
Zeit2009-03-17 01:52:33
Autorshizuki <shizuki@1ca2...>
Commitershizuki

Log Message

bookmarklet.php内のuniDecode関数で、「preg_replace_callback」のコールバック関数名がクォートでくくられていなかったのを修正

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk/utf8@976 1ca29b6e-896d-4ea0-84a5-967f57386b96

Ändern Zusammenfassung

Diff

--- a/nucleus/bookmarklet.php
+++ b/nucleus/bookmarklet.php
@@ -19,358 +19,358 @@
1919 * $NucleusJP: bookmarklet.php,v 1.9.2.1 2007/09/07 07:16:39 kimitake Exp $
2020 */
2121
22-// bookmarklet is part of admin area (might need XML-RPC)
23-$CONF = array();
24-$CONF['UsingAdminArea'] = 1;
25-
26-// include all classes and config data
27-include('../config.php');
28-
29-$action = requestVar('action');
30-
31-if ($action == 'contextmenucode') {
32- bm_doContextMenuCode();
33- exit;
34-}
35-
36-if (!$member->isLoggedIn() ) {
37- bm_loginAndPassThrough();
38- exit;
39-}
40-
41-// on successfull login
42-if ( ($action == 'login') && ($member->isLoggedIn() ) ) {
43- $action = requestVar('nextaction');
44-}
45-
46-if ($action == '') {
47- $action = 'add';
48-}
49-
50-sendContentType('text/html', 'bookmarklet-' . $action);
51-
52-// check ticket
53-$action = strtolower($action);
54-$aActionsNotToCheck = array('login', 'add', 'edit');
55-
56-if (!in_array($action, $aActionsNotToCheck) ) {
57-
58- if (!$manager->checkTicket() ) {
59- bm_doError(_ERROR_BADTICKET);
60- }
61-
62-}
63-
64-// find out what to do
65-switch ($action) {
66- // adds the item for real
67- case 'additem':
68- bm_doAddItem();
69- break;
70-
71- // shows the edit item form
72- case 'edit':
73- bm_doEditForm();
74- break;
75-
76- // edits the item for real
77- case 'edititem':
78- bm_doEditItem();
79- break;
80-
81- // on login, 'action' gets changed to 'nextaction'
82- case 'login':
83- bm_doError('Something went wrong');
84- break;
85-
86- // shows the fill in form
87- case 'add':
88- default:
89- bm_doShowForm();
90- break;
91-}
92-
93-function bm_doAddItem() {
94- global $member, $manager, $CONF;
95-
96- $manager->loadClass('ITEM');
97- $result = ITEM::createFromRequest();
98-
99- if ($result['status'] == 'error') {
100- bm_doError($result['message']);
101- }
102-
103- $blogid = getBlogIDFromItemID($result['itemid']);
104- $blog =& $manager->getBlog($blogid);
105-
106- if ($result['status'] == 'newcategory') {
107- $href = 'index.php?action=categoryedit&amp;blogid=' . $blogid . '&amp;catid=' . $result['catid'];
108- $onclick = 'if (event &amp;&amp; event.preventDefault) event.preventDefault(); window.open(this.href); return false;';
109- $title = _BOOKMARKLET_NEW_WINDOW;
110- $aTag = ' <a href="' . $href . '" onclick="' . $onclick . '" title="' . $title . '">';
111- $message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>';
112- $extrahead = '';
113- } elseif ( (postVar('actiontype') == 'addnow') && $blog->sendPing() ) {
114- $message = _BOOKMARKLET_SEND_PING;
115- $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid) );
116- $extrahead = '<meta http-equiv="refresh" content="1; url=' . htmlspecialchars($pingUrl) . '" />';
117- } else {
118- $message = _ITEM_ADDED;
119- $extrahead = '';
120- }
121-
122- bm_message(_ITEM_ADDED, _ITEM_ADDED, $message,$extrahead);
123-}
124-
125-function bm_doEditItem() {
126- global $member, $manager, $CONF;
127-
128- $itemid = intRequestVar('itemid');
129- $catid = postVar('catid');
130-
131- // only allow if user is allowed to alter item
132- if (!$member->canUpdateItem($itemid, $catid) ) {
133- bm_doError(_ERROR_DISALLOWED);
134- }
135-
136- $body = postVar('body');
137- $title = postVar('title');
138- $more = postVar('more');
139- $closed = intPostVar('closed');
140- $actiontype = postVar('actiontype');
141- $draftid = intPostVar('draftid');
142-
143- // redirect to admin area on delete (has delete confirmation)
144- if ($actiontype == 'delete') {
145- redirect('index.php?action=itemdelete&itemid=' . $itemid);
146- exit;
147- }
148-
149- // create new category if needed (only on edit/changedate)
150- if (strstr($catid,'newcat') ) {
151- // get blogid
152- list($blogid) = sscanf($catid, "newcat-%d");
153-
154- // create
155- $blog =& $manager->getBlog($blogid);
156- $catid = $blog->createNewCategory();
157-
158- // show error when sth goes wrong
159- if (!$catid) {
160- bm_doError('Could not create new category');
161- }
162- }
163-
164- // only edit action is allowed for bookmarklet edit
165- switch ($actiontype) {
166- case 'changedate':
167- $publish = 1;
168- $wasdraft = 0;
169- $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year') );
170- break;
171- case 'edit':
172- $publish = 1;
173- $wasdraft = 0;
174- $timestamp = 0;
175- break;
176- case 'backtodrafts':
177- $publish = 0;
178- $wasdraft = 0;
179- $timestamp = 0;
180- break;
181- default:
182- bm_doError('Something went wrong');
183- }
184-
185- // update item for real
186- ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
187-
188- if ($draftid > 0) {
189- ITEM::delete($draftid);
190- }
191-
192- // show success message
193- if ($catid != intPostVar('catid') ) {
194- $href = 'index.php?action=categoryedit&amp;blogid=' . $blog->getID() . '&amp;catid=' . $catid;
195- $onclick = 'if (event &amp;&amp; event.preventDefault) event.preventDefault(); window.open(this.href); return false;';
196- $title = _BOOKMARKLET_NEW_WINDOW;
197- $aTag = ' <a href="' . $href . '" onclick="' . $onclick . '" title="' . $title . '">';
198- $message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>';
199- bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>', '');
200- } else {
201- bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _ITEM_UPDATED, '');
202- }
203-}
204-
205-function bm_loginAndPassThrough() {
206-
207- $blogid = intRequestVar('blogid');
208- $log_text = requestVar('logtext');
209- $log_link = requestVar('loglink');
210- $log_linktitle = requestVar('loglinktitle');
211-
212- ?>
213-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
214- <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>
215- <head>
216- <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
217- <title>Nucleus</title>
218- <?php bm_style(); ?>
219- </head>
220- <body>
221- <h1><?php echo _LOGIN_PLEASE ?></h1>
222-
223- <form method="post" action="bookmarklet.php">
224- <p>
225- <input name="action" value="login" type="hidden" />
226- <input name="blogid" value="<?php echo htmlspecialchars($blogid); ?>" type="hidden" />
227- <input name="logtext" value="<?php echo htmlspecialchars($log_text); ?>" type="hidden" />
228- <input name="loglink" value="<?php echo htmlspecialchars($log_link); ?>" type="hidden" />
229- <input name="loglinktitle" value="<?php echo htmlspecialchars($log_linktitle); ?>" type="hidden" />
230- <?php echo _LOGINFORM_NAME ?>:
231- <br /><input name="login" />
232- <br /><?php echo _LOGINFORM_PWD ?>:
233- <br /><input name="password" type="password" />
234- <br /><br />
235- <br /><input type="submit" value="<?php echo _LOGIN ?>" />
236- </p>
237- </form>
238- <p><a href="bookmarklet.php" onclick="window.close();"><?php echo _POPUP_CLOSE ?></a></p>
239- </body>
240- </html>
241- <?php
242-}
243-
244-function bm_doShowForm() {
245- global $member;
246-
247- $blogid = intRequestVar('blogid');
248- $log_text = trim(requestVar('logtext'));
249- $log_link = requestVar('loglink');
250- $log_linktitle = requestVar('loglinktitle');
251-
252- $log_text = uniDecode($log_text,_CHARSET);
253- $log_linktitle = uniDecode($log_linktitle,_CHARSET);
254-
255- if (!BLOG::existsID($blogid) ) {
256- bm_doError(_ERROR_NOSUCHBLOG);
257- }
258-
259- if (!$member->isTeamMember($blogid) ) {
260- bm_doError(_ERROR_NOTONTEAM);
261- }
262-
263- $logje = '';
264-
265- if ($log_text) {
266- $logje .= '<blockquote><div>"' . htmlspecialchars($log_text) . '"</div></blockquote>' . "\n";
267- }
268-
269- if (!$log_linktitle) {
270- $log_linktitle = $log_link;
271- }
272-
273- if ($log_link) {
274- $logje .= '<a href="' . htmlspecialchars($log_link) . '">' . htmlspecialchars($log_linktitle) . '</a>';
275- }
276-
277- $item['body'] = $logje;
278- $item['title'] = htmlspecialchars($log_linktitle);
279-
280- $factory = new PAGEFACTORY($blogid);
281- $factory->createAddForm('bookmarklet', $item);
282-}
283-
284-function bm_doEditForm() {
285- global $member, $manager;
286-
287- $itemid = intRequestVar('itemid');
288-
289- if (!$manager->existsItem($itemid, 0, 0) ) {
290- bm_doError(_ERROR_NOSUCHITEM);
291- }
292-
293- if (!$member->canAlterItem($itemid) ) {
294- bm_doError(_ERROR_DISALLOWED);
295- }
296-
297- $item =& $manager->getItem($itemid, 1, 1);
298- $blog =& $manager->getBlog(getBlogIDFromItemID($itemid) );
299-
300- $manager->notify('PrepareItemForEdit', array('item' => &$item) );
301-
302- if ($blog->convertBreaks() ) {
303- $item['body'] = removeBreaks($item['body']);
304- $item['more'] = removeBreaks($item['more']);
305- }
306-
307- $formfactory = new PAGEFACTORY($blog->getID() );
308- $formfactory->createEditForm('bookmarklet', $item);
309-}
310-
311-function bm_doError($msg) {
312- bm_message(_ERROR, _ERRORMSG, $msg);
313- die;
314-}
315-
316-function bm_message($title, $head, $msg, $extrahead = '') {
317- ?>
318-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
319- <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>
320- <head>
321- <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
322- <title><?php echo $title ?></title>
323- <?php bm_style(); ?>
324- <?php echo $extrahead; ?>
325- </head>
326- <body>
327- <h1><?php echo $head; ?></h1>
328- <p><?php echo $msg; ?></p>
329- <p><a href="bookmarklet.php" onclick="window.close();window.opener.location.reload();"><?php echo _POPUP_CLOSE ?></a></p>
330- </body>
331- </html>
332-
333- <?php
334-}
335-
336-function bm_style() {
337- echo '<link rel="stylesheet" type="text/css" href="styles/bookmarklet.css" />';
338- echo '<link rel="stylesheet" type="text/css" href="styles/addedit.css" />';
339-}
340-
341-function bm_doContextMenuCode() {
342- global $CONF;
343- ?>
344-<script type="text/javascript" defer="defer">
345-doc = external.menuArguments.document;
346-lt = escape(doc.selection.createRange().text);
347-loglink = escape(external.menuArguments.location.href);
348-loglinktitle = escape(doc.title);
349-wingm = window.open('<?php echo $CONF['AdminURL']?>bookmarklet.php?blogid=<?php echo intGetVar('blogid')?>&logtext=' + lt + '&loglink=' + loglink + '&loglinktitle=' + loglinktitle, 'nucleusbm', 'scrollbars=yes,width=600,height=500,left=10,top=10,status=yes,resizable=yes');
350-wingm.focus();
351-</script>
352- <?php
353-}
354-
355-function uniDecode($str,$charcode){
356- $text = preg_replace_callback("/%u[0-9A-Za-z]{4}/",toUtf8,$str);
357- return mb_convert_encoding($text, $charcode, 'UTF-8');
358-}
359-function toUtf8($ar){
360- foreach($ar as $val){
361- $val = intval(substr($val,2),16);
362- if($val < 0x7F){ // 0000-007F
363- $c .= chr($val);
364- }elseif($val < 0x800) { // 0080-0800
365- $c .= chr(0xC0 | ($val / 64));
366- $c .= chr(0x80 | ($val % 64));
367- }else{ // 0800-FFFF
368- $c .= chr(0xE0 | (($val / 64) / 64));
369- $c .= chr(0x80 | (($val / 64) % 64));
370- $c .= chr(0x80 | ($val % 64));
371- }
372- }
373- return $c;
374-}
375-
22+// bookmarklet is part of admin area (might need XML-RPC)
23+$CONF = array();
24+$CONF['UsingAdminArea'] = 1;
25+
26+// include all classes and config data
27+include('../config.php');
28+
29+$action = requestVar('action');
30+
31+if ($action == 'contextmenucode') {
32+ bm_doContextMenuCode();
33+ exit;
34+}
35+
36+if (!$member->isLoggedIn() ) {
37+ bm_loginAndPassThrough();
38+ exit;
39+}
40+
41+// on successfull login
42+if ( ($action == 'login') && ($member->isLoggedIn() ) ) {
43+ $action = requestVar('nextaction');
44+}
45+
46+if ($action == '') {
47+ $action = 'add';
48+}
49+
50+sendContentType('text/html', 'bookmarklet-' . $action);
51+
52+// check ticket
53+$action = strtolower($action);
54+$aActionsNotToCheck = array('login', 'add', 'edit');
55+
56+if (!in_array($action, $aActionsNotToCheck) ) {
57+
58+ if (!$manager->checkTicket() ) {
59+ bm_doError(_ERROR_BADTICKET);
60+ }
61+
62+}
63+
64+// find out what to do
65+switch ($action) {
66+ // adds the item for real
67+ case 'additem':
68+ bm_doAddItem();
69+ break;
70+
71+ // shows the edit item form
72+ case 'edit':
73+ bm_doEditForm();
74+ break;
75+
76+ // edits the item for real
77+ case 'edititem':
78+ bm_doEditItem();
79+ break;
80+
81+ // on login, 'action' gets changed to 'nextaction'
82+ case 'login':
83+ bm_doError('Something went wrong');
84+ break;
85+
86+ // shows the fill in form
87+ case 'add':
88+ default:
89+ bm_doShowForm();
90+ break;
91+}
92+
93+function bm_doAddItem() {
94+ global $member, $manager, $CONF;
95+
96+ $manager->loadClass('ITEM');
97+ $result = ITEM::createFromRequest();
98+
99+ if ($result['status'] == 'error') {
100+ bm_doError($result['message']);
101+ }
102+
103+ $blogid = getBlogIDFromItemID($result['itemid']);
104+ $blog =& $manager->getBlog($blogid);
105+
106+ if ($result['status'] == 'newcategory') {
107+ $href = 'index.php?action=categoryedit&amp;blogid=' . $blogid . '&amp;catid=' . $result['catid'];
108+ $onclick = 'if (event &amp;&amp; event.preventDefault) event.preventDefault(); window.open(this.href); return false;';
109+ $title = _BOOKMARKLET_NEW_WINDOW;
110+ $aTag = ' <a href="' . $href . '" onclick="' . $onclick . '" title="' . $title . '">';
111+ $message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>';
112+ $extrahead = '';
113+ } elseif ( (postVar('actiontype') == 'addnow') && $blog->sendPing() ) {
114+ $message = _BOOKMARKLET_SEND_PING;
115+ $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid) );
116+ $extrahead = '<meta http-equiv="refresh" content="1; url=' . htmlspecialchars($pingUrl) . '" />';
117+ } else {
118+ $message = _ITEM_ADDED;
119+ $extrahead = '';
120+ }
121+
122+ bm_message(_ITEM_ADDED, _ITEM_ADDED, $message,$extrahead);
123+}
124+
125+function bm_doEditItem() {
126+ global $member, $manager, $CONF;
127+
128+ $itemid = intRequestVar('itemid');
129+ $catid = postVar('catid');
130+
131+ // only allow if user is allowed to alter item
132+ if (!$member->canUpdateItem($itemid, $catid) ) {
133+ bm_doError(_ERROR_DISALLOWED);
134+ }
135+
136+ $body = postVar('body');
137+ $title = postVar('title');
138+ $more = postVar('more');
139+ $closed = intPostVar('closed');
140+ $actiontype = postVar('actiontype');
141+ $draftid = intPostVar('draftid');
142+
143+ // redirect to admin area on delete (has delete confirmation)
144+ if ($actiontype == 'delete') {
145+ redirect('index.php?action=itemdelete&itemid=' . $itemid);
146+ exit;
147+ }
148+
149+ // create new category if needed (only on edit/changedate)
150+ if (strstr($catid,'newcat') ) {
151+ // get blogid
152+ list($blogid) = sscanf($catid, "newcat-%d");
153+
154+ // create
155+ $blog =& $manager->getBlog($blogid);
156+ $catid = $blog->createNewCategory();
157+
158+ // show error when sth goes wrong
159+ if (!$catid) {
160+ bm_doError('Could not create new category');
161+ }
162+ }
163+
164+ // only edit action is allowed for bookmarklet edit
165+ switch ($actiontype) {
166+ case 'changedate':
167+ $publish = 1;
168+ $wasdraft = 0;
169+ $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year') );
170+ break;
171+ case 'edit':
172+ $publish = 1;
173+ $wasdraft = 0;
174+ $timestamp = 0;
175+ break;
176+ case 'backtodrafts':
177+ $publish = 0;
178+ $wasdraft = 0;
179+ $timestamp = 0;
180+ break;
181+ default:
182+ bm_doError('Something went wrong');
183+ }
184+
185+ // update item for real
186+ ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
187+
188+ if ($draftid > 0) {
189+ ITEM::delete($draftid);
190+ }
191+
192+ // show success message
193+ if ($catid != intPostVar('catid') ) {
194+ $href = 'index.php?action=categoryedit&amp;blogid=' . $blog->getID() . '&amp;catid=' . $catid;
195+ $onclick = 'if (event &amp;&amp; event.preventDefault) event.preventDefault(); window.open(this.href); return false;';
196+ $title = _BOOKMARKLET_NEW_WINDOW;
197+ $aTag = ' <a href="' . $href . '" onclick="' . $onclick . '" title="' . $title . '">';
198+ $message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>';
199+ bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>', '');
200+ } else {
201+ bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _ITEM_UPDATED, '');
202+ }
203+}
204+
205+function bm_loginAndPassThrough() {
206+
207+ $blogid = intRequestVar('blogid');
208+ $log_text = requestVar('logtext');
209+ $log_link = requestVar('loglink');
210+ $log_linktitle = requestVar('loglinktitle');
211+
212+ ?>
213+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
214+ <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>
215+ <head>
216+ <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
217+ <title>Nucleus</title>
218+ <?php bm_style(); ?>
219+ </head>
220+ <body>
221+ <h1><?php echo _LOGIN_PLEASE ?></h1>
222+
223+ <form method="post" action="bookmarklet.php">
224+ <p>
225+ <input name="action" value="login" type="hidden" />
226+ <input name="blogid" value="<?php echo htmlspecialchars($blogid); ?>" type="hidden" />
227+ <input name="logtext" value="<?php echo htmlspecialchars($log_text); ?>" type="hidden" />
228+ <input name="loglink" value="<?php echo htmlspecialchars($log_link); ?>" type="hidden" />
229+ <input name="loglinktitle" value="<?php echo htmlspecialchars($log_linktitle); ?>" type="hidden" />
230+ <?php echo _LOGINFORM_NAME ?>:
231+ <br /><input name="login" />
232+ <br /><?php echo _LOGINFORM_PWD ?>:
233+ <br /><input name="password" type="password" />
234+ <br /><br />
235+ <br /><input type="submit" value="<?php echo _LOGIN ?>" />
236+ </p>
237+ </form>
238+ <p><a href="bookmarklet.php" onclick="window.close();"><?php echo _POPUP_CLOSE ?></a></p>
239+ </body>
240+ </html>
241+ <?php
242+}
243+
244+function bm_doShowForm() {
245+ global $member;
246+
247+ $blogid = intRequestVar('blogid');
248+ $log_text = trim(requestVar('logtext'));
249+ $log_link = requestVar('loglink');
250+ $log_linktitle = requestVar('loglinktitle');
251+
252+ $log_text = uniDecode($log_text,_CHARSET);
253+ $log_linktitle = uniDecode($log_linktitle,_CHARSET);
254+
255+ if (!BLOG::existsID($blogid) ) {
256+ bm_doError(_ERROR_NOSUCHBLOG);
257+ }
258+
259+ if (!$member->isTeamMember($blogid) ) {
260+ bm_doError(_ERROR_NOTONTEAM);
261+ }
262+
263+ $logje = '';
264+
265+ if ($log_text) {
266+ $logje .= '<blockquote><div>"' . htmlspecialchars($log_text) . '"</div></blockquote>' . "\n";
267+ }
268+
269+ if (!$log_linktitle) {
270+ $log_linktitle = $log_link;
271+ }
272+
273+ if ($log_link) {
274+ $logje .= '<a href="' . htmlspecialchars($log_link) . '">' . htmlspecialchars($log_linktitle) . '</a>';
275+ }
276+
277+ $item['body'] = $logje;
278+ $item['title'] = htmlspecialchars($log_linktitle);
279+
280+ $factory = new PAGEFACTORY($blogid);
281+ $factory->createAddForm('bookmarklet', $item);
282+}
283+
284+function bm_doEditForm() {
285+ global $member, $manager;
286+
287+ $itemid = intRequestVar('itemid');
288+
289+ if (!$manager->existsItem($itemid, 0, 0) ) {
290+ bm_doError(_ERROR_NOSUCHITEM);
291+ }
292+
293+ if (!$member->canAlterItem($itemid) ) {
294+ bm_doError(_ERROR_DISALLOWED);
295+ }
296+
297+ $item =& $manager->getItem($itemid, 1, 1);
298+ $blog =& $manager->getBlog(getBlogIDFromItemID($itemid) );
299+
300+ $manager->notify('PrepareItemForEdit', array('item' => &$item) );
301+
302+ if ($blog->convertBreaks() ) {
303+ $item['body'] = removeBreaks($item['body']);
304+ $item['more'] = removeBreaks($item['more']);
305+ }
306+
307+ $formfactory = new PAGEFACTORY($blog->getID() );
308+ $formfactory->createEditForm('bookmarklet', $item);
309+}
310+
311+function bm_doError($msg) {
312+ bm_message(_ERROR, _ERRORMSG, $msg);
313+ die;
314+}
315+
316+function bm_message($title, $head, $msg, $extrahead = '') {
317+ ?>
318+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
319+ <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>
320+ <head>
321+ <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
322+ <title><?php echo $title ?></title>
323+ <?php bm_style(); ?>
324+ <?php echo $extrahead; ?>
325+ </head>
326+ <body>
327+ <h1><?php echo $head; ?></h1>
328+ <p><?php echo $msg; ?></p>
329+ <p><a href="bookmarklet.php" onclick="window.close();window.opener.location.reload();"><?php echo _POPUP_CLOSE ?></a></p>
330+ </body>
331+ </html>
332+
333+ <?php
334+}
335+
336+function bm_style() {
337+ echo '<link rel="stylesheet" type="text/css" href="styles/bookmarklet.css" />';
338+ echo '<link rel="stylesheet" type="text/css" href="styles/addedit.css" />';
339+}
340+
341+function bm_doContextMenuCode() {
342+ global $CONF;
343+ ?>
344+<script type="text/javascript" defer="defer">
345+doc = external.menuArguments.document;
346+lt = escape(doc.selection.createRange().text);
347+loglink = escape(external.menuArguments.location.href);
348+loglinktitle = escape(doc.title);
349+wingm = window.open('<?php echo $CONF['AdminURL']?>bookmarklet.php?blogid=<?php echo intGetVar('blogid')?>&logtext=' + lt + '&loglink=' + loglink + '&loglinktitle=' + loglinktitle, 'nucleusbm', 'scrollbars=yes,width=600,height=500,left=10,top=10,status=yes,resizable=yes');
350+wingm.focus();
351+</script>
352+ <?php
353+}
354+
355+function uniDecode($str,$charcode){
356+ $text = preg_replace_callback("/%u[0-9A-Za-z]{4}/", 'toUtf8', $str);
357+ return mb_convert_encoding($text, $charcode, 'UTF-8');
358+}
359+function toUtf8($ar){
360+ foreach($ar as $val){
361+ $val = intval(substr($val,2),16);
362+ if($val < 0x7F){ // 0000-007F
363+ $c .= chr($val);
364+ }elseif($val < 0x800) { // 0080-0800
365+ $c .= chr(0xC0 | ($val / 64));
366+ $c .= chr(0x80 | ($val % 64));
367+ }else{ // 0800-FFFF
368+ $c .= chr(0xE0 | (($val / 64) / 64));
369+ $c .= chr(0x80 | (($val / 64) % 64));
370+ $c .= chr(0x80 | ($val % 64));
371+ }
372+ }
373+ return $c;
374+}
375+
376376 ?>
\ No newline at end of file
Show on old repository browser