*
* @license http://nucleuscms.org/license.txt GNU General Public License
* @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: bookmarklet.php,v 1.10 2008-02-08 09:31:22 kimitake Exp $
+ * @version $Id$
* $NucleusJP: bookmarklet.php,v 1.9.2.1 2007/09/07 07:16:39 kimitake Exp $
*/
-// bookmarklet is part of admin area (might need XML-RPC)
-$CONF = array();
-$CONF['UsingAdminArea'] = 1;
-
-// include all classes and config data
-include('../config.php');
-
-$action = requestVar('action');
-
-if ($action == 'contextmenucode') {
- bm_doContextMenuCode();
- exit;
-}
-
-if (!$member->isLoggedIn() ) {
- bm_loginAndPassThrough();
- exit;
-}
-
-// on successfull login
-if ( ($action == 'login') && ($member->isLoggedIn() ) ) {
- $action = requestVar('nextaction');
-}
-
-if ($action == '') {
- $action = 'add';
-}
-
-sendContentType('application/xhtml+xml', 'bookmarklet-' . $action);
-
-// check ticket
-$action = strtolower($action);
-$aActionsNotToCheck = array('login', 'add', 'edit');
-
-if (!in_array($action, $aActionsNotToCheck) ) {
-
- if (!$manager->checkTicket() ) {
- bm_doError(_ERROR_BADTICKET);
- }
-
-}
-
-// find out what to do
-switch ($action) {
- // adds the item for real
- case 'additem':
- bm_doAddItem();
- break;
-
- // shows the edit item form
- case 'edit':
- bm_doEditForm();
- break;
-
- // edits the item for real
- case 'edititem':
- bm_doEditItem();
- break;
-
- // on login, 'action' gets changed to 'nextaction'
- case 'login':
- bm_doError('Something went wrong');
- break;
-
- // shows the fill in form
- case 'add':
- default:
- bm_doShowForm();
- break;
-}
-
-function bm_doAddItem() {
- global $member, $manager, $CONF;
-
- $manager->loadClass('ITEM');
- $result = ITEM::createFromRequest();
-
- if ($result['status'] == 'error') {
- bm_doError($result['message']);
- }
-
- $blogid = getBlogIDFromItemID($result['itemid']);
- $blog =& $manager->getBlog($blogid);
-
- if ($result['status'] == 'newcategory') {
+// bookmarklet is part of admin area (might need XML-RPC)\r
+$CONF = array();\r
+$CONF['UsingAdminArea'] = 1;\r
+\r
+// include all classes and config data\r
+include('../config.php');\r
+\r
+$action = requestVar('action');\r
+\r
+if ($action == 'contextmenucode') {\r
+ bm_doContextMenuCode();\r
+ exit;\r
+}\r
+\r
+if (!$member->isLoggedIn() ) {\r
+ bm_loginAndPassThrough();\r
+ exit;\r
+}\r
+\r
+// on successfull login\r
+if ( ($action == 'login') && ($member->isLoggedIn() ) ) {\r
+ $action = requestVar('nextaction');\r
+}\r
+\r
+if ($action == '') {\r
+ $action = 'add';\r
+}\r
+\r
+sendContentType('text/html', 'bookmarklet-' . $action);\r
+\r
+// check ticket\r
+$action = strtolower($action);\r
+$aActionsNotToCheck = array('login', 'add', 'edit');\r
+\r
+if (!in_array($action, $aActionsNotToCheck) ) {\r
+\r
+ if (!$manager->checkTicket() ) {\r
+ bm_doError(_ERROR_BADTICKET);\r
+ }\r
+\r
+}\r
+\r
+// find out what to do\r
+switch ($action) {\r
+ // adds the item for real\r
+ case 'additem':\r
+ bm_doAddItem();\r
+ break;\r
+\r
+ // shows the edit item form\r
+ case 'edit':\r
+ bm_doEditForm();\r
+ break;\r
+\r
+ // edits the item for real\r
+ case 'edititem':\r
+ bm_doEditItem();\r
+ break;\r
+\r
+ // on login, 'action' gets changed to 'nextaction'\r
+ case 'login':\r
+ bm_doError('Something went wrong');\r
+ break;\r
+\r
+ // shows the fill in form\r
+ case 'add':\r
+ default:\r
+ bm_doShowForm();\r
+ break;\r
+}\r
+\r
+function bm_doAddItem() {\r
+ global $member, $manager, $CONF;\r
+\r
+ $manager->loadClass('ITEM');\r
+ $result = ITEM::createFromRequest();\r
+\r
+ if ($result['status'] == 'error') {\r
+ bm_doError($result['message']);\r
+ }\r
+\r
+ $blogid = getBlogIDFromItemID($result['itemid']);\r
+ $blog =& $manager->getBlog($blogid);\r
+\r
+ if ($result['status'] == 'newcategory') {\r
$href = 'index.php?action=categoryedit&blogid=' . $blogid . '&catid=' . $result['catid'];\r
$onclick = 'if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;';\r
$title = _BOOKMARKLET_NEW_WINDOW;\r
$aTag = ' <a href="' . $href . '" onclick="' . $onclick . '" title="' . $title . '">';\r
$message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>';\r
$extrahead = '';\r
- } elseif ( (postVar('actiontype') == 'addnow') && $blog->sendPing() ) {
- $message = _BOOKMARKLET_SEND_PING;
- $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid) );
- $extrahead = '<meta http-equiv="refresh" content="1; url=' . htmlspecialchars($pingUrl) . '" />';
- } else {
- $message = _ITEM_ADDED;
- $extrahead = '';
- }
-
- bm_message(_ITEM_ADDED, _ITEM_ADDED, $message,$extrahead);
-}
-
-function bm_doEditItem() {
- global $member, $manager, $CONF;
-
- $itemid = intRequestVar('itemid');
- $catid = postVar('catid');
-
- // only allow if user is allowed to alter item
- if (!$member->canUpdateItem($itemid, $catid) ) {
- bm_doError(_ERROR_DISALLOWED);
- }
-
- $body = postVar('body');
- $title = postVar('title');
- $more = postVar('more');
- $closed = intPostVar('closed');
- $actiontype = postVar('actiontype');
- $draftid = intPostVar('draftid');
-
- // redirect to admin area on delete (has delete confirmation)
- if ($actiontype == 'delete') {
- redirect('index.php?action=itemdelete&itemid=' . $itemid);
- exit;
- }
-
- // create new category if needed (only on edit/changedate)
- if (strstr($catid,'newcat') ) {
- // get blogid
- list($blogid) = sscanf($catid, "newcat-%d");
-
- // create
- $blog =& $manager->getBlog($blogid);
- $catid = $blog->createNewCategory();
-
- // show error when sth goes wrong
- if (!$catid) {
- bm_doError('Could not create new category');
- }
- }
-
- // only edit action is allowed for bookmarklet edit
- switch ($actiontype) {
- case 'changedate':
- $publish = 1;
- $wasdraft = 0;
- $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year') );
- break;
- case 'edit':
- $publish = 1;
- $wasdraft = 0;
- $timestamp = 0;
- break;
+ } elseif ( (postVar('actiontype') == 'addnow') && $blog->sendPing() ) {\r
+ $message = _BOOKMARKLET_SEND_PING;\r
+ $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid) );\r
+ $extrahead = '<meta http-equiv="refresh" content="1; url=' . htmlspecialchars($pingUrl) . '" />';\r
+ } else {\r
+ $message = _ITEM_ADDED;\r
+ $extrahead = '';\r
+ }\r
+\r
+ bm_message(_ITEM_ADDED, _ITEM_ADDED, $message,$extrahead);\r
+}\r
+\r
+function bm_doEditItem() {\r
+ global $member, $manager, $CONF;\r
+\r
+ $itemid = intRequestVar('itemid');\r
+ $catid = postVar('catid');\r
+\r
+ // only allow if user is allowed to alter item\r
+ if (!$member->canUpdateItem($itemid, $catid) ) {\r
+ bm_doError(_ERROR_DISALLOWED);\r
+ }\r
+\r
+ $body = postVar('body');\r
+ $title = postVar('title');\r
+ $more = postVar('more');\r
+ $closed = intPostVar('closed');\r
+ $actiontype = postVar('actiontype');\r
+ $draftid = intPostVar('draftid');\r
+\r
+ // redirect to admin area on delete (has delete confirmation)\r
+ if ($actiontype == 'delete') {\r
+ redirect('index.php?action=itemdelete&itemid=' . $itemid);\r
+ exit;\r
+ }\r
+\r
+ // create new category if needed (only on edit/changedate)\r
+ if (strstr($catid,'newcat') ) {\r
+ // get blogid\r
+ list($blogid) = sscanf($catid, "newcat-%d");\r
+\r
+ // create\r
+ $blog =& $manager->getBlog($blogid);\r
+ $catid = $blog->createNewCategory();\r
+\r
+ // show error when sth goes wrong\r
+ if (!$catid) {\r
+ bm_doError('Could not create new category');\r
+ }\r
+ }\r
+\r
+ // only edit action is allowed for bookmarklet edit\r
+ switch ($actiontype) {\r
+ case 'changedate':\r
+ $publish = 1;\r
+ $wasdraft = 0;\r
+ $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year') );\r
+ break;\r
+ case 'edit':\r
+ $publish = 1;\r
+ $wasdraft = 0;\r
+ $timestamp = 0;\r
+ break;\r
case 'backtodrafts':\r
$publish = 0;\r
$wasdraft = 0;\r
$timestamp = 0;\r
break;\r
- default:
- bm_doError('Something went wrong');
- }
-
- // update item for real
- ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
-
- if ($draftid > 0) {
- ITEM::delete($draftid);
- }
-
- // show success message
- if ($catid != intPostVar('catid') ) {
+ default:\r
+ bm_doError('Something went wrong');\r
+ }\r
+\r
+ // update item for real\r
+ ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);\r
+\r
+ if ($draftid > 0) {\r
+ ITEM::delete($draftid);\r
+ }\r
+\r
+ // show success message\r
+ if ($catid != intPostVar('catid') ) {\r
$href = 'index.php?action=categoryedit&blogid=' . $blog->getID() . '&catid=' . $catid;\r
$onclick = 'if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;';\r
$title = _BOOKMARKLET_NEW_WINDOW;\r
$aTag = ' <a href="' . $href . '" onclick="' . $onclick . '" title="' . $title . '">';\r
$message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>';\r
- bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>', '');
- } else {
- bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _ITEM_UPDATED, '');
- }
-}
-
-function bm_loginAndPassThrough() {
-
- $blogid = intRequestVar('blogid');
- $log_text = requestVar('logtext');
- $log_link = requestVar('loglink');
- $log_linktitle = requestVar('loglinktitle');
-
- ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
- <title>Nucleus</title>
- <?php bm_style(); ?>
- </head>
- <body>
- <h1><?php echo _LOGIN_PLEASE ?></h1>
-
- <form method="post" action="bookmarklet.php">
- <p>
- <input name="action" value="login" type="hidden" />
- <input name="blogid" value="<?php echo htmlspecialchars($blogid); ?>" type="hidden" />
- <input name="logtext" value="<?php echo htmlspecialchars($log_text); ?>" type="hidden" />
- <input name="loglink" value="<?php echo htmlspecialchars($log_link); ?>" type="hidden" />
- <input name="loglinktitle" value="<?php echo htmlspecialchars($log_linktitle); ?>" type="hidden" />
- <?php echo _LOGINFORM_NAME ?>:
- <br /><input name="login" />
- <br /><?php echo _LOGINFORM_PWD ?>:
- <br /><input name="password" type="password" />
- <br /><br />
- <br /><input type="submit" value="<?php echo _LOGIN ?>" />
- </p>
- </form>
- <p><a href="bookmarklet.php" onclick="window.close();"><?php echo _POPUP_CLOSE ?></a></p>
- </body>
- </html>
- <?php
-}
-
-function bm_doShowForm() {
- global $member;
-
- $blogid = intRequestVar('blogid');
- $log_text = trim(requestVar('logtext'));
- $log_link = requestVar('loglink');
- $log_linktitle = requestVar('loglinktitle');
-
- $log_text = uniDecode($log_text,_CHARSET);
- $log_linktitle = uniDecode($log_linktitle,_CHARSET);
-
- if (!BLOG::existsID($blogid) ) {
- bm_doError(_ERROR_NOSUCHBLOG);
- }
-
- if (!$member->isTeamMember($blogid) ) {
- bm_doError(_ERROR_NOTONTEAM);
- }
-
- $logje = '';
-
- if ($log_text) {
- $logje .= '<blockquote><div>"' . htmlspecialchars($log_text) . '"</div></blockquote>' . "\n";
- }
-
- if (!$log_linktitle) {
- $log_linktitle = $log_link;
- }
-
- if ($log_link) {
- $logje .= '<a href="' . htmlspecialchars($log_link) . '">' . htmlspecialchars($log_linktitle) . '</a>';
- }
-
- $item['body'] = $logje;
- $item['title'] = htmlspecialchars($log_linktitle);
-
- $factory = new PAGEFACTORY($blogid);
- $factory->createAddForm('bookmarklet', $item);
-}
-
-function bm_doEditForm() {
- global $member, $manager;
-
- $itemid = intRequestVar('itemid');
-
- if (!$manager->existsItem($itemid, 0, 0) ) {
- bm_doError(_ERROR_NOSUCHITEM);
- }
-
- if (!$member->canAlterItem($itemid) ) {
- bm_doError(_ERROR_DISALLOWED);
- }
-
- $item =& $manager->getItem($itemid, 1, 1);
- $blog =& $manager->getBlog(getBlogIDFromItemID($itemid) );
-
- $manager->notify('PrepareItemForEdit', array('item' => &$item) );
-
- if ($blog->convertBreaks() ) {
- $item['body'] = removeBreaks($item['body']);
- $item['more'] = removeBreaks($item['more']);
- }
-
- $formfactory = new PAGEFACTORY($blog->getID() );
- $formfactory->createEditForm('bookmarklet', $item);
-}
-
-function bm_doError($msg) {
- bm_message(_ERROR, _ERRORMSG, $msg);
- die;
-}
-
-function bm_message($title, $head, $msg, $extrahead = '') {
- ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
- <title><?php echo $title ?></title>
- <?php bm_style(); ?>
- <?php echo $extrahead; ?>
- </head>
- <body>
- <h1><?php echo $head; ?></h1>
- <p><?php echo $msg; ?></p>
- <p><a href="bookmarklet.php" onclick="window.close();window.opener.location.reload();"><?php echo _POPUP_CLOSE ?></a></p>
- </body>
- </html>
-
- <?php
-}
-
-function bm_style() {
- echo '<link rel="stylesheet" type="text/css" href="styles/bookmarklet.css" />';
- echo '<link rel="stylesheet" type="text/css" href="styles/addedit.css" />';
-}
-
-function bm_doContextMenuCode() {
- global $CONF;
- ?>
-<script type="text/javascript" defer="defer">
-doc = external.menuArguments.document;
-lt = escape(doc.selection.createRange().text);
-loglink = escape(external.menuArguments.location.href);
-loglinktitle = escape(doc.title);
-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');
-wingm.focus();
-</script>
- <?php
-}
-
-function uniDecode($str,$charcode){
- $text = preg_replace_callback("/%u[0-9A-Za-z]{4}/",toUtf8,$str);
- return mb_convert_encoding($text, $charcode, 'UTF-8');
-}
-function toUtf8($ar){
- foreach($ar as $val){
- $val = intval(substr($val,2),16);
- if($val < 0x7F){ // 0000-007F
- $c .= chr($val);
- }elseif($val < 0x800) { // 0080-0800
- $c .= chr(0xC0 | ($val / 64));
- $c .= chr(0x80 | ($val % 64));
- }else{ // 0800-FFFF
- $c .= chr(0xE0 | (($val / 64) / 64));
- $c .= chr(0x80 | (($val / 64) % 64));
- $c .= chr(0x80 | ($val % 64));
- }
- }
- return $c;
-}
-
-?>
+ bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>', '');\r
+ } else {\r
+ bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _ITEM_UPDATED, '');\r
+ }\r
+}\r
+\r
+function bm_loginAndPassThrough() {\r
+\r
+ $blogid = intRequestVar('blogid');\r
+ $log_text = requestVar('logtext');\r
+ $log_link = requestVar('loglink');\r
+ $log_linktitle = requestVar('loglinktitle');\r
+\r
+ ?>\r
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+ <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>\r
+ <head>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />\r
+ <title>Nucleus</title>\r
+ <?php bm_style(); ?>\r
+ </head>\r
+ <body>\r
+ <h1><?php echo _LOGIN_PLEASE ?></h1>\r
+\r
+ <form method="post" action="bookmarklet.php">\r
+ <p>\r
+ <input name="action" value="login" type="hidden" />\r
+ <input name="blogid" value="<?php echo htmlspecialchars($blogid); ?>" type="hidden" />\r
+ <input name="logtext" value="<?php echo htmlspecialchars($log_text); ?>" type="hidden" />\r
+ <input name="loglink" value="<?php echo htmlspecialchars($log_link); ?>" type="hidden" />\r
+ <input name="loglinktitle" value="<?php echo htmlspecialchars($log_linktitle); ?>" type="hidden" />\r
+ <?php echo _LOGINFORM_NAME ?>:\r
+ <br /><input name="login" />\r
+ <br /><?php echo _LOGINFORM_PWD ?>:\r
+ <br /><input name="password" type="password" />\r
+ <br /><br />\r
+ <br /><input type="submit" value="<?php echo _LOGIN ?>" />\r
+ </p>\r
+ </form>\r
+ <p><a href="bookmarklet.php" onclick="window.close();"><?php echo _POPUP_CLOSE ?></a></p>\r
+ </body>\r
+ </html>\r
+ <?php\r
+}\r
+\r
+function bm_doShowForm() {\r
+ global $member;\r
+\r
+ $blogid = intRequestVar('blogid');\r
+ $log_text = trim(requestVar('logtext'));\r
+ $log_link = requestVar('loglink');\r
+ $log_linktitle = requestVar('loglinktitle');\r
+\r
+ $log_text = uniDecode($log_text,_CHARSET);\r
+ $log_linktitle = uniDecode($log_linktitle,_CHARSET);\r
+ \r
+ if (!BLOG::existsID($blogid) ) {\r
+ bm_doError(_ERROR_NOSUCHBLOG);\r
+ }\r
+\r
+ if (!$member->isTeamMember($blogid) ) {\r
+ bm_doError(_ERROR_NOTONTEAM);\r
+ }\r
+\r
+ $logje = '';\r
+\r
+ if ($log_text) {\r
+ $logje .= '<blockquote><div>"' . htmlspecialchars($log_text) . '"</div></blockquote>' . "\n";\r
+ }\r
+\r
+ if (!$log_linktitle) {\r
+ $log_linktitle = $log_link;\r
+ }\r
+\r
+ if ($log_link) {\r
+ $logje .= '<a href="' . htmlspecialchars($log_link) . '">' . htmlspecialchars($log_linktitle) . '</a>';\r
+ }\r
+\r
+ $item['body'] = $logje;\r
+ $item['title'] = htmlspecialchars($log_linktitle);\r
+\r
+ $factory = new PAGEFACTORY($blogid);\r
+ $factory->createAddForm('bookmarklet', $item);\r
+}\r
+\r
+function bm_doEditForm() {\r
+ global $member, $manager;\r
+\r
+ $itemid = intRequestVar('itemid');\r
+\r
+ if (!$manager->existsItem($itemid, 0, 0) ) {\r
+ bm_doError(_ERROR_NOSUCHITEM);\r
+ }\r
+\r
+ if (!$member->canAlterItem($itemid) ) {\r
+ bm_doError(_ERROR_DISALLOWED);\r
+ }\r
+\r
+ $item =& $manager->getItem($itemid, 1, 1);\r
+ $blog =& $manager->getBlog(getBlogIDFromItemID($itemid) );\r
+\r
+ $manager->notify('PrepareItemForEdit', array('item' => &$item) );\r
+\r
+ if ($blog->convertBreaks() ) {\r
+ $item['body'] = removeBreaks($item['body']);\r
+ $item['more'] = removeBreaks($item['more']);\r
+ }\r
+\r
+ $formfactory = new PAGEFACTORY($blog->getID() );\r
+ $formfactory->createEditForm('bookmarklet', $item);\r
+}\r
+\r
+function bm_doError($msg) {\r
+ bm_message(_ERROR, _ERRORMSG, $msg);\r
+ die;\r
+}\r
+\r
+function bm_message($title, $head, $msg, $extrahead = '') {\r
+ ?>\r
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+ <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>\r
+ <head>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />\r
+ <title><?php echo $title ?></title>\r
+ <?php bm_style(); ?>\r
+ <?php echo $extrahead; ?>\r
+ </head>\r
+ <body>\r
+ <h1><?php echo $head; ?></h1>\r
+ <p><?php echo $msg; ?></p>\r
+ <p><a href="bookmarklet.php" onclick="window.close();window.opener.location.reload();"><?php echo _POPUP_CLOSE ?></a></p>\r
+ </body>\r
+ </html>\r
+\r
+ <?php\r
+}\r
+\r
+function bm_style() {\r
+ echo '<link rel="stylesheet" type="text/css" href="styles/bookmarklet.css" />';\r
+ echo '<link rel="stylesheet" type="text/css" href="styles/addedit.css" />';\r
+}\r
+\r
+function bm_doContextMenuCode() {\r
+ global $CONF;\r
+ ?>\r
+<script type="text/javascript" defer="defer">\r
+doc = external.menuArguments.document;\r
+lt = escape(doc.selection.createRange().text);\r
+loglink = escape(external.menuArguments.location.href);\r
+loglinktitle = escape(doc.title);\r
+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');\r
+wingm.focus();\r
+</script>\r
+ <?php\r
+}\r
+\r
+function uniDecode($str,$charcode){\r
+ $text = preg_replace_callback("/%u[0-9A-Za-z]{4}/",toUtf8,$str);\r
+ return mb_convert_encoding($text, $charcode, 'UTF-8');\r
+}\r
+function toUtf8($ar){\r
+ foreach($ar as $val){\r
+ $val = intval(substr($val,2),16);\r
+ if($val < 0x7F){ // 0000-007F\r
+ $c .= chr($val);\r
+ }elseif($val < 0x800) { // 0080-0800\r
+ $c .= chr(0xC0 | ($val / 64));\r
+ $c .= chr(0x80 | ($val % 64));\r
+ }else{ // 0800-FFFF\r
+ $c .= chr(0xE0 | (($val / 64) / 64));\r
+ $c .= chr(0x80 | (($val / 64) % 64));\r
+ $c .= chr(0x80 | ($val % 64));\r
+ }\r
+ }\r
+ return $c;\r
+}\r
+\r
+?>
\ No newline at end of file