Exemple #1
0
function block_spacenews($paramarr)
{
    global $_SGLOBAL, $_SGET;
    $_SGLOBAL['attachsql'] = 'a.aid AS a_aid, a.type AS a_type, a.itemid AS a_itemid, a.uid AS a_uid, a.dateline AS a_dateline, a.filename AS a_filename, a.subject AS a_subject, a.attachtype AS a_attachtype, a.isimage AS a_isimage, a.size AS a_size, a.filepath AS a_filepath, a.thumbpath AS a_thumbpath, a.downloads AS a_downloads';
    if (empty($paramarr['sql'])) {
        $sql = array();
        $sql['select'] = 'SELECT i.*';
        $sql['from'] = 'FROM ' . tname('spaceitems') . ' i';
        $sql['join'] = '';
        $wherearr = array();
        $showpic = 0;
        //where
        if (!empty($paramarr['itemid'])) {
            $paramarr['itemid'] = getdotstring($paramarr['itemid'], 'int');
            if ($paramarr['itemid']) {
                $wherearr[] = 'i.itemid IN (' . $paramarr['itemid'] . ')';
            }
        } else {
            //作者
            if (!empty($paramarr['uid'])) {
                $paramarr['uid'] = getdotstring($paramarr['uid'], 'int');
                if ($paramarr['uid']) {
                    $wherearr[] = 'i.uid IN (' . $paramarr['uid'] . ')';
                }
            }
            //分类
            if (!empty($paramarr['catid'])) {
                $paramarr['catid'] = getdotstring($paramarr['catid'], 'int');
                if ($paramarr['catid']) {
                    $wherearr[] = 'i.catid IN (' . $paramarr['catid'] . ')';
                }
            }
            //限制
            if (empty($paramarr['catid']) && empty($paramarr['notype'])) {
                $wherearr[] = 'i.type=\'news\'';
            }
            $wherearr[] = 'i.folder=1';
            //站点审核
            if (!empty($paramarr['grade'])) {
                $paramarr['grade'] = getdotstring($paramarr['grade'], 'int');
                if (!empty($paramarr['grade'])) {
                    $wherearr[] = 'i.grade IN (' . $paramarr['grade'] . ')';
                }
            } else {
                if (empty($paramarr['uid'])) {
                    if (!empty($_SCONFIG['needcheck'])) {
                        $wherearr[] = 'i.grade>0';
                    }
                }
            }
            if (!empty($paramarr['digest'])) {
                $paramarr['digest'] = getdotstring($paramarr['digest'], 'int');
                if ($paramarr['digest']) {
                    $wherearr[] = 'i.digest IN (' . $paramarr['digest'] . ')';
                }
            }
            if (!empty($paramarr['top'])) {
                $paramarr['top'] = getdotstring($paramarr['top'], 'int');
                if ($paramarr['top']) {
                    $wherearr[] = 'i.top IN (' . $paramarr['top'] . ')';
                }
            }
            if (!empty($paramarr['dateline'])) {
                $paramarr['dateline'] = intval($paramarr['dateline']);
                if ($paramarr['dateline']) {
                    $wherearr[] = 'i.dateline >= ' . ($_SGLOBAL['timestamp'] - $paramarr['dateline']);
                }
            }
            if (!empty($paramarr['lastpost'])) {
                $paramarr['lastpost'] = intval($paramarr['lastpost']);
                if ($paramarr['lastpost']) {
                    $wherearr[] = 'i.lastpost >= ' . ($_SGLOBAL['timestamp'] - $paramarr['lastpost']);
                }
            }
            $scopequery = getscopequery('i', 'viewnum', $paramarr);
            if (!empty($scopequery)) {
                $wherearr[] = $scopequery;
            }
            $scopequery = getscopequery('i', 'replynum', $paramarr);
            if (!empty($scopequery)) {
                $wherearr[] = $scopequery;
            }
            $scopequery = getscopequery('i', 'goodrate', $paramarr);
            if (!empty($scopequery)) {
                $wherearr[] = $scopequery;
            }
            $scopequery = getscopequery('i', 'badrate', $paramarr);
            if (!empty($scopequery)) {
                $wherearr[] = $scopequery;
            }
            $paramarr['haveattach'] = intval($paramarr['haveattach']);
            if (!empty($paramarr['haveattach']) && $paramarr['haveattach'] == 1) {
                $wherearr[] = 'i.haveattach = 1';
            }
            //兼容早期的图文$paramarr['showattach']
            if (!empty($paramarr['showattach']) || !empty($paramarr['haveattach']) && $paramarr['haveattach'] == 2) {
                $showpic = 1;
                $wherearr[] = 'i.picid != 0';
            }
        }
        if (!empty($wherearr)) {
            $sql['where'] = 'WHERE ' . implode(' AND ', $wherearr);
        }
        //order
        if (!empty($paramarr['order'])) {
            $sql['order'] = 'ORDER BY ' . $paramarr['order'];
        }
        //limit
        if (!empty($paramarr['perpage'])) {
            $paramarr['perpage'] = intval($paramarr['perpage']);
            if (empty($paramarr['perpage'])) {
                $paramarr['perpage'] = 20;
            }
            if (empty($_SGET['page'])) {
                $_SGET['page'] = 1;
            }
            $_SGET['page'] = intval($_SGET['page']);
            if ($_SGET['page'] < 1) {
                $_SGET['page'] = 1;
            }
            $start = ($_SGET['page'] - 1) * $paramarr['perpage'];
            $sql['limit'] = 'LIMIT ' . $start . ',' . $paramarr['perpage'];
        } else {
            if (empty($paramarr['limit'])) {
                $sql['limit'] = 'LIMIT 0,1';
            } else {
                $paramarr['limit'] = getdotstring($paramarr['limit'], 'int', true, array(), 1, false);
                if ($paramarr['limit']) {
                    $sql['limit'] = 'LIMIT ' . $paramarr['limit'];
                } else {
                    $sql['limit'] = 'LIMIT 0,1';
                }
            }
        }
        //query
        $sqlstring = implode(' ', $sql);
        //multi
        $listcount = 1;
        if (!empty($paramarr['perpage'])) {
            $listcount = $_SGLOBAL['db']->result($_SGLOBAL['db']->query('SELECT COUNT(*) FROM ' . tname('spaceitems') . ' i ' . $sql['where']), 0);
            if ($listcount) {
                $urlarr = $_SGET;
                unset($urlarr['page']);
                $theblockarr['multipage'] = multi($listcount, $paramarr['perpage'], $_SGET['page'], $urlarr, 0);
            }
        }
    } else {
        include_once S_ROOT . './function/block_sql.func.php';
        list($sqlstring, $listcount) = runsql($paramarr);
        if (!empty($paramarr['perpage'])) {
            if ($listcount) {
                $urlarr = $_SGET;
                unset($urlarr['page']);
                $theblockarr['multipage'] = multi($listcount, $paramarr['perpage'], $_SGET['page'], $urlarr, 0);
            }
        }
    }
    if ($listcount) {
        //预处理
        if (empty($paramarr['subjectdot'])) {
            $paramarr['subjectdot'] = 0;
        }
        if (empty($paramarr['messagedot'])) {
            $paramarr['messagedot'] = 0;
        }
        if (!empty($paramarr['showcategory'])) {
            include_once S_ROOT . './data/system/category.cache.php';
        }
        $query = $_SGLOBAL['db']->query($sqlstring);
        $allitemids = $aids = array();
        while ($value = $_SGLOBAL['db']->fetch_array($query)) {
            //处理
            $value['subjectall'] = $value['subject'];
            if (!empty($value['subject']) && !empty($paramarr['subjectlen'])) {
                $value['subject'] = cutstr($value['subject'], $paramarr['subjectlen'], $paramarr['subjectdot']);
            }
            //处理标题样式
            if (!empty($value['styletitle'])) {
                $value['subject'] = '<span style=\'' . mktitlestyle($value['styletitle']) . '\'>' . $value['subject'] . '</span>';
            }
            //链接
            $value['url'] = geturl('action/viewnews/itemid/' . $value['itemid']);
            //附件
            if ($value['picid'] && $value['hash']) {
                $aids[] = $value['picid'];
            }
            $allitemids[] = $value['itemid'];
            //相关tag
            if (!empty($value['relativetags'])) {
                $value['relativetags'] = $value['tags'] = unserialize($value['relativetags']);
            }
            //分类名
            if (!empty($_SGLOBAL['category'][$value['catid']])) {
                $value['catname'] = $_SGLOBAL['category'][$value['catid']];
            }
            //附件
            if (!empty($value['picid']) && ($value['type'] == 'blog' || $value['type'] == 'news')) {
                $value['subject'] = $value['subject'] . $lang['block_image'];
            }
            $theblockarr[$value['itemid']] = $value;
        }
        //分页内容处理/取第一页
        if (!empty($paramarr['showdetail'])) {
            if (!empty($allitemids)) {
                $theitemarr = array();
                $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('spacenews') . ' WHERE itemid IN (\'' . implode('\',\'', $allitemids) . '\') ORDER BY nid');
                while ($value = $_SGLOBAL['db']->fetch_array($query)) {
                    if (empty($theitemarr[$value['itemid']])) {
                        if (!empty($value['message']) && !empty($paramarr['messagelen'])) {
                            $value['message'] = strip_tags(trim($value['message']));
                            $value['message'] = trim(cutstr($value['message'], $paramarr['messagelen'], $paramarr['messagedot']));
                        }
                        $theitemarr[$value['itemid']] = 1;
                        $theblockarr[$value['itemid']] = array_merge($theblockarr[$value['itemid']], $value);
                    }
                }
            }
        }
        if (!empty($showpic)) {
            $attacharr = array();
            if (!empty($aids)) {
                $query = $_SGLOBAL['db']->query('SELECT ' . $_SGLOBAL['attachsql'] . ' FROM ' . tname('attachments') . ' a WHERE a.aid IN (\'' . implode('\',\'', $aids) . '\') ORDER BY a.dateline');
                while ($value = $_SGLOBAL['db']->fetch_array($query)) {
                    //处理
                    if (!empty($attacharr[$value['a_itemid']])) {
                        continue;
                    }
                    $value['a_subjectall'] = $value['a_subject'];
                    if (!empty($value['a_subject']) && !empty($paramarr['subjectlen'])) {
                        $value['a_subject'] = cutstr($value['a_subject'], $paramarr['subjectlen'], $paramarr['subjectdot']);
                    }
                    //附件处理
                    if (!empty($value['a_thumbpath'])) {
                        $value['a_thumbpath'] = A_URL . '/' . $value['a_thumbpath'];
                    }
                    if (!empty($value['a_filepath'])) {
                        $value['a_filepath'] = A_URL . '/' . $value['a_filepath'];
                    }
                    if (empty($value['a_thumbpath'])) {
                        if (empty($value['a_filepath'])) {
                            $value['a_thumbpath'] = S_URL . '/images/base/nopic.gif';
                        } else {
                            $value['a_thumbpath'] = $value['a_filepath'];
                        }
                    }
                    if (empty($value['a_filepath'])) {
                        $value['a_filepath'] = $value['a_thumbpath'];
                    }
                    $attacharr[$value['a_itemid']] = $value;
                    $theblockarr[$value['a_itemid']] = array_merge($theblockarr[$value['a_itemid']], $value);
                }
            }
        }
    }
    return $theblockarr;
}
function gethotnews2($catids)
{
    global $_SGLOBAL, $catarr;
    $hotnews2 = array();
    $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('spaceitems') . " WHERE folder =1 AND digest IN (1,2,3) AND catid IN (" . $catids . ") ORDER BY viewnum DESC, dateline DESC LIMIT 0, 10");
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        $value['subject'] = cutstr($value['subject'], 30, 0);
        //标题样式
        if (!empty($value['styletitle'])) {
            $value['subject'] = '<span style=\'' . mktitlestyle($value['styletitle']) . '\'>' . $value['subject'] . '</span>';
        }
        $value['url'] = gethtmlurl2($value['catid']) . '/' . sgmdate($value['dateline'], 'Y') . '/' . sgmdate($value['dateline'], 'n') . '/' . $catarr[$value['catid']]['pre_html'] . $value['itemid'] . '.html';
        $hotnews2[] = $value;
    }
    return $hotnews2;
}
Exemple #3
0
$thevalue['allowmax'] = 100;
$thevalue[allowtype] = '';
$thevalue['noinsert'] = 0;
$thevalue['hash'] = smd5($_SGLOBAL['supe_uid'] . '/' . $_SGLOBAL['timestamp'] . random(6));
//setcookie('attachhash', $thevalue['hash']);
#End
if ($op == 'add') {
    if (empty($item)) {
        $mktitlestyle = '';
        $item = array('subject' => '', 'catid' => $catid, 'message' => '', 'tagname' => '', 'newsauthor' => '', 'newsfrom' => '', 'newsfromurl' => '');
    }
} elseif ($op == 'edit') {
    if ($itemid && ($item['uid'] != $_SGLOBAL['supe_uid'] || empty($_SGLOBAL['supe_uid']))) {
        showmessage('no_permission', 'cp.php?ac=news&op=list');
    }
    $mktitlestyle = empty($item['styletitle']) ? '' : mktitlestyle($item['styletitle']);
    $item['subject'] = shtmlspecialchars($item['subject']);
    //	$item['message'] = jsstrip($item['message']);
    #Modify by chenguoren
    $thevalue['uploadarr'] = array();
    if ($item['hash'] && $item['haveattach']) {
        $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('attachments') . ' WHERE hash=\'' . $item['hash'] . '\' ORDER BY dateline');
        while ($attach = $_SGLOBAL['db']->fetch_array($query)) {
            $thevalue['uploadarr'][] = $attach;
        }
        if (!empty($thevalue['uploadarr'])) {
            if (empty($thevalue['noinsert'])) {
                $thevalue['noinsert'] = 0;
                $inserthtml = getuploadinserthtml($thevalue['uploadarr']);
            } else {
                $inserthtml = getuploadinserthtml($thevalue['uploadarr'], 1);
Exemple #4
0
     array_unshift($prefieldarr['newsfrom'], array('id' => 0, 'type' => 'news', 'field' => 'newsfrom', 'value' => $_COOKIE[$_SC['cookiepre'] . 'newsfrom'], 'isdefault' => 1));
 }
 //NEWS AUTHOR
 $newsauthorstr = prefieldhtml($thevalue, $prefieldarr, 'newsauthor', 1, '20');
 //NEWS FROM
 $newsfromstr = prefieldhtml($thevalue, $prefieldarr, 'newsfrom', 1, '20');
 if (!empty($thevalue['itemid'])) {
     $optext = '<a href="' . $theurl . '&op=addpage&itemid=' . $thevalue['itemid'] . '"><img src="admin/images/icon_folder.gif" align="absmiddle" border="0" /> ' . $alang['spacenews_title_message_op_add'] . '</a>';
 } else {
     $optext = $alang['spacenews_page_need_submit'];
 }
 if ($listcount > 1) {
     $optext .= ' &nbsp;&nbsp; <a href="' . $theurl . '&op=deletepage&itemid=' . $thevalue['itemid'] . '&nid=' . $thevalue['nid'] . '&pageorder=' . $thevalue['pageorder'] . '"><img src="admin/images/icon_folder3.gif" align="absmiddle" border="0" /> ' . $alang['spacenews_title_message_op_delete'] . '</a>';
 }
 $thevalue['subject'] = shtmlspecialchars($thevalue['subject']);
 $mktitlestyle = empty($thevalue['styletitle']) ? '' : mktitlestyle($thevalue['styletitle']);
 //NEWS MESSAGE
 $thevalue['message'] = addcslashes($thevalue['message'], '/"\\');
 $thevalue['message'] = str_replace("\r", '\\r', $thevalue['message']);
 $thevalue['message'] = str_replace("\n", '\\n', $thevalue['message']);
 $count = count($thevalue['uploadarr']);
 if (empty($thevalue['noinsert'])) {
     $thevalue['noinsert'] = 0;
     $inserthtml = getuploadinserthtml($thevalue['uploadarr']);
 } else {
     $inserthtml = getuploadinserthtml($thevalue['uploadarr'], 1);
 }
 if (empty($thevalue['allowtype'])) {
     $thevalue['allowtype'] = '';
 }
 if ($listcount > 1) {
Exemple #5
0
     $optext = $alang['spacenews_page_need_submit'];
 }
 if ($listcount > 1) {
     $optext .= ' &nbsp;&nbsp; <a href="' . $theurl . '&op=deletepage&itemid=' . $thevalue['itemid'] . '&nid=' . $thevalue['nid'] . '&pageorder=' . $thevalue['pageorder'] . '"><img src="admin/images/icon_folder3.gif" align="absmiddle" border="0" /> ' . $alang['spacenews_title_message_op_delete'] . '</a>';
 }
 echo label(array('type' => 'form-start', 'name' => 'thevalueform', 'action' => $newurl, 'other' => ' onSubmit="return validate(this)"'));
 echo label(array('type' => 'div-start'));
 echo label(array('type' => 'table-start'));
 if (checkperm('needcheck')) {
     echo label(array('type' => 'text', 'alang' => 'common_note', 'text' => $alang['spacenews_needcheck']));
 }
 if ($page == 1) {
     if (empty($thevalue['styletitle'])) {
         $mktitlestyle = '';
     } else {
         $mktitlestyle = mktitlestyle($thevalue['styletitle']);
     }
     echo '<tr id="tr_subject"><th>' . $alang['spacenews_title_subject'] . '</th><td><input name="subject" type="text" id="subject" onblur="relatekw();" size="60" maxlength="80" value="' . shtmlspecialchars($thevalue['subject']) . '" style="width: 500px;' . $mktitlestyle . '"  onkeyup="textCounter(this, \'maxlimit\', 80);" /><br />' . $alang['spacenews_title_subject_note'] . '</td></tr>';
     if (checkperm('managecheck')) {
         printjs();
         print <<<EOF
t\t<tr>
t\t<th>{$alang['titlestyle']}
t\t</th>
t\t<td>{$alang['titlestylecolor']}
t\t\t<select name="fontcolor" id="fontcolor" onChange="settitlestyle();" style="width: 80px;background-color: #000000">
  \t\t\t   <option value="" selected="selected">default</option>
t\t\t</select> 
t\t\t{$alang['titlestylesize']}
t\t     \t<select name="fontsize" id="fontsize" onChange="settitlestyle();">
  \t\t\t   <option value="" selected="selected">default</option>
Exemple #6
0
}
$keywords = implode(',', $newtagarr);
$guidearr = array();
$guidearr[] = array('url' => geturl('action/news'), 'name' => $channels['menus']['news']['name']);
if (!empty($thecat['upname'])) {
    $guidearr[] = array('url' => geturl('action/category/catid/' . $thecat['upid']), 'name' => $thecat['upname']);
}
$guidearr[] = array('url' => geturl('action/category/catid/' . $thecat['catid']), 'name' => $thecat['name']);
$title = $news['subject'] . ' - ' . $_SCONFIG['sitename'];
if (!empty($thecat['viewtpl']) && file_exists(S_ROOT . './templates/' . $_SCONFIG['template'] . '/' . $thecat['viewtpl'] . '.html.php')) {
    $tplname = $thecat['viewtpl'];
} else {
    $tplname = 'news_view';
}
if (!empty($news['styletitle'])) {
    $news['styletitle'] = mktitlestyle($news['styletitle']);
}
$title = strip_tags($title);
$keywords = strip_tags($keywords);
$description = strip_tags($description);
include template($tplname);
ob_out();
if (!empty($_SCONFIG['htmlviewnews'])) {
    ehtml('make');
} else {
    maketplblockvalue('cache');
}
function freshcookie($itemid)
{
    global $_SC, $_SGLOBAL;
    $isupdate = 1;