OSDN Git Service

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk@937 1ca29b...
authorshizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Fri, 13 Feb 2009 01:25:12 +0000 (01:25 +0000)
committershizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Fri, 13 Feb 2009 01:25:12 +0000 (01:25 +0000)
utf8/extra/htaccess/media/media.htaccess [new file with mode: 0644]
utf8/extra/htaccess/media/readme.ja.txt [new file with mode: 0644]
utf8/extra/htaccess/media/readme.txt [new file with mode: 0644]
utf8/extra/htaccess/skins/readme.ja.txt [new file with mode: 0644]
utf8/extra/htaccess/skins/readme.txt [new file with mode: 0644]
utf8/extra/htaccess/skins/skins.htaccess [new file with mode: 0644]
utf8/nucleus/documentation/devdocs/custominstall.html
utf8/nucleus/documentation/history.html
utf8/nucleus/libs/BLOG.php
utf8/nucleus/libs/globalfunctions.php
utf8/nucleus/libs/showlist.php

diff --git a/utf8/extra/htaccess/media/media.htaccess b/utf8/extra/htaccess/media/media.htaccess
new file mode 100644 (file)
index 0000000..da274e3
--- /dev/null
@@ -0,0 +1,11 @@
+# You may modify following line to avoid script execution completely.\r
+# In environment where multiple users are using Nucleus,\r
+# be sure that any script cannot be executed due to your server setting.\r
+# Note that this isn't needed when all members are super-admin.\r
+# スクリプトの実行を避ける為に、適宜追加してください。\r
+# サーバの設定によっては、アップロードされたファイルをスクリプトとして\r
+# 実行される恐れがありますので、複数人でNucleusを運用している場合は特に\r
+# 注意が必要です。\r
+#\r
+\r
+RemoveHandler php cgi pl py rb shtml
\ No newline at end of file
diff --git a/utf8/extra/htaccess/media/readme.ja.txt b/utf8/extra/htaccess/media/readme.ja.txt
new file mode 100644 (file)
index 0000000..73b4d8a
--- /dev/null
@@ -0,0 +1,17 @@
+Nucleus Media ディレクトリ
+-----------------------
+
+アップロードされた画像等のファイルは、最終的にこのディレクトリに移動されます。
+
+
+サブディレクトリについて:
+
+* 数字 (例 /media/1/)
+
+アップロードしたメンバーだけがファイルを使用できます。(ディレクトリ名はメンバーIDになります)
+
+* 数字以外 (例 /media/common/)
+
+誰が使ってもいいファイルを保存しておく為のディレクトリ。
+ディレクトリを作ってパーミッションを777等にしておくだけで、新しいコレクションとして追加されます。
+
diff --git a/utf8/extra/htaccess/media/readme.txt b/utf8/extra/htaccess/media/readme.txt
new file mode 100644 (file)
index 0000000..308d3a1
--- /dev/null
@@ -0,0 +1,15 @@
+Nucleus Media Directory
+-----------------------
+
+Uploaded images will end up in the media directory.
+
+Subdirectories work as follows:
+
+* numeric (e.g. /media/1/)
+
+Media files for a certain member (directory name is the memberid)
+
+* other directories (e.g. /media/common/)
+
+Global media collections that can be used by any member that is on a team. In order to create a new collection, simply create a new directory and assure write access is enabled for it.
+
diff --git a/utf8/extra/htaccess/skins/readme.ja.txt b/utf8/extra/htaccess/skins/readme.ja.txt
new file mode 100644 (file)
index 0000000..073d092
--- /dev/null
@@ -0,0 +1,12 @@
+Nucleus skins ディレクトリ
+-----------------------
+
+注意:このディレクトリ内(サブディレクトリを含む)にある、skinbackup.xml や skindata.xml 等のファイルを直接編集することは避けてください。
+         これらのファイルはユーザーに配布する為に、Nucleusの機能を使用して作成されています。
+
+         スキンを編集する時は、Nucleusの管理エリアで左のメニューから「スキン編集」を選択し、スキン編集画面へと進んでください。
+
+注意:このディレクトリの.htaccessファイルは、ディレクトリ内(サブディレクトリを含む)の .inc ファイルや .php ファイルに外部から直接アクセス
+         することを禁止する為のものです。
+         サーバの設定によっては、.htaccessに記述された内容が、意図したとおりに動作しないことがあります。
+         スキンの表示が壊れている時は、.htaccess ファイルを修正することで直ることがあります。
\ No newline at end of file
diff --git a/utf8/extra/htaccess/skins/readme.txt b/utf8/extra/htaccess/skins/readme.txt
new file mode 100644 (file)
index 0000000..3844617
--- /dev/null
@@ -0,0 +1,8 @@
+Nucleus skins directory
+-----------------------
+
+PLEASE NOTE: the skinbackup.xml or skindata.xml files in these directories are not where you should edit the skins. These files get generated by the Nucleus skin export function and are meant to distribute skins between Nucleus users.
+
+To edit skins, open the Nucleus Admin Area, and select 'skins' in the left menu.
+
+PLEASE NOTE: the .htaccess file in this directory is intended to prohibit, for enhanced security, direct access .inc and .php files in the skin folders. Depending on the web server configuration, the code in this .htaccess file may not work as intended. In this case, your site will be displayed incorrectly, with missing content or style. Renaming the .htaccess file should fix the problem.
\ No newline at end of file
diff --git a/utf8/extra/htaccess/skins/skins.htaccess b/utf8/extra/htaccess/skins/skins.htaccess
new file mode 100644 (file)
index 0000000..f7027bd
--- /dev/null
@@ -0,0 +1,4 @@
+<FilesMatch "\.(php|inc)$">\r
+Order allow,deny\r
+Deny from all\r
+</FilesMatch>
\ No newline at end of file
index fe829f7..44a2a22 100755 (executable)
     <link rel="index" href="./index.html" />\r
        <title>Nucleus - インストールスクリプトのカスタマイズ</title>\r
        <link rel="stylesheet" type="text/css" href="styles/manual.css" />\r
+       <script src="http://www.google.com/jsapi"></script>\r
        <script type="text/javascript">\r
-               function fontSizeChange(size) {\r
-                       var elem = document.getElementById('body');\r
-                       var flrg = document.getElementById('fontLarge');\r
-                       var fmdl = document.getElementById('fontMiddle');\r
-                       var fsml = document.getElementById('fontSmall');\r
-                       switch(size) {\r
-                               case 'l':\r
-                                       elem.style.fontSize = 'large';\r
-                                       flrg.style.fontWeight = 'bold';\r
-                                       fmdl.style.fontWeight = 'normal';\r
-                                       fsml.style.fontWeight = 'normal';\r
-                                       break;\r
-                               case 'm':\r
-                                       elem.style.fontSize = 'medium';\r
-                                       flrg.style.fontWeight = 'normal';\r
-                                       fmdl.style.fontWeight = 'bold';\r
-                                       fsml.style.fontWeight = 'normal';\r
-                                       break;\r
-                               case 's':\r
-                                       elem.style.fontSize = 'small';\r
-                                       flrg.style.fontWeight = 'normal';\r
-                                       fmdl.style.fontWeight = 'normal';\r
-                                       fsml.style.fontWeight = 'bold';\r
-                                       break;\r
-                       }\r
-                       \r
-               }\r
+               google.load("jquery", "1");\r
+               google.setOnLoadCallback(function() {\r
+                       $.getScript("../../javascript/documentation.fontsizeChanger.js");\r
+               });\r
        </script>\r
 </head>\r
 <body>\r
 <div id="fontSizeCanger">\r
-<a href="#top" onClick="fontSizeChange('s');return false;" id="fontSmall">小</a>\r
-<a href="#top" onClick="fontSizeChange('m');return false;" id="fontMiddle">中</a>\r
-<a href="#top" onClick="fontSizeChange('l');return false;" id="fontLarge">大</a>\r
+<a href="#top" id="fontSmall">小</a>\r
+<a href="#top" id="fontMiddle">中</a>\r
+<a href="#top" id="fontLarge">大</a>\r
 </div>\r
 <div id="body">\r
 \r
index ce24a4c..07521a7 100755 (executable)
@@ -50,6 +50,8 @@
                        <li>CHANGED: NP_SkinFilesオプション用言語定義追加(NP_SkinFiles option word update via language file)(shizuki)</li>\r
                        <li>UPDATED: NP_SkinFiles 2.03に差し替え(code:yama/commit:shizuki)(NP_SkinFiles update to 2.03)(code:yama,katsumi/commit:shizuki)</li>\r
                        <li>FIXED: 「General」カテゴリのUPDATE漏れ修正(install.php)(preinstall default category name is not localize)(shizuki)</li>\r
+                       <li>CHANGED: Comment count at items list display via 'sprintf()'. (shizuki)</li>\r
+                       <li>ADDED: instructions for manually adding .htaccess files to media and skins folder after upgrade. (ftruscot)</li>\r
                        <li>FIXED: the unwished ping after adding an item to a new category (what you have written here: http://forum.nucleuscms.org/viewtopic.php?p=89142#89142)(shizuki)</li>\r
                        <li>FIXED: Few hardcoded strings moved to langage file(shizuki)</li>\r
                        <li>CHANGED: Ease the solution for the new member option for autosave draft(kaigreve)</li>\r
index b9508d1..aef93a5 100755 (executable)
  * $NucleusJP: BLOG.php,v 1.12.2.2 2007/08/08 05:26:22 kimitake Exp $
  */
 
-if ( !function_exists('requestVar') ) exit;\r
-require_once dirname(__FILE__) . '/ITEMACTIONS.php';\r
-\r
-class BLOG {\r
-\r
-       // blog id\r
-       var $blogid;\r
-\r
-       // ID of currently selected category\r
-       var $selectedcatid;\r
-\r
-       // After creating an object of the blog class, contains true if the BLOG object is\r
-       // valid (the blog exists)\r
-       var $isValid;\r
-\r
-       // associative array, containing all blogsettings (use the get/set functions instead)\r
-       var $settings;\r
-\r
-       /**\r
-        * Creates a new BLOG object for the given blog\r
-        *\r
-        * @param $id blogid\r
-        */\r
-       function BLOG($id) {\r
-               $this->blogid = intval($id);\r
-               $this->readSettings();\r
-\r
-               // try to set catid\r
-               // (the parse functions in SKIN.php will override this, so it's mainly useless)\r
-               global $catid;\r
-               $this->setSelectedCategory($catid);\r
-       }\r
-\r
-       /**\r
-        * Shows the given amount of items for this blog\r
-        *\r
-        * @param $template\r
-        *              String representing the template _NAME_ (!)\r
-        * @param $amountEntries\r
-        *              amount of entries to show\r
-        * @param $startpos\r
-        *              offset from where items should be shown (e.g. 5 = start at fifth item)\r
-        * @returns int\r
-        *              amount of items shown\r
-        */\r
-       function readLog($template, $amountEntries, $offset = 0, $startpos = 0) {\r
-               return $this->readLogAmount($template,$amountEntries,'','',1,1,$offset, $startpos);\r
-       }\r
-\r
-       /**\r
-        * Shows an archive for a given month\r
-        *\r
-        * @param $year\r
-        *              year\r
-        * @param $month\r
-        *              month\r
-        * @param $template\r
-        *              String representing the template name to be used\r
-        */\r
-       function showArchive($templatename, $year, $month, $day=0) {\r
-\r
-               // create extra where clause for select query\r
-               if ($day == 0) {\r
-                       $timestamp_start = mktime(0,0,0,$month,1,$year);\r
-                       $timestamp_end = mktime(0,0,0,$month+1,1,$year);  // also works when $month==12\r
-               } else {\r
-                       $timestamp_start = mktime(0,0,0,$month,$day,$year);\r
-                       $timestamp_end = mktime(0,0,0,$month,$day+1,$year);\r
-               }\r
-               $extra_query = ' and i.itime>=' . mysqldate($timestamp_start)\r
-                                        . ' and i.itime<' . mysqldate($timestamp_end);\r
-\r
-\r
-               $this->readLogAmount($templatename,0,$extra_query,'',1,1);\r
-\r
-       }\r
-\r
-\r
-       // sets/gets current category (only when category exists)\r
-       function setSelectedCategory($catid) {\r
-               if ($this->isValidCategory($catid) || (intval($catid) == 0))\r
-                       $this->selectedcatid = intval($catid);\r
-       }\r
-\r
-       function setSelectedCategoryByName($catname) {\r
-               $this->setSelectedCategory($this->getCategoryIdFromName($catname));\r
-       }\r
-\r
-       function getSelectedCategory() {\r
-               return $this->selectedcatid;\r
-       }\r
-\r
-       /**\r
-        * Shows the given amount of items for this blog\r
-        *\r
-        * @param $template\r
-        *              String representing the template _NAME_ (!)\r
-        * @param $amountEntries\r
-        *              amount of entries to show (0 = no limit)\r
-        * @param $extraQuery\r
-        *              extra conditions to be added to the query\r
-        * @param $highlight\r
-        *              contains a query that should be highlighted\r
-        * @param $comments\r
-        *              1=show comments 0=don't show comments\r
-        * @param $dateheads\r
-        *              1=show dateheads 0=don't show dateheads\r
-        * @param $offset\r
-        *              offset\r
-        * @returns int\r
-        *              amount of items shown\r
-        */\r
-       function readLogAmount($template, $amountEntries, $extraQuery, $highlight, $comments, $dateheads, $offset = 0, $startpos = 0) {\r
-\r
-               $query = $this->getSqlBlog($extraQuery);\r
-\r
-               if ($amountEntries > 0) {\r
-                               // $offset zou moeten worden:\r
-                               // (($startpos / $amountentries) + 1) * $offset ... later testen ...\r
-                          $query .= ' LIMIT ' . intval($startpos + $offset).',' . intval($amountEntries);\r
-               }\r
-               return $this->showUsingQuery($template, $query, $highlight, $comments, $dateheads);\r
-       }\r
-\r
-       function showUsingQuery($templateName, $query, $highlight = '', $comments = 0, $dateheads = 1) {\r
-               global $CONF, $manager;\r
-\r
-               $lastVisit = cookieVar($CONF['CookiePrefix'] .'lastVisit');\r
-               if ($lastVisit != 0)\r
-                       $lastVisit = $this->getCorrectTime($lastVisit);\r
-\r
-               // set templatename as global variable (so plugins can access it)\r
-               global $currentTemplateName;\r
-               $currentTemplateName = $templateName;\r
-\r
-               $template =& $manager->getTemplate($templateName);\r
-\r
-               // create parser object & action handler\r
-               $actions =& new ITEMACTIONS($this);\r
-               $parser =& new PARSER($actions->getDefinedActions(),$actions);\r
-               $actions->setTemplate($template);\r
-               $actions->setHighlight($highlight);\r
-               $actions->setLastVisit($lastVisit);\r
-               $actions->setParser($parser);\r
-               $actions->setShowComments($comments);\r
-\r
-               // execute query\r
-               $items = sql_query($query);\r
-\r
-               // loop over all items\r
-               $old_date = 0;\r
-               while ($item = mysql_fetch_object($items)) {\r
-\r
-                       $item->timestamp = strtotime($item->itime);     // string timestamp -> unix timestamp\r
-\r
-                       // action handler needs to know the item we're handling\r
-                       $actions->setCurrentItem($item);\r
-\r
-                       // add date header if needed\r
-                       if ($dateheads) {\r
-                               $new_date = date('dFY',$item->timestamp);\r
-                               if ($new_date != $old_date) {\r
-                                       // unless this is the first time, write date footer\r
-                                       $timestamp = $item->timestamp;\r
-                                       if ($old_date != 0) {\r
-                                               $oldTS = strtotime($old_date);\r
-                                               $manager->notify('PreDateFoot',array('blog' => &$this, 'timestamp' => $oldTS));\r
-                                               $tmp_footer = strftime($template['DATE_FOOTER'], $oldTS);\r
-                                               $parser->parse($tmp_footer);\r
-                                               $manager->notify('PostDateFoot',array('blog' => &$this, 'timestamp' => $oldTS));\r
-                                       }\r
-                                       $manager->notify('PreDateHead',array('blog' => &$this, 'timestamp' => $timestamp));\r
-                                       // note, to use templatvars in the dateheader, the %-characters need to be doubled in\r
-                                       // order to be preserved by strftime\r
-                                       $tmp_header = strftime((isset($template['DATE_HEADER']) ? $template['DATE_HEADER'] : null), $timestamp);\r
-                                       $parser->parse($tmp_header);\r
-                                       $manager->notify('PostDateHead',array('blog' => &$this, 'timestamp' => $timestamp));\r
-                               }\r
-                               $old_date = $new_date;\r
-                       }\r
-\r
-                       // parse item\r
-                       $parser->parse($template['ITEM_HEADER']);\r
-                       $manager->notify('PreItem', array('blog' => &$this, 'item' => &$item));\r
-                       $parser->parse($template['ITEM']);\r
-                       $manager->notify('PostItem', array('blog' => &$this, 'item' => &$item));\r
-                       $parser->parse($template['ITEM_FOOTER']);\r
-\r
-               }\r
-\r
-               $numrows = mysql_num_rows($items);\r
-\r
-               // add another date footer if there was at least one item\r
-               if (($numrows > 0) && $dateheads) {\r
-                       $manager->notify('PreDateFoot',array('blog' => &$this, 'timestamp' => strtotime($old_date)));\r
-                       $parser->parse($template['DATE_FOOTER']);\r
-                       $manager->notify('PostDateFoot',array('blog' => &$this, 'timestamp' => strtotime($old_date)));\r
-               }\r
-\r
-               mysql_free_result($items);      // free memory\r
-\r
-               return $numrows;\r
-\r
-       }\r
-\r
-       function showOneitem($itemid, $template, $highlight) {\r
-               $extraQuery = ' and inumber=' . intval($itemid);\r
-\r
-               return $this->readLogAmount($template, 1, $extraQuery, $highlight, 0, 0);\r
-       }\r
-\r
-\r
-       /**\r
-         * Adds an item to this blog\r
-         */\r
-       function additem($catid, $title, $body, $more, $blogid, $authorid, $timestamp, $closed, $draft, $posted='1') {\r
-               global $manager;\r
-\r
-               $blogid         = intval($blogid);\r
-               $authorid       = intval($authorid);\r
-               $title          = $title;\r
-               $body           = $body;\r
-               $more           = $more;\r
-               $catid          = intval($catid);\r
-\r
-               // convert newlines to <br />\r
-               if ($this->convertBreaks()) {\r
-                       $body = addBreaks($body);\r
-                       $more = addBreaks($more);\r
-               }\r
-\r
-               if ($closed != '1') $closed = '0';\r
-               if ($draft != '0') $draft = '1';\r
-\r
-               if (!$this->isValidCategory($catid))\r
-                       $catid = $this->getDefaultCategory();\r
-\r
-               if ($timestamp > $this->getCorrectTime())\r
-                       $isFuture = 1;\r
-\r
-               $timestamp = date('Y-m-d H:i:s',$timestamp);\r
-\r
-               $manager->notify('PreAddItem',array('title' => &$title, 'body' => &$body, 'more' => &$more, 'blog' => &$this, 'authorid' => &$authorid, 'timestamp' => &$timestamp, 'closed' => &$closed, 'draft' => &$draft, 'catid' => &$catid));\r
-\r
-               $title = addslashes($title);\r
-               $body = addslashes($body);\r
-               $more = addslashes($more);\r
-\r
-               $query = 'INSERT INTO '.sql_table('item').' (ITITLE, IBODY, IMORE, IBLOG, IAUTHOR, ITIME, ICLOSED, IDRAFT, ICAT, IPOSTED) '\r
-                          . "VALUES ('$title', '$body', '$more', $blogid, $authorid, '$timestamp', $closed, $draft, $catid, $posted)";\r
-               sql_query($query);\r
-               $itemid = mysql_insert_id();\r
-\r
-               $manager->notify('PostAddItem',array('itemid' => $itemid));\r
-\r
-               if (!$draft)\r
-                       $this->updateUpdateFile();\r
-\r
-               // send notification mail\r
-               if (!$draft && !$isFuture && $this->getNotifyAddress() && $this->notifyOnNewItem())\r
-                       $this->sendNewItemNotification($itemid, stripslashes($title), stripslashes($body));\r
-\r
-               return $itemid;\r
-       }\r
-\r
-       function sendNewItemNotification($itemid, $title, $body) {\r
-               global $CONF, $member;\r
-\r
-               // create text version of html post\r
-               $ascii = toAscii($body);\r
-\r
-               $mailto_msg = _NOTIFY_NI_MSG . " \n";\r
-//             $mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $itemid . "\n\n";\r
-               $temp = parse_url($CONF['Self']);\r
-               if ($temp['scheme']) {\r
-                       $mailto_msg .= createItemLink($itemid) . "\n\n";\r
-               } else {\r
-                       $tempurl = $this->getURL();\r
-                       if (substr($tempurl, -1) == '/' || substr($tempurl, -4) == '.php') {\r
-                               $mailto_msg .= $tempurl . '?itemid=' . $itemid . "\n\n";\r
-                       } else {\r
-                               $mailto_msg .= $tempurl . '/?itemid=' . $itemid . "\n\n";\r
-                       }\r
-               }\r
-               $mailto_msg .= _NOTIFY_TITLE . ' ' . strip_tags($title) . "\n";\r
-               $mailto_msg .= _NOTIFY_CONTENTS . "\n " . $ascii . "\n";\r
-               $mailto_msg .= getMailFooter();\r
-\r
-               $mailto_title = $this->getName() . ': ' . _NOTIFY_NI_TITLE;\r
-\r
-               $frommail = $member->getNotifyFromMailAddress();\r
-\r
-               $notify =& new NOTIFICATION($this->getNotifyAddress());\r
-               $notify->notify($mailto_title, $mailto_msg , $frommail);\r
-\r
-\r
-\r
-       }\r
-\r
-\r
-       /**\r
-         * Creates a new category for this blog\r
-         *\r
-         * @param $catName\r
-         *             name of the new category. When empty, a name is generated automatically\r
-         *             (starting with newcat)\r
-         * @param $catDescription\r
-         *             description of the new category. Defaults to 'New Category'\r
-         *\r
-         * @returns\r
-         *             the new category-id in case of success.\r
-         *             0 on failure\r
-         */\r
-       function createNewCategory($catName = '', $catDescription = _CREATED_NEW_CATEGORY_DESC) {\r
-               global $member, $manager;\r
-\r
-               if ($member->blogAdminRights($this->getID())) {\r
-                       // generate\r
-                       if ($catName == '')\r
-                       {\r
-                               $catName = _CREATED_NEW_CATEGORY_NAME;\r
-                               $i = 1;\r
-\r
-                               $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cname='".$catName.$i."' and cblog=".$this->getID());\r
-                               while (mysql_num_rows($res) > 0)\r
-                               {\r
-                                       $i++;\r
-                                       $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cname='".$catName.$i."' and cblog=".$this->getID());\r
-                               }\r
-\r
-                               $catName = $catName . $i;\r
-                       }\r
-\r
-                       $manager->notify(\r
-                               'PreAddCategory',\r
-                               array(\r
-                                       'blog' => &$this,\r
-                                       'name' => &$catName,\r
-                                       'description' => $catDescription\r
-                               )\r
-                       );\r
-\r
-                       $query = 'INSERT INTO '.sql_table('category').' (cblog, cname, cdesc) VALUES (' . $this->getID() . ", '" . addslashes($catName) . "', '" . addslashes($catDescription) . "')";\r
-                       sql_query($query);\r
-                       $catid = mysql_insert_id();\r
-\r
-                       $manager->notify(\r
-                               'PostAddCategory',\r
-                               array(\r
-                                       'blog' => &$this,\r
-                                       'name' => $catName,\r
-                                       'description' => $catDescription,\r
-                                       'catid' => $catid\r
-                               )\r
-                       );\r
-\r
-                       return $catid;\r
-               } else {\r
-                       return 0;\r
-               }\r
-\r
-       }\r
-\r
-\r
-       /**\r
-        * Searches all months of this blog for the given query\r
-        *\r
-        * @param $query\r
-        *              search query\r
-        * @param $template\r
-        *              template to be used (__NAME__ of the template)\r
-        * @param $amountMonths\r
-        *              max amount of months to be search (0 = all)\r
-        * @param $maxresults\r
-        *              max number of results to show\r
-        * @param $startpos\r
-        *              offset\r
-        * @returns\r
-        *              amount of hits found\r
-        */\r
-       function search($query, $template, $amountMonths, $maxresults, $startpos) {\r
-               global $CONF, $manager;\r
-\r
-               $highlight      = '';\r
-               $sqlquery       = $this->getSqlSearch($query, $amountMonths, $highlight);\r
-\r
-               if ($sqlquery == '')\r
-               {\r
-                       // no query -> show everything\r
-                       $extraquery = '';\r
-                       $amountfound = $this->readLogAmount($template, $maxresults, $extraQuery, $query, 1, 1);\r
-               } else {\r
-\r
-                       // add LIMIT to query (to split search results into pages)\r
-                       if (intval($maxresults > 0))\r
-                               $sqlquery .= ' LIMIT ' . intval($startpos).',' . intval($maxresults);\r
-\r
-                       // show results\r
-                       $amountfound = $this->showUsingQuery($template, $sqlquery, $highlight, 1, 1);\r
-\r
-                       // when no results were found, show a message\r
-                       if ($amountfound == 0)\r
-                       {\r
-                               $template =& $manager->getTemplate($template);\r
-                               $vars = array(\r
-                                       'query'         => htmlspecialchars($query),\r
-                                       'blogid'        => $this->getID()\r
-                               );\r
-                               echo TEMPLATE::fill($template['SEARCH_NOTHINGFOUND'],$vars);\r
-                       }\r
-               }\r
-\r
-               return $amountfound;\r
-       }\r
-\r
-       /**\r
-        * Returns an SQL query to use for a search query\r
-        *\r
-        * @param $query\r
-        *              search query\r
-        * @param $amountMonths\r
-        *              amount of months to search back. Default = 0 = unlimited\r
-        * @param $mode\r
-        *              either empty, or 'count'. In this case, the query will be a SELECT COUNT(*) query\r
-        * @returns $highlight\r
-        *              words to highlight (out parameter)\r
-        * @returns\r
-        *              either a full SQL query, or an empty string (if querystring empty)\r
-        * @note\r
-        *              No LIMIT clause is added. (caller should add this if multiple pages are requested)\r
-        */\r
-       function getSqlSearch($query, $amountMonths = 0, &$highlight, $mode = '')\r
-       {\r
-               $searchclass =& new SEARCH($query);\r
-\r
-               $highlight        = $searchclass->inclusive;\r
-\r
-               // if querystring is empty, return empty string\r
-               if ($searchclass->inclusive == '')\r
-                       return '';\r
-\r
-\r
-               $where  = $searchclass->boolean_sql_where('ititle,ibody,imore');\r
-               $select = $searchclass->boolean_sql_select('ititle,ibody,imore');\r
-\r
-               // get list of blogs to search\r
-               $blogs          = $searchclass->blogs;          // array containing blogs that always need to be included\r
-               $blogs[]        = $this->getID();                       // also search current blog (duh)\r
-               $blogs          = array_unique($blogs);         // remove duplicates\r
-               $selectblogs = '';\r
-               if (count($blogs) > 0)\r
-                       $selectblogs = ' and i.iblog in (' . implode(',', $blogs) . ')';\r
-\r
-               if ($mode == '')\r
-               {\r
-                       $query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author, m.mrealname as authorname, i.itime, i.imore as more, m.mnumber as authorid, m.memail as authormail, m.murl as authorurl, c.cname as category, i.icat as catid, i.iclosed as closed';\r
-                       if ($select)\r
-                               $query .= ', '.$select. ' as score ';\r
-               } else {\r
-                       $query = 'SELECT COUNT(*) as result ';\r
-               }\r
-\r
-               $query .= ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c'\r
-                          . ' WHERE i.iauthor=m.mnumber'\r
-                          . ' and i.icat=c.catid'\r
-                          . ' and i.idraft=0'  // exclude drafts\r
-                          . $selectblogs\r
-                                       // don't show future items\r
-                          . ' and i.itime<=' . mysqldate($this->getCorrectTime())\r
-                          . ' and '.$where;\r
-\r
-               // take into account amount of months to search\r
-               if ($amountMonths > 0)\r
-               {\r
-                       $localtime = getdate($this->getCorrectTime());\r
-                       $timestamp_start = mktime(0,0,0,$localtime['mon'] - $amountMonths,1,$localtime['year']);\r
-                       $query .= ' and i.itime>' . mysqldate($timestamp_start);\r
-               }\r
-\r
-               if ($mode == '')\r
-               {\r
-                       if ($select)\r
-                               $query .= ' ORDER BY score DESC';\r
-                       else\r
-                               $query .= ' ORDER BY i.itime DESC ';\r
-               }\r
-\r
-               return $query;\r
-       }\r
-\r
-       /**\r
-        * Returns the SQL query that's normally used to display the blog items on the index type skins\r
-        *\r
-        * @param $mode\r
-        *              either empty, or 'count'. In this case, the query will be a SELECT COUNT(*) query\r
-        * @returns\r
-        *              either a full SQL query, or an empty string\r
-        * @note\r
-        *              No LIMIT clause is added. (caller should add this if multiple pages are requested)\r
-        */\r
-       function getSqlBlog($extraQuery, $mode = '')\r
-       {\r
-               if ($mode == '')\r
-                       $query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author, m.mrealname as authorname, i.itime, i.imore as more, m.mnumber as authorid, m.memail as authormail, m.murl as authorurl, c.cname as category, i.icat as catid, i.iclosed as closed';\r
-               else\r
-                       $query = 'SELECT COUNT(*) as result ';\r
-\r
-               $query .= ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c'\r
-                          . ' WHERE i.iblog='.$this->blogid\r
-                          . ' and i.iauthor=m.mnumber'\r
-                          . ' and i.icat=c.catid'\r
-                          . ' and i.idraft=0'  // exclude drafts\r
-                                       // don't show future items\r
-                          . ' and i.itime<=' . mysqldate($this->getCorrectTime());\r
-\r
-               if ($this->getSelectedCategory())\r
-                       $query .= ' and i.icat=' . $this->getSelectedCategory() . ' ';\r
-\r
-\r
-               $query .= $extraQuery;\r
-\r
-               if ($mode == '')\r
-                       $query .= ' ORDER BY i.itime DESC';\r
-\r
-               return $query;\r
-       }\r
-\r
-       /**\r
-         * Shows the archivelist using the given template\r
-         */\r
-       function showArchiveList($template, $mode = 'month', $limit = 0) {\r
-               global $CONF, $catid, $manager;\r
-\r
-               if ($catid)\r
-                       $linkparams = array('catid' => $catid);\r
-\r
-               $template =& $manager->getTemplate($template);\r
-               $data['blogid'] = $this->getID();\r
-\r
-               echo TEMPLATE::fill($template['ARCHIVELIST_HEADER'],$data);\r
-\r
-               $query = 'SELECT itime, SUBSTRING(itime,1,4) AS Year, SUBSTRING(itime,6,2) AS Month, SUBSTRING(itime,9,2) as Day FROM '.sql_table('item')\r
-               . ' WHERE iblog=' . $this->getID()\r
-               . ' and itime <=' . mysqldate($this->getCorrectTime())  // don't show future items!\r
-               . ' and idraft=0'; // don't show draft items\r
-\r
-               if ($catid)\r
-                       $query .= ' and icat=' . intval($catid);\r
-\r
-               $query .= ' GROUP BY Year, Month';\r
-               if ($mode == 'day')\r
-                       $query .= ', Day';\r
-\r
-\r
-               $query .= ' ORDER BY itime DESC';\r
-\r
-               if ($limit > 0)\r
-                       $query .= ' LIMIT ' . intval($limit);\r
-\r
-               $res = sql_query($query);\r
-\r
-               while ($current = mysql_fetch_object($res)) {\r
-                       $current->itime = strtotime($current->itime);   // string time -> unix timestamp\r
-\r
-                       if ($mode == 'day') {\r
-                               $archivedate    = date('Y-m-d',$current->itime);\r
-                               $archive['day'] = date('d',$current->itime);\r
-                               $data['day']    = date('d',$current->itime);\r
-                       } else {\r
-                               $archivedate = date('Y-m',$current->itime);\r
-                       }\r
-                       $data['month'] = date('m',$current->itime);\r
-                       $data['year'] = date('Y',$current->itime);\r
-                       $data['archivelink'] = createArchiveLink($this->getID(),$archivedate,$linkparams);\r
-\r
-                       $manager->notify(\r
-                               'PreArchiveListItem',\r
-                               array(\r
-                                       'listitem' => &$data\r
-                               )\r
-                       );\r
-\r
-                       $temp = TEMPLATE::fill($template['ARCHIVELIST_LISTITEM'],$data);\r
-                       echo strftime($temp,$current->itime);\r
-\r
-               }\r
-\r
-               mysql_free_result($res);\r
-\r
-               echo TEMPLATE::fill($template['ARCHIVELIST_FOOTER'],$data);\r
-       }\r
-\r
-\r
-       /**\r
-         * Shows the list of categories using a given template\r
-         */\r
-       function showCategoryList($template) {\r
-               global $CONF, $manager;\r
-\r
-               // determine arguments next to catids\r
-               // I guess this can be done in a better way, but it works\r
-               global $archive, $archivelist;\r
-\r
-               $linkparams = array();\r
-               if ($archive) {\r
-                       $blogurl = createArchiveLink($this->getID(), $archive, '');\r
-                       $linkparams['blogid'] = $this->getID();\r
-                       $linkparams['archive'] = $archive;\r
-               } else if ($archivelist) {\r
-                       $blogurl = createArchiveListLink($this->getID(), '');\r
-                       $linkparams['archivelist'] = $archivelist;\r
-               } else {\r
-                       $blogurl = createBlogidLink($this->getID(), '');\r
-                       $linkparams['blogid'] = $this->getID();\r
-               }\r
-\r
-               //$blogurl = $this->getURL() . $qargs;\r
-               //$blogurl = createBlogLink($this->getURL(), $linkparams);\r
-\r
-               $template =& $manager->getTemplate($template);\r
-\r
-               echo TEMPLATE::fill((isset($template['CATLIST_HEADER']) ? $template['CATLIST_HEADER'] : null),\r
-                                                       array(\r
-                                                               'blogid' => $this->getID(),\r
-                                                               'blogurl' => $blogurl,\r
-                                                               'self' => $CONF['Self']\r
-                                                       ));\r
-\r
-               $query = 'SELECT catid, cdesc as catdesc, cname as catname FROM '.sql_table('category').' WHERE cblog=' . $this->getID() . ' ORDER BY cname ASC';\r
-               $res = sql_query($query);\r
-\r
-\r
-               while ($data = mysql_fetch_assoc($res)) {\r
-                       $data['blogid'] = $this->getID();\r
-                       $data['blogurl'] = $blogurl;\r
-                       $data['catlink'] = createLink(\r
-                                                               'category',\r
-                                                               array(\r
-                                                                       'catid' => $data['catid'],\r
-                                                                       'name' => $data['catname'],\r
-                                                                       'extra' => $linkparams\r
-                                                               )\r
-                                                          );\r
-                       $data['self'] = $CONF['Self'];\r
-\r
-                       $manager->notify(\r
-                               'PreCategoryListItem',\r
-                               array(\r
-                                       'listitem' => &$data\r
-                               )\r
-                       );\r
-                       \r
-                       echo TEMPLATE::fill((isset($template['CATLIST_LISTITEM']) ? $template['CATLIST_LISTITEM'] : null), $data);\r
-                       //$temp = TEMPLATE::fill((isset($template['CATLIST_LISTITEM']) ? $template['CATLIST_LISTITEM'] : null), $data);\r
-                       //echo strftime($temp, $current->itime);\r
-\r
-               }\r
-\r
-               mysql_free_result($res);\r
-\r
-               echo TEMPLATE::fill((isset($template['CATLIST_FOOTER']) ? $template['CATLIST_FOOTER'] : null),\r
-                                                       array(\r
-                                                               'blogid' => $this->getID(),\r
-                                                               'blogurl' => $blogurl,\r
-                                                               'self' => $CONF['Self']\r
-                                                       ));\r
-       }\r
-       \r
-       /**\r
-         * Shows a list of all blogs in the system using a given template\r
-         * ordered by  number, name, shortname or description\r
-         * in ascending or descending order        \r
-         */\r
-       function showBlogList($template, $bnametype, $orderby, $direction) {\r
-               global $CONF, $manager;\r
-               \r
-               switch ($orderby) {\r
-                       case 'number':\r
-                               $orderby='bnumber';\r
-                               break;\r
-                       case 'name':\r
-                               $orderby='bname';\r
-                               break;\r
-                       case 'shortname':\r
-                               $orderby='bshortname';\r
-                               break;\r
-                       case 'description':\r
-                               $orderby='bdesc';\r
-                               break;\r
-                       default:\r
-                               $orderby='bnumber';\r
-                               break;\r
-               }\r
-               \r
-               $direction=strtolower($direction);\r
-               switch ($direction) {\r
-                       case 'asc':\r
-                               $direction='ASC';\r
-                               break;\r
-                       case 'desc':\r
-                               $direction='DESC';\r
-                               break;\r
-                       default:\r
-                               $direction='ASC';\r
-                               break;\r
-               }\r
-               \r
-               $template =& $manager->getTemplate($template);\r
-               \r
-               echo TEMPLATE::fill((isset($template['BLOGLIST_HEADER']) ? $template['BLOGLIST_HEADER'] : null),\r
-                                                       array(\r
-                                                               'sitename' => $CONF['SiteName'],\r
-                                                               'siteurl' => $CONF['IndexURL']\r
-                                                       ));\r
-               \r
-               $query = 'SELECT bnumber, bname, bshortname, bdesc, burl FROM '.sql_table('blog').' ORDER BY '.$orderby.' '.$direction;\r
-               $res = sql_query($query);\r
-               \r
-               while ($data = mysql_fetch_assoc($res)) {\r
-               \r
-                       $list = array();\r
-               \r
-//                     $list['bloglink'] = createLink('blog', array('blogid' => $data['bnumber']));\r
-                       $list['bloglink'] = createBlogidLink($data['bnumber']);\r
-               \r
-                       $list['blogdesc'] = $data['bdesc'];\r
-                       \r
-                       $list['blogurl'] = $data['burl'];\r
-                       \r
-                       if ($bnametype=='shortname') {\r
-                               $list['blogname'] = $data['bshortname'];\r
-                       }\r
-                       else { // all other cases\r
-                               $list['blogname'] = $data['bname'];\r
-                       }\r
-                       \r
-                       $manager->notify(\r
-                               'PreBlogListItem',\r
-                               array(\r
-                                       'listitem' => &$list\r
-                               )\r
-                       );\r
-                       \r
-                       echo TEMPLATE::fill((isset($template['BLOGLIST_LISTITEM']) ? $template['BLOGLIST_LISTITEM'] : null), $list);\r
-                       \r
-               }\r
-               \r
-               mysql_free_result($res);\r
-               \r
-               echo TEMPLATE::fill((isset($template['BLOGLIST_FOOTER']) ? $template['BLOGLIST_FOOTER'] : null),\r
-                                                       array(\r
-                                                               'sitename' => $CONF['SiteName'],\r
-                                                               'siteurl' => $CONF['IndexURL']\r
-                                                       ));\r
-\r
-       }\r
-\r
-       /**\r
-         * Blogsettings functions\r
-         */\r
-\r
-       function readSettings() {\r
-               $query =  'SELECT *'\r
-                          . ' FROM '.sql_table('blog')\r
-                          . ' WHERE bnumber=' . $this->blogid;\r
-               $res = sql_query($query);\r
-\r
-               $this->isValid = (mysql_num_rows($res) > 0);\r
-               if (!$this->isValid)\r
-                       return;\r
-\r
-               $this->settings = mysql_fetch_assoc($res);\r
-       }\r
-\r
-       function writeSettings() {\r
-\r
-               // (can't use floatval since not available prior to PHP 4.2)\r
-               $offset = $this->getTimeOffset();\r
-               if (!is_float($offset))\r
-                       $offset = intval($offset);\r
-\r
-               $query =  'UPDATE '.sql_table('blog')\r
-                          . " SET bname='" . addslashes($this->getName()) . "',"\r
-                          . "     bshortname='". addslashes($this->getShortName()) . "',"\r
-                          . "     bcomments=". intval($this->commentsEnabled()) . ","\r
-                          . "     bmaxcomments=" . intval($this->getMaxComments()) . ","\r
-                          . "     btimeoffset=" . $offset . ","\r
-                          . "     bpublic=" . intval($this->isPublic()) . ","\r
-                          . "     breqemail=" . intval($this->emailRequired()) . ","\r
-                          . "     bsendping=" . intval($this->sendPing()) . ","\r
-                          . "     bconvertbreaks=" . intval($this->convertBreaks()) . ","\r
-                          . "     ballowpast=" . intval($this->allowPastPosting()) . ","\r
-                          . "     bnotify='" . addslashes($this->getNotifyAddress()) . "',"\r
-                          . "     bnotifytype=" . intval($this->getNotifyType()) . ","\r
-                          . "     burl='" . addslashes($this->getURL()) . "',"\r
-                          . "     bupdate='" . addslashes($this->getUpdateFile()) . "',"\r
-                          . "     bdesc='" . addslashes($this->getDescription()) . "',"\r
-                          . "     bdefcat=" . intval($this->getDefaultCategory()) . ","\r
-                          . "     bdefskin=" . intval($this->getDefaultSkin()) . ","\r
-                          . "     bincludesearch=" . intval($this->getSearchable())\r
-                          . " WHERE bnumber=" . intval($this->getID());\r
-               sql_query($query);\r
-\r
-       }\r
-\r
-\r
-\r
-       // update update file if requested\r
-       function updateUpdatefile() {\r
-                if ($this->getUpdateFile()) {\r
-                       $f_update = fopen($this->getUpdateFile(),'w');\r
-                       fputs($f_update,$this->getCorrectTime());\r
-                       fclose($f_update);\r
-                }\r
-\r
-       }\r
-\r
-       function isValidCategory($catid) {\r
-               $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog=' . $this->getID() . ' and catid=' . intval($catid);\r
-               $res = sql_query($query);\r
-               return (mysql_num_rows($res) != 0);\r
-       }\r
-\r
-       function getCategoryName($catid) {\r
-               $res = sql_query('SELECT cname FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and catid=' . intval($catid));\r
-               $o = mysql_fetch_object($res);\r
-               return $o->cname;\r
-       }\r
-\r
-       function getCategoryDesc($catid) {\r
-               $res = sql_query('SELECT cdesc FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and catid=' . intval($catid));\r
-               $o = mysql_fetch_object($res);\r
-               return $o->cdesc;\r
-       }\r
-\r
-       function getCategoryIdFromName($name) {\r
-               $res = sql_query('SELECT catid FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and cname="' . addslashes($name) . '"');\r
-               if (mysql_num_rows($res) > 0) {\r
-                       $o = mysql_fetch_object($res);\r
-                       return $o->catid;\r
-               } else {\r
-                       return $this->getDefaultCategory();\r
-               }\r
-       }\r
-\r
-       function sendPing() {\r
-               return $this->getSetting('bsendping');\r
-       }\r
-\r
-       function setPingUserland($val) {\r
-               $this->setSetting('bsendping',$val);\r
-       }\r
-\r
-       function convertBreaks() {\r
-               return $this->getSetting('bconvertbreaks');\r
-       }\r
-\r
-       function insertJavaScriptInfo($authorid = '') {\r
-               global $member, $CONF;\r
-\r
-               if ($authorid == '')\r
-                       $authorid = $member->getID();\r
-\r
-               ?>\r
-               <script type="text/javascript">\r
-                       setConvertBreaks(<?php echo  $this->convertBreaks() ? 'true' : 'false' ?>);\r
-                       setMediaUrl("<?php echo $CONF['MediaURL']?>");\r
-                       setAuthorId(<?php echo $authorid?>);\r
-               </script><?php  }\r
-\r
-       function setConvertBreaks($val) {\r
-               $this->setSetting('bconvertbreaks',$val);\r
-       }\r
-       function setAllowPastPosting($val) {\r
-               $this->setSetting('ballowpast',$val);\r
-       }\r
-       function allowPastPosting() {\r
-               return $this->getSetting('ballowpast');\r
-       }\r
-\r
-       function getCorrectTime($t=0) {\r
-               if ($t == 0) $t = time();\r
-               return ($t + 3600 * $this->getTimeOffset());\r
-       }\r
-\r
-       function getName() {\r
-               return $this->getSetting('bname');\r
-       }\r
-\r
-       function getShortName() {\r
-               return $this->getSetting('bshortname');\r
-       }\r
-\r
-       function getMaxComments() {\r
-               return $this->getSetting('bmaxcomments');\r
-       }\r
-\r
-       function getNotifyAddress() {\r
-               return $this->getSetting('bnotify');\r
-       }\r
-\r
-       function getNotifyType() {\r
-               return $this->getSetting('bnotifytype');\r
-       }\r
-\r
-       function notifyOnComment() {\r
-               $n = $this->getNotifyType();\r
-               return (($n != 0) && (($n % 3) == 0));\r
-       }\r
-\r
-       function notifyOnVote() {\r
-               $n = $this->getNotifyType();\r
-               return (($n != 0) && (($n % 5) == 0));\r
-       }\r
-\r
-       function notifyOnNewItem() {\r
-               $n = $this->getNotifyType();\r
-               return (($n != 0) && (($n % 7) == 0));\r
-       }\r
-\r
-       function setNotifyType($val) {\r
-               $this->setSetting('bnotifytype',$val);\r
-       }\r
-\r
-\r
-       function getTimeOffset() {\r
-               return $this->getSetting('btimeoffset');\r
-       }\r
-\r
-       function commentsEnabled() {\r
-               return $this->getSetting('bcomments');\r
-       }\r
-\r
-       function getURL() {\r
-               return $this->getSetting('burl');\r
-       }\r
-\r
-       function getDefaultSkin() {\r
-               return $this->getSetting('bdefskin');\r
-       }\r
-\r
-       function getUpdateFile() {\r
-               return $this->getSetting('bupdate');\r
-       }\r
-\r
-       function getDescription() {\r
-               return $this->getSetting('bdesc');\r
-       }\r
-\r
-       function isPublic() {\r
-               return $this->getSetting('bpublic');\r
-       }\r
-\r
-       function emailRequired() {\r
-               return $this->getSetting('breqemail');\r
-       }\r
-\r
-       function getSearchable() {\r
-               return $this->getSetting('bincludesearch');\r
-       }\r
-\r
-       function getDefaultCategory() {\r
-               return $this->getSetting('bdefcat');\r
-       }\r
-\r
-       function setPublic($val) {\r
-               $this->setSetting('bpublic',$val);\r
-       }\r
-\r
-       function setSearchable($val) {\r
-               $this->setSetting('bincludesearch',$val);\r
-       }\r
-\r
-       function setDescription($val) {\r
-               $this->setSetting('bdesc',$val);\r
-       }\r
-\r
-       function setUpdateFile($val) {\r
-               $this->setSetting('bupdate',$val);\r
-       }\r
-\r
-       function setDefaultSkin($val) {\r
-               $this->setSetting('bdefskin',$val);\r
-       }\r
-\r
-       function setURL($val) {\r
-               $this->setSetting('burl',$val);\r
-       }\r
-\r
-       function setName($val) {\r
-               $this->setSetting('bname',$val);\r
-       }\r
-\r
-       function setShortName($val) {\r
-               $this->setSetting('bshortname',$val);\r
-       }\r
-\r
-       function setCommentsEnabled($val) {\r
-               $this->setSetting('bcomments',$val);\r
-       }\r
-\r
-       function setMaxComments($val) {\r
-               $this->setSetting('bmaxcomments',$val);\r
-       }\r
-\r
-       function setNotifyAddress($val) {\r
-               $this->setSetting('bnotify',$val);\r
-       }\r
-\r
-       function setEmailRequired($val) {\r
-               $this->setSetting('breqemail',$val);\r
-       }\r
-\r
-       function setTimeOffset($val) {\r
-               // check validity of value\r
-               // 1. replace , by . (common mistake)\r
-               $val = str_replace(',','.',$val);\r
-               // 2. cast to float or int\r
-               if (is_numeric($val) && strstr($val,'.5')) {\r
-                       $val = (float) $val;\r
-               } else {\r
-                       $val = intval($val);\r
-               }\r
-\r
-               $this->setSetting('btimeoffset',$val);\r
-       }\r
-\r
-       function setDefaultCategory($val) {\r
-               $this->setSetting('bdefcat',$val);\r
-       }\r
-\r
-       function getSetting($key) {\r
-               return $this->settings[$key];\r
-       }\r
-\r
-       function setSetting($key,$value) {\r
-               $this->settings[$key] = $value;\r
-       }\r
-\r
-\r
-       // tries to add a member to the team. Returns false if the member was already on\r
-       // the team\r
-       function addTeamMember($memberid, $admin) {\r
-               global $manager;\r
-\r
-               $memberid = intval($memberid);\r
-               $admin = intval($admin);\r
-\r
-               // check if member is already a member\r
-               $tmem = MEMBER::createFromID($memberid);\r
-\r
-               if ($tmem->isTeamMember($this->getID()))\r
-                       return 0;\r
-\r
-               $manager->notify(\r
-                       'PreAddTeamMember',\r
-                       array(\r
-                               'blog' => &$this,\r
-                               'member' => &$tmem,\r
-                               'admin' => &$admin\r
-                       )\r
-               );\r
-\r
-               // add to team\r
-               $query = 'INSERT INTO '.sql_table('team').' (TMEMBER, TBLOG, TADMIN) '\r
-                          . 'VALUES (' . $memberid .', '.$this->getID().', "'.$admin.'")';\r
-               sql_query($query);\r
-\r
-               $manager->notify(\r
-                       'PostAddTeamMember',\r
-                       array(\r
-                               'blog' => &$this,\r
-                               'member' => &$tmem,\r
-                               'admin' => $admin\r
-                       )\r
-\r
-               );\r
-\r
-               $logMsg = sprintf(_TEAM_ADD_NEWTEAMMEMBER, $tmem->getDisplayName(), $memberid, $this->getName());\r
-               ACTIONLOG::add(INFO, $logMsg);\r
-\r
-               return 1;\r
-       }\r
-\r
-       function getID() {\r
-               return intVal($this->blogid);\r
-       }\r
-\r
-       // returns true if there is a blog with the given shortname (static)\r
-       function exists($name) {\r
-               $r = sql_query('select * FROM '.sql_table('blog').' WHERE bshortname="'.addslashes($name).'"');\r
-               return (mysql_num_rows($r) != 0);\r
-       }\r
-\r
-       // returns true if there is a blog with the given ID (static)\r
-       function existsID($id) {\r
-               $r = sql_query('select * FROM '.sql_table('blog').' WHERE bnumber='.intval($id));\r
-               return (mysql_num_rows($r) != 0);\r
-       }\r
-\r
-        // flag there is a future post pending\r
-        function setFuturePost() {\r
-               $query =  'UPDATE '.sql_table('blog')\r
-                          . " SET bfuturepost='1' WHERE bnumber=" . $this->getID();\r
-               sql_query($query);\r
-        }\r
-\r
-       // clear there is a future post pending\r
-       function clearFuturePost() {\r
-               $query =  'UPDATE '.sql_table('blog')\r
-                          . " SET bfuturepost='0' WHERE bnumber=" . $this->getID();\r
-               sql_query($query);\r
-       }\r
-\r
-       // check if we should throw justPosted event\r
-       function checkJustPosted() {\r
-               global $manager;\r
-\r
-               if ($this->settings['bfuturepost'] == 1) {\r
-                       $blogid = $this->getID();\r
-                       $result = sql_query("SELECT * FROM " . sql_table('item')\r
-                                 . " WHERE iposted=0 AND iblog=" . $blogid . " AND itime<NOW()");\r
-                       if (mysql_num_rows($result) > 0) {\r
-                               // This $pinged is allow a plugin to tell other hook to the event that a ping is sent already\r
-                               // Note that the plugins's calling order is subject to thri order in the plugin list\r
-                               $pinged = false;\r
-                               $manager->notify(\r
-                                               'JustPosted',\r
-                                               array('blogid' => $blogid,\r
-                                               'pinged' => &$pinged\r
-                                               )\r
-                               );\r
-\r
-                               // clear all expired future posts\r
-                               sql_query("UPDATE " . sql_table('item') . " SET iposted='1' WHERE iblog=" . $blogid . " AND itime<NOW()");\r
-\r
-                               // check to see any pending future post, clear the flag is none \r
-                               $result = sql_query("SELECT * FROM " . sql_table('item') \r
-                                         . " WHERE iposted=0 AND iblog=" . $blogid);\r
-                               if (mysql_num_rows($result) == 0) {\r
-                                       $this->clearFuturePost();\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Shows the given list of items for this blog\r
-        *\r
-        * @param $itemarray\r
-        *              array of item numbers to be displayed\r
-        * @param $template\r
-        *              String representing the template _NAME_ (!)      \r
-        * @param $highlight\r
-        *              contains a query that should be highlighted\r
-        * @param $comments\r
-        *              1=show comments 0=don't show comments\r
-        * @param $dateheads\r
-        *              1=show dateheads 0=don't show dateheads\r
-        * @returns int\r
-        *              amount of items shown\r
-        */\r
-       function readLogFromList($itemarray, $template, $highlight = '', $comments = 1, $dateheads = 1) {\r
-\r
-               $query = $this->getSqlItemList($itemarray);\r
-\r
-               return $this->showUsingQuery($template, $query, $highlight, $comments, $dateheads);\r
-       }\r
-       \r
-       /**\r
-        * Returns the SQL query used to fill out templates for a list of items\r
-        *\r
-        * @param $itemarray\r
-        *              an array holding the item numbers of the items to be displayed\r
-        * @returns\r
-        *              either a full SQL query, or an empty string\r
-        * @note\r
-        *              No LIMIT clause is added. (caller should add this if multiple pages are requested)\r
-        */\r
-       function getSqlItemList($itemarray)\r
-       {\r
-               if (!is_array($itemarray)) return '';\r
-               $items = array();\r
-               foreach ($itemarray as $value) {\r
-                       if (intval($value)) $items[] = intval($value);\r
-               }\r
-               if (!count($items)) return '';\r
-               //$itemlist = implode(',',$items);\r
-               $i = count($items);\r
-               $query = '';\r
-               foreach ($items as $value) {\r
-                       $query .= '('\r
-                                       .   'SELECT'\r
-                                       .   ' i.inumber as itemid,'\r
-                                       .   ' i.ititle as title,'\r
-                                       .   ' i.ibody as body,'\r
-                                       .   ' m.mname as author,'\r
-                                       .   ' m.mrealname as authorname,'\r
-                                       .   ' i.itime,'\r
-                                       .   ' i.imore as more,'\r
-                                       .   ' m.mnumber as authorid,'\r
-                                       .   ' m.memail as authormail,'\r
-                                       .   ' m.murl as authorurl,'\r
-                                       .   ' c.cname as category,'\r
-                                       .   ' i.icat as catid,'\r
-                                       .   ' i.iclosed as closed';\r
-                       \r
-                       $query .= ' FROM '\r
-                                       . sql_table('item') . ' as i, '\r
-                                       . sql_table('member') . ' as m, '\r
-                                       . sql_table('category').' as c'\r
-                                   . ' WHERE'\r
-                                       .     ' i.iblog   = ' . $this->blogid\r
-                                   . ' and i.iauthor = m.mnumber'\r
-                                   . ' and i.icat    = c.catid'\r
-                                   . ' and i.idraft  = 0'      // exclude drafts\r
-                                               // don't show future items\r
-                                   . ' and i.itime  <= ' . mysqldate($this->getCorrectTime());\r
-\r
-                       //$query .= ' and i.inumber IN ('.$itemlist.')';\r
-                       $query .= ' and i.inumber = '.intval($value);\r
-                       $query .= ')';\r
-                       $i--;\r
-                       if ($i) $query .= ' UNION ';\r
-               }\r
-               \r
-               return $query;\r
-       }\r
-\r
-}\r
-\r
+if ( !function_exists('requestVar') ) exit;
+require_once dirname(__FILE__) . '/ITEMACTIONS.php';
+
+class BLOG {
+
+       // blog id
+       var $blogid;
+
+       // ID of currently selected category
+       var $selectedcatid;
+
+       // After creating an object of the blog class, contains true if the BLOG object is
+       // valid (the blog exists)
+       var $isValid;
+
+       // associative array, containing all blogsettings (use the get/set functions instead)
+       var $settings;
+
+       /**
+        * Creates a new BLOG object for the given blog
+        *
+        * @param $id blogid
+        */
+       function BLOG($id) {
+               $this->blogid = intval($id);
+               $this->readSettings();
+
+               // try to set catid
+               // (the parse functions in SKIN.php will override this, so it's mainly useless)
+               global $catid;
+               $this->setSelectedCategory($catid);
+       }
+
+       /**
+        * Shows the given amount of items for this blog
+        *
+        * @param $template
+        *              String representing the template _NAME_ (!)
+        * @param $amountEntries
+        *              amount of entries to show
+        * @param $startpos
+        *              offset from where items should be shown (e.g. 5 = start at fifth item)
+        * @returns int
+        *              amount of items shown
+        */
+       function readLog($template, $amountEntries, $offset = 0, $startpos = 0) {
+               return $this->readLogAmount($template,$amountEntries,'','',1,1,$offset, $startpos);
+       }
+
+       /**
+        * Shows an archive for a given month
+        *
+        * @param $year
+        *              year
+        * @param $month
+        *              month
+        * @param $template
+        *              String representing the template name to be used
+        */
+       function showArchive($templatename, $year, $month, $day=0) {
+
+               // create extra where clause for select query
+               if ($day == 0) {
+                       $timestamp_start = mktime(0,0,0,$month,1,$year);
+                       $timestamp_end = mktime(0,0,0,$month+1,1,$year);  // also works when $month==12
+               } else {
+                       $timestamp_start = mktime(0,0,0,$month,$day,$year);
+                       $timestamp_end = mktime(0,0,0,$month,$day+1,$year);
+               }
+               $extra_query = ' and i.itime>=' . mysqldate($timestamp_start)
+                                        . ' and i.itime<' . mysqldate($timestamp_end);
+
+
+               $this->readLogAmount($templatename,0,$extra_query,'',1,1);
+
+       }
+
+
+       // sets/gets current category (only when category exists)
+       function setSelectedCategory($catid) {
+               if ($this->isValidCategory($catid) || (intval($catid) == 0))
+                       $this->selectedcatid = intval($catid);
+       }
+
+       function setSelectedCategoryByName($catname) {
+               $this->setSelectedCategory($this->getCategoryIdFromName($catname));
+       }
+
+       function getSelectedCategory() {
+               return $this->selectedcatid;
+       }
+
+       /**
+        * Shows the given amount of items for this blog
+        *
+        * @param $template
+        *              String representing the template _NAME_ (!)
+        * @param $amountEntries
+        *              amount of entries to show (0 = no limit)
+        * @param $extraQuery
+        *              extra conditions to be added to the query
+        * @param $highlight
+        *              contains a query that should be highlighted
+        * @param $comments
+        *              1=show comments 0=don't show comments
+        * @param $dateheads
+        *              1=show dateheads 0=don't show dateheads
+        * @param $offset
+        *              offset
+        * @returns int
+        *              amount of items shown
+        */
+       function readLogAmount($template, $amountEntries, $extraQuery, $highlight, $comments, $dateheads, $offset = 0, $startpos = 0) {
+
+               $query = $this->getSqlBlog($extraQuery);
+
+               if ($amountEntries > 0) {
+                               // $offset zou moeten worden:
+                               // (($startpos / $amountentries) + 1) * $offset ... later testen ...
+                          $query .= ' LIMIT ' . intval($startpos + $offset).',' . intval($amountEntries);
+               }
+               return $this->showUsingQuery($template, $query, $highlight, $comments, $dateheads);
+       }
+
+       function showUsingQuery($templateName, $query, $highlight = '', $comments = 0, $dateheads = 1) {
+               global $CONF, $manager;
+
+               $lastVisit = cookieVar($CONF['CookiePrefix'] .'lastVisit');
+               if ($lastVisit != 0)
+                       $lastVisit = $this->getCorrectTime($lastVisit);
+
+               // set templatename as global variable (so plugins can access it)
+               global $currentTemplateName;
+               $currentTemplateName = $templateName;
+
+               $template =& $manager->getTemplate($templateName);
+
+               // create parser object & action handler
+               $actions =& new ITEMACTIONS($this);
+               $parser =& new PARSER($actions->getDefinedActions(),$actions);
+               $actions->setTemplate($template);
+               $actions->setHighlight($highlight);
+               $actions->setLastVisit($lastVisit);
+               $actions->setParser($parser);
+               $actions->setShowComments($comments);
+
+               // execute query
+               $items = sql_query($query);
+
+               // loop over all items
+               $old_date = 0;
+               while ($item = mysql_fetch_object($items)) {
+
+                       $item->timestamp = strtotime($item->itime);     // string timestamp -> unix timestamp
+
+                       // action handler needs to know the item we're handling
+                       $actions->setCurrentItem($item);
+
+                       // add date header if needed
+                       if ($dateheads) {
+                               $new_date = date('dFY',$item->timestamp);
+                               if ($new_date != $old_date) {
+                                       // unless this is the first time, write date footer
+                                       $timestamp = $item->timestamp;
+                                       if ($old_date != 0) {
+                                               $oldTS = strtotime($old_date);
+                                               $manager->notify('PreDateFoot',array('blog' => &$this, 'timestamp' => $oldTS));
+                                               $tmp_footer = strftime(isset($template['DATE_FOOTER'])?$template['DATE_FOOTER']:'', $oldTS);
+                                               $parser->parse($tmp_footer);
+                                               $manager->notify('PostDateFoot',array('blog' => &$this, 'timestamp' => $oldTS));
+                                       }
+                                       $manager->notify('PreDateHead',array('blog' => &$this, 'timestamp' => $timestamp));
+                                       // note, to use templatvars in the dateheader, the %-characters need to be doubled in
+                                       // order to be preserved by strftime
+                                       $tmp_header = strftime((isset($template['DATE_HEADER']) ? $template['DATE_HEADER'] : null), $timestamp);
+                                       $parser->parse($tmp_header);
+                                       $manager->notify('PostDateHead',array('blog' => &$this, 'timestamp' => $timestamp));
+                               }
+                               $old_date = $new_date;
+                       }
+
+                       // parse item
+                       $parser->parse($template['ITEM_HEADER']);
+                       $manager->notify('PreItem', array('blog' => &$this, 'item' => &$item));
+                       $parser->parse($template['ITEM']);
+                       $manager->notify('PostItem', array('blog' => &$this, 'item' => &$item));
+                       $parser->parse($template['ITEM_FOOTER']);
+
+               }
+
+               $numrows = mysql_num_rows($items);
+
+               // add another date footer if there was at least one item
+               if (($numrows > 0) && $dateheads) {
+                       $manager->notify('PreDateFoot',array('blog' => &$this, 'timestamp' => strtotime($old_date)));
+                       $parser->parse($template['DATE_FOOTER']);
+                       $manager->notify('PostDateFoot',array('blog' => &$this, 'timestamp' => strtotime($old_date)));
+               }
+
+               mysql_free_result($items);      // free memory
+
+               return $numrows;
+
+       }
+
+       function showOneitem($itemid, $template, $highlight) {
+               $extraQuery = ' and inumber=' . intval($itemid);
+
+               return $this->readLogAmount($template, 1, $extraQuery, $highlight, 0, 0);
+       }
+
+
+       /**
+         * Adds an item to this blog
+         */
+       function additem($catid, $title, $body, $more, $blogid, $authorid, $timestamp, $closed, $draft, $posted='1') {
+               global $manager;
+
+               $blogid         = intval($blogid);
+               $authorid       = intval($authorid);
+               $title          = $title;
+               $body           = $body;
+               $more           = $more;
+               $catid          = intval($catid);
+
+               // convert newlines to <br />
+               if ($this->convertBreaks()) {
+                       $body = addBreaks($body);
+                       $more = addBreaks($more);
+               }
+
+               if ($closed != '1') $closed = '0';
+               if ($draft != '0') $draft = '1';
+
+               if (!$this->isValidCategory($catid))
+                       $catid = $this->getDefaultCategory();
+
+               if ($timestamp > $this->getCorrectTime())
+                       $isFuture = 1;
+
+               $timestamp = date('Y-m-d H:i:s',$timestamp);
+
+               $manager->notify('PreAddItem',array('title' => &$title, 'body' => &$body, 'more' => &$more, 'blog' => &$this, 'authorid' => &$authorid, 'timestamp' => &$timestamp, 'closed' => &$closed, 'draft' => &$draft, 'catid' => &$catid));
+
+               $title = addslashes($title);
+               $body = addslashes($body);
+               $more = addslashes($more);
+
+               $query = 'INSERT INTO '.sql_table('item').' (ITITLE, IBODY, IMORE, IBLOG, IAUTHOR, ITIME, ICLOSED, IDRAFT, ICAT, IPOSTED) '
+                          . "VALUES ('$title', '$body', '$more', $blogid, $authorid, '$timestamp', $closed, $draft, $catid, $posted)";
+               sql_query($query);
+               $itemid = mysql_insert_id();
+
+               $manager->notify('PostAddItem',array('itemid' => $itemid));
+
+               if (!$draft)
+                       $this->updateUpdateFile();
+
+               // send notification mail
+               if (!$draft && !$isFuture && $this->getNotifyAddress() && $this->notifyOnNewItem())
+                       $this->sendNewItemNotification($itemid, stripslashes($title), stripslashes($body));
+
+               return $itemid;
+       }
+
+       function sendNewItemNotification($itemid, $title, $body) {
+               global $CONF, $member;
+
+               // create text version of html post
+               $ascii = toAscii($body);
+
+               $mailto_msg = _NOTIFY_NI_MSG . " \n";
+//             $mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $itemid . "\n\n";
+               $temp = parse_url($CONF['Self']);
+               if ($temp['scheme']) {
+                       $mailto_msg .= createItemLink($itemid) . "\n\n";
+               } else {
+                       $tempurl = $this->getURL();
+                       if (substr($tempurl, -1) == '/' || substr($tempurl, -4) == '.php') {
+                               $mailto_msg .= $tempurl . '?itemid=' . $itemid . "\n\n";
+                       } else {
+                               $mailto_msg .= $tempurl . '/?itemid=' . $itemid . "\n\n";
+                       }
+               }
+               $mailto_msg .= _NOTIFY_TITLE . ' ' . strip_tags($title) . "\n";
+               $mailto_msg .= _NOTIFY_CONTENTS . "\n " . $ascii . "\n";
+               $mailto_msg .= getMailFooter();
+
+               $mailto_title = $this->getName() . ': ' . _NOTIFY_NI_TITLE;
+
+               $frommail = $member->getNotifyFromMailAddress();
+
+               $notify =& new NOTIFICATION($this->getNotifyAddress());
+               $notify->notify($mailto_title, $mailto_msg , $frommail);
+
+
+
+       }
+
+
+       /**
+         * Creates a new category for this blog
+         *
+         * @param $catName
+         *             name of the new category. When empty, a name is generated automatically
+         *             (starting with newcat)
+         * @param $catDescription
+         *             description of the new category. Defaults to 'New Category'
+         *
+         * @returns
+         *             the new category-id in case of success.
+         *             0 on failure
+         */
+       function createNewCategory($catName = '', $catDescription = _CREATED_NEW_CATEGORY_DESC) {
+               global $member, $manager;
+
+               if ($member->blogAdminRights($this->getID())) {
+                       // generate
+                       if ($catName == '')
+                       {
+                               $catName = _CREATED_NEW_CATEGORY_NAME;
+                               $i = 1;
+
+                               $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cname='".$catName.$i."' and cblog=".$this->getID());
+                               while (mysql_num_rows($res) > 0)
+                               {
+                                       $i++;
+                                       $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cname='".$catName.$i."' and cblog=".$this->getID());
+                               }
+
+                               $catName = $catName . $i;
+                       }
+
+                       $manager->notify(
+                               'PreAddCategory',
+                               array(
+                                       'blog' => &$this,
+                                       'name' => &$catName,
+                                       'description' => $catDescription
+                               )
+                       );
+
+                       $query = 'INSERT INTO '.sql_table('category').' (cblog, cname, cdesc) VALUES (' . $this->getID() . ", '" . addslashes($catName) . "', '" . addslashes($catDescription) . "')";
+                       sql_query($query);
+                       $catid = mysql_insert_id();
+
+                       $manager->notify(
+                               'PostAddCategory',
+                               array(
+                                       'blog' => &$this,
+                                       'name' => $catName,
+                                       'description' => $catDescription,
+                                       'catid' => $catid
+                               )
+                       );
+
+                       return $catid;
+               } else {
+                       return 0;
+               }
+
+       }
+
+
+       /**
+        * Searches all months of this blog for the given query
+        *
+        * @param $query
+        *              search query
+        * @param $template
+        *              template to be used (__NAME__ of the template)
+        * @param $amountMonths
+        *              max amount of months to be search (0 = all)
+        * @param $maxresults
+        *              max number of results to show
+        * @param $startpos
+        *              offset
+        * @returns
+        *              amount of hits found
+        */
+       function search($query, $template, $amountMonths, $maxresults, $startpos) {
+               global $CONF, $manager;
+
+               $highlight      = '';
+               $sqlquery       = $this->getSqlSearch($query, $amountMonths, $highlight);
+
+               if ($sqlquery == '')
+               {
+                       // no query -> show everything
+                       $extraquery = '';
+                       $amountfound = $this->readLogAmount($template, $maxresults, $extraQuery, $query, 1, 1);
+               } else {
+
+                       // add LIMIT to query (to split search results into pages)
+                       if (intval($maxresults > 0))
+                               $sqlquery .= ' LIMIT ' . intval($startpos).',' . intval($maxresults);
+
+                       // show results
+                       $amountfound = $this->showUsingQuery($template, $sqlquery, $highlight, 1, 1);
+
+                       // when no results were found, show a message
+                       if ($amountfound == 0)
+                       {
+                               $template =& $manager->getTemplate($template);
+                               $vars = array(
+                                       'query'         => htmlspecialchars($query),
+                                       'blogid'        => $this->getID()
+                               );
+                               echo TEMPLATE::fill($template['SEARCH_NOTHINGFOUND'],$vars);
+                       }
+               }
+
+               return $amountfound;
+       }
+
+       /**
+        * Returns an SQL query to use for a search query
+        *
+        * @param $query
+        *              search query
+        * @param $amountMonths
+        *              amount of months to search back. Default = 0 = unlimited
+        * @param $mode
+        *              either empty, or 'count'. In this case, the query will be a SELECT COUNT(*) query
+        * @returns $highlight
+        *              words to highlight (out parameter)
+        * @returns
+        *              either a full SQL query, or an empty string (if querystring empty)
+        * @note
+        *              No LIMIT clause is added. (caller should add this if multiple pages are requested)
+        */
+       function getSqlSearch($query, $amountMonths = 0, &$highlight, $mode = '')
+       {
+               $searchclass =& new SEARCH($query);
+
+               $highlight        = $searchclass->inclusive;
+
+               // if querystring is empty, return empty string
+               if ($searchclass->inclusive == '')
+                       return '';
+
+
+               $where  = $searchclass->boolean_sql_where('ititle,ibody,imore');
+               $select = $searchclass->boolean_sql_select('ititle,ibody,imore');
+
+               // get list of blogs to search
+               $blogs          = $searchclass->blogs;          // array containing blogs that always need to be included
+               $blogs[]        = $this->getID();                       // also search current blog (duh)
+               $blogs          = array_unique($blogs);         // remove duplicates
+               $selectblogs = '';
+               if (count($blogs) > 0)
+                       $selectblogs = ' and i.iblog in (' . implode(',', $blogs) . ')';
+
+               if ($mode == '')
+               {
+                       $query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author, m.mrealname as authorname, i.itime, i.imore as more, m.mnumber as authorid, m.memail as authormail, m.murl as authorurl, c.cname as category, i.icat as catid, i.iclosed as closed';
+                       if ($select)
+                               $query .= ', '.$select. ' as score ';
+               } else {
+                       $query = 'SELECT COUNT(*) as result ';
+               }
+
+               $query .= ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c'
+                          . ' WHERE i.iauthor=m.mnumber'
+                          . ' and i.icat=c.catid'
+                          . ' and i.idraft=0'  // exclude drafts
+                          . $selectblogs
+                                       // don't show future items
+                          . ' and i.itime<=' . mysqldate($this->getCorrectTime())
+                          . ' and '.$where;
+
+               // take into account amount of months to search
+               if ($amountMonths > 0)
+               {
+                       $localtime = getdate($this->getCorrectTime());
+                       $timestamp_start = mktime(0,0,0,$localtime['mon'] - $amountMonths,1,$localtime['year']);
+                       $query .= ' and i.itime>' . mysqldate($timestamp_start);
+               }
+
+               if ($mode == '')
+               {
+                       if ($select)
+                               $query .= ' ORDER BY score DESC';
+                       else
+                               $query .= ' ORDER BY i.itime DESC ';
+               }
+
+               return $query;
+       }
+
+       /**
+        * Returns the SQL query that's normally used to display the blog items on the index type skins
+        *
+        * @param $mode
+        *              either empty, or 'count'. In this case, the query will be a SELECT COUNT(*) query
+        * @returns
+        *              either a full SQL query, or an empty string
+        * @note
+        *              No LIMIT clause is added. (caller should add this if multiple pages are requested)
+        */
+       function getSqlBlog($extraQuery, $mode = '')
+       {
+               if ($mode == '')
+                       $query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author, m.mrealname as authorname, i.itime, i.imore as more, m.mnumber as authorid, m.memail as authormail, m.murl as authorurl, c.cname as category, i.icat as catid, i.iclosed as closed';
+               else
+                       $query = 'SELECT COUNT(*) as result ';
+
+               $query .= ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c'
+                          . ' WHERE i.iblog='.$this->blogid
+                          . ' and i.iauthor=m.mnumber'
+                          . ' and i.icat=c.catid'
+                          . ' and i.idraft=0'  // exclude drafts
+                                       // don't show future items
+                          . ' and i.itime<=' . mysqldate($this->getCorrectTime());
+
+               if ($this->getSelectedCategory())
+                       $query .= ' and i.icat=' . $this->getSelectedCategory() . ' ';
+
+
+               $query .= $extraQuery;
+
+               if ($mode == '')
+                       $query .= ' ORDER BY i.itime DESC';
+
+               return $query;
+       }
+
+       /**
+         * Shows the archivelist using the given template
+         */
+       function showArchiveList($template, $mode = 'month', $limit = 0) {
+               global $CONF, $catid, $manager;
+
+               if ($catid)
+                       $linkparams = array('catid' => $catid);
+
+               $template =& $manager->getTemplate($template);
+               $data['blogid'] = $this->getID();
+
+               echo TEMPLATE::fill($template['ARCHIVELIST_HEADER'],$data);
+
+               $query = 'SELECT itime, SUBSTRING(itime,1,4) AS Year, SUBSTRING(itime,6,2) AS Month, SUBSTRING(itime,9,2) as Day FROM '.sql_table('item')
+               . ' WHERE iblog=' . $this->getID()
+               . ' and itime <=' . mysqldate($this->getCorrectTime())  // don't show future items!
+               . ' and idraft=0'; // don't show draft items
+
+               if ($catid)
+                       $query .= ' and icat=' . intval($catid);
+
+               $query .= ' GROUP BY Year, Month';
+               if ($mode == 'day')
+                       $query .= ', Day';
+
+
+               $query .= ' ORDER BY itime DESC';
+
+               if ($limit > 0)
+                       $query .= ' LIMIT ' . intval($limit);
+
+               $res = sql_query($query);
+
+               while ($current = mysql_fetch_object($res)) {
+                       $current->itime = strtotime($current->itime);   // string time -> unix timestamp
+
+                       if ($mode == 'day') {
+                               $archivedate    = date('Y-m-d',$current->itime);
+                               $archive['day'] = date('d',$current->itime);
+                               $data['day']    = date('d',$current->itime);
+                       } else {
+                               $archivedate = date('Y-m',$current->itime);
+                       }
+                       $data['month'] = date('m',$current->itime);
+                       $data['year'] = date('Y',$current->itime);
+                       $data['archivelink'] = createArchiveLink($this->getID(),$archivedate,$linkparams);
+
+                       $manager->notify(
+                               'PreArchiveListItem',
+                               array(
+                                       'listitem' => &$data
+                               )
+                       );
+
+                       $temp = TEMPLATE::fill($template['ARCHIVELIST_LISTITEM'],$data);
+                       echo strftime($temp,$current->itime);
+
+               }
+
+               mysql_free_result($res);
+
+               echo TEMPLATE::fill($template['ARCHIVELIST_FOOTER'],$data);
+       }
+
+
+       /**
+         * Shows the list of categories using a given template
+         */
+       function showCategoryList($template) {
+               global $CONF, $manager;
+
+               // determine arguments next to catids
+               // I guess this can be done in a better way, but it works
+               global $archive, $archivelist;
+
+               $linkparams = array();
+               if ($archive) {
+                       $blogurl = createArchiveLink($this->getID(), $archive, '');
+                       $linkparams['blogid'] = $this->getID();
+                       $linkparams['archive'] = $archive;
+               } else if ($archivelist) {
+                       $blogurl = createArchiveListLink($this->getID(), '');
+                       $linkparams['archivelist'] = $archivelist;
+               } else {
+                       $blogurl = createBlogidLink($this->getID(), '');
+                       $linkparams['blogid'] = $this->getID();
+               }
+
+               //$blogurl = $this->getURL() . $qargs;
+               //$blogurl = createBlogLink($this->getURL(), $linkparams);
+
+               $template =& $manager->getTemplate($template);
+
+               echo TEMPLATE::fill((isset($template['CATLIST_HEADER']) ? $template['CATLIST_HEADER'] : null),
+                                                       array(
+                                                               'blogid' => $this->getID(),
+                                                               'blogurl' => $blogurl,
+                                                               'self' => $CONF['Self']
+                                                       ));
+
+               $query = 'SELECT catid, cdesc as catdesc, cname as catname FROM '.sql_table('category').' WHERE cblog=' . $this->getID() . ' ORDER BY cname ASC';
+               $res = sql_query($query);
+
+
+               while ($data = mysql_fetch_assoc($res)) {
+                       $data['blogid'] = $this->getID();
+                       $data['blogurl'] = $blogurl;
+                       $data['catlink'] = createLink(
+                                                               'category',
+                                                               array(
+                                                                       'catid' => $data['catid'],
+                                                                       'name' => $data['catname'],
+                                                                       'extra' => $linkparams
+                                                               )
+                                                          );
+                       $data['self'] = $CONF['Self'];
+
+                       $manager->notify(
+                               'PreCategoryListItem',
+                               array(
+                                       'listitem' => &$data
+                               )
+                       );
+                       
+                       echo TEMPLATE::fill((isset($template['CATLIST_LISTITEM']) ? $template['CATLIST_LISTITEM'] : null), $data);
+                       //$temp = TEMPLATE::fill((isset($template['CATLIST_LISTITEM']) ? $template['CATLIST_LISTITEM'] : null), $data);
+                       //echo strftime($temp, $current->itime);
+
+               }
+
+               mysql_free_result($res);
+
+               echo TEMPLATE::fill((isset($template['CATLIST_FOOTER']) ? $template['CATLIST_FOOTER'] : null),
+                                                       array(
+                                                               'blogid' => $this->getID(),
+                                                               'blogurl' => $blogurl,
+                                                               'self' => $CONF['Self']
+                                                       ));
+       }
+       
+       /**
+         * Shows a list of all blogs in the system using a given template
+         * ordered by  number, name, shortname or description
+         * in ascending or descending order        
+         */
+       function showBlogList($template, $bnametype, $orderby, $direction) {
+               global $CONF, $manager;
+               
+               switch ($orderby) {
+                       case 'number':
+                               $orderby='bnumber';
+                               break;
+                       case 'name':
+                               $orderby='bname';
+                               break;
+                       case 'shortname':
+                               $orderby='bshortname';
+                               break;
+                       case 'description':
+                               $orderby='bdesc';
+                               break;
+                       default:
+                               $orderby='bnumber';
+                               break;
+               }
+               
+               $direction=strtolower($direction);
+               switch ($direction) {
+                       case 'asc':
+                               $direction='ASC';
+                               break;
+                       case 'desc':
+                               $direction='DESC';
+                               break;
+                       default:
+                               $direction='ASC';
+                               break;
+               }
+               
+               $template =& $manager->getTemplate($template);
+               
+               echo TEMPLATE::fill((isset($template['BLOGLIST_HEADER']) ? $template['BLOGLIST_HEADER'] : null),
+                                                       array(
+                                                               'sitename' => $CONF['SiteName'],
+                                                               'siteurl' => $CONF['IndexURL']
+                                                       ));
+               
+               $query = 'SELECT bnumber, bname, bshortname, bdesc, burl FROM '.sql_table('blog').' ORDER BY '.$orderby.' '.$direction;
+               $res = sql_query($query);
+               
+               while ($data = mysql_fetch_assoc($res)) {
+               
+                       $list = array();
+               
+//                     $list['bloglink'] = createLink('blog', array('blogid' => $data['bnumber']));
+                       $list['bloglink'] = createBlogidLink($data['bnumber']);
+               
+                       $list['blogdesc'] = $data['bdesc'];
+                       
+                       $list['blogurl'] = $data['burl'];
+                       
+                       if ($bnametype=='shortname') {
+                               $list['blogname'] = $data['bshortname'];
+                       }
+                       else { // all other cases
+                               $list['blogname'] = $data['bname'];
+                       }
+                       
+                       $manager->notify(
+                               'PreBlogListItem',
+                               array(
+                                       'listitem' => &$list
+                               )
+                       );
+                       
+                       echo TEMPLATE::fill((isset($template['BLOGLIST_LISTITEM']) ? $template['BLOGLIST_LISTITEM'] : null), $list);
+                       
+               }
+               
+               mysql_free_result($res);
+               
+               echo TEMPLATE::fill((isset($template['BLOGLIST_FOOTER']) ? $template['BLOGLIST_FOOTER'] : null),
+                                                       array(
+                                                               'sitename' => $CONF['SiteName'],
+                                                               'siteurl' => $CONF['IndexURL']
+                                                       ));
+
+       }
+
+       /**
+         * Blogsettings functions
+         */
+
+       function readSettings() {
+               $query =  'SELECT *'
+                          . ' FROM '.sql_table('blog')
+                          . ' WHERE bnumber=' . $this->blogid;
+               $res = sql_query($query);
+
+               $this->isValid = (mysql_num_rows($res) > 0);
+               if (!$this->isValid)
+                       return;
+
+               $this->settings = mysql_fetch_assoc($res);
+       }
+
+       function writeSettings() {
+
+               // (can't use floatval since not available prior to PHP 4.2)
+               $offset = $this->getTimeOffset();
+               if (!is_float($offset))
+                       $offset = intval($offset);
+
+               $query =  'UPDATE '.sql_table('blog')
+                          . " SET bname='" . addslashes($this->getName()) . "',"
+                          . "     bshortname='". addslashes($this->getShortName()) . "',"
+                          . "     bcomments=". intval($this->commentsEnabled()) . ","
+                          . "     bmaxcomments=" . intval($this->getMaxComments()) . ","
+                          . "     btimeoffset=" . $offset . ","
+                          . "     bpublic=" . intval($this->isPublic()) . ","
+                          . "     breqemail=" . intval($this->emailRequired()) . ","
+                          . "     bsendping=" . intval($this->sendPing()) . ","
+                          . "     bconvertbreaks=" . intval($this->convertBreaks()) . ","
+                          . "     ballowpast=" . intval($this->allowPastPosting()) . ","
+                          . "     bnotify='" . addslashes($this->getNotifyAddress()) . "',"
+                          . "     bnotifytype=" . intval($this->getNotifyType()) . ","
+                          . "     burl='" . addslashes($this->getURL()) . "',"
+                          . "     bupdate='" . addslashes($this->getUpdateFile()) . "',"
+                          . "     bdesc='" . addslashes($this->getDescription()) . "',"
+                          . "     bdefcat=" . intval($this->getDefaultCategory()) . ","
+                          . "     bdefskin=" . intval($this->getDefaultSkin()) . ","
+                          . "     bincludesearch=" . intval($this->getSearchable())
+                          . " WHERE bnumber=" . intval($this->getID());
+               sql_query($query);
+
+       }
+
+
+
+       // update update file if requested
+       function updateUpdatefile() {
+                if ($this->getUpdateFile()) {
+                       $f_update = fopen($this->getUpdateFile(),'w');
+                       fputs($f_update,$this->getCorrectTime());
+                       fclose($f_update);
+                }
+
+       }
+
+       function isValidCategory($catid) {
+               $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog=' . $this->getID() . ' and catid=' . intval($catid);
+               $res = sql_query($query);
+               return (mysql_num_rows($res) != 0);
+       }
+
+       function getCategoryName($catid) {
+               $res = sql_query('SELECT cname FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and catid=' . intval($catid));
+               $o = mysql_fetch_object($res);
+               return $o->cname;
+       }
+
+       function getCategoryDesc($catid) {
+               $res = sql_query('SELECT cdesc FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and catid=' . intval($catid));
+               $o = mysql_fetch_object($res);
+               return $o->cdesc;
+       }
+
+       function getCategoryIdFromName($name) {
+               $res = sql_query('SELECT catid FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and cname="' . addslashes($name) . '"');
+               if (mysql_num_rows($res) > 0) {
+                       $o = mysql_fetch_object($res);
+                       return $o->catid;
+               } else {
+                       return $this->getDefaultCategory();
+               }
+       }
+
+       function sendPing() {
+               return $this->getSetting('bsendping');
+       }
+
+       function setPingUserland($val) {
+               $this->setSetting('bsendping',$val);
+       }
+
+       function convertBreaks() {
+               return $this->getSetting('bconvertbreaks');
+       }
+
+       function insertJavaScriptInfo($authorid = '') {
+               global $member, $CONF;
+
+               if ($authorid == '')
+                       $authorid = $member->getID();
+
+               ?>
+               <script type="text/javascript">
+                       setConvertBreaks(<?php echo  $this->convertBreaks() ? 'true' : 'false' ?>);
+                       setMediaUrl("<?php echo $CONF['MediaURL']?>");
+                       setAuthorId(<?php echo $authorid?>);
+               </script><?php  }
+
+       function setConvertBreaks($val) {
+               $this->setSetting('bconvertbreaks',$val);
+       }
+       function setAllowPastPosting($val) {
+               $this->setSetting('ballowpast',$val);
+       }
+       function allowPastPosting() {
+               return $this->getSetting('ballowpast');
+       }
+
+       function getCorrectTime($t=0) {
+               if ($t == 0) $t = time();
+               return ($t + 3600 * $this->getTimeOffset());
+       }
+
+       function getName() {
+               return $this->getSetting('bname');
+       }
+
+       function getShortName() {
+               return $this->getSetting('bshortname');
+       }
+
+       function getMaxComments() {
+               return $this->getSetting('bmaxcomments');
+       }
+
+       function getNotifyAddress() {
+               return $this->getSetting('bnotify');
+       }
+
+       function getNotifyType() {
+               return $this->getSetting('bnotifytype');
+       }
+
+       function notifyOnComment() {
+               $n = $this->getNotifyType();
+               return (($n != 0) && (($n % 3) == 0));
+       }
+
+       function notifyOnVote() {
+               $n = $this->getNotifyType();
+               return (($n != 0) && (($n % 5) == 0));
+       }
+
+       function notifyOnNewItem() {
+               $n = $this->getNotifyType();
+               return (($n != 0) && (($n % 7) == 0));
+       }
+
+       function setNotifyType($val) {
+               $this->setSetting('bnotifytype',$val);
+       }
+
+
+       function getTimeOffset() {
+               return $this->getSetting('btimeoffset');
+       }
+
+       function commentsEnabled() {
+               return $this->getSetting('bcomments');
+       }
+
+       function getURL() {
+               return $this->getSetting('burl');
+       }
+
+       function getDefaultSkin() {
+               return $this->getSetting('bdefskin');
+       }
+
+       function getUpdateFile() {
+               return $this->getSetting('bupdate');
+       }
+
+       function getDescription() {
+               return $this->getSetting('bdesc');
+       }
+
+       function isPublic() {
+               return $this->getSetting('bpublic');
+       }
+
+       function emailRequired() {
+               return $this->getSetting('breqemail');
+       }
+
+       function getSearchable() {
+               return $this->getSetting('bincludesearch');
+       }
+
+       function getDefaultCategory() {
+               return $this->getSetting('bdefcat');
+       }
+
+       function setPublic($val) {
+               $this->setSetting('bpublic',$val);
+       }
+
+       function setSearchable($val) {
+               $this->setSetting('bincludesearch',$val);
+       }
+
+       function setDescription($val) {
+               $this->setSetting('bdesc',$val);
+       }
+
+       function setUpdateFile($val) {
+               $this->setSetting('bupdate',$val);
+       }
+
+       function setDefaultSkin($val) {
+               $this->setSetting('bdefskin',$val);
+       }
+
+       function setURL($val) {
+               $this->setSetting('burl',$val);
+       }
+
+       function setName($val) {
+               $this->setSetting('bname',$val);
+       }
+
+       function setShortName($val) {
+               $this->setSetting('bshortname',$val);
+       }
+
+       function setCommentsEnabled($val) {
+               $this->setSetting('bcomments',$val);
+       }
+
+       function setMaxComments($val) {
+               $this->setSetting('bmaxcomments',$val);
+       }
+
+       function setNotifyAddress($val) {
+               $this->setSetting('bnotify',$val);
+       }
+
+       function setEmailRequired($val) {
+               $this->setSetting('breqemail',$val);
+       }
+
+       function setTimeOffset($val) {
+               // check validity of value
+               // 1. replace , by . (common mistake)
+               $val = str_replace(',','.',$val);
+               // 2. cast to float or int
+               if (is_numeric($val) && strstr($val,'.5')) {
+                       $val = (float) $val;
+               } else {
+                       $val = intval($val);
+               }
+
+               $this->setSetting('btimeoffset',$val);
+       }
+
+       function setDefaultCategory($val) {
+               $this->setSetting('bdefcat',$val);
+       }
+
+       function getSetting($key) {
+               return $this->settings[$key];
+       }
+
+       function setSetting($key,$value) {
+               $this->settings[$key] = $value;
+       }
+
+
+       // tries to add a member to the team. Returns false if the member was already on
+       // the team
+       function addTeamMember($memberid, $admin) {
+               global $manager;
+
+               $memberid = intval($memberid);
+               $admin = intval($admin);
+
+               // check if member is already a member
+               $tmem = MEMBER::createFromID($memberid);
+
+               if ($tmem->isTeamMember($this->getID()))
+                       return 0;
+
+               $manager->notify(
+                       'PreAddTeamMember',
+                       array(
+                               'blog' => &$this,
+                               'member' => &$tmem,
+                               'admin' => &$admin
+                       )
+               );
+
+               // add to team
+               $query = 'INSERT INTO '.sql_table('team').' (TMEMBER, TBLOG, TADMIN) '
+                          . 'VALUES (' . $memberid .', '.$this->getID().', "'.$admin.'")';
+               sql_query($query);
+
+               $manager->notify(
+                       'PostAddTeamMember',
+                       array(
+                               'blog' => &$this,
+                               'member' => &$tmem,
+                               'admin' => $admin
+                       )
+
+               );
+
+               $logMsg = sprintf(_TEAM_ADD_NEWTEAMMEMBER, $tmem->getDisplayName(), $memberid, $this->getName());
+               ACTIONLOG::add(INFO, $logMsg);
+
+               return 1;
+       }
+
+       function getID() {
+               return intVal($this->blogid);
+       }
+
+       // returns true if there is a blog with the given shortname (static)
+       function exists($name) {
+               $r = sql_query('select * FROM '.sql_table('blog').' WHERE bshortname="'.addslashes($name).'"');
+               return (mysql_num_rows($r) != 0);
+       }
+
+       // returns true if there is a blog with the given ID (static)
+       function existsID($id) {
+               $r = sql_query('select * FROM '.sql_table('blog').' WHERE bnumber='.intval($id));
+               return (mysql_num_rows($r) != 0);
+       }
+
+        // flag there is a future post pending
+        function setFuturePost() {
+               $query =  'UPDATE '.sql_table('blog')
+                          . " SET bfuturepost='1' WHERE bnumber=" . $this->getID();
+               sql_query($query);
+        }
+
+       // clear there is a future post pending
+       function clearFuturePost() {
+               $query =  'UPDATE '.sql_table('blog')
+                          . " SET bfuturepost='0' WHERE bnumber=" . $this->getID();
+               sql_query($query);
+       }
+
+       // check if we should throw justPosted event
+       function checkJustPosted() {
+               global $manager;
+
+               if ($this->settings['bfuturepost'] == 1) {
+                       $blogid = $this->getID();
+                       $result = sql_query("SELECT * FROM " . sql_table('item')
+                                 . " WHERE iposted=0 AND iblog=" . $blogid . " AND itime<NOW()");
+                       if (mysql_num_rows($result) > 0) {
+                               // This $pinged is allow a plugin to tell other hook to the event that a ping is sent already
+                               // Note that the plugins's calling order is subject to thri order in the plugin list
+                               $pinged = false;
+                               $manager->notify(
+                                               'JustPosted',
+                                               array('blogid' => $blogid,
+                                               'pinged' => &$pinged
+                                               )
+                               );
+
+                               // clear all expired future posts
+                               sql_query("UPDATE " . sql_table('item') . " SET iposted='1' WHERE iblog=" . $blogid . " AND itime<NOW()");
+
+                               // check to see any pending future post, clear the flag is none 
+                               $result = sql_query("SELECT * FROM " . sql_table('item') 
+                                         . " WHERE iposted=0 AND iblog=" . $blogid);
+                               if (mysql_num_rows($result) == 0) {
+                                       $this->clearFuturePost();
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * Shows the given list of items for this blog
+        *
+        * @param $itemarray
+        *              array of item numbers to be displayed
+        * @param $template
+        *              String representing the template _NAME_ (!)      
+        * @param $highlight
+        *              contains a query that should be highlighted
+        * @param $comments
+        *              1=show comments 0=don't show comments
+        * @param $dateheads
+        *              1=show dateheads 0=don't show dateheads
+        * @returns int
+        *              amount of items shown
+        */
+       function readLogFromList($itemarray, $template, $highlight = '', $comments = 1, $dateheads = 1) {
+
+               $query = $this->getSqlItemList($itemarray);
+
+               return $this->showUsingQuery($template, $query, $highlight, $comments, $dateheads);
+       }
+       
+       /**
+        * Returns the SQL query used to fill out templates for a list of items
+        *
+        * @param $itemarray
+        *              an array holding the item numbers of the items to be displayed
+        * @returns
+        *              either a full SQL query, or an empty string
+        * @note
+        *              No LIMIT clause is added. (caller should add this if multiple pages are requested)
+        */
+       function getSqlItemList($itemarray)
+       {
+               if (!is_array($itemarray)) return '';
+               $items = array();
+               foreach ($itemarray as $value) {
+                       if (intval($value)) $items[] = intval($value);
+               }
+               if (!count($items)) return '';
+               //$itemlist = implode(',',$items);
+               $i = count($items);
+               $query = '';
+               foreach ($items as $value) {
+                       $query .= '('
+                                       .   'SELECT'
+                                       .   ' i.inumber as itemid,'
+                                       .   ' i.ititle as title,'
+                                       .   ' i.ibody as body,'
+                                       .   ' m.mname as author,'
+                                       .   ' m.mrealname as authorname,'
+                                       .   ' i.itime,'
+                                       .   ' i.imore as more,'
+                                       .   ' m.mnumber as authorid,'
+                                       .   ' m.memail as authormail,'
+                                       .   ' m.murl as authorurl,'
+                                       .   ' c.cname as category,'
+                                       .   ' i.icat as catid,'
+                                       .   ' i.iclosed as closed';
+                       
+                       $query .= ' FROM '
+                                       . sql_table('item') . ' as i, '
+                                       . sql_table('member') . ' as m, '
+                                       . sql_table('category').' as c'
+                                   . ' WHERE'
+                                       .     ' i.iblog   = ' . $this->blogid
+                                   . ' and i.iauthor = m.mnumber'
+                                   . ' and i.icat    = c.catid'
+                                   . ' and i.idraft  = 0'      // exclude drafts
+                                               // don't show future items
+                                   . ' and i.itime  <= ' . mysqldate($this->getCorrectTime());
+
+                       //$query .= ' and i.inumber IN ('.$itemlist.')';
+                       $query .= ' and i.inumber = '.intval($value);
+                       $query .= ')';
+                       $i--;
+                       if ($i) $query .= ' UNION ';
+               }
+               
+               return $query;
+       }
+
+}
+
 ?>
\ No newline at end of file
index d121ff2..d9ef2f9 100755 (executable)
@@ -839,6 +839,8 @@ function selector() {
 \r
                if ($b->isValidCategory($catid) ) {\r
                        $catextra = ' and icat=' . $catid;\r
+               } else {\r
+                       $catextra = '';\r
                }\r
 \r
                // get previous itemid and title\r
@@ -2055,7 +2057,7 @@ function getBookmarklet($blogid) {
        $document = 'document';\r
        $bookmarkletline = "javascript:Q='';x=".$document.";y=window;if(x.selection){Q=x.selection.createRange().text;}else if(y.getSelection){Q=y.getSelection();}else if(x.getSelection){Q=x.getSelection();}wingm=window.open('";\r
        $bookmarkletline .= $CONF['AdminURL'] . "bookmarklet.php?blogid=$blogid";\r
-       $bookmarkletline .="&logtext='+escape(Q)+'&loglink='+escape(x.location.href)+'&loglinktitle='+escape(x.title),'nucleusbm','status=no,toolbar=no,scrollbars=no,width=600,height=550,left=10,top=10,status=yes,resizable=yes');wingm.focus();";\r
+       $bookmarkletline .="&logtext='+escape(Q)+'&loglink='+escape(x.location.href)+'&loglinktitle='+escape(x.title),'nucleusbm','toolbar=no,scrollbars=no,width=600,height=550,left=10,top=10,status=no,resizable=yes');wingm.focus();";\r
 \r
        return $bookmarkletline;\r
 }\r
index f879f60..74781cc 100644 (file)
@@ -366,7 +366,8 @@ function listplug_table_itemlist($template, $type) {
                        // evaluate amount of comments for the item
                        $camount = $COMMENTS->amountComments();
                        if ($camount>0) {
-                               echo    "<br /><a href='index.php?action=itemcommentlist&amp;itemid=$current->inumber'>".sprintf(_LIST_ITEM_COMMENTS, $COMMENTS->amountComments())."</a>";
+                               echo "<br /><a href='index.php?action=itemcommentlist&amp;itemid=$current->inumber'>";
+                               echo "( " . sprintf(_LIST_ITEM_COMMENTS, $COMMENTS->amountComments())." )</a>";
                        }
                        else {
                                echo "<br />"._LIST_ITEM_NOCONTENT;