有限会社全行団は、日本行政書士会連合会及び地方協議会から出資を受けた行政書士の福利厚生、事務所運営を目的とした営利法人です。
〒150-0045 東京都渋谷区神泉町20-10
上野ビル2階
TEL.03-3770-5675/FAX.03-3770-2677
サイトに関するお問い合わせ
webmaster@zengyodan.co.jp
ショップに関するお問い合わせ
shop@zengyodan.co.jp
その他のお問い合わせはこちら
-
if (!function_exists('sql_table')){
function sql_table($name) { return 'nucleus_'.$name; }
}
class NP_MultiBlogs extends NucleusPlugin {
function getName() { return 'MultiBlogs'; }
function getAuthor() { return 'jun'; }
function getURL() { return 'http://feles.jp/bb/viewtopic.php?t=423'; }
function getVersion() { return '1.0'; }
function getDescription() { return 'Displaying items (and fixed items) of all or each or other blogs (and categories), and the link to other pages, and sorting at new order or old order or random.'; }
function supportsFeature($what) {
switch($what) {
case 'SqlTablePrefix':
return 1;
default:
return 0;
}
}
function doSkinVar($skinType, $template = 'default', $items = 10, $bmode = '',$bpage = '', $msort = '', $mcat = '') {
global $blog, $blogid, $catid, $archive, $itemid, $memberid;
/** Please fill in BlogID to except of all blogs. " $hide = array(1,4,5) " **/
$hide = array();
// blog query
$q1 = 'SELECT DISTINCT i.inumber as itemid, i.iblog as blog, i.ibody as body, m.mname as author, m.mrealname as authorname, UNIX_TIMESTAMP(i.itime) as timestamp, i.itime, i.imore as more, m.mnumber as authorid, c.cname as category, i.icat as catid, i.iclosed as closed,';
$q2 = ' i.ititle as title';
$q3 = ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c';
$q4 = ' WHERE i.iauthor = m.mnumber and i.icat = c.catid and i.idraft = 0 and i.itime <= '.mysqldate($blog -> getCorrectTime());
// fixed items
if($bmode == 'fix' or $bmode == 'fixall') {
if($page = getVar('page') or $page = getVar('startpos')) {
if($page > 1 && $bpage != 'all') return;
}
if(!$catid || $msort == '1') {
$items = explode('/', $items);
foreach($items as $mitem){
$query = $q1.$q2.$q3.$q4.' and i.inumber = '.$mitem;
if($bmode == 'fix') $query .= ' and i.iblog = '.$blogid;
$bitem = mysql_num_rows(mysql_query($query));
if($bitem) $blog -> showUsingQuery($template, $query);
}
}
}else {
// for NP_StickyIT (* Thanks for Mr. Fujisaki, 2004.08.09)
$result = mysql_query('SELECT snumber FROM '.sql_table('plug_stickyit').'');
if($result) {
$q5 = ' left join '.sql_table('plug_stickyit').' on snumber = i.inumber';
$q6 = ' and snumber is null';
}
$query = $q1.$q2.$q3.$q5.', '.sql_table('blog').' as b'.$q4.$q6;
$q7 = ' and b.bnumber = c.cblog';
$items = explode('/', $items);
$uri = sprintf('%s%s%s', 'http://', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
// search
if($items[0] == 's') {
$uri1 = explode('query=', $uri);
$uri2 = explode('&', $uri1[1]);
$post = (urldecode($uri2[0]));
$post = mb_convert_encoding($post, _CHARSET, 'auto');
$post = ereg_replace('[\\]+','\\',$post);
$post = ereg_replace('[_%]+','\\\0',$post);
$post = ereg_replace('[[:space:]]+|+',' ',$post);
$post = explode(' ', htmlspecialchars(trim($post)));
$s1 = array('i.ititle', '" or i.ibody', '" or i.imore');
foreach($post as $s2){
$s2 = ' LIKE "%'.$s2.'%';
$query .= ' and ( '.$s1[0].$s2.$s1[1].$s2.$s1[2].$s2.'" )';
}
$post = stripslashes(implode(' ', $post));
}
// category
if($mcat) {
$mcat = explode('/', $mcat);
if($mcat[0] == 'c') {
$q8 = ' or i.imore LIKE "%[-'.$catid.'-]%" )';
}elseif($mcat[0] == 'm') {
$query .= ' and BINARY i.imore LIKE "%[-'.$mcat[1].'-]%"';
}elseif($mcat[0] == 's') {
$s1 = mysql_query('SELECT ititle FROM '.sql_table('item').' WHERE inumber = '.$itemid);
while($s2 = mysql_fetch_assoc($s1)) {
$s3 = explode(' ', $s2['ititle']);
}
$query .= ($s3[1]) ? ' and ( i.ititle LIKE "%'.$s3[1].'%" or i.ibody LIKE "%'.$s3[1].'%" or i.imore LIKE "%'.$s3[1].'%" )' : ' and i.inumber = '.$itemid;
}elseif($mcat[0] == 'mem') {
$query .= ($mcat[1]) ? ' and i.iauthor = '.$mcat[1] : ' and i.iauthor = '.$memberid;
}else {
$mcat = implode(', ', $mcat);
$query .= ' and i.icat in ('.$mcat.')';
}
}
// archive
if($archive) {
sscanf($archive, '%d-%d-%d', $y , $m, $d);
if($d) {
$time_s = mktime(0, 0, 0, $m, $d, $y);
$time_e = mktime(0, 0, 0, $m, $d + 1, $y);
}else {
$time_s = mktime(0, 0, 0, $m, 1, $y);
$time_e = mktime(0, 0, 0, $m + 1, 1, $y);
}
$query .= $q7.' and i.itime >= '.mysqldate($time_s)
.' and i.itime < ' .mysqldate($time_e);
if(!$bmode) $query .= ' and i.iblog = '.$blogid;
// all blogs
}elseif ($bmode == 'all') {
$query .= $q7;
if($hide[0]) foreach($hide as $hides){
$query .= ' and i.iblog != '.$hides;
}
// each blog
}elseif ($bmode == '' || $bmode == 0) {
if($mcat[0] == 'c' && $catid) {
$query .= $q7.' and ( i.icat = '.$catid.$q8;
}else {
$query .= $q7.' and i.';
$query .= (!$catid) ? 'iblog = '.$blogid : 'icat = '.$catid;
}
// other blogs
}else {
$bmode = str_replace('/', ', ', $bmode);
$query .= ' and i.iblog in ('.$bmode.')';
}
// item
if($items[0] == 'item') {
if($msort == 'a') {
$itemcatid = quickQuery('SELECT icat as result FROM '.sql_table('item').' WHERE inumber='.$itemid);
$query .= ' and c.catid = '.$itemcatid;
}
$itemtime = quickQuery('SELECT itime as result FROM '.sql_table('item').' WHERE inumber='.$itemid);
$qnext = $query.' and i.itime > "'.$itemtime.'" ORDER BY i.itime ASC LIMIT 1';
$qprev = $query.' and i.itime < "'.$itemtime.'" ORDER BY i.itime DESC LIMIT '.$items[1];
$query .= ' and i.inumber = '.$itemid.' LIMIT 1';
}else {
// sort
if($msort == '2') {
$query .= ' ORDER BY RAND() ';
}elseif($msort == '1') {
$query .= ' ORDER BY i.itime ASC ';
}else {
$query .= ' ORDER BY i.itime DESC ';
}
// non pageswitch
$bitem = mysql_num_rows(mysql_query($query));
$ite = ($items[0] == 's') ? $items[1] : $items[0];
if($bpage == '' || $bpage == 0) {
$query .= 'LIMIT '.$ite;
// pageswitch
}else {
if($bitem > $ite || $items[0] == 's') $psh = '
';
if($bitem > $ite) {
list($plink, $mpage) = explode('page=', $uri);
$max = (!$bitem) ? 1 : ceil($bitem / $ite);
if(intval($mpage) > 0) {
$mpages = (intval($mpage) - 1) * $max;
}else {
$mpage = 1;
$uri = parse_url($plink);
$plink .= ($uri['query']) ? '&' : '?';
$plink = str_replace('&&', '&', $plink);
}
$mpages = $mpage * $ite - $ite;
$query .= 'LIMIT '.$mpages.','.$ite;
// pageswitch output
$plk = 'Prev [' : 'Prev [';
$psh .= 'P.'.$mpage.'/'.$max.'] ';
$psh .= ($mpage == $max || !$bitem) ? 'Next' : $plk.($mpage + 1).'">Next';
}
if(($bitem > $ite || $items[0] == 's') && $bpage == '2') {
$max2 = ($max == $mpage) ? $bitem : $mpages + $ite;
$psh .= ' [*';
if($items[0] == 's') $psh .= 'Search results: ';
$psh .= 'No.'.($mpages + 1).'-'.$max2.' of '.$bitem.'';
if($items[0] == 's') $psh .= ' for "'.$post.'"';
$psh .= ' ] ';
}
if($bitem > $ite && $bpage == '2') {
$psh .= ($mpage != 1) ? $plk.'1">First ' : 'First ';
$psh .= ($mpage != $max) ? $plk.$max.'">Last' : 'Last';
}
if($bitem > $ite || $items[0] == 's') $psh .= '
';
}
}
// printout
echo $psh;
if($s3[1]) echo 'Search Word > '.$s3[1]."\n"; $blog -> showUsingQuery($template, $query); echo $psh; if($items[0] == 'item') { echo "
\n
\n";
if(mysql_num_rows(mysql_query($qnext))) {
echo "» Next
\n"; $blog -> showUsingQuery($bpage, $qnext); } if(mysql_num_rows(mysql_query($qprev))) { echo "« Prev
\n"; $blog -> showUsingQuery($bpage, $qprev); } echo "
\n";
}
}
}
}
?>
\n"; $blog -> showUsingQuery($bpage, $qnext); } if(mysql_num_rows(mysql_query($qprev))) { echo "« Prev
\n"; $blog -> showUsingQuery($bpage, $qprev); } echo "