各位大哥下面这个是 SupeSite的sitemap生成文件其中$itemvalue['message']这是调用整个文章内容我想把它改成只调用部分内容 只截取前20个字符后面省略号改怎么修改
此处仅为部分代码 完整代码请下载http://www.xunleidianying.net.cn/admin_sitemap.rar<?php/*
[SupeSite] (C) 2007-2009 Comsenz Inc.
$Id: admin_sitemap.php 11878 2009-03-30 03:11:53Z zhaofei $
*/if(!defined('IN_SUPESITE_ADMINCP')) {
exit('Access Denied');
}//权限
if(!checkperm('managesitemap')) {
showmessage('no_authority_management_operation');
}//组建html url
$htmlurl = H_URL;
if(!strexists($htmlurl, '://')) $htmlurl = S_URL_ALL.substr(H_DIR, 1);$addclass = $viewclass = $slogidarr = '';
$listarr = array();
$sitemapdata = array('index'=>'', 'file' => array());
$baidu_style = 'none';
$google_style = '';
$options = array('always'=>'always', 'hourly'=>'hourly', 'daily'=>'daily', 'weekly'=>'weekly', 'monthly'=>'monthly', 'yearly'=>'yearly', 'never'=>'never');
$start = empty($_GET['start']) ? 0 : intval($_GET['start']);
$countnum = 0;
$lastfileid = 0;
$sitemap_path = S_ROOT.'./data/sitemap/';
if(!file_exists($sitemap_path)) {
@mkdir($sitemap_path, '0666');
}if(submitcheck('thevalue')) {
if(!preg_match("/^[0-9a-z_]+$/i", $_POST['mapname']) || strlen($_POST['mapname']) > 50) {
showmessage('sitemap_name_error');
}
$mapdata = addslashes(serialize($sitemapdata));
$_POST['maptype'] = saddslashes(shtmlspecialchars($_POST['maptype']));
$_POST['mapnum'] = $_POST['maptype'] == 'google' ? intval($_POST['mapnum_google']) : intval($_POST['mapnum_baidu']);
$_POST['createtype'] = intval($_POST['createtype']);
$_POST['changefreq'] = $_POST['maptype'] == 'google' ? saddslashes(shtmlspecialchars($_POST['changefreq_google'])) : saddslashes(shtmlspecialchars($_POST['changefreq_baidu']));
if(!empty($_POST['slogid'])) {
$_SGLOBAL['db']->query("UPDATE ".tname('sitemaplogs')." SET mapname='$_POST[mapname]', maptype='$_POST[maptype]', mapnum='$_POST[mapnum]', createtype='$_POST[createtype]', changefreq='$_POST[changefreq]' WHERE slogid='$_POST[slogid]'");
showmessage('sitemap_config_update', $theurl);
} else {
$query = $_SGLOBAL['db']->query("SELECT count(*) FROM ".tname('sitemaplogs')." WHERE mapname='$_POST[mapname]'");
if($value = $_SGLOBAL['db']->result($query,0)) {
showmessage('sitemap_name_exists');
}
$_SGLOBAL['db']->query("INSERT INTO ".tname('sitemaplogs')."(mapname, maptype, mapnum, mapdata, createtype, changefreq) VALUES ('$_POST[mapname]', '$_POST[maptype]', '$_POST[mapnum]', '$mapdata', '$_POST[createtype]', '$_POST[changefreq]')");
showmessage('sitemap_config_add', $theurl);
}} elseif(submitcheck('listsubmit')) {
if(!empty($_POST['slogidarr'])) {
$slogidarr = implode('\',\'', $_POST['slogidarr']);
$_SGLOBAL['db']->query('DELETE FROM '.tname('sitemaplogs').' WHERE slogid IN (\''.$slogidarr.'\')');
}
showmessage('robotmessage_op_success', $theurl);
}if(empty($_GET['op'])) {
$viewclass = ' class="active"';
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('sitemaplogs'));
while($value = $_SGLOBAL['db']->fetch_array($query)) {
$value['dateline'] = sgmdate($value['dateline']);
$listarr[] = $value;
}
} elseif($_GET['op'] == 'add') {
$addclass = ' class="active"';
$thevalue = array('slogid'=>'', 'maptype'=>'google', 'dateline'=>'', 'createtype'=>'', 'lastitemid'=>'', 'mapnum' => '');
} elseif($_GET['op'] == 'edit') {
$_GET['slogid'] = intval($_GET['slogid']);
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('sitemaplogs')." WHERE slogid='$_GET[slogid]'");
$thevalue = $_SGLOBAL['db']->fetch_array($query);
$thevalue['dateline'] = sgmdate($thevalue['dateline']);
if($thevalue['maptype'] == 'baidu') {
$baidu_style = '';
$google_style = 'none';
$disabled = 'disabled';
} else {
$baidu_style = 'none';
$google_style = '';
$disabled = '';
}
} elseif($_GET['op'] == 'update') {
if(is_dir($sitemap_path) && is_writable($sitemap_path)){
$_GET['slogid'] = intval($_GET['slogid']);
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('sitemaplogs')." WHERE slogid='$_GET[slogid]'");
if($value = $_SGLOBAL['db']->fetch_array($query)) {
$value['lastitemid'] = intval($value['lastitemid']) > 0 ? intval($value['lastitemid']) : 1;
$sitemapdata = unserialize($value['mapdata']);
$sitemapdata['index'] = $value['mapname'].'.xml';
$limit = $idvalue = $itemurl = ''; $fp = @fopen(S_ROOT.$sitemapdata['index'], 'w+');
if($value['maptype'] == 'baidu') {
$limit = 'ORDER BY itemid DESC limit '.$value['mapnum'];
$submiturl = "http://news.baidu.com/newsop.html#ks5";
write('<?xml version="1.0" encoding="'.($_SCONFIG['charset'] == 'gbk' ? 'GB2312' : $_SCONFIG['charset']).'"?>');
write('<document>');
write('<webSite>'.S_URL_ALL.'</webSite>');
write('<webMaster>'.$adminemail.'</webMaster>');
write('<updatePeri>'.$value['changefreq'].'</updatePeri>');
} else {
$limit = 'ORDER BY itemid limit '.$value['mapnum'];
$submiturl = "https://www.google.com/webmasters/sitemaps/";
}
//重新生成
if($value['createtype'] == '0' && empty($start)) {
$value['lastitemid'] = 0;
$value['lastfileid'] = 0;
$sitemapdata['file'] = array();
} $i = $n = 0;
$query = $_SGLOBAL['db']->query("SELECT max(itemid) FROM ".tname('spaceitems')." WHERE type='news' AND folder='1'");
$countnum =$_SGLOBAL['db']->result($query, 0);
$query = $_SGLOBAL['db']->query("SELECT si.itemid, si.type, si.uid, si.dateline, si.subject, si.username, sn.message FROM ".tname('spaceitems')." si, ".tname('spacenews')." sn WHERE si.type='news' AND si.itemid = sn.itemid AND si.itemid > $value[lastitemid] AND si.folder='1' ".$limit);
while($itemvalue = $_SGLOBAL['db']->fetch_array($query)) {
$itemvalue['dateline'] = sgmdate($itemvalue['dateline'], "Y-m-d H:i:s");
$itemvalue['subject'] = htmlspecialchars(strip_tags(trim($itemvalue['subject'])));
                $itemvalue['message'] = htmlspecialchars(strip_tags(trim($itemvalue['message'])));
$itemvalue['username'] = htmlspecialchars(strip_tags(trim($itemvalue['username'])));

if($_SCONFIG['urltype'] != 4 && $_SCONFIG['urltype'] != 5) {
$itemurl = geturl("action/viewnews/itemid/$itemvalue[itemid]", 2);
} else {
$itemurl = geturl("action/viewnews/itemid/$itemvalue[itemid]", 0);
} $idvalue = ($itemvalue['itemid']>9)?substr($itemvalue['itemid'], -2, 2):$itemvalue['itemid'];
$htmlpath = $idvalue.'/n-'.$itemvalue['itemid'].'.html';
if(file_exists(H_DIR.'/'.$htmlpath)) {
$itemurl = $htmlurl.'/'.$htmlpath;
} //防止$siteurl没有填时
if(!strexists($itemurl, '://')) {
$itemurl = S_URL_ALL.$itemurl;
} if($value['maptype'] == 'google') {
$n = floor($i / $value['mapnum']) + $value['lastfileid'];
$sitemapfile = S_URL_ALL.'/data/sitemap/'.$value['mapname'].'_'.$n.'.xml';
$urlarr[$n][] = $itemurl;
if(!in_array($sitemapfile, $sitemapdata['file'])) {
$sitemapdata['file'][] = $sitemapfile;
}
} elseif($value['maptype'] == 'baidu') {
write('<item>');
write('<title>'.$itemvalue['subject'].'</title>');
write('<link>'.$itemurl.'</link>');
write('<text>'.$itemvalue['message'].'</text>');
write('<image />');
write('<source>'.S_URL_ALL.'</source>');
write('<author>'.$itemvalue['username'].'</author>');
write('<date>'.sgmdate($_SGLOBAL['timestamp'], 'Y-m-d').'</date>');
write('</item>');
}
$value['lastitemid'] = $itemvalue['itemid'] > $value['lastitemid'] ? $itemvalue['itemid'] : $value['lastitemid']; //更新最后的itemid为当前的itemid值
$i++;
}