• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの


Commit MetaInfo

Revision6b66a0911586569a152b14bfb1c06df665e6af82 (tree)
Time2006-09-29 17:18:42
Authorkimitake <kimitake@1ca2...>
Commiterkimitake

Log Message

fixing security issue.

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

Change Summary

Incremental Difference

--- /dev/null
+++ b/trunk/NP_MultiBlogs/NP_MultiBlogs.php
@@ -0,0 +1,1027 @@
1+<?php
2+/*
3+ * Nucleus MultiBlogs plugin
4+ * Copyright (C) 2004-2006 Jun
5+ *
6+ * This program is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU General Public License
8+ * as published by the Free Software Foundation; either version 2
9+ * of the License, or (at your option) any later version.
10+ * (see nucleus/documentation/index.html#license for more info)
11+ *
12+ * @license http://nucleuscms.org/license.txt GNU General Public License
13+ */
14+/*
15+ * Changes:
16+ * v2.622 Jun - security fix
17+ * v3.00 kimitake - security fix
18+ */
19+
20+if(!function_exists('sql_table')) {
21+ function sql_table($name) { return 'nucleus_'.$name; }
22+}
23+
24+class NP_MultiBlogs extends NucleusPlugin {
25+
26+ function getName() { return 'MultiBlogs'; }
27+ function getAuthor() { return 'kimitake'; }
28+ function getURL() { return 'http://japan.nucleuscms.org/bb/viewtopic.php?t=515'; }
29+ function getVersion() { return '3.00'; }
30+
31+ function getDescription() { return 'It can replace &lt;%blog%&gt;, '.
32+ '&lt;%item%&gt;, or &lt;%searchresults%&gt;. It is possible to link '.
33+ 'to other pages. You can specify blogs or categories to show. You can '.
34+ 'sort items by date, title(ascending or descending), or at random.'; }
35+
36+ function supportsFeature($what) {
37+ switch($what) {
38+ case 'SqlTablePrefix':
39+ return 1;
40+ default:
41+ return 0;
42+ }
43+ }
44+
45+ function install() {
46+ $this->createOption('blog_except',
47+ 'BlogID to except. (example) 1/4','text','');
48+ $this->createOption('item_except',
49+ 'ItemID to except for NP_View. (example) 3/15/120','text','');
50+ $this->createOption('group_num',
51+ 'Group mode: Do you display the number of the items?','yesno','yes');
52+ $this->createOption('group_link',
53+ 'Group mode: Do you display the title link?','yesno','no');
54+ $this->createOption('group_more',
55+ "Group mode: String to display 'more' link.",'text','more');
56+ $this->createOption('group_other',
57+ "Group mode: Do you display 'Other items'?",'text','');
58+ $this->createOption('group_tagt',
59+ 'Group mode: CSS title tag. (*ex1. div)(*ex2. ol)','text','div');
60+ $this->createOption('group_tag',
61+ 'Group mode: CSS body tag. (*ex1. div)(*ex2. ol)','text','div');
62+ $this->createOption('category_except',
63+ 'Group mode: CategoryID to except. (example) 2/3','text','');
64+ $this->createOption('subcategory_except',
65+ 'Group mode: SubategoryID to except. (example) 1/3','text','');
66+ }
67+
68+ function unInstall() {
69+ $this->deleteOption('blog_except');
70+ $this->deleteOption('item_except');
71+ $this->deleteOption('group_num');
72+ $this->deleteOption('group_link');
73+ $this->deleteOption('group_more');
74+ $this->deleteOption('group_other');
75+ $this->deleteOption('group_tagt');
76+ $this->deleteOption('group_tag');
77+ $this->deleteOption('category_except');
78+ $this->deleteOption('subcategory_except');
79+ }
80+
81+ function doTemplateCommentsVar(&$item, &$comment, $mode = '') {
82+ if (!$mode || $mode=='i') {
83+ $this->doTemplateVar(&$item, $mode);
84+ }
85+ }
86+
87+ function doTemplateVar(&$item, $mode = '') {
88+
89+ global $CONF, $manager;
90+
91+ $itemid = intval($item->itemid);
92+
93+ // support MultipleCategories plugin
94+ $mact = $manager->pluginInstalled('NP_MultipleCategories');
95+
96+ $q0 = 'SELECT iblog, icat ';
97+ if ($mact) {
98+ $q0 .= ',subcategories ,categories ';
99+ }
100+ $q0 .= 'FROM '.sql_table('blog').', '.sql_table('category')
101+ .', '.sql_table('item');
102+ if ($mact) {
103+ $q0 .= ' left join '.sql_table('plug_multiple_categories')
104+ .' on item_id = inumber';
105+ }
106+ $q0 .= ' WHERE bnumber = iblog and catid = icat and inumber = '.$itemid;
107+
108+ $q1 = mysql_query($q0);
109+ while($row = mysql_fetch_assoc($q1)) {
110+ $blink = quickQuery('SELECT burl as result FROM '.sql_table('blog')
111+ .' WHERE bnumber = '.$row['iblog']);
112+ $clink = createBlogidLink($row['iblog'], array('catid' => $row['icat']));
113+
114+ if ($mact && $row['subcategories'] && $row['categories']==$row['icat']) {
115+ $scat = explode(',' ,$row['subcategories']);
116+ $ilink = createItemLink($itemid, array('subcatid' => $scat[0]));
117+ } else {
118+ $ilink = createItemLink($itemid, array('catid' => $row['icat']));
119+ }
120+ }
121+ if (!$mode || $mode=='i') {
122+ echo $blink.$ilink;
123+ }
124+ if ($mode=='b') {
125+ echo $blink;
126+ }
127+ if ($mode=='c') {
128+ echo $clink;
129+ }
130+ }
131+
132+ function doSkinVar($skinType, $template = 'grey/short', $items = 10,
133+ $bmode = '', $bpage = '', $msort = '', $mcat = '', $mform = '',
134+ $templates = '') {
135+
136+ global $blog, $blogid, $catid, $archive, $itemid, $member;
137+ global $memberid, $CONF, $manager, $archivelist;
138+
139+ $blogid = intval($blogid);
140+ $catid = intval($catid);
141+ $itemid = intval($itemid);
142+ $memberid = intval($memberid);
143+ $meid = intval($member->getID());
144+ $temple = explode('/', $template, 4);
145+
146+ // basic query
147+ $q1 = ' i.inumber as itemid, i.iblog as blog, i.ibody as body, '
148+ . 'm.mname as author, m.mrealname as authorname, '
149+ . 'UNIX_TIMESTAMP(i.itime) as timestamp, i.itime, i.imore as more, '
150+ . 'm.mnumber as authorid, c.cname as category, i.icat as catid, '
151+ . 'i.iclosed as closed, m.memail as authormail, m.murl as authorurl,';
152+ $q2 = ' i.ititle as title';
153+ $q3 = ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '
154+ . sql_table('category').' as c';
155+ $q4 = ' WHERE i.iauthor = m.mnumber and i.icat = c.catid and i.idraft = 0';
156+
157+ if (substr($templates, 0, 6) != 'future') {
158+ $q4 .= ' and i.itime <= '.mysqldate($blog -> getCorrectTime());
159+ }
160+
161+ // MultiBlogs
162+ switch(TRUE) {
163+ case (!($bmode=='fix' || $bmode=='fixall' || $temple[0]=='multitag')):
164+ $items = explode('/', $items, 4);
165+ $mform = explode('/', $mform, 4);
166+
167+ $uri1 = "";
168+ switch (TRUE) {
169+ case ($_GET['query']):
170+ $uri1 = $_GET['query'];
171+ break;
172+ case ($_GET['que']):
173+ $uri1 = $_GET['que'];
174+ break;
175+ }
176+ if (get_magic_quotes_gpc()) {
177+ $uri1 = stripslashes($uri1);
178+ }
179+ $uri1 = addslashes($uri1);
180+
181+ // for NP_StickyIT (* Thanks for Fujisaki, 2004.08.09)
182+ if ($manager->pluginInstalled('NP_StickyIT')) {
183+ $q5 = ' left join '.sql_table('plug_stickyit').' on snumber = i.inumber';
184+ $q6 = ' and snumber is null';
185+ }
186+
187+ // for NP_View
188+ $sort = intval($_GET['sort']);
189+ if ($manager->pluginInstalled('NP_View') &&
190+ (($msort >= '11' && $msort <= '6') ||
191+ ($mform[0] && $sort >= 6 && $sort <= 11))) {
192+
193+ $vtime = date("Y-m-d H:i:s");
194+ sscanf($vtime, '%d-%d-%d', $y, $m, $d);
195+ $t0 = mktime(0, 0, 0, $m, $d, $y);
196+ $t0m = date("m", $t0);
197+ $vday = 'v.week'.strftime("%w", $t0);
198+ $vmonth = 'v.month'.$t0m;
199+
200+ switch (TRUE) {
201+ case($mform[0] && $sort == 8) :
202+ $q200 = ', '.$vday.' as vday';
203+ break;
204+ case($mform[0] && $sort == 9) :
205+ $q200 = ', v.week0+v.week1+v.week2+v.week3+'
206+ . 'v.week4+v.week5+v.week6 as vweek';
207+ break;
208+ case($mform[0] && $sort == 10) :
209+ $q200 = ', '.$vmonth.' as vmonth';
210+ break;
211+ case($mform[0] && $sort == 11) :
212+ $q200 = ', v.month01+v.month02+v.month03+'
213+ . 'v.month04+v.month05+v.month06+'
214+ . 'v.month07+v.month08+v.month09+'
215+ . 'v.month10+v.month11+v.month12 as vyear';
216+ break;
217+ }
218+ $q20 = ', '.sql_table('plugin_view').' as v';
219+ $q21 = ' and v.id = i.inumber';
220+ }
221+
222+ // for Comment
223+ if ($items[0] == 'c') {
224+ $q22 = ', '.sql_table('comment').' as co';
225+ $q23 = ' and co.citem = i.inumber';
226+ }
227+ // for NP_TrackBack
228+ if ($manager->pluginInstalled('NP_TrackBack') && $items[0] == 'tb') {
229+ $q24 = ', '.sql_table('plugin_tb').' as tb';
230+ $q25 = ' and tb.tb_id = i.inumber';
231+ }
232+// for Search
233+ if ($items[0] == 's' || ($_GET['que'] && $mform[0])) {
234+ $q26 = ' left join '.sql_table('comment').' as cm on i.inumber = cm.citem';
235+ if ($manager -> pluginInstalled('NP_TrackBack')) {
236+ $q26 .= ' left join '.sql_table('plugin_tb').' as t on i.inumber = t.tb_id';
237+ $s0 = array('i.ititle', '" or i.ibody', '" or i.imore', '" or m.mname', '" or cm.cbody', '" or cm.cuser', '" or t.title', '" or t.excerpt');
238+ }
239+ }
240+// for NP_MultipleCategories (* Thanks for Taka, 2005.01.20)
241+ $mact = $manager->pluginInstalled('NP_MultipleCategories');
242+ switch(TRUE) {
243+ case(!$mact) :
244+ $q31 = ($mcat[0] == 'blog' || $items[0] == 'item' || !$catid) ? 'i.iblog = '.$blogid : 'i.icat = '.$catid;
245+ break;
246+ default:
247+ global $subcatid;
248+ $subcatid = intval($subcatid);
249+ $mplugin =& $manager -> getPlugin('NP_MultipleCategories');
250+ $q30 = ' left join '.sql_table('plug_multiple_categories').' as p on p.item_id = i.inumber';
251+ $mcat = explode('/', $mcat, 2);
252+ switch(TRUE) {
253+ case (!($mcat[0] == 'scat' || $mcat[0] == 'blog' || $items[0] == 'item' || !$catid)):
254+ $q31 = '(p.categories REGEXP "(^|,)'.$catid.'(,|$)" or ';
255+ $q31 .= ($mcat[0] == 'blog') ? 'i.iblog = '.$blogid.')' : 'i.icat = '.$catid.')';
256+ break;
257+ case ($mcat[0] == 'blog' || $items[0] == 'item' || !$catid):
258+ $qq = sql_query('SELECT DISTINCT icat FROM '.sql_table('item').' WHERE iblog = '.$blogid);
259+ $q31 = '(';
260+ while($row = mysql_fetch_assoc($qq)) {
261+ $q31 .= 'p.categories REGEXP "(^|,)'.$row['icat'].'(,|$)" or ';
262+ }
263+ $q31 .= 'i.iblog = '.$blogid.')';
264+ break;
265+ default:
266+ $q30 .= ' left join '.sql_table('plug_multiple_categories_sub').' as ps on ps.catid = i.icat';
267+ if ($subcatid) {
268+ $scat = quickQuery('SELECT scatid as result FROM '.sql_table('plug_multiple_categories_sub').', '.sql_table('item').' WHERE icat = catid and inumber = '.$itemid.' LIMIT 1');
269+ }
270+
271+ $mcats = explode('/', $mcat[1]);
272+ switch(TRUE) {
273+ case($mcat[1]) :
274+ foreach($mcats as $mitems){
275+ $q31 .= ' p.subcategories REGEXP "(^|,)'.$mitems.'(,|$)" or';
276+ }
277+ $q31 = substr($q31 ,0, -3);
278+ $q31 = '('.$q31.')';
279+ break;
280+ case($scat) :
281+ $q31 = ' p.subcategories > 0 and ps.scatid = '.$scat;
282+ break;
283+ default:
284+ $q31 = ' c.catid = '.$catid;
285+ }
286+ }
287+ switch(TRUE) {
288+ case($subcatid) :
289+ $sname = quickQuery('SELECT sname as result FROM '.sql_table('plug_multiple_categories_sub').' WHERE scatid = '.$subcatid);
290+ $subcatlink = createBlogidLink($blogid, array('subcatid' => $subcatid));
291+ if (method_exists($mplugin, "getRequestName")) {
292+ $q31 .= ' and (p.subcategories REGEXP "(^|,)'.$subcatid.'(,|$)"';
293+ }
294+ $q31 .= ($mcat[0] == 'blog') ? ' or i.iblog = '.$blogid.')' : ')';
295+ $q32 = ($itemid) ? '<a href="'.$subcatlink.'">'.$sname."</a> &raquo; " : $sname." &raquo; ";
296+ }
297+ $mcat = implode('/', $mcat);
298+ }
299+// for NP_ItemFlag
300+ if ($manager->pluginInstalled('NP_ItemFlag') && $mform[0]) {
301+ if ($_GET['rank'] || $_GET['sort'] == 2 || $_GET['sort'] == 5 || $msort == '9' || $msort == '10') {
302+ $q33 = ' ,ifg.iflagflag';
303+ $q34 = ' left join '.sql_table('plugin_itemflag').' as ifg on ifg.iflagid = i.inumber';
304+ }
305+ }
306+// blog mode
307+ $item =& $manager -> getItem($itemid, 0, 0);
308+ $q0 = ($items[0] == 'c' || $items[0] == 'tb') ? 'SELECT ' : 'SELECT DISTINCT ';
309+ $query = $q0.$q1.$q2.$q200.$q33.$q3.$q5.$q26.$q30.$q20.$q22.$q24.', '.sql_table('blog').' as b'.$q34.$q4.$q6.$q21.$q23.$q25;
310+ $q7 = ' and b.bnumber = c.cblog';
311+ $ihide = $this -> getOption('item_except');
312+ $bhide = $this -> getOption('blog_except');
313+ $ihide = explode('/', $ihide);
314+ $bhide = explode('/', $bhide);
315+ if ($items[0] != 'item') $bpage = explode('/', $bpage);
316+ $uri = sprintf('%s%s%s', 'http://', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
317+ $s1 = ($s0) ? $s0 : array('i.ititle', '" or i.ibody', '" or i.imore', '" or m.mname', '" or cm.cbody', '" or cm.cuser');
318+// rank
319+ $rank = intval($_GET['rank']);
320+ if ($q33 && $_GET['rank'] != 'a' && $_GET['rank']) $query .= ' and ifg.iflagflag = '.$rank;
321+// search
322+ $post = urldecode($uri1);
323+ if($items[0] == 's' || ($_GET['que'] && $mform[0])) $query .= $this->SearchQuery($post, $s1, $s0);
324+// switch form
325+ switch(TRUE) {
326+ case($mform[0] || $template == 'switch') :
327+ $p_sform = '<form method="get" action="';
328+ $p_sform .= ($template == 'switch' || $mform[0] == 'd') ? createBlogidLink($blogid) : $_SERVER['PHP_SELF'];
329+ $p_sform .= '">';
330+ if ($CONF['URLMode'] != 'pathinfo' && $mform[1]) {
331+ switch(TRUE) {
332+ case ($catid):
333+ $p_sform .= '<input name="catid" value="'.$catid.'" type="hidden">';
334+ break;
335+ case ($blogid):
336+ $p_sform .= '<input name="blogid" value="'.$blogid.'" type="hidden">';
337+ break;
338+ case ($archivelist):
339+ $p_sform .= '<input name="archivelist" value="'.$blogid.'" type="hidden">';
340+ break;
341+ case ($archive):
342+ $p_sform .= '<input name="archive" value="'.$archive.'" type="hidden">';
343+ }
344+ }
345+ $p_time0 = array(
346+ '' => 'Today',
347+ 1 => '1day',
348+ 3 => '3days',
349+ 7 => '1week',
350+ 30 => '1month',
351+ 365 => '1year',
352+ );
353+ $p_time = array(
354+ 9999 => 'All period',
355+ 1 => 'In 1day',
356+ 3 => 'In 3days',
357+ 7 => 'In 1week',
358+ 30 => 'In 1month',
359+ 365 => 'In 1year',
360+ );
361+ $p_sort = array(
362+ 99 => 'New',
363+ 1 => 'Old',
364+ 4 => 'A-&gt;Z',
365+ 3 => 'Z-&gt;A',
366+ );
367+/* add $p_sort
368+ 2 => 'Update',
369+ 5 => 'Rank',
370+ 7 => 'ViewTime',
371+ 6 => 'MostView',
372+ 8 => 'MostView(day)',
373+ 9 => 'MostView(week)',
374+ 10 => 'MostView(month)',
375+ 11 => 'MostView(year)',
376+*/
377+ $p_view = array(
378+ 10 => '10 results',
379+ 20 => '20 results',
380+ 30 => '30 results',
381+ 40 => '40 results',
382+ 50 => '50 results',
383+ );
384+ $p_blog = array(
385+ 1 => 'Category',
386+ 2 => 'All page',
387+ );
388+ $p_rank = array(
389+ a => 'Rank',
390+ 1 => '*',
391+ 2 => '**',
392+ 3 => '***',
393+ 4 => '****',
394+ 5 => '*****',
395+ );
396+ switch(TRUE) {
397+ case (preg_match('/b/', $mform[1])):
398+ $b_sform = ' <select name="time0">';
399+ foreach($p_time0 as $p_s2 => $p_s3) {
400+ $p_flag = ($p_s2 == $_GET['time0']) ? ' selected="selected"' : '';
401+ if ($p_s2 == $_GET['time0'] && $_GET['sbmt']) $p_sf = '['.$p_s3.']';
402+ $b_sform .= '<option value="'.$p_s2.'"'.$p_flag.'>'.$p_s3.'</option>';
403+ }
404+ case (preg_match('/c/', $mform[1])):
405+ $c_sform = ' <select name="time">';
406+ foreach($p_time as $p_s2 => $p_s3) {
407+ $p_flag = ($p_s2 == $_GET['time']) ? ' selected="selected"' : '';
408+ if ($p_s2 == $_GET['time'] && $_GET['sbmt']) $p_sf .= '['.$p_s3.']';
409+ $c_sform .= '<option value="'.$p_s2.'"'.$p_flag.'>'.$p_s3.'</option>';
410+ }
411+ case (preg_match('/d/', $mform[1])):
412+ $d_sform = ' <select name="sort">';
413+ foreach($p_sort as $p_s2 => $p_s3) {
414+ $p_flag = ($p_s2 == $_GET['sort']) ? ' selected="selected"' : '';
415+ if ($p_s2 == $_GET['sort'] && $_GET['sbmt']) $p_sf .= '['.$p_s3.' sort]';
416+ $d_sform .= '<option value="'.$p_s2.'"'.$p_flag.'>'.$p_s3.'</option>';
417+ }
418+ case (preg_match('/e/', $mform[1])):
419+ $e_sform = ' <select name="view">';
420+ foreach($p_view as $p_s2 => $p_s3) {
421+ $p_flag = ($p_s2 == $_GET['view']) ? ' selected="selected"' : '';
422+ if ($p_s2 == $_GET['view'] && $_GET['sbmt']) $p_sf .= '['.$p_s3.']';
423+ $e_sform .= '<option value="'.$p_s2.'"'.$p_flag.'>'.$p_s3.'</option>';
424+ }
425+ case (preg_match('/f/', $mform[1])):
426+ $f_sform = ' <select name="blog">';
427+ foreach($p_blog as $p_s2 => $p_s3) {
428+ $p_flag = ($p_s2 == $_GET['blog']) ? ' selected="selected"' : '';
429+ if ($p_s2 == $_GET['blog'] && $_GET['sbmt']) $p_sf .= '['.$p_s3.']';
430+ $f_sform .= '<option value="'.$p_s2.'"'.$p_flag.'>'.$p_s3.'</option>';
431+ }
432+ case (preg_match('/g/', $mform[1])):
433+ $g_sform = ' <select name="rank">';
434+ foreach($p_rank as $p_s2 => $p_s3) {
435+ $p_flag = ($p_s2 == $_GET['rank']) ? ' selected="selected"' : '';
436+ if ($p_s2 == $_GET['rank'] && $_GET['sbmt']) $p_sf .= '['.$p_s3.']';
437+ $g_sform .= '<option value="'.$p_s2.'"'.$p_flag.'>'.$p_s3.'</option>';
438+ }
439+ }
440+ list($plink, $mpage) = explode('?', $uri, 2);
441+// switch form sort
442+ switch(TRUE) {
443+ case (preg_match('/a/', $mform[1])):
444+ $p_sform .= ' <input type="text" name="que" size="12" maxlength="60" value="'.addslashes($_GET['que']).'" />';
445+ case (preg_match('/s/', $mform[1])):
446+ $p_sform .= ' <input type="submit" name="sbmt" value="Push" />';
447+ case (preg_match('/b/', $mform[1])):
448+ $p_sform .= $b_sform.'</select> -&gt;';
449+ case (preg_match('/c/', $mform[1])):
450+ $p_sform .= $c_sform.'</select>';
451+ case (preg_match('/d/', $mform[1])):
452+ $p_sform .= $d_sform.'</select>';
453+ case (preg_match('/e/', $mform[1])):
454+ $p_sform .= $e_sform.'</select>';
455+ case (preg_match('/f/', $mform[1])):
456+ $p_sform .= $f_sform.'</select>';
457+ case (preg_match('/g/', $mform[1])):
458+ $p_sform .= $g_sform.'</select>';
459+ case (preg_match('/r/', $mform[1])):
460+ if ($_GET['sbmt']) $p_sform .= ' [<a href="'.$plink.'">Reset</a>]';
461+ }
462+ $p_sform .= '</form>';
463+ if ($template == 'switch' && $mform[1]) {
464+ echo '<div class="switchform">'.$p_sform.'</div>';
465+ return;
466+ }
467+ }
468+// category
469+ $mcats = explode('/', $mcat, 2);
470+ switch(TRUE) {
471+ case($mcat && $items[0] != 'item') :
472+ $mcat = explode('/', $mcat);
473+ switch($mcat[0]) {
474+ case 'c':
475+ $q8 = ' or i.imore LIKE "%[-'.$catid.'-]%" )';
476+ break;
477+ case 'b':
478+ $q8 = ' or i.imore LIKE "%[-b'.$blogid.'-]%" )';
479+ break;
480+ case 'm':
481+ $query .= ' and BINARY i.imore LIKE "%[-'.$mcat[1].'-]%"';
482+ break;
483+ case 's':
484+ $s2 = quickQuery('SELECT ititle as result FROM '.sql_table('item').' WHERE inumber = '.$itemid);
485+ $s3 = explode(' ', $s2);
486+ $s4 = ' LIKE "%'.addslashes($s3[1]).'%';
487+ $query .= ($s3[1]) ? ' and ( '.$s1[0].$s4.$s1[1].$s4.$s1[2].$s4.'" )' : ' and i.inumber = '.$itemid;
488+ break;
489+ case 'mem':
490+ $query .= ($mcat[1]) ? ' and i.iauthor = '.$mcat[1] : ' and i.iauthor = '.$memberid;
491+ break;
492+ case 'mem2':
493+ $query .= ' and i.iauthor = '.$memid;
494+ break;
495+ case 'a':
496+ $query .= ' and c.catid = '.$item['catid'];
497+ break;
498+ case 'all':
499+ $mcat = explode('/', $mcats[1]);
500+ foreach($mcat as $mcats) $query .= ' and i.icat != '.$mcats;
501+ break;
502+ default:
503+ if($mcat[0] != 'blog' && $mcat[0] != 'archive' && $mcat[0] != 'scat') {
504+ $mcat = implode(', ', $mcat);
505+ $query .= ' and i.icat in ('.$mcat.')';
506+ }
507+ }
508+ }
509+// blog
510+ $bmodes = explode('/', $bmode, 2);
511+ if ($bmodes[0] == 'all' && $bmodes[1]) $bhide = explode('/', $bmodes[1]);
512+ switch(TRUE) {
513+ case ($bmode == 'all' || $bmodes[0] == 'all' || ($_GET['blog'] == '2' && $mform[0])):
514+ $query .= $q7;
515+ if ($bhide[0]) foreach($bhide as $hides) {
516+ $query .= ' and i.iblog != '.$hides;
517+ }
518+ break;
519+ case ($bmode == '' || $bmode == 0):
520+ switch(TRUE) {
521+ case ($mcat[0] == 'c' && $catid):
522+ $query .= $q7.' and ( i.icat = '.$catid.$q8;
523+ break;
524+ case ($mcat[0] == 'b' && $blogid):
525+ $query .= $q7.' and ( i.iblog = '.$blogid.$q8;
526+ break;
527+ default:
528+ $query .= $q7.' and '.$q31;
529+ }
530+ break;
531+ default:
532+ $bmode = str_replace('/', ', ', $bmode);
533+ $query .= ' and i.iblog in ('.$bmode.')';
534+ }
535+// archive
536+ switch(TRUE) {
537+ case ($_GET['time0'] && $mform[0]):
538+ $time0 = intval($_GET['time0']);
539+ $query .= ' and i.itime <= '.mysqldate($blog -> getCorrectTime() - 86400 * $time0);
540+ break;
541+ case ($_GET['time'] && $mform[0]):
542+ $time1 = intval($_GET['time']);
543+ $query .= ' and i.itime >= '.mysqldate($blog -> getCorrectTime() - 86400 * $time1);
544+ break;
545+ case ($archive && !($mcat[0] == 'archive' || $mcat[0] == 'blog')):
546+ sscanf($archive, '%d-%d-%d', $y , $m, $d);
547+ switch(TRUE) {
548+ case($d) :
549+ $time_s = mktime(0, 0, 0, $m, $d, $y);
550+ $time_e = mktime(0, 0, 0, $m, $d + 1, $y);
551+ break;
552+ case($m) :
553+ $time_s = mktime(0, 0, 0, $m, 1, $y);
554+ $time_e = mktime(0, 0, 0, $m + 1, 1, $y);
555+ break;
556+ default:
557+ $time_s = mktime(0, 0, 0, 1, 1, $y);
558+ $time_e = mktime(0, 0, 0, 12, 31, $y);
559+ }
560+ $query .= $q7.' and i.itime >= '.mysqldate($time_s)
561+ .' and i.itime < '.mysqldate($time_e);
562+ }
563+//group
564+ if (substr($templates, 0, 5) == 'group') $q101 = $query;
565+// item
566+ if ($ihide[0] && $result2 && ($msort == '5' || $msort == '6')) foreach($ihide as $ihides){
567+ $query .= ' and i.inumber != '.$ihides;
568+ }
569+ switch(TRUE) {
570+ case($items[0] != 'item' || $_GET['que']) :
571+// sort
572+ $que1 = ' ORDER BY ';
573+ switch(TRUE) {
574+ case ($_GET['sort'] == 1 && $mform[0]):
575+ $que1 .= 'i.itime ASC ';
576+ break;
577+ case ($_GET['sort'] == 2 && $mform[0]):
578+ $que1 .= 'ifg.iflagtime DESC, i.itime DESC ';
579+ break;
580+ case ($_GET['sort'] == 3 && $mform[0]):
581+ $que1 .= 'i.ititle DESC ';
582+ break;
583+ case ($_GET['sort'] == 4 && $mform[0]):
584+ $que1 .= 'i.ititle ASC ';
585+ break;
586+ case ($_GET['sort'] == 5 && $mform[0]):
587+ $que1 .= 'ifg.iflagflag DESC ';
588+ break;
589+ case ($_GET['sort'] == 6 && $mform[0]):
590+ $que1 .= 'v.view DESC ';
591+ break;
592+ case ($_GET['sort'] == 7 && $mform[0]):
593+ $que1 .= 'v.vtime DESC ';
594+ break;
595+ case ($_GET['sort'] == 8 && $mform[0]):
596+ $que1 .= 'vday DESC ';
597+ break;
598+ case ($_GET['sort'] == 9 && $mform[0]):
599+ $que1 .= 'vweek DESC ';
600+ break;
601+ case ($_GET['sort'] == 10 && $mform[0]):
602+ $que1 .= 'vmonth DESC ';
603+ break;
604+ case ($_GET['sort'] == 11 && $mform[0]):
605+ $que1 .= 'vyear DESC ';
606+ break;
607+ case ($_GET['sort'] == 99 && $mform[0]):
608+ $que1 .= 'i.itime DESC ';
609+ break;
610+ case ($msort == 1):
611+ $que1 .= 'i.itime ASC ';
612+ break;
613+ case ($msort == 2):
614+ $que1 .= 'RAND() ';
615+ break;
616+ case ($msort == 3):
617+ $que1 .= 'i.ititle DESC ';
618+ break;
619+ case ($msort == 4):
620+ $que1 .= 'i.ititle ASC ';
621+ break;
622+ case ($msort == 7):
623+ $que1 .= 'co.ctime DESC ';
624+ break;
625+ case ($result3 && $msort == 8):
626+ $que1 .= 'tb.timestamp DESC ';
627+ break;
628+ case ($q33 && $msort == 9):
629+ $que1 .= 'ifg.iflagflag DESC ';
630+ break;
631+ case ($q33 && $msort == 10):
632+ $que1 .= 'ifg.iflagtime DESC, i.itime DESC ';
633+ break;
634+ case ($result2 && $msort == 11):
635+ $que1 .= 'v.view DESC ';
636+ break;
637+ case ($result2 && $msort == 12):
638+ $que1 .= 'v.vtime DESC ';
639+ break;
640+ default:
641+ $que1 .= 'i.itime DESC ';
642+ }
643+ $query .= $que1;
644+// non pageswitch
645+ $bitem = mysql_num_rows(mysql_query($query));
646+ switch(TRUE) {
647+ case($items[0] == 's' || $items[0] == 'c' || $items[0] == 'tb') :
648+ $ite = $items[1];
649+ break;
650+ default:
651+ $ite = $items[0];
652+ if ($items[1] > 0) $ite0 = $items[1].', ';
653+ }
654+
655+ if ($_GET['sbmt'] && $mform[3]) $template = $mform[3];
656+ if ($_GET['sbmt'] && $mform[2]) $ite = $mform[2];
657+ if ($_GET['view'] && $mform[0]) $ite = $_GET['view'];
658+
659+ switch(TRUE) {
660+ case(($bpage[0] == '' || $bpage[0] == 0) && !$mform[0]) :
661+ $query .= 'LIMIT '.$ite0.$ite;
662+ break;
663+// pageswitch
664+ default:
665+ if ($bitem > $ite || $items[0] == 's' || ($mform[0] && $bitem && $_GET['sbmt'])) $psh = '<div class="pageswitch">';
666+ switch(TRUE) {
667+ case($bitem > $ite && $bpage[0]) :
668+ list($plink, $mpage) = explode('page=', $uri);
669+ $max = ($items[2] == 'b') ? ceil(($bitem - $items[1]) / $ite + 1) : ceil($bitem / $ite);
670+ $plink = htmlspecialchars($plink);
671+ switch(TRUE) {
672+ case(intval($mpage) > 0) :
673+ $mpages = (intval($mpage) - 1) * $max;
674+ break;
675+
676+ default:
677+ $mpage = 1;
678+ $uri = parse_url($plink);
679+ $plink .= ($uri['query']) ? '&' : '?';
680+ $plink = str_replace('&&', '&', $plink);
681+ }
682+
683+ switch(TRUE) {
684+ case($items[2] == 'b' && $mpages == 0) :
685+ $query .= 'LIMIT 0,'.$items[1];
686+ $max2 = $items[1];
687+ if ($items[3] && !$_GET['sbmt']) $template = $items[3];
688+ break;
689+
690+ default:
691+ $mpages = $mpage * $ite - $ite;
692+ if ($items[2] == 'b') $mpages = $mpages - $ite + $items[1];
693+ $query .= 'LIMIT '.$mpages.','.$ite;
694+ $max2 = ($max == $mpage) ? $bitem : $mpages + $ite;
695+ }
696+// pageswitch output
697+ $plk = '<a href="'.$plink.'page=';
698+ $psh .= ($mpage != 1) ? $plk.($mpage - 1).'">Prev</a>' : 'Prev';
699+ $psh .= ' [P.'.$mpage.'/'.$max.'] ';
700+ $psh .= ($mpage != $max) ? $plk.($mpage + 1).'">Next</a>' : 'Next';
701+ break;
702+ default:
703+ $max2 = $bitem;
704+ }
705+
706+ if ((($bitem > $ite || $items[0] == 's') && $bpage[0] == '2') || ($mform[0] && $bitem && $_GET['sbmt'])) {
707+ $psh .= ' [*';
708+ if (!($bitem > $ite && $bpage[0] == '2')) $psh .= 'Results ';
709+ if($items[0] == 's' || ($_GET['que'] && $mform[0])) $psh .= 'for "<strong>'.htmlspecialchars($post).'</strong>": ';
710+ if ($bitem) $psh .= 'No.'.($mpages + 1).'-'.$max2.' of '.$bitem;
711+ $psh .= '] ';
712+ }
713+
714+ if ($bitem > $ite && $bpage[0] == '2') {
715+ $psh .= ($mpage != 1) ? $plk.'1">First</a> / ' : 'First / ';
716+ $psh .= ($mpage != $max) ? $plk.$max.'">Last</a>' : 'Last';
717+ }
718+
719+ if ($bitem > $ite || $items[0] == 's' || ($mform[0] && $bitem && $_GET['sbmt'])) $psh .= '</div>';
720+ if (substr($templates, 0, 5) == 'group' && !$subcatid) $psh = '';
721+ }
722+ break;
723+
724+ default:
725+ if ($mcat == 'a') $query .= ' and c.catid = '.$item['catid'];
726+ $qnex = $query.' and i.itime > "'.$item['itime'].'" ORDER BY i.itime ASC LIMIT '.$items[1];
727+ if ($items[1] && $items[1] != 1) sql_query("CREATE TEMPORARY TABLE tnext as ".$qnex);
728+ $qnext = ($items[1] != 1) ? 'SELECT itemid, blog, body, author, authorname, timestamp, itime, more, authorid, category, catid, closed, authormail, authorurl, title FROM tnext ORDER BY itime DESC' : $query.' and i.itime > "'.$item['itime'].'" ORDER BY i.itime ASC LIMIT 1';
729+ $qprev = $query.' and i.itime < "'.$item['itime'].'" ORDER BY i.itime DESC LIMIT '.$items[1];
730+ $query .= ' and i.inumber = '.$itemid.' LIMIT 1';
731+ }
732+// Prev or Next
733+
734+ if ($items[0] == 'item' && $items[1] && !$_GET['que']) {
735+ $bp4 = explode('/', $bpage, 4);
736+ $ms4 = explode('/', $msort, 4);
737+ echo "<div class=\"linkswitch\">\n";
738+// echo "[Prev or Next items]<br />\n";
739+ switch(TRUE) {
740+ case(($items[3] == 'a' || $items[3] == 'd') && mysql_num_rows(mysql_query($qprev))) :
741+ echo "&laquo; Prev : ";
742+ switch(TRUE) {
743+ case($bp4[0] == 'multiblogs') :
744+ $this -> MultiTitle($bp4, $qprev);
745+ break;
746+ default :
747+ $blog -> showUsingQuery($bpage, $qprev, 1, 1, 1);
748+ }
749+ case(mysql_num_rows(mysql_query($qnext))) :
750+ if ($items[3] == 'a' || $items[3] == 'd') echo "&raquo; Next : ";
751+ switch(TRUE) {
752+ case($itemid && $bp4[0] == 'multiblogs') :
753+ $this -> MultiTitle($bp4, $qnext);
754+ break;
755+ case($itemid) :
756+ $blog -> showUsingQuery($bpage, $qnext, 1, 1, 1);
757+ }
758+ }
759+ if ($items[3] == '' || $items[3] == 'c') {
760+ switch(TRUE) {
761+ case($ms4[0] == 'multiblogs') :
762+ $this -> MultiTitle($ms4, $query, $temple[0]);
763+ break;
764+ default :
765+ $blog -> showUsingQuery($msort, $query, 1, 1, 1);
766+ }
767+ }
768+ if (!($items[3] == 'a' || $items[3] == 'd') && mysql_num_rows(mysql_query($qprev))) {
769+ switch(TRUE) {
770+ case($bp4[0] == 'multiblogs') :
771+ $this -> MultiTitle($bp4, $qprev);
772+ break;
773+ default :
774+ $blog -> showUsingQuery($bpage, $qprev, 1, 1, 1);
775+ }
776+ }
777+ echo "</div>\n";
778+ }
779+// pagenavi
780+ if ($items[3]) {
781+ $cid = ($itemid) ? $item['catid'] : $catid;
782+ $catname = $blog -> getCategoryName($cid);
783+ $catlink = createBlogidLink($blogid, array('catid' => $cid));
784+ $blogname = getBlogNameFromID($blogid);
785+// $bloglink = createBlogidLink($blogid);
786+ $bloglink = quickQuery('SELECT burl as result FROM '.sql_table('blog').' WHERE bnumber ='.$blogid);
787+ $navi .= "<div class=\"pagenavi\">\n<a href=\"".$CONF['IndexURL']."\">HOME</a> &raquo; ";
788+ if ($blogid != $CONF['DefaultBlog']) $navi .= (!$cid) ? $blogname." &raquo; " : "<a href=\"".$bloglink."\">".$blogname."</a> &raquo; ";
789+ if ($cid) $navi .= ($item['catid'] || $archive || $archivelist || $subcatid) ? "<a href=\"".$catlink."\">".$catname."</a> &raquo; " : $catname." &raquo; ";
790+ $navi .= $q32.$item['title'];
791+ if($archive) $navi .= 'Archive:'.htmlspecialchars($archive);
792+ if ($archivelist) $navi .= 'ArchiveList';
793+ $navi .= "</div>\n";
794+ if ($items[3] == 'a' || $items[3] == 'b') echo $navi;
795+ }
796+// printout
797+ if ($_GET['sbmt'] && preg_match('/z/', $mform[1])) {
798+ $p_sg = '*Results ';
799+ if ($post) $p_sg .= 'for "'.$post.'" ';
800+ $p_sg .= ' ('.$bitem.') : <span class="iteminfo">'.$p_sf.'</span>';
801+ }
802+ if (($mform[0] == 'a' || $mform[0] == 'c' || $mform[0] == 'd') && substr($templates, 0, 5) != 'group') echo '<div class="switchform">'.$p_sform.$p_sg.'</div>';
803+ if ($bpage[1] != 'a' && !($bpage[2] && !$_GET['sbmt'])) echo $psh;
804+ if ($s3[1]) echo 'Search Word > '.$s3[1]."<br />\n";
805+// loggedin change
806+ $templates = explode('/', $templates, 2);
807+ if ($memid) $tblog = quickQuery('SELECT tblog as result FROM '.sql_table('team').' WHERE tmember = '.$memid);
808+ if (!$member -> isLoggedIn() && $templates[0] == 1) $template = $templates[1];
809+// category template change
810+ if (substr($templates[0], 0, 3) == 'cat' && $catid) {
811+ $ccat = explode(':', $templates[0]);
812+ foreach($ccat as $ccat2){
813+ if ($ccat2 != 'cat' && $catid == $ccat2) $template = $templates[1];
814+ }
815+ }
816+ switch(TRUE) {
817+// main print
818+ case($templates[0] != 'group' || $subcatid) :
819+ switch(TRUE) {
820+ case($temple[0] == 'multiblogs') :
821+ $this -> MultiTitle($temple, $query);
822+ break;
823+ case($items[2] != 'a') :
824+ $blog -> showUsingQuery($template, $query, 1, 1, 1);
825+ }
826+ break;
827+ default:
828+// group
829+ switch(TRUE) {
830+ case($mact && $catid) :
831+ $sj = $this -> getOption('subcategory_except');
832+ $shide = explode('/', $sj);
833+ $q111 = 'SELECT s.catid, s.scatid, s.sname, s.sdesc FROM '.sql_table('category').' as c, '.sql_table('plug_multiple_categories_sub').' as s WHERE s.catid = c.catid and c.catid = '.$catid;
834+ if ($sj) foreach($shide as $shide2) $q111 .= ' and s.scatid != '.$shide2;
835+ $q111 .= ' GROUP BY s.scatid ORDER BY ';
836+ switch(TRUE) {
837+ case($templates[1] == 1) :
838+ $q111 .= 'sname';
839+ break;
840+ case($templates[1] == 2) :
841+ $q111 .= 'sdesc';
842+ break;
843+ default:
844+ $q111 .= 'scatid';
845+ }
846+ break;
847+ default:
848+ if ($catid) $q110 = ' and catid = '.$catid;
849+ $cj = $this -> getOption('category_except');
850+ $chide = explode('/', $cj);
851+ $q111 = 'SELECT catid, cname, cdesc FROM '.sql_table('item').', '.sql_table('category').' WHERE catid = icat and cblog = '.$blogid.$q110;
852+ if ($cj) foreach($chide as $chide2) $q111 .= ' and catid != '.$chide2;
853+ $q111 .= ' GROUP BY catid ORDER BY ';
854+ switch(TRUE) {
855+ case($templates[1] == 1) :
856+ $q111 .= 'cname';
857+ break;
858+ case($templates[1] == 2) :
859+ $q111 .= 'cdesc';
860+ break;
861+ default:
862+ $q111 .= 'catid';
863+ }
864+ }
865+ $gcat = mysql_query($q111);
866+ while($rcat = mysql_fetch_assoc($gcat)) {
867+ switch(TRUE) {
868+ case($mact) :
869+ $q102 = ' and (p.categories REGEXP "(^|,)'.$rcat['catid'].'(,|$)" or i.icat = '.$rcat['catid'].')';
870+ if ($catid) $q102a = ' and (p.subcategories REGEXP "(^|,)'.$rcat['scatid'].'(,|$)")';
871+ $q102e = ' and (';
872+ $q102g = ' (categories REGEXP "(^|,)'.$rcat['catid'].'(,|$)" or icat = '.$rcat['catid'].') and subcategories is null)';
873+ break;
874+ default:
875+ $q102 = ' and i.icat = '.$rcat['catid'];
876+ }
877+ $gcount = mysql_num_rows(mysql_query($q101.$q102.$q102a));
878+ $q103 = $q101.$q102.$q102a.$que1.' LIMIT '.$items[0];
879+ switch(TRUE) {
880+ case($catid && $mact) :
881+ $gid = $rcat['scatid'];
882+ $gname = $rcat['sname'];
883+ $gdesc = $rcat['sdesc'];
884+ break;
885+ default:
886+ $gid = $rcat['catid'];
887+ $gname = $rcat['cname'];
888+ $gdesc = $rcat['cdesc'];
889+ }
890+ $par = ($catid && $mact) ? array('subcatid' => $gid) : array('catid' => $gid);
891+ if ($mact) $gnum = 'SELECT COUNT(ititle) as result FROM '.sql_table('item').' left join '.sql_table('plug_multiple_categories').' on inumber = item_id WHERE (categories REGEXP "(^|,)'.$rcat['catid'].'(,|$)" or icat = '.$rcat['catid'].')';
892+ if ($catid) $gnum .= ' and (subcategories REGEXP "(^|,)'.$rcat['scatid'].'(,|$)")';
893+ $gnum = quickQuery($gnum);
894+ $clink = createBlogidLink($blogid, $par);
895+ echo '<'.$this -> getOption('group_tagt').' class="grouptitle">';
896+ if ($this -> getOption('group_link') == 'yes') { echo '<a href="'.$clink.'">'.$gname.'</a>'; }else { echo $gname;}
897+ if ($this -> getOption('group_num') == 'yes') echo ' ('.$gnum.')';
898+ if ($gcount > $items[0]) echo ' [<a href="'.$clink.'">'.$this -> getOption('group_more').'</a>]';
899+ echo "</".$this -> getOption('group_tagt').">\n<".$this -> getOption('group_tag');
900+ if ($this -> getOption('group_tag') != "") echo ' class="groupbody"';
901+ echo ">";
902+ switch(TRUE) {
903+ case($temple[0] == 'multiblogs') :
904+ $this -> MultiTitle($temple, $q103);
905+ break;
906+ default :
907+ $blog -> showUsingQuery($template, $q103, 1, 1, 1);
908+ }
909+ echo '</'.$this -> getOption('group_tag').'>';
910+ }
911+ mysql_free_result($gcat);
912+ $q103 = $q101.$q102e.$q102g.$que1.' LIMIT '.$items[0];
913+
914+ if ($catid && !$subcatid && $mact && $this -> getOption('group_other') && mysql_num_rows(mysql_query($q103))) {
915+ echo "<".$this -> getOption('group_tagt')." class=\"grouptitle\">".$this -> getOption('group_other')."</".$this -> getOption('group_tagt').">\n<".$this -> getOption('group_tag');
916+ if ($this -> getOption('group_tag') != "") echo ' class="groupbody"';
917+ echo ">";
918+ switch(TRUE) {
919+ case($temple[0] == 'multiblogs') :
920+ $this -> MultiTitle($temple, $q103);
921+ break;
922+ default :
923+ $blog -> showUsingQuery($template, $q103, 1, 1, 1);
924+ }
925+ echo '</'.$this -> getOption('group_tag').'>';
926+ }
927+ }
928+ if ($bpage[1] != 'b' && !($bpage[2] && !$_GET['sbmt'])) echo $psh;
929+ if (($mform[0] == 'b' || $mform[0] == 'c') && $templates[0] != 'group') echo '<div class="switchform">'.$p_sform.$p_sg.'</div>';
930+ if ($items[3] == 'b' || $items[3] == 'c') echo $navi;
931+//print_r($query);
932+ return;
933+// fixed items
934+ default:
935+ if ($page = getVar('page') && $page > 1 && $bpage == '') return;
936+ if($catid && $msort != '1') return;
937+ $items = explode('/', $items);
938+ foreach($items as $mitem){
939+ $query = 'SELECT DISTINCT'.$q1.$q2.$q3.$q4.' and i.inumber = '.$mitem;
940+ if($bmode == 'fix') $query .= ' and i.iblog = '.$blogid;
941+ if($mcat == 'cat') $query .= ' and i.icat = '.$catid;
942+ $query .= ' LIMIT 1';
943+ $bitem = mysql_num_rows(mysql_query($query));
944+ switch(TRUE) {
945+ case($temple[0] == 'multiblogs' && $bitem) :
946+ $this -> MultiTitle($temple, $query);
947+ break;
948+ case($bitem) :
949+ $blog -> showUsingQuery($template, $query, 1, 1, 1);
950+ }
951+ }
952+ }
953+ }
954+
955+ function SearchQuery($post = '', $s1 = '', $s0 = '') {
956+ $order = (_CHARSET == 'EUC-JP') ? 'EUC-JP, UTF-8,' : 'UTF-8, EUC-JP,';
957+ $post = mb_convert_encoding($post, _CHARSET, $order.' JIS, SJIS, ASCII');
958+ $post = mb_convert_kana($post, 's');
959+ $post = ereg_replace('[\\]+', '\\', $post);
960+ $post = ereg_replace('[_%]+', '\\\0', $post);
961+ $post = ereg_replace('[[:space:]]+', ' ', $post);
962+ $post = explode(' ', trim($post));
963+ foreach ($post as $s2) {
964+ $s2 = ' LIKE "%'.addslashes($s2).'%';
965+ $query .= ' and ( ';
966+ $query .= $s1[0].$s2.$s1[1].$s2.$s1[2].$s2.$s1[3].$s2.$s1[4].$s2.$s1[5].$s2;
967+ if($s0) {
968+ $query .= $s1[6].$s2.$s1[7].$s2;
969+ }
970+ $query .= '" )';
971+ }
972+ return $query;
973+ }
974+
975+ function MultiTitle($temple = '', $query = '', $jd = '') {
976+ switch(TRUE) {
977+ case ($temple[1] == 'tr'):
978+ $m1 = 'tr';
979+ $m1a = 'td';
980+ break;
981+ case (!$temple[1]):
982+ $m1 = 'div';
983+ $m1a = 'span';
984+ break;
985+ default:
986+ $m1 = $temple[1];
987+ $m1a = 'span';
988+ }
989+
990+ $tj = intval(substr($temple[2], 2, 1));
991+ $tp = sql_query($query);
992+ while ($row = mysql_fetch_assoc($tp)) {
993+ echo '<'.$m1.' class="multiblogs_top">';
994+ switch(TRUE) {
995+ case($temple[3]) :
996+ $date = date($temple[3], $row['timestamp']);
997+ echo '<'.$m1a.' class="multiblogs_date">'.$date.'</'.$m1a.'>';
998+ }
999+ switch (TRUE) {
1000+ case ($jd == 1) :
1001+ echo '<'.$m1a.' class="multiblogs_title">'.$row['title'].'</'.$m1a.'>';
1002+ break;
1003+ default :
1004+ echo '<'.$m1a.' class="multiblogs_title"><a href="'
1005+ . createItemLink($row['itemid']).'">'
1006+ . $row['title'].'</a></'.$m1a.'>';
1007+ }
1008+ if ($temple[2]) {
1009+ echo '<'.$m1a.' class="multiblogs_cat">'
1010+ . substr($temple[2], 0, 1)
1011+ . $row['category']
1012+ . substr($temple[2], 1, 1).'</'.$m1a.'>';
1013+ }
1014+ echo '</'.$m1.'>';
1015+
1016+ switch(TRUE) {
1017+ case($tj == 1) :
1018+ echo '<'.$m1.' class="multiblogs_body">'
1019+ . shorten(strip_tags($row['body'].$row['more']), ($tj*100), '...').'</'.$m1.'>
1020+';
1021+ break;
1022+ }
1023+ }
1024+ return;
1025+ }
1026+}
1027+?>
Show on old repository browser