Heim  >  Artikel  >  php教程  >  Tcms 免费开源的政府网站群管理系统

Tcms 免费开源的政府网站群管理系统

PHP中文网
PHP中文网Original
2016-05-25 17:07:222361Durchsuche

tsys for php cms , 一个免费开源的政府网站群内容管理系统,运行在apache+mysql+php环境,可用此系统实现政府网络群模式管理网站,政府信息公开、互动办事平台等。谢谢!

1. [文件]     dbcontrol_class.php 

<?php
/*
	Tcms 数据库控制类
	作者:三木
*/
class DbControl
{
	//建立数据库链接
	public function Db_conn()
	{
		$conn = @mysql_connect(DB_HOST,DB_USERNAME,DB_USERPASS);
		if($conn==FALSE)
		{
			echo "数据库服务连接失败!";
			exit();
		}else{
			$dbsele = @mysql_select_db(DB_DATABASE);
			if($dbsele==FALSE)
			{
				echo "数据库连接失败!";
				exit();
			}
		}
	}
	//执行sql语句
	public function sql_query($sql)
	{
		mysql_query(&#39;set names \&#39;utf8\&#39;&#39;);
		return mysql_query($sql);
	}
	public function sql_fetchrow($result)
	{
		return mysql_fetch_array($result);
	}
	public function sql_numrows($result)
	{
		return mysql_num_rows($result);
	}
}
?>

2. [文件]     filesys_class.php  

Tcms 免费开源的政府网站群管理系统filesys_class.rar

3. [文件]     manager_class.php 

Tcms 免费开源的政府网站群管理系统manager_class.rar

4. [文件]     rescreator_class.php 

<?php
/*
	类名:Tcms-模板解析器
	简介:
	   分析资源模板内CACO标签,转换成最终数据保存到指定目录内。
	属性:
	   -
	方法:
   createres               创建资源
*/
class ResCreator {
	/*
		方法:创建资源(主方法)
		参数:
		   Resource    资源Rs记录对象
		   TContent    资源所将要套用的模板内容
		返回:
		   0   生成失败
		   1   生成成功
	*/
	public function createres($resinfo,$tempcontent) {
		//模板为空及生成目录不确定的资源不生成
		if($tempcontent==&#39;&#39; || $resinfo[&#39;directory_rule&#39;]==&#39;&#39; || $resinfo[&#39;filename_rule&#39;]==&#39;&#39; || is_null($resinfo[&#39;directory_rule&#39;]) or is_null( $resinfo[&#39;filename_rule&#39;])) return 0;
		global $cfg,$mysql,$tparser,$flib;
		$resinfo[&#39;directory_rule&#39;] = $flib->creat_path($resinfo[&#39;directory_rule&#39;],$resinfo[&#39;class_id&#39;]);
		$resinfo[&#39;replace_path_url&#39;] = $flib->creat_url($resinfo[&#39;replace_path_url&#39;],$resinfo[&#39;class_id&#39;]);
		$resinfo[&#39;replace_path&#39;] = $flib->creat_path($resinfo[&#39;replace_path&#39;],$resinfo[&#39;class_id&#39;]);
		//具有跳链接的资源无需生成
		if($resinfo[&#39;go_url&#39;]!=&#39;&#39;) {
			$sql = "UPDATE ".DB_FIXTABLE."resource_list SET visit_url=&#39;".$resinfo[&#39;go_url&#39;]."&#39;,created=1 WHERE id=".$resinfo[&#39;id&#39;];
			$mysql->sql_query($sql);
			return 1;
		}
		//解析模板 没有分页
		$tempcontent = $tparser->parser($resinfo,$tempcontent);
		$arrfileinfo = $this->path_parser($resinfo);
		$OK = file_put_contents($arrfileinfo[1],$tempcontent);
		if($OK){
			$sql = "UPDATE ".DB_FIXTABLE."resource_list SET file_path=&#39;".addslashes($arrfileinfo[1])."&#39;,visit_url=&#39;".$arrfileinfo[2]."&#39;,created=1 WHERE id=".$resinfo[&#39;id&#39;];
			$mysql->sql_query($sql);
			$re_createres = 1;
		}else{
			$sql = "UPDATE ".DB_FIXTABLE."resource_list SET checked=0,created=0,file_path=&#39;&#39;,visit_url=&#39;&#39; WHERE id=".$resinfo[&#39;id&#39;];
			$mysql->sql_query($sql);
			$re_createres = 0;
		}
		return $re_createres;
	}
	/*
		方法:内容生成文件、目录规则解析
		参数:-
		返回:
		   路径信息数组
		   (0) 未转成实际路径的路径的路径信息
		   (1) 已转成实际路径的路径信息
		   (2) 内容对外访问用的Url信息
	*/
	private function path_parser($resinfo){
		global $flib,$cfg;
		$tmp_directory_rule		=&#39;&#39;;
		$tmp_directory_rule2	=&#39;&#39;;
		$tmp_filname_rule		=&#39;&#39;;
		$fileurl				=&#39;&#39;;
		$tmp_directory_rule = $resinfo[&#39;directory_rule&#39;];
		if(strpos($tmp_directory_rule,&#39;{class}&#39;)!==false)$tmp_directory_rule = str_replace(&#39;{class}&#39;,$resinfo[&#39;class_id&#39;],$tmp_directory_rule);
		if(strpos($tmp_directory_rule,&#39;{Y}&#39;)!==false)$tmp_directory_rule = str_replace(&#39;{Y}&#39;,date(&#39;Y&#39;,$resinfo[&#39;addtime&#39;]),$tmp_directory_rule);
		if(strpos($tmp_directory_rule,&#39;{m}&#39;)!==false)$tmp_directory_rule = str_replace(&#39;{m}&#39;,date(&#39;m&#39;,$resinfo[&#39;addtime&#39;]),$tmp_directory_rule);
		if(strpos($tmp_directory_rule,&#39;{d}&#39;)!==false)$tmp_directory_rule = str_replace(&#39;{d}&#39;,date(&#39;d&#39;,$resinfo[&#39;addtime&#39;]),$tmp_directory_rule);
		if(strpos($tmp_directory_rule,&#39;{N}&#39;)!==false)$tmp_directory_rule = str_replace(&#39;{N}&#39;,date(&#39;N&#39;,$resinfo[&#39;addtime&#39;]),$tmp_directory_rule);
		
		$tmp_filname_rule	= $resinfo[&#39;filename_rule&#39;];
		if(strpos($tmp_filname_rule,&#39;{id}&#39;)!==false)$tmp_filname_rule	= str_replace(&#39;{id}&#39;,$resinfo[&#39;id&#39;],$tmp_filname_rule);
		if(strpos($tmp_filname_rule,&#39;{class}&#39;)!==false)$tmp_filname_rule	= str_replace(&#39;{class}&#39;,$resinfo[&#39;class_id&#39;],$tmp_filname_rule);
		if(strpos($tmp_filname_rule,&#39;{title}&#39;)!==false)$tmp_filname_rule	= str_replace(&#39;{title}&#39;,$resinfo[&#39;title&#39;],$tmp_filname_rule);
		if(strpos($tmp_filname_rule,&#39;{author}&#39;)!==false)$tmp_filname_rule	= str_replace(&#39;{author}&#39;,$resinfo[&#39;author&#39;],$tmp_filname_rule);
		if($resinfo[&#39;replace_path&#39;]!=&#39;&#39;)
		{
			if($resinfo[&#39;replace_path&#39;]==&#39;{head}&#39;)
			{
				$fileurl = $resinfo[&#39;replace_path_url&#39;].$tmp_directory_rule;
			}else{
				$fileurl = str_replace($resinfo[&#39;replace_path&#39;],$resinfo[&#39;replace_path_url&#39;],$tmp_directory_rule);
			}
		}
		if(strpos($fileurl,"\\")!==false)$fileurl = str_replace("\\","/",$fileurl);
		if(strpos($tmp_directory_rule,"\\")!==false)$tmp_directory_rule = str_replace("\\","/",$tmp_directory_rule);
		$tmp_directory_rule2 = $cfg->webroot.$tmp_directory_rule;
		if(!file_exists($tmp_directory_rule2))$flib->rmkdir($tmp_directory_rule2);
		
		$arrfileinfo = array(&#39;&#39;);
		$arrfileinfo[0] = $tmp_directory_rule.&#39;/&#39;.$tmp_filname_rule;
		$arrfileinfo[1] = $tmp_directory_rule2.&#39;/&#39;.$tmp_filname_rule;
		$arrfileinfo[2] = $fileurl.&#39;/&#39;.$tmp_filname_rule;
		return $arrfileinfo;
	}
}
?>

5. [文件]     tagparser_class.php 

<?php
/*
	类名:Tcms标签库解析
	说明:
	所有CACO模板资源标签格式:
           <!--CACO:指令名([参数])-->
*/
class TagParser {
	private $resinfo;
	public function parser($res,$str){
		$this->resinfo = $res;
		$tempcontent = $str;
		$tempcontent1= &#39;&#39;;
		preg_match_all ("/(\<\!\-\-(TSYS|CACO):(.*?)\-\-\>)/",$tempcontent,$cacotag,PREG_SET_ORDER);
		for($i=0;$i<count($cacotag);$i++){
			$tempcontent = str_replace($cacotag[$i][1],$this->forparser($cacotag[$i][3]),$tempcontent);
		}
		return $tempcontent;
	}
/*
	递归处理嵌套标签
*/
	private function forparser($myflag) {
		if(preg_match_all ("/([a-z0-9_]{1,50})\(((?:(?![a-z0-9_]{1,50}\(.*?\)).)*?)\)/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			switch($cacotag_name[0][1]){
				case &#39;data&#39;:$cacotag_parser_switch = $this->cacotag_data_field($cacotag_name[0][2]);break;
				case &#39;format_date&#39;:$cacotag_parser_switch = $this->cacotag_format_date($cacotag_name[0][2]);break;
				case &#39;filter_html&#39;:$cacotag_parser_switch = $this->cacotag_filter_html($cacotag_name[0][2]);break;
				case &#39;left&#39;:$cacotag_parser_switch = $this->cacotag_left($cacotag_name[0][2]);break;
				case &#39;left_title&#39;:$cacotag_parser_switch = $this->cacotag_left_title($cacotag_name[0][2]);break;
				case &#39;address_list&#39;:$cacotag_parser_switch = $this->cacotag_address_list($cacotag_name[0][2]);break;
				case &#39;photo_show_all&#39;:$cacotag_parser_switch = $this->cacotag_photo_show_all($cacotag_name[0][2]);break;
				//图片信息图片地址调用
				case &#39;photo_show_pic&#39;:$cacotag_parser_switch = $this->cacotag_photo_show_pic($cacotag_name[0][2]);break;
				//图片信息信息链接地址调用
				case &#39;photo_show_link&#39;:$cacotag_parser_switch = $this->cacotag_photo_show_link($cacotag_name[0][2]);break;
				//图片信息信息标题调用
				case &#39;photo_show_text&#39;:$cacotag_parser_switch = $this->cacotag_photo_show_text($cacotag_name[0][2]);break;
				//新信息图标调用
				case &#39;newres_ico&#39;:$cacotag_parser_switch = $this->cacotag_newres_ico($cacotag_name[0][2]);break;
				//相关内容列表调用
				case &#39;relate_list&#39;:$cacotag_parser_switch = $this->cacotag_relate_list($cacotag_name[0][2]);break;
				//安全字符调用
				case &#39;safe_str&#39;:$cacotag_parser_switch = $this->cacotag_safe_str($cacotag_name[0][2]);break;
				default:return $myflag;break;
			}
			$tempcontent = str_replace($cacotag_name[0][0],$cacotag_parser_switch,$myflag);
			return $this->forparser($tempcontent);
		}else{
			return $myflag;
		}
	}
	/*
		&#39;方法:当前位置导航栏生成 CACO:address_list(栏目ID,&#39;链接字符&#39;,Flag)
		&#39;Flag =0 表示引用网站名称 <> 表示将网站名称改为首页
		&#39;参数:CACO标签
		&#39;返回:栏目ID位置导航
	*/
	private function cacotag_address_list($myflag){
		$re_cacotag_address_list = &#39;Err&#39;;
		if(preg_match_all ("/([0-9]{1,}),&#39;(.*?)&#39;,([0-9]{1,})/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			$re_cacotag_address_list = $this->cacotag_address_list_classlist($cacotag_name[0][1],$cacotag_name[0][2],$cacotag_name[0][3]);
		}
		return $re_cacotag_address_list;
	}
	private function cacotag_address_list_classlist($id,$linkstr,$flag,$liststr=&#39;&#39;){
		global $mysql,$flib;
		$re_cacotag_address_list_classlist = $liststr;
		$sql = "SELECT id,parent,title,home_url,isshow FROM ".DB_FIXTABLE."resclass_list WHERE id=$id LIMIT 0,1";
		$row = $mysql->sql_fetchrow($mysql->sql_query($sql));
		if(!$row)return $re_cacotag_address_list_classlist;
		$pid = $row[&#39;parent&#39;];
		$title = $row[&#39;title&#39;];
		$home_url = $flib->creat_url($row[&#39;home_url&#39;],$row[&#39;id&#39;]);
		$isshow = $row[&#39;isshow&#39;];
		if($pid==0){
			if($flag!=0)$title=&#39;首页&#39;;
		}
		if($isshow==1){
			$re_cacotag_address_list_classlist .= $this->cacotag_address_list_classlist($pid,$linkstr,$flag,$liststr).(($pid==0)?&#39;&#39;:$linkstr)."<a href=\"".$home_url."\">". $title.&#39;</a>&#39;;
		}else{
			$re_cacotag_address_list_classlist .= $this->cacotag_address_list_classlist($pid,$linkstr,$flag,$liststr);
		}
		return $re_cacotag_address_list_classlist;
	}
	/*
		方法:资源字段读取标签处理 CACO:data(字段名)
		参数:caco标签
		返回:内容字段数据
	*/
	private function cacotag_data_field($myflag){
		global $flib;
		$re_cacotag_data_field = &#39;&#39;;
		if(!(is_null($myflag)||$myflag==&#39;&#39;)){
			if($myflag==&#39;home_url&#39;){
				$re_cacotag_data_field = $flib->creat_url($this->resinfo[$myflag],$this->resinfo[&#39;class_id&#39;]);
			}else if($myflag==&#39;file_path&#39;){
				$re_cacotag_data_field = base64_encode($this->resinfo[$myflag]);
			}else{
				$re_cacotag_data_field = $this->resinfo[$myflag];
			}
		}
		return $re_cacotag_data_field;
	}
	/*
		方法:格式化时间格式 CACO:format_date(时间, &#39;时间格式串&#39;)
		参数:caco标签
		返回:格式化后的时间
	*/
	private function cacotag_format_date($myflag){
		$re_cacotag_format_date = &#39;Err&#39;;
		if(preg_match_all ("/([0-9]{1,}),&#39;(.*?)&#39;/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			$re_cacotag_format_date = date($cacotag_name[0][2],$cacotag_name[0][1]);
		}
		return $re_cacotag_format_date;
	}
	/*
		方法:清除html标签 CACO:filter_html(字符串)
		参数:CACO标签
		返回:清除后字符串
	*/
	private function cacotag_filter_html($myflag){
		return preg_replace("/<.+?>/","",$myflag);
	}
	/*
		方法:字符串截取函数 CACO:left(字符串, 截取长度, &#39;补给串&#39;)
		参数:CACO标签
		返回:截取后字符串
	*/
	private function cacotag_left($myflag){
		$re_cacotag_format_date = &#39;Err&#39;;
		if(preg_match_all ("/(.*?),([0-9]{1,}),&#39;(.*?)&#39;/",$myflag,$cacotag_name,PREG_SET_ORDER)){

			if(mb_strlen($cacotag_name[0][1])>($cacotag_name[0][2]/2)){
				$re_cacotag_format_date = $this->utf_substr($cacotag_name[0][1],$cacotag_name[0][2],$cacotag_name[0][3]);
				//$re_cacotag_format_date = mb_substr($cacotag_name[0][1],0,$cacotag_name[0][2]).$cacotag_name[0][3];
			}else{
				$re_cacotag_format_date = $cacotag_name[0][1];
			}
		}
		return $re_cacotag_format_date;
	}
	/*
		方法:Html字符截取函数 CACO:left_title(字符串, 截取长度, &#39;补给串&#39;)
		参数:CACO标签
		返回:截取后字符串
	*/
	private function cacotag_left_title($myflag){
		$re_cacotag_format_date = &#39;Err&#39;;
		if(preg_match_all ("/(.*?),([0-9]{1,}),&#39;(.*?)&#39;/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			$tempstr = $this->cacotag_filter_html($cacotag_name[0][1]);
			if(mb_strlen($tempstr)>$cacotag_name[0][2]/2){
				$re_cacotag_format_date = str_replace($tempstr,$this->cacotag_left($tempstr.",".$cacotag_name[0][2].",&#39;".$cacotag_name[0][3]."&#39;"),$cacotag_name[0][1]);
			}else{
				$re_cacotag_format_date = $cacotag_name[0][1];
			}
		}
		return $re_cacotag_format_date;
	}
	/*
		方法:图片信息调用 CACO:photo_show_all(ClassID, 调用数量, 截取字数)
		参数:CACO标签
		返回:文章标题串+地址串+小图片串
	*/
	private function cacotag_photo_show_all($myflag){
		global $flib,$mysql;
		$re_cacotag_photo_show_all = &#39;Err&#39;;
		if(preg_match_all ("/([0-9]{1,}),([0-9]{1,}),([0-9]{1,})/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			$re_cacotag_photo_show_all = &#39;&#39;;
			$classid = $cacotag_name[0][1];
			$topnum = $cacotag_name[0][2];
			$titlenum = $cacotag_name[0][3];
			$picstr_title = &#39;&#39;;
			$picstr_url = &#39;&#39;;
			$picstr_img = &#39;&#39;;
			$classidlist = $flib->childenlist($classid);
			if($classidlist==&#39;&#39;){
				$classidlist = $classid;
			}else{
				$classidlist = $classid.&#39;,&#39;.$classidlist;
			}
			$sql = "SELECT title,visit_url,small_img FROM ".DB_FIXTABLE."resource_list WHERE checked=1 AND created=1 AND deleted=0 AND small_isimg=1 AND class_id IN($classidlist) ORDER BY istop DESC,addtime DESC LIMIT 0,$topnum";
			$result = $mysql->sql_query($sql);
			while($row=$mysql->sql_fetchrow($result)){
				$temptitle = $this->cacotag_left($this->cacotag_filter_html($row[&#39;title&#39;]).",".$titlenum.",&#39;...&#39;");
				$tempurl = $row[&#39;visit_url&#39;];
				$tempimg = $row[&#39;small_img&#39;];
				$picstr_title .= ($picstr_title==&#39;&#39;)?($temptitle):(&#39;|&#39;.$temptitle);
				$picstr_url .=  ($picstr_url==&#39;&#39;)?($tempurl):(&#39;|&#39;.$tempurl);
				$picstr_img .=  ($picstr_img==&#39;&#39;)?($tempimg):(&#39;|&#39;.$tempimg);
			}
			$re_cacotag_photo_show_all = $picstr_title.&#39;##CACOCMSPIC##&#39;.$picstr_url.&#39;##CACOCMSPIC##&#39;.$picstr_img;
		}
		return $re_cacotag_photo_show_all;
	}
	/*
		方法:图片信息信息标题调用 CACO:photo_show_text(ClassID, 调用数量, 截取字数)
		参数:CACO标签
		返回:图片信息地址
	*/
	private function cacotag_photo_show_text($myflag){
		global $flib,$mysql;
		$re_cacotag_photo_show_text = &#39;Err&#39;;
		if(preg_match_all ("/([0-9]{1,}),([0-9]{1,}),([0-9]{1,})/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			$re_cacotag_photo_show_text = &#39;&#39;;
			$classid = $cacotag_name[0][1];
			$topnum = $cacotag_name[0][2];
			$titlenum = $cacotag_name[0][3];
			$picsstr = &#39;&#39;;
			$classidlist = $flib->childenlist($classid);
			if($classidlist==&#39;&#39;){
				$classidlist = $classid;
			}else{
				$classidlist = $classid.&#39;,&#39;.$classidlist;
			}
			$sql = "SELECT title FROM ".DB_FIXTABLE."resource_list WHERE checked=1 AND created=1 AND deleted=0 AND small_isimg=1 AND class_id IN($classidlist) ORDER BY istop DESC,addtime DESC LIMIT 0,$topnum";
			$result = $mysql->sql_query($sql);
			while($row=$mysql->sql_fetchrow($result)){
				$temptitle = $this->cacotag_left($this->cacotag_filter_html($row[&#39;title&#39;]).",".$titlenum.",&#39;...&#39;");
				if($picsstr==&#39;&#39;){
					$picsstr = $temptitle;
				}else{
					$picsstr.= &#39;|&#39;.$temptitle;
				}
			}
			$re_cacotag_photo_show_text = $picsstr;
		}
		return $re_cacotag_photo_show_text;
	}
	/*
		方法:图片信息信息链接地址调用 CACO:photo_show_link(ClassID, 调用数量)
		参数:CACO标签
		返回:图片信息地址
	*/
	private function cacotag_photo_show_link($myflag){
		global $flib,$mysql;
		$re_cacotag_photo_show_link = &#39;Err&#39;;
		if(preg_match_all ("/([0-9]{1,}),([0-9]{1,})/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			$re_cacotag_photo_show_link = &#39;&#39;;
			$classid = $cacotag_name[0][1];
			$topnum = $cacotag_name[0][2];
			$picsstr = &#39;&#39;;
			$classidlist = $flib->childenlist($classid);
			if($classidlist==&#39;&#39;){
				$classidlist = $classid;
			}else{
				$classidlist = $classid.&#39;,&#39;.$classidlist;
			}
			$sql = "SELECT visit_url FROM ".DB_FIXTABLE."resource_list WHERE checked=1 AND created=1 AND deleted=0 AND small_isimg=1 AND class_id IN($classidlist) ORDER BY istop DESC,addtime DESC LIMIT 0,$topnum";
			$result = $mysql->sql_query($sql);
			while($row=$mysql->sql_fetchrow($result)){
				if($picsstr==&#39;&#39;){
					$picsstr = $row[&#39;visit_url&#39;];
				}else{
					$picsstr.= &#39;|&#39;.$row[&#39;visit_url&#39;];
				}
			}
			$re_cacotag_photo_show_link = $picsstr;
		}
		return $re_cacotag_photo_show_link;
	}
	/*
		方法:图片信息地址调用 CACO:photo_show_pic(ClassID, 调用数量)
		参数:CACO标签
		返回:图片信息地址
	*/
	private function cacotag_photo_show_pic($myflag){
		global $flib,$mysql;
		$re_cacotag_photo_show_pic = &#39;Err&#39;;
		if(preg_match_all ("/([0-9]{1,}),([0-9]{1,})/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			$re_cacotag_photo_show_pic = &#39;&#39;;
			$classid = $cacotag_name[0][1];
			$topnum = $cacotag_name[0][2];
			$picsstr = &#39;&#39;;
			$classidlist = $flib->childenlist($classid);
			if($classidlist==&#39;&#39;){
				$classidlist = $classid;
			}else{
				$classidlist = $classid.&#39;,&#39;.$classidlist;
			}
			$sql = "SELECT small_img FROM ".DB_FIXTABLE."resource_list WHERE checked=1 AND created=1 AND deleted=0 AND small_isimg =1 AND class_id IN($classidlist) ORDER BY istop DESC,addtime DESC LIMIT 0,$topnum";
			$result = $mysql->sql_query($sql);
			while($row=$mysql->sql_fetchrow($result)){
				if($picsstr==&#39;&#39;){
					$picsstr = $row[&#39;small_img&#39;];
				}else{
					$picsstr.= &#39;|&#39;.$row[&#39;small_img&#39;];
				}
			}
			$re_cacotag_photo_show_pic = $picsstr;
		}
		return $re_cacotag_photo_show_pic;
	}
	/*
		方法:新信息图标调用 CACO:newres_ico(图片URL, 开始时间, 有效时间)
		参数:CACO标签,图片url访问地址,起始时间,有效显示 秒
		返回:图片信息地址
	*/
	private function cacotag_newres_ico($myflag){
		global $cfg;
		$re_cacotag_newres_ico = &#39;Err&#39;;
		if(preg_match_all ("/(.*?),([0-9]{1,}),([0-9]{1,})/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			if($cfg->nowtime - $cacotag_name[0][2] <= $cacotag_name[0][3] ){
				$re_cacotag_newres_ico = "<img src=".$cacotag_name[0][1]." />";
			}else{
				$re_cacotag_newres_ico = &#39;&#39;;
			}
		}
		return $re_cacotag_newres_ico;
	}
	/*
		方法:相关资源列表 CACO:relate_list(数目, "相关列表样式模板")
		参数:Tsys标签
		返回:列表Html字符串
		说明:
		   相关列表样式模板:便用用户定义个性化的相关列表效果
		样式模板内部可用的动态变量有:
		   {id}            资源id
		   {title}         资源标题
		   {url}           资源访问地址
		   {author}        作者
		   {addtime}       添加时间
		   {class_title}   频道名称
		   {class_id}      频道id
		   {class_url}     频道地址
	*/
	private function cacotag_relate_list($myflag){
		$re_cacotag_relate_list = &#39;Err&#39;;
		if(is_null($this->resinfo[&#39;relate_list&#39;]) || $this->resinfo[&#39;relate_list&#39;]==&#39;&#39;)return &#39;&#39;;
		if(preg_match_all ("/(.*?),([0-9]{1,})/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			global $flib,$mysql;
			$re_cacotag_relate_list = &#39;&#39;;
			$topnum = $cacotag_name[0][2];
			$strtemplate = $cacotag_name[0][1];
			$strtemplate2 = &#39;&#39;;
			$sql = "SELECT rl.id,rl.class_id,rl.title,rl.author,rl.visit_url,rl.addtime,cl.title AS class_title,cl.home_url AS class_url FROM ".DB_FIXTABLE."resource_list AS rl LEFT JOIN ".DB_FIXTABLE."resclass_list AS cl ON rl.class_id=cl.id WHERE rl.id IN (".$this->resinfo[&#39;relate_list&#39;].") AND rl.checked=1 AND rl.deleted=0 AND rl.created=1 ORDER BY rl.istop DESC,rl.id DESC LIMIT 0,$topnum";
			$result = $mysql->sql_query($sql);
			while($row=$mysql->sql_fetchrow($result)){
				$tmp_class_url = $row[7];
				if(strpos($tmp_class_url,&#39;{class}&#39;)!==false)$tmp_class_url = str_replace(&#39;{class}&#39;,$row[1],$row[7]);
				if(strpos($strtemplate,&#39;{title}&#39;)!==false)$strtemplate2 = str_replace(&#39;{title}&#39;,$row[2],$strtemplate);
				if(strpos($strtemplate2,&#39;{id}&#39;)!==false)$strtemplate2 = str_replace(&#39;{id}&#39;,$row[0],$strtemplate2);
				if(strpos($strtemplate2,&#39;{url}&#39;)!==false)$strtemplate2 = str_replace(&#39;{url}&#39;,$row[4],$strtemplate2);
				if(strpos($strtemplate2,&#39;{author}&#39;)!==false)$strtemplate2 = str_replace(&#39;{author}&#39;,$row[3],$strtemplate2);
				if(strpos($strtemplate2,&#39;{addtime}&#39;)!==false)$strtemplate2 = str_replace(&#39;{addtime}&#39;,date(&#39;Y-m-d H:i:s&#39;, $row[5]),$strtemplate2);
				if(strpos($strtemplate2,&#39;{class_title}&#39;)!==false)$strtemplate2 = str_replace(&#39;{class_title}&#39;,$row[6],$strtemplate2);
				if(strpos($strtemplate2,&#39;{class_id}&#39;)!==false)$strtemplate2 = str_replace(&#39;{class_id}&#39;,$row[1],$strtemplate2);
				if(strpos($strtemplate2,&#39;{class_url}&#39;)!==false)$strtemplate2 = str_replace(&#39;{class_url}&#39;,$tmp_class_url,$strtemplate2);
				$re_cacotag_relate_list .= $strtemplate2;
			}
		}
		return $re_cacotag_relate_list;
	}
	/*
		方法:安全字符串 CACO:safe_str(&#39;时间格式串&#39;)
		参数:caco标签
		返回:格式化后的时间
	*/
	private function cacotag_safe_str($myflag){
		$re_cacotag_safe_str = &#39;Err&#39;;
		if(preg_match_all ("/(.*?)/",$myflag,$cacotag_name,PREG_SET_ORDER)){
			$re_cacotag_safe_str = addslashes($myflag);
		}
		return $re_cacotag_safe_str;
	}

	private function utf_substr($str,$len,$sadd=&#39;…&#39;){ 
		$ok_str = $str;
		$ok_str_1 = &#39;&#39;;
		$ok_str_1_len = $len-2;
		for($i=0;$i<$len;$i++) { 
			$temp_str=substr($str,0,1); 
			if(ord($temp_str) > 127) { 
				$i++; 
				if($i<$len) { 
					$new_str[]=substr($str,0,3); 
					$str=substr($str,3); 
				} 
			} else { 
				$new_str[]=substr($str,0,1); 
				$str=substr($str,1); 
			}
			if($i <= $ok_str_1_len)$re_str_1 = join($new_str);
		} 
		$re_str = join($new_str);
		return ($re_str == $ok_str)?($re_str):($re_str_1.$sadd);
	} 
}
?>

6. [图片] 001.png    

Tcms 免费开源的政府网站群管理系统

                                           

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:PHP读取XMLNächster Artikel:分享3个php获取日历的函数_php技巧