From f957a0e44a7734e5199eaf09e5de7b002c771d14 Mon Sep 17 00:00:00 2001 From: shizuki Date: Mon, 16 Mar 2009 16:52:33 +0000 Subject: [PATCH] =?utf8?q?bookmarklet.php=E5=86=85=E3=81=AEuniDecode?= =?utf8?q?=E9=96=A2=E6=95=B0=E3=81=A7=E3=80=81=EF=BD=A2preg=5Freplace=5Fca?= =?utf8?q?llback=EF=BD=A3=E3=81=AE=E3=82=B3=E3=83=BC=E3=83=AB=E3=83=90?= =?utf8?q?=E3=83=83=E3=82=AF=E9=96=A2=E6=95=B0=E5=90=8D=E3=81=8C=E3=82=AF?= =?utf8?q?=E3=82=A9=E3=83=BC=E3=83=88=E3=81=A7=E3=81=8F=E3=81=8F=E3=82=89?= =?utf8?q?=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F?= =?utf8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk/utf8@976 1ca29b6e-896d-4ea0-84a5-967f57386b96 --- nucleus/bookmarklet.php | 708 ++++++++++++++++++++++++------------------------ 1 file changed, 354 insertions(+), 354 deletions(-) diff --git a/nucleus/bookmarklet.php b/nucleus/bookmarklet.php index 0388874..7caa805 100755 --- a/nucleus/bookmarklet.php +++ b/nucleus/bookmarklet.php @@ -19,358 +19,358 @@ * $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('text/html', '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') { - $href = 'index.php?action=categoryedit&blogid=' . $blogid . '&catid=' . $result['catid']; - $onclick = 'if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;'; - $title = _BOOKMARKLET_NEW_WINDOW; - $aTag = ' '; - $message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . ''; - $extrahead = ''; - } elseif ( (postVar('actiontype') == 'addnow') && $blog->sendPing() ) { - $message = _BOOKMARKLET_SEND_PING; - $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid) ); - $extrahead = ''; - } 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; - case 'backtodrafts': - $publish = 0; - $wasdraft = 0; - $timestamp = 0; - break; - 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') ) { - $href = 'index.php?action=categoryedit&blogid=' . $blog->getID() . '&catid=' . $catid; - $onclick = 'if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;'; - $title = _BOOKMARKLET_NEW_WINDOW; - $aTag = ' '; - $message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . ''; - bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '', ''); - } 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'); - - ?> - - > - - - Nucleus - - - -

- -
-

- - - - - - : -
-
: -
-

-
-

-
-

- - - isTeamMember($blogid) ) { - bm_doError(_ERROR_NOTONTEAM); - } - - $logje = ''; - - if ($log_text) { - $logje .= '
"' . htmlspecialchars($log_text) . '"
' . "\n"; - } - - if (!$log_linktitle) { - $log_linktitle = $log_link; - } - - if ($log_link) { - $logje .= '' . htmlspecialchars($log_linktitle) . ''; - } - - $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 = '') { - ?> - - > - - - <?php echo $title ?> - - - - -

-

-

- - - - '; - echo ''; -} - -function bm_doContextMenuCode() { - global $CONF; - ?> - - isLoggedIn() ) { + bm_loginAndPassThrough(); + exit; +} + +// on successfull login +if ( ($action == 'login') && ($member->isLoggedIn() ) ) { + $action = requestVar('nextaction'); +} + +if ($action == '') { + $action = 'add'; +} + +sendContentType('text/html', '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') { + $href = 'index.php?action=categoryedit&blogid=' . $blogid . '&catid=' . $result['catid']; + $onclick = 'if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;'; + $title = _BOOKMARKLET_NEW_WINDOW; + $aTag = ' '; + $message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . ''; + $extrahead = ''; + } elseif ( (postVar('actiontype') == 'addnow') && $blog->sendPing() ) { + $message = _BOOKMARKLET_SEND_PING; + $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid) ); + $extrahead = ''; + } 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; + case 'backtodrafts': + $publish = 0; + $wasdraft = 0; + $timestamp = 0; + break; + 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') ) { + $href = 'index.php?action=categoryedit&blogid=' . $blog->getID() . '&catid=' . $catid; + $onclick = 'if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;'; + $title = _BOOKMARKLET_NEW_WINDOW; + $aTag = ' '; + $message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . ''; + bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '', ''); + } 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'); + + ?> + + > + + + Nucleus + + + +

+ +
+

+ + + + + + : +
+
: +
+

+
+

+
+

+ + + isTeamMember($blogid) ) { + bm_doError(_ERROR_NOTONTEAM); + } + + $logje = ''; + + if ($log_text) { + $logje .= '
"' . htmlspecialchars($log_text) . '"
' . "\n"; + } + + if (!$log_linktitle) { + $log_linktitle = $log_link; + } + + if ($log_link) { + $logje .= '' . htmlspecialchars($log_linktitle) . ''; + } + + $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 = '') { + ?> + + > + + + <?php echo $title ?> + + + + +

+

+

+ + + + '; + echo ''; +} + +function bm_doContextMenuCode() { + global $CONF; + ?> + + \ No newline at end of file -- 2.11.0