帝国cms代码片段备忘录
时间:2023年05月25日
/来源:网络
/编辑:佚名
",$navinfor[newstext]);
$pgcount=count($pg);
?>
内容分页数量:<?=$pgcount?>
#T=权限 - 验证
//验证权限
CheckLevel($logininid,$loginin,$classid,"totaldata");
/* http://www.zhongyf.com/qita/rj/2015-10-24/97501.html 这里有权限检测代码大全 */
#T=全局变量-函数内声明
global $empire,$public_r,$dbtbpre;
#T=日期时间-格式化
<?=date('Y-m-d',$r[newstime])?>
<?php echo gmstrftime('%H时%M分%S秒',$bqr['shichang']); ?>
#T=手机端 - 跳转
<script type=”text/javascript”>
if(!(/pc=1/i.test(window.location.search)) && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))window.location = window.location.href.replace(/www.zhongyf.com/,'m.zhongyf.com');
</script>
#T=数据表 - 投稿数
[e:loop={'select * from (SELECT userid, username, COUNT( userid ) AS total FROM phome_ecms_news where (ismember = 1) AND (newstime > 1388709198) and userid in (select m.userid from phome_enewsmember m left join phome_enewsmembergroup g on m.groupid=g.groupid where g.groupid=1 ) GROUP BY userid,username) t order by total desc',10,24,1,'',''}]
未审核:<?$bqr[nocheck]=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_news_check where ismember=1 and userid='$bqr[userid]'");echo $bqr[nocheck];?>
未审核+合计:<?=$bqr[nocheck]+$bqr[total]?>
<li>
<table>
<tr>
<td width="78px" height="35px" style="border-bottom:1px dashed #ccc; text-indent:-40px;" align="center" ><?=$bqno?></td>
<td width="78px" height="35px" style="border-bottom:1px dashed #ccc;" align="center"><?=$bqr[username]?></td>
<td width="78px" height="35px" style="border-bottom:1px dashed #ccc;" align="center"><?=$bqr[total]?></td>
</tr>
</table>
</li>
[/e:loop]
#T=数据库 - left join -会员表
"select ".$fields." from ".eReturnMemberTable()." u LEFT JOIN {$dbtbpre}enewsmemberadd ui ON u.".egetmf('userid')."=ui.userid where u.".egetmf('userid')."='$uid' limit 1"
#T=数据库 - mysql日期函数大全
1.当日
select * from [!db.pre!]ecms_news where newstime>UNIX_TIMESTAMP(curdate())
2.一周内
[ecmsinfo]"select * from phome_ecms_news where newstime>SUBDATE(NOW(),INTERVAL 7 DAY) order by onclick desc limit 10",10,30,0,24,7,0[/ecmsinfo]
[e:loop={"select * from {$dbtbpre}ecms_news where FROM_UNIXTIME(newstime)>SUBDATE(NOW(),INTERVAL 7 DAY) order by onclick desc limit 10",0,24,0}]
<a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a> <br>
[/e:loop]
3.7日内
UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 7 DAY));
4.历史上的今天
<?
date_default_timezone_set(PRC);
$yue=date("n");
$ri=date("j");
?>
[e:loop={0,10,3,0,"month(FROM_UNIXTIME(newstime))=$yue and day(FROM_UNIXTIME(newstime))=$ri"}]
<li>
<a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a>
</li>
[/e:loop]
或者
<?php
$biaoName=$dbtbpre."请在这里输入表名,不用带前缀,比如:ecms_news";
$jieguo="";
$h = $empire->fetch1("select FROM_UNIXTIME(unix_timestamp(),'%m%d') as jieguo");
echo $h[jieguo];
?>
#T=数据库 - SQL随机快速
<!--code.start-->?php
require('../class/connect.php'); //引入数据库配置文件和公共函数文件
require('../class/db_sql.php'); //引入数据库操作文件
$link=db_connect(); //连接MYSQL
$empire=new mysqlquery(); //声明数据库操作类
?<!--code.end-->
<!--code.start-->?php
$sql="SELECT * FROM {$dbtbpre}ecms_news AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM {$dbtbpre}ecms_news )-(SELECT MIN(id) FROM {$dbtbpre}ecms_news))+(SELECT MIN(id)
FROM {$dbtbpre}ecms_news )) AS id) AS t2 WHERE t1.id >= t2.id ORDER BY t1.id LIMIT 1";
$str="";
$rid=array();
$i=0;
while($i<10){
$nr= $empire->fetch1($sql);
$titleurl=sys_ReturnBqTitleLink($nr);
if(in_array($nr['id'], $rid)){
} else {
$str=$str."<li><a href='".$titleurl."' title='".$nr['title']."'>".$nr['title']."</a></li> ";
$rid[]=$nr['id'];
$i=$i+1;
}
}
db_close(); //关闭MYSQL链接
$empire=null; //注消操作类变量
echo $str;
?<!--code.end-->
另外一种方法:
$sql="select group_concat(id) as total from {$dbtbpre}ecms_news where title regexp '尿床' ";
$idset=$empire->gettotal($sql);
$ids='';
$dh='';
$allids=explode(',',$idset);
// $hl=shuffle($allids);
$limit=min(10,count($allids));
$jhc=array_rand($allids,$limit);
foreach($jhc as $key=>$value){$ids.=$dh.$allids[$value];$dh=',';}
echo $ids;
#T=数据库 - sql最新信息
<?php
$classid=111;
$tbname=$class_r[$classid][tbname];
$newbook=$empire->query("select * from {$dbtbpre}ecms_{$tbname} where classid ={$classid} order by newstime desc limit 1");
while($yf=$empire->fetch($newbook)) {
?>
<div class="zhongyf"><a href="<?=sys_ReturnBqTitleLink($yf)?>" target="_blank"><img alt="<?=$yf[title]?>" src="<?=$yf[titlepic]?>"><?=$yf[title]?></a></div>
<?php
}
?>
#T=数据库 - 标题图片修复
update [!db.pre!]ecms_news a,[!db.pre!]enewsfile_1 b set a.titlepic=concat(substring_index(a.titlepic,'small',1),b.filename) where a.id=b.id and
a.classid=b.classid and locate(concat('small',substring_index(a.titlepic,'small',-1)),b.filename)>0
#T=数据库 - 点击数清0
执行sql语句:update phome_ecms_表 set onclick=0 where 条件;
#T=数据库 - 函数 mysql字符个数
select (length(name)-length(REPLACE(name, 'fei', '')))/length('fei') from user
#T=数据库 - 会员积分
// jiuhecai add begin
$hongfen=2;
$sql="update ".eReturnMemberTable()." a,{$dbtbpre}enewsmemberadd b set a.".egetmf('userfen')."=a.".egetmf('userfen')."+'$hongfen'";
$where=" where a.".egetmf('userid')."='$r[userid]' and b.".egetmf('userid')."='$r[userid]' and to_days(now())<>to_days(from_unixtime(b.lasttime))";
$empire->query($sql.$where);
//jiuhecai add end
#T=数据库 - 跨库访问
[e:loop={"select uid,username from bbs.bbs_common_member where avatarstatus!=0 order by uid desc limit 6",0,24}]
#T=数据库 - 跨数据库调用
帝国CMS灵动标签SQL调用任意数据表数据(例如Discuz,PHPwind) 帝国cms - 安全、强大、稳定、灵活
http://bbs.phome.net/showthread-31-353180-0.html
#T=数据库 - 去掉字段里的汉字
update 表名 set 字段名=replace(replace(convert(replace(字段名,'?','jiuhecailove') using ascii) ,'?',''),'jiuhecailove','?');
#T=数据库 - 统计推荐数
[e:loop={"select count(*) as mynum from {$dbtbpre}ecms_news where isgood>0",0,24,0}]<?=$bqr[mynum]?>[/e:loop]
#T=数据库 - 自定义连接
<?php
$keyword=urldecode($_GET["keyword"]);
echo($keyword);
if(strlen($keyword)<2){echo "please input keywords!";} else{
$conn=mysql_connect("localhost","root","kj02fei");
mysql_query("SET NAMES 'utf8'", $conn);
mysql_select_db("sq8zhongyf");
$sql="SELECT * FROM phome_ecms_news_data_1";
echo($sql);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
if(strpos($row["newstext"],$keyword)>0){
echo $row["id"]." ok!<br />";
}
}
mysql_close($conn);
}
?>
#T=数据库 SQL文中取图
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext, 'src=', -1),'.jpg',1),'"',''),'.jpg') where a.newstext like '%.jpg%' and b.titlepic='' and a.id=b.id;
// 提取第一张图片
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext, '.jpg', 1),'src=',-1),'"',''),'.jpg') where a.newstext like '%.jpg%' and b.titlepic='' and a.id=b.id;
#T=数据库 SQL语句拾贝
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.keyboard=a.infotags where a.id=b.id and b.keyboard='';//把tag复制到关键词
update [!db.pre!]ecms_news set onclick=onclick+增加数量; //批量增加点击数量
#T=数据库- 反馈表
$rzip=egetip();
$inum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsfeedback where ip='$rzip' and date_format(saytime,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')");
if($inum){
echo printerror2("IP".$rzip."今日已发一条反馈!");
exit; // date_format(saytime,'%Y-%m-%d') =curdate() , or to_days(saytime) =to_days(now()) , or date(saytime) =curdate()
}
#T=数据库--打开
require('../../class/connect.php'); //引入数据库配置文件和公共函数文件
require('../../class/db_sql.php'); //引入数据库操作文件
require("../../class/functions.php"); //引入基本函数库文件
require('../../data/dbcache/class.php'); //引入栏目缓存文件
$link=db_connect(); //连接MYSQL
$empire=new mysqlquery(); //声明数据库操作类
$editor=1; //声明目录层次
/*
函数需结合$editor变量来确定目录层次。默认$editor变量为0。
当程序文件在/e/path/目录,$editor不用设置,也就是用默认0。
当程序文件在/e/path/path2/目录,$editor=1。
当程序文件在/e/path/path2/path3/目录,$editor=2。
当程序文件在/e/path/path2/path3/path4/目录,$editor=3。
*/
#T=数据库--关闭
db_close(); //关闭MYSQL链接
$empire=null; //注消操作类变量
#T=数据库-取多条记录
$sql=$empire->query("select * from {$dbtbpre}ecms_news");
while($r=$empire->fetch($sql))
{
echo"标题:".$r['title']."<br>";
}
#T=数据库-取一条记录
$rs=$empire->fetch1($sql);
#T=数据库-全局变量
global $empire;
#T=图片 - 返回图片地址
//文件
$fspath=ReturnFileSavePath($r[classid],$r[fpath]);
$filepath=$r[path]?$r[path].'/':$r[path];
$file=$fspath['fileurl'].$filepath.$r[filename];
#T=图片 - 图集
<?php
$arr = array();
$arr = $navinfor['morepic'];
$newarr = explode(egetzy('rn'),$arr);
$count = count(explode(egetzy('rn'),$navinfor[morepic]));//图集的图片数量
for($i=0;$i<$count;$i++)
{
$s_arr = array();
$s_arr[] = $newarr[$i];
$str = $s_arr[0];
$bot_arr = explode("::::::", $str);
$spic = $bot_arr[0];//小图
$bpic = $bot_arr[1];//大图
$picinfo = $bot_arr[2];//图片说明
echo '<img src="'.$spic.'" data-large="'.$bpic.'" alt="'.$picinfo.'" width="65" height="65" />';
}
?>
morepic 属于图片集多值字段,通常在附表。第一分隔符rn,可以用egetzy('rn')代替 ,第二分隔符::::::(6个冒号)
jiuhecai 的发明,用正则来写
<?
preg_match_all("/(.*)::::::(.*)::::::(.*)/",$navinfor['morepic'],$morepic);
?>
<li><div class="pic"><a href=""><img class="vcenter" src="<?=$morepic[2][0]?>" alt="<?=$morepic[3][0]?>" /></a></div></li>
<li><div class="pic"><a href=""><img class="vcenter" src="<?=$morepic[2][1]?>" alt="<?=$morepic[3][0]?>" /></a></div></li>
<li><div class="pic"><a href=""><img class="vcenter" src="<?=$morepic[2][2]?>" alt="<?=$morepic[3][0]?>" /></a></div></li>
#T=图片- 缩率图 - 调用小图
<?php
$r['titlepic']="/d/file/dianzibao/yuandan/20170528/2e3c1e1725c040bc93a23c1feb511d42.jpg";
echo dirname($r['titlepic']).'/small'.basename($r['titlepic']);
?>
or:
<?$pos=strrpos($bqr['titlepic'],'/');echo substr($bqr['titlepic'],0,$pos).'/small'.substr($bqr['titlepic'],$pos+1,strlen($bqr['titlepic']));?>
#T=图片- 提取
$pattern="/<[img|IMG].*?src=['|"](.*?(?:[.gif|.jpg]))['|"].*?[/]?>/";
$preg = "/<[img|IMG].*?src=['|"](.*?(?:[.gif|.jpg]))['|"].*?[/]?>/i";
#T=图片- 统计图片数
function totalimg($day){ //统计图片数
global $empire,$dbtbpre;
if($day)
{
if($day==1)//今日信息
{
$date=date("Y-m-d");
$starttime=$date." 00:00:01";
$endtime=$date." 23:59:59";
}
elseif($day==2)//本月信息
{
$date=date("Y-m");
$starttime=$date."-01 00:00:01";
$endtime=$date."-".date("t")." 23:59:59";
}
elseif($day==3)//本年信息
{
$date=date("Y");
$starttime=$date."-01-01 00:00:01";
$endtime=($date+1)."-01-01 00:00:01";
}
$and=" newstime>=".to_time($starttime)." and newstime<=".to_time($endtime);
}
$query="select count(*) as total from {$dbtbpre}ecms_photo where ".$and;
$num=$empire->gettotal($query);
if(!empty($num)){
$tj=$empire->query("select morepic from {$dbtbpre}ecms_photo_data_1 limit $num");
while($rs=$empire->fetch($tj)) {
$morepic=$rs['morepic'];
$rexp=egetzy('rn');
$rr=explode($rexp,$morepic);
$count+=count($rr);
}
echo $count;
}
else{echo 0;}
}
#T=图片集 - 大小图 数量
<?php
$picr=explode(egetzy('rn'),$navinfor[morepic]);
for($p=0;$p<count($picr);$p++)
{
$pic=explode("::::::",$picr[$p]);// 0缩略图,1大图,2图片名称
?>
<li data-sPic="<?=$pic[1]?>"> <img src="<?=$pic[0]?>"> </li>
<?php
}
?>
内容模板调用图集数量:
<?
$pic=explode(egetzy("rn"),$navinfor[morepic]);
echo count($pic);
?>
<?php
$morepic_num=empty($navinfor[morepic])?0:count(explode(chr(13),$navinfor[morepic]));
echo $morepic_num;
?>
#T=图像处理 - 资源
$file=fopen("f.txt","r"); //打开文件
$con=mysql_connect("localhost","root","root"); //连接数据库
$img=imagecreate(100,100);//图形画布
#T=网站关键词
$pr=$empire->fetch1("select sitekey,siteintro,indexpagedt from {$dbtbpre}enewspublic limit 1");
if($pr['indexpagedt']||(Moreport_ReturnMustDt()&&!defined('ECMS_SELFPATH')))//moreport
{
return '';
}
//页面
$pagetitle=ehtmlspecialchars($public_r['sitename']);
$pagekey=ehtmlspecialchars($pr['sitekey']);
$pagedes=ehtmlspecialchars($pr['siteintro']);
#T=网站缩略图
http://api.webthumbnail.org/?width=480&height=330&screen=1280&url=www.a1hyz.com
#T=文件 打开fopen
//首先采用“fopen”函数打开文件,得到返回值的就是资源类型。
$file_handle = fopen("/data/webroot/resource/php/f.txt","r");
if ($file_handle){
//接着采用while循环(后面语言结构语句中的循环结构会详细介绍)一行行地读取文件,然后输出每行的文字
while (!feof($file_handle)) { //判断是否到最后一行
$line = fgets($file_handle); //读取一行文本
echo $line; //输出一行文本
echo "<br />"; //换行
}
}
fclose($file_handle);//关闭文件
#T=文件- 导入
/*
导入栏目、专题、标题分类缓存文件:/e/data/dbcache/class.php
导入会员组缓存文件:/e/data/dbcache/MemberLevel.php
导入标签函数文件:/e/class/t_functions.php
导入编译标签文件:/e/class/functions.php
*/
#T=文件-引入-包含
require("setup.php");
require(ECMS_PATH.'e/template/incfile/header.php');
#T=文件下载 - 代码
<?php
$file = '.'.'/d/txt/123453.txt';
// $out_filename = $r['title'].'.txt';
$down_name="武林外传123.txt";
if(!file_exists($file)){
echo '没有找到' .$down_name;
exit;
}
else
{
$fp = fopen($file,"r");
$file_size = filesize($file);
//下载文件需要用到的头
header("Content-type: application/octet-stream");
header("Accept-Ranges: bytes");
header("Accept-Length:".$file_size);
header("Content-Disposition: attachment; filename=".$down_name);
$buffer = 1024;
$file_count = 0;
//向浏览器返回数据
while(!feof($fp) && $file_count < $file_size){
$file_con = fread($fp,$buffer);
$file_count += $buffer;
echo $file_con;
}
fclose($fp);
exit;
}
?>
或者
<?php
$filename = '.'.'/d/txt/123453.txt';
// $out_filename = $r['title'].'.txt';
$out_filename="武林外传123.txt";
if(!file_exists($filename)){
echo '没有找到' .$out_filename;
exit;
}
else
{
@header("Content-Type: application/force-download");
@header("Content-Disposition: attachment; filename=".$out_filename);
$file = @fopen($filename, "r");
echo @fread($file, @filesize($filename));
@fclose($file);
exit;
}
?>
#T=销毁cookie和session
//销毁SESSION和COOKIE
function exterminate() {
$_SESSION = array();
foreach ( $_COOKIE as $key ) {
setcookie($key, null);
}
session_destroy();
$_COOKIE = array();
return true;
}
#T=页面 - 自定义
[e:loop={"select *,b.classname as classname from [!db.pre!]enewspage a left join [!db.pre!]enewspageclass b on a.classid=b.classid",0,24}]
<?echo $bqr[title],'...'.$bqr[classname].'</br>';?>
[/e:loop]
#T=移动信息 - 删除原信息文件
移动后删除信息文件的修正:
在文件/e/class/hinfofun.php的函数
//移动信息
function MoveNews_all($classid,$id,$to_classid,$userid,$username){
中,查找
//返回表信息
$infotbr=ReturnInfoTbname($tbname,$index_r['checked'],$r['stb']);
在其后增加语句:
//jiuhecai add 删除信息文件,未审核的因为没有信息文件,所以不用删除
if($index_r['checked']){
$mid=$class_r[$classid][modid];
$pf=$emod_r[$mid]['pagef'];
$stf=$emod_r[$mid]['savetxtf'];
if($pf)
{
if(strstr($emod_r[$mid]['tbdataf'],','.$pf.','))
{
$jhcr=$empire->fetch1("select ".$pf." from {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." where id='{$id[$i]}'");
$r[$pf]=$jhcr[$pf];
}
if($stf&&$stf==$pf)//存放文本
{
$r[$pf]=GetTxtFieldText($r[$pf]);
}
}
DelNewsFile($r[filename],$r[newspath],$r[classid],$r[$pf],$r[groupid]);
}
//jiuhecai end
即可。
进一步 随后的语句中
//更新信息附加表
UpdateSingleInfoOtherData($r['classid'],$id[$i],$to_classid,$r,0,0);
//jiuhecai add 生成新的信息表
GetHtml($to_classid,$id[$i],'',0,1);
//jiuhecai end
这样处理后,就可以生成新的信息了。
#T=用户- 验证
//验证用户
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
#T=友情链接js
自定义JS
select lname as title,lurl as titleurl from [!db.pre!]enewslink where classid=1 order by lid
然后JS模板
[!--empirenews.listtemp--]<li><a href="[!--titleurl--]" title="[!--title--]">[!--title--]</a></li>[!--empirenews.listtemp--]
#T=语言包 - 导入
require ECMS_PATH.'e/data/'.LoadLang('pub/fun.php');
/*
导入语言包文件地址是相对于 ../data/language/ 目录,例子:
(1)、如果程序文件在/e/extend/目录,比如:/e/extend/a.php,则导入语言包可以用:
require LoadLang('pub/fun.php');
(2)、如果程序文件在/e/extend/helloworld/目录,比如:/e/extend/helloworld/a.php,则导入语言包可以用:
require '../'.LoadLang('pub/fun.php');
(3)、如果程序文件在根目录,比如:/a.php,则导入语言包可以用:
require ECMS_PATH.'e/data/'.LoadLang('pub/fun.php');
*/
#T=找不见的操作
修改栏目目录后要重新更新信息页地址:后台-系统-数据更新-更新信息页地址
#T=专题 - 灵动标签
帝国CMS内置的专题调用标签总是不理想,调用不方便,还是灵动标签调用来得方便实在。
代码:
[e:loop={'select ztid,ztname,ztimg,maxnum,intro,onclick,ztpath from [!db.pre!]enewszt where showzt=1 order by ztid limit 8',10,24,0}]
<li>
<div class="i"><a href="<?=$public_r[newsurl]?><?=$bqr[ztpath]?>" target="_blank"><img src="<?=$bqr[ztimg]?>" alt="<?=$bqr[ztname]?>" width="150px" height="100px" /></a></div>
<div class="t"><a href="<?=$public_r[newsurl]?><?=$bqr[ztpath]?>" target="_blank"><?=$bqr[ztname]?></a></div>
<div class="s"><?=$bqr[intro]?></div>
<div class="s"><span class="l"><?=$bqr[onclick]?>次点击</span><span class="fr"><?=$bqr[maxnum]?>首</span></div>
</li>
[/e:loop]
enewszt 为专题表,要调用专题什么信息就查询什么字段。
showzt=1 为专题分类ID,如要调用多个专类分类, showzt=1 改成:showzt in(1,2,3,4,5,6,7)
#T=专题 - 专题地址 专题字段
专题地址用:/<?=$class_zr[$GLOBALS[navclassid]][ztpath]?>
使用内置调用专题自定义字段函数:ReturnZtAddField(专题ID,字段名),专题ID=0为当前专题ID。取多个字段内容可用逗号隔开,例子:
取得'classtext'字段内容:$value=ReturnZtAddField(0,'classtext'); //$value就是字段内容。
取得多个字段内容:$value=ReturnZtAddField(1,'ztid,classtext'); //$value['classtext']才是字段内容。
#T=自定义页面
/*
帝国CMS使用技巧之调用自定义页面
我们做单页(比如“公司介绍”、“联系我们”等页面)时一般采用自定义页面来做,而调用出自定义页面导航可以用标签SQL调用。如下:
<!--调用自定义页面分类ID=1的页面导航-->
[e:loop={'select id,path,title from [!db.pre!]enewspage where classid=1 order by id limit 20',24}]
<?php
$pageurl=$public_r['newsurl'].str_replace('../../','',$bqr['path']);
?>
<li><a href="<?=$pageurl?>"><?=$bqr[title]?></a></li>
[/e:loop]
例子2:调用自定义页面导航并识别当前自定义页面
[e:loop={'select id,path,title from [!db.pre!]enewspage where classid=1 order by id limit 20',0,24}]
<?php
$pageurl=$public_r['newsurl'].str_replace('../../','',$bqr['path']);
$css='pagecss';
if($classid=='page'.$bqr[id])
{
$css='selfpagecss';
}
?>
<li class="<?=$css?>"><a href="<?=$pageurl?>"><?=$bqr[title]?></a></li>
[/e:loop]
#T=字段 - 存文本 - 读取
<?php
if($emod_r[$mid]['savetxtf']&&$emod_r[$mid]['savetxtf']==$f)//存文本
{
$val=stripSlashes(GetTxtFieldText($val));
}
?>
#T=字段 - 用灵动复杂读取
[e:loop={34,1,0,0}]
<?php
$f='newstext';
$mid=$class_r[$bqr[classid]][modid];
$tbdataf=$emod_r[$mid][tbdataf];
if(strstr($tbdataf,','.$f.',')){
$tbname="{$dbtbpre}ecms_{$class_r[$bqr[classid]][tbname]}_data_{$bqr[stb]}";
}else{
$tbname="{$dbtbpre}ecms_{$class_r[$bqr[classid]][tbname]}";
}
$fr=$empire->fetch1("select newstext from $tbname where id='$bqr[id]'");?>
<?
if($emod_r[$mid]['savetxtf']&&$emod_r[$mid]['savetxtf']==$f)//存文本
{
$fr[newstext]=GetTxtFieldText($fr[newstext]);
}
echo esub(stripslashes($fr[newstext]),10000)
?>
[/e:loop]
#指定栏目或者当前栏目下随机信息
<?php
$classid=1; //指定id,当前为 $navclassid
$limit=7; // 七条
$tbname='news';
list(,$classids)=sys_ReturnMoreClass($classid,1);
$ids=$empire->gettotal("select group_concat(id) as total from {$dbtbpre}ecms_{$tbname} where $classids");
$idsr=explode(',',$ids);
$max=count($idsr)-1;
$ids=array();
$i=0;
while($i<$limit){
$key=rand(0,$max);
if(array_key_exists($key,$ids))continue;
$ids[$key]=$idsr[$key];$i++;
}
$rand=implode(',',$ids);
?>
[e:loop={"select * from {$dbtbpre}ecms_{$tbname} where id in($rand) limit $limit",0,24}]
<a href="<?=$bqsr['titleurl']?>"><?=$bqr[title]?></a>
[/e:loop]
#数据库插入
function r2sql($r)
$jhc='';
foreach($r as $key=>$value){if(!is_numeric($key))$jhc.=$key."='".$value."',";}
return rtrim($jhc,',');
}
#t=print
printerror2("DbError","history.go(-1)");
#t=tags
$infotagsr=explode(',',$r['infotags']);
$r[title]=addslashes($r[title]);
$sql=$empire->query("select tagname,tagid from {$dbtbpre}enewstags where locate(tagname,'$r[title]')>0");
while($jhcr=$empire->fetch($sql)){
if(in_array($jhcr[tagname],$infotagsr))continue;
$infotagsr[]=$jhcr[tagname];
$empire->query("update {$dbtbpre}enewstags set num=num+1 where tagid='$jhcr[tagid]'");
$classid=(int)$r[classid];
$mid=(int)$class_r[$classid][modid];
$empire->query("insert into {$dbtbpre}enewstagsdata set tagid={$jhcr[tagid]},classid=$classid,id={$r[id]},newstime='$r[newstime]',mid=$mid");
}
$r['infotags']=trim(implode(',',$infotagsr),',');
$listtemp='infotags';
#sql union
"SELECT titlepic AS titlepic,yuyan AS yuyan FROM www_jiuxz_com_ecms_azsoft where title like '%$guanjianci%' UNION SELECT titlepic AS titlepic,yuyan AS yuyan FROM www_jiuxz_com_ecms_azgame where title like '%$guanjianci%'"
# js 判断js是否屏蔽
<div id="NoJs" >你禁用了javascript。你真操蛋!我要给你看公告</div>
<script>document.getElementById("NoJs").style.display="none"; </script>
$pgcount=count($pg);
?>
内容分页数量:<?=$pgcount?>
#T=权限 - 验证
//验证权限
CheckLevel($logininid,$loginin,$classid,"totaldata");
/* http://www.zhongyf.com/qita/rj/2015-10-24/97501.html 这里有权限检测代码大全 */
#T=全局变量-函数内声明
global $empire,$public_r,$dbtbpre;
#T=日期时间-格式化
<?=date('Y-m-d',$r[newstime])?>
<?php echo gmstrftime('%H时%M分%S秒',$bqr['shichang']); ?>
#T=手机端 - 跳转
<script type=”text/javascript”>
if(!(/pc=1/i.test(window.location.search)) && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))window.location = window.location.href.replace(/www.zhongyf.com/,'m.zhongyf.com');
</script>
#T=数据表 - 投稿数
[e:loop={'select * from (SELECT userid, username, COUNT( userid ) AS total FROM phome_ecms_news where (ismember = 1) AND (newstime > 1388709198) and userid in (select m.userid from phome_enewsmember m left join phome_enewsmembergroup g on m.groupid=g.groupid where g.groupid=1 ) GROUP BY userid,username) t order by total desc',10,24,1,'',''}]
未审核:<?$bqr[nocheck]=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_news_check where ismember=1 and userid='$bqr[userid]'");echo $bqr[nocheck];?>
未审核+合计:<?=$bqr[nocheck]+$bqr[total]?>
<li>
<table>
<tr>
<td width="78px" height="35px" style="border-bottom:1px dashed #ccc; text-indent:-40px;" align="center" ><?=$bqno?></td>
<td width="78px" height="35px" style="border-bottom:1px dashed #ccc;" align="center"><?=$bqr[username]?></td>
<td width="78px" height="35px" style="border-bottom:1px dashed #ccc;" align="center"><?=$bqr[total]?></td>
</tr>
</table>
</li>
[/e:loop]
#T=数据库 - left join -会员表
"select ".$fields." from ".eReturnMemberTable()." u LEFT JOIN {$dbtbpre}enewsmemberadd ui ON u.".egetmf('userid')."=ui.userid where u.".egetmf('userid')."='$uid' limit 1"
#T=数据库 - mysql日期函数大全
1.当日
select * from [!db.pre!]ecms_news where newstime>UNIX_TIMESTAMP(curdate())
2.一周内
[ecmsinfo]"select * from phome_ecms_news where newstime>SUBDATE(NOW(),INTERVAL 7 DAY) order by onclick desc limit 10",10,30,0,24,7,0[/ecmsinfo]
[e:loop={"select * from {$dbtbpre}ecms_news where FROM_UNIXTIME(newstime)>SUBDATE(NOW(),INTERVAL 7 DAY) order by onclick desc limit 10",0,24,0}]
<a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a> <br>
[/e:loop]
3.7日内
UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 7 DAY));
4.历史上的今天
<?
date_default_timezone_set(PRC);
$yue=date("n");
$ri=date("j");
?>
[e:loop={0,10,3,0,"month(FROM_UNIXTIME(newstime))=$yue and day(FROM_UNIXTIME(newstime))=$ri"}]
<li>
<a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a>
</li>
[/e:loop]
或者
<?php
$biaoName=$dbtbpre."请在这里输入表名,不用带前缀,比如:ecms_news";
$jieguo="";
$h = $empire->fetch1("select FROM_UNIXTIME(unix_timestamp(),'%m%d') as jieguo");
echo $h[jieguo];
?>
#T=数据库 - SQL随机快速
<!--code.start-->?php
require('../class/connect.php'); //引入数据库配置文件和公共函数文件
require('../class/db_sql.php'); //引入数据库操作文件
$link=db_connect(); //连接MYSQL
$empire=new mysqlquery(); //声明数据库操作类
?<!--code.end-->
<!--code.start-->?php
$sql="SELECT * FROM {$dbtbpre}ecms_news AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM {$dbtbpre}ecms_news )-(SELECT MIN(id) FROM {$dbtbpre}ecms_news))+(SELECT MIN(id)
FROM {$dbtbpre}ecms_news )) AS id) AS t2 WHERE t1.id >= t2.id ORDER BY t1.id LIMIT 1";
$str="";
$rid=array();
$i=0;
while($i<10){
$nr= $empire->fetch1($sql);
$titleurl=sys_ReturnBqTitleLink($nr);
if(in_array($nr['id'], $rid)){
} else {
$str=$str."<li><a href='".$titleurl."' title='".$nr['title']."'>".$nr['title']."</a></li> ";
$rid[]=$nr['id'];
$i=$i+1;
}
}
db_close(); //关闭MYSQL链接
$empire=null; //注消操作类变量
echo $str;
?<!--code.end-->
另外一种方法:
$sql="select group_concat(id) as total from {$dbtbpre}ecms_news where title regexp '尿床' ";
$idset=$empire->gettotal($sql);
$ids='';
$dh='';
$allids=explode(',',$idset);
// $hl=shuffle($allids);
$limit=min(10,count($allids));
$jhc=array_rand($allids,$limit);
foreach($jhc as $key=>$value){$ids.=$dh.$allids[$value];$dh=',';}
echo $ids;
#T=数据库 - sql最新信息
<?php
$classid=111;
$tbname=$class_r[$classid][tbname];
$newbook=$empire->query("select * from {$dbtbpre}ecms_{$tbname} where classid ={$classid} order by newstime desc limit 1");
while($yf=$empire->fetch($newbook)) {
?>
<div class="zhongyf"><a href="<?=sys_ReturnBqTitleLink($yf)?>" target="_blank"><img alt="<?=$yf[title]?>" src="<?=$yf[titlepic]?>"><?=$yf[title]?></a></div>
<?php
}
?>
#T=数据库 - 标题图片修复
update [!db.pre!]ecms_news a,[!db.pre!]enewsfile_1 b set a.titlepic=concat(substring_index(a.titlepic,'small',1),b.filename) where a.id=b.id and
a.classid=b.classid and locate(concat('small',substring_index(a.titlepic,'small',-1)),b.filename)>0
#T=数据库 - 点击数清0
执行sql语句:update phome_ecms_表 set onclick=0 where 条件;
#T=数据库 - 函数 mysql字符个数
select (length(name)-length(REPLACE(name, 'fei', '')))/length('fei') from user
#T=数据库 - 会员积分
// jiuhecai add begin
$hongfen=2;
$sql="update ".eReturnMemberTable()." a,{$dbtbpre}enewsmemberadd b set a.".egetmf('userfen')."=a.".egetmf('userfen')."+'$hongfen'";
$where=" where a.".egetmf('userid')."='$r[userid]' and b.".egetmf('userid')."='$r[userid]' and to_days(now())<>to_days(from_unixtime(b.lasttime))";
$empire->query($sql.$where);
//jiuhecai add end
#T=数据库 - 跨库访问
[e:loop={"select uid,username from bbs.bbs_common_member where avatarstatus!=0 order by uid desc limit 6",0,24}]
#T=数据库 - 跨数据库调用
帝国CMS灵动标签SQL调用任意数据表数据(例如Discuz,PHPwind) 帝国cms - 安全、强大、稳定、灵活
http://bbs.phome.net/showthread-31-353180-0.html
#T=数据库 - 去掉字段里的汉字
update 表名 set 字段名=replace(replace(convert(replace(字段名,'?','jiuhecailove') using ascii) ,'?',''),'jiuhecailove','?');
#T=数据库 - 统计推荐数
[e:loop={"select count(*) as mynum from {$dbtbpre}ecms_news where isgood>0",0,24,0}]<?=$bqr[mynum]?>[/e:loop]
#T=数据库 - 自定义连接
<?php
$keyword=urldecode($_GET["keyword"]);
echo($keyword);
if(strlen($keyword)<2){echo "please input keywords!";} else{
$conn=mysql_connect("localhost","root","kj02fei");
mysql_query("SET NAMES 'utf8'", $conn);
mysql_select_db("sq8zhongyf");
$sql="SELECT * FROM phome_ecms_news_data_1";
echo($sql);
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
if(strpos($row["newstext"],$keyword)>0){
echo $row["id"]." ok!<br />";
}
}
mysql_close($conn);
}
?>
#T=数据库 SQL文中取图
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext, 'src=', -1),'.jpg',1),'"',''),'.jpg') where a.newstext like '%.jpg%' and b.titlepic='' and a.id=b.id;
// 提取第一张图片
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext, '.jpg', 1),'src=',-1),'"',''),'.jpg') where a.newstext like '%.jpg%' and b.titlepic='' and a.id=b.id;
#T=数据库 SQL语句拾贝
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.keyboard=a.infotags where a.id=b.id and b.keyboard='';//把tag复制到关键词
update [!db.pre!]ecms_news set onclick=onclick+增加数量; //批量增加点击数量
#T=数据库- 反馈表
$rzip=egetip();
$inum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsfeedback where ip='$rzip' and date_format(saytime,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')");
if($inum){
echo printerror2("IP".$rzip."今日已发一条反馈!");
exit; // date_format(saytime,'%Y-%m-%d') =curdate() , or to_days(saytime) =to_days(now()) , or date(saytime) =curdate()
}
#T=数据库--打开
require('../../class/connect.php'); //引入数据库配置文件和公共函数文件
require('../../class/db_sql.php'); //引入数据库操作文件
require("../../class/functions.php"); //引入基本函数库文件
require('../../data/dbcache/class.php'); //引入栏目缓存文件
$link=db_connect(); //连接MYSQL
$empire=new mysqlquery(); //声明数据库操作类
$editor=1; //声明目录层次
/*
函数需结合$editor变量来确定目录层次。默认$editor变量为0。
当程序文件在/e/path/目录,$editor不用设置,也就是用默认0。
当程序文件在/e/path/path2/目录,$editor=1。
当程序文件在/e/path/path2/path3/目录,$editor=2。
当程序文件在/e/path/path2/path3/path4/目录,$editor=3。
*/
#T=数据库--关闭
db_close(); //关闭MYSQL链接
$empire=null; //注消操作类变量
#T=数据库-取多条记录
$sql=$empire->query("select * from {$dbtbpre}ecms_news");
while($r=$empire->fetch($sql))
{
echo"标题:".$r['title']."<br>";
}
#T=数据库-取一条记录
$rs=$empire->fetch1($sql);
#T=数据库-全局变量
global $empire;
#T=图片 - 返回图片地址
//文件
$fspath=ReturnFileSavePath($r[classid],$r[fpath]);
$filepath=$r[path]?$r[path].'/':$r[path];
$file=$fspath['fileurl'].$filepath.$r[filename];
#T=图片 - 图集
<?php
$arr = array();
$arr = $navinfor['morepic'];
$newarr = explode(egetzy('rn'),$arr);
$count = count(explode(egetzy('rn'),$navinfor[morepic]));//图集的图片数量
for($i=0;$i<$count;$i++)
{
$s_arr = array();
$s_arr[] = $newarr[$i];
$str = $s_arr[0];
$bot_arr = explode("::::::", $str);
$spic = $bot_arr[0];//小图
$bpic = $bot_arr[1];//大图
$picinfo = $bot_arr[2];//图片说明
echo '<img src="'.$spic.'" data-large="'.$bpic.'" alt="'.$picinfo.'" width="65" height="65" />';
}
?>
morepic 属于图片集多值字段,通常在附表。第一分隔符rn,可以用egetzy('rn')代替 ,第二分隔符::::::(6个冒号)
jiuhecai 的发明,用正则来写
<?
preg_match_all("/(.*)::::::(.*)::::::(.*)/",$navinfor['morepic'],$morepic);
?>
<li><div class="pic"><a href=""><img class="vcenter" src="<?=$morepic[2][0]?>" alt="<?=$morepic[3][0]?>" /></a></div></li>
<li><div class="pic"><a href=""><img class="vcenter" src="<?=$morepic[2][1]?>" alt="<?=$morepic[3][0]?>" /></a></div></li>
<li><div class="pic"><a href=""><img class="vcenter" src="<?=$morepic[2][2]?>" alt="<?=$morepic[3][0]?>" /></a></div></li>
#T=图片- 缩率图 - 调用小图
<?php
$r['titlepic']="/d/file/dianzibao/yuandan/20170528/2e3c1e1725c040bc93a23c1feb511d42.jpg";
echo dirname($r['titlepic']).'/small'.basename($r['titlepic']);
?>
or:
<?$pos=strrpos($bqr['titlepic'],'/');echo substr($bqr['titlepic'],0,$pos).'/small'.substr($bqr['titlepic'],$pos+1,strlen($bqr['titlepic']));?>
#T=图片- 提取
$pattern="/<[img|IMG].*?src=['|"](.*?(?:[.gif|.jpg]))['|"].*?[/]?>/";
$preg = "/<[img|IMG].*?src=['|"](.*?(?:[.gif|.jpg]))['|"].*?[/]?>/i";
#T=图片- 统计图片数
function totalimg($day){ //统计图片数
global $empire,$dbtbpre;
if($day)
{
if($day==1)//今日信息
{
$date=date("Y-m-d");
$starttime=$date." 00:00:01";
$endtime=$date." 23:59:59";
}
elseif($day==2)//本月信息
{
$date=date("Y-m");
$starttime=$date."-01 00:00:01";
$endtime=$date."-".date("t")." 23:59:59";
}
elseif($day==3)//本年信息
{
$date=date("Y");
$starttime=$date."-01-01 00:00:01";
$endtime=($date+1)."-01-01 00:00:01";
}
$and=" newstime>=".to_time($starttime)." and newstime<=".to_time($endtime);
}
$query="select count(*) as total from {$dbtbpre}ecms_photo where ".$and;
$num=$empire->gettotal($query);
if(!empty($num)){
$tj=$empire->query("select morepic from {$dbtbpre}ecms_photo_data_1 limit $num");
while($rs=$empire->fetch($tj)) {
$morepic=$rs['morepic'];
$rexp=egetzy('rn');
$rr=explode($rexp,$morepic);
$count+=count($rr);
}
echo $count;
}
else{echo 0;}
}
#T=图片集 - 大小图 数量
<?php
$picr=explode(egetzy('rn'),$navinfor[morepic]);
for($p=0;$p<count($picr);$p++)
{
$pic=explode("::::::",$picr[$p]);// 0缩略图,1大图,2图片名称
?>
<li data-sPic="<?=$pic[1]?>"> <img src="<?=$pic[0]?>"> </li>
<?php
}
?>
内容模板调用图集数量:
<?
$pic=explode(egetzy("rn"),$navinfor[morepic]);
echo count($pic);
?>
<?php
$morepic_num=empty($navinfor[morepic])?0:count(explode(chr(13),$navinfor[morepic]));
echo $morepic_num;
?>
#T=图像处理 - 资源
$file=fopen("f.txt","r"); //打开文件
$con=mysql_connect("localhost","root","root"); //连接数据库
$img=imagecreate(100,100);//图形画布
#T=网站关键词
$pr=$empire->fetch1("select sitekey,siteintro,indexpagedt from {$dbtbpre}enewspublic limit 1");
if($pr['indexpagedt']||(Moreport_ReturnMustDt()&&!defined('ECMS_SELFPATH')))//moreport
{
return '';
}
//页面
$pagetitle=ehtmlspecialchars($public_r['sitename']);
$pagekey=ehtmlspecialchars($pr['sitekey']);
$pagedes=ehtmlspecialchars($pr['siteintro']);
#T=网站缩略图
http://api.webthumbnail.org/?width=480&height=330&screen=1280&url=www.a1hyz.com
#T=文件 打开fopen
//首先采用“fopen”函数打开文件,得到返回值的就是资源类型。
$file_handle = fopen("/data/webroot/resource/php/f.txt","r");
if ($file_handle){
//接着采用while循环(后面语言结构语句中的循环结构会详细介绍)一行行地读取文件,然后输出每行的文字
while (!feof($file_handle)) { //判断是否到最后一行
$line = fgets($file_handle); //读取一行文本
echo $line; //输出一行文本
echo "<br />"; //换行
}
}
fclose($file_handle);//关闭文件
#T=文件- 导入
/*
导入栏目、专题、标题分类缓存文件:/e/data/dbcache/class.php
导入会员组缓存文件:/e/data/dbcache/MemberLevel.php
导入标签函数文件:/e/class/t_functions.php
导入编译标签文件:/e/class/functions.php
*/
#T=文件-引入-包含
require("setup.php");
require(ECMS_PATH.'e/template/incfile/header.php');
#T=文件下载 - 代码
<?php
$file = '.'.'/d/txt/123453.txt';
// $out_filename = $r['title'].'.txt';
$down_name="武林外传123.txt";
if(!file_exists($file)){
echo '没有找到' .$down_name;
exit;
}
else
{
$fp = fopen($file,"r");
$file_size = filesize($file);
//下载文件需要用到的头
header("Content-type: application/octet-stream");
header("Accept-Ranges: bytes");
header("Accept-Length:".$file_size);
header("Content-Disposition: attachment; filename=".$down_name);
$buffer = 1024;
$file_count = 0;
//向浏览器返回数据
while(!feof($fp) && $file_count < $file_size){
$file_con = fread($fp,$buffer);
$file_count += $buffer;
echo $file_con;
}
fclose($fp);
exit;
}
?>
或者
<?php
$filename = '.'.'/d/txt/123453.txt';
// $out_filename = $r['title'].'.txt';
$out_filename="武林外传123.txt";
if(!file_exists($filename)){
echo '没有找到' .$out_filename;
exit;
}
else
{
@header("Content-Type: application/force-download");
@header("Content-Disposition: attachment; filename=".$out_filename);
$file = @fopen($filename, "r");
echo @fread($file, @filesize($filename));
@fclose($file);
exit;
}
?>
#T=销毁cookie和session
//销毁SESSION和COOKIE
function exterminate() {
$_SESSION = array();
foreach ( $_COOKIE as $key ) {
setcookie($key, null);
}
session_destroy();
$_COOKIE = array();
return true;
}
#T=页面 - 自定义
[e:loop={"select *,b.classname as classname from [!db.pre!]enewspage a left join [!db.pre!]enewspageclass b on a.classid=b.classid",0,24}]
<?echo $bqr[title],'...'.$bqr[classname].'</br>';?>
[/e:loop]
#T=移动信息 - 删除原信息文件
移动后删除信息文件的修正:
在文件/e/class/hinfofun.php的函数
//移动信息
function MoveNews_all($classid,$id,$to_classid,$userid,$username){
中,查找
//返回表信息
$infotbr=ReturnInfoTbname($tbname,$index_r['checked'],$r['stb']);
在其后增加语句:
//jiuhecai add 删除信息文件,未审核的因为没有信息文件,所以不用删除
if($index_r['checked']){
$mid=$class_r[$classid][modid];
$pf=$emod_r[$mid]['pagef'];
$stf=$emod_r[$mid]['savetxtf'];
if($pf)
{
if(strstr($emod_r[$mid]['tbdataf'],','.$pf.','))
{
$jhcr=$empire->fetch1("select ".$pf." from {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." where id='{$id[$i]}'");
$r[$pf]=$jhcr[$pf];
}
if($stf&&$stf==$pf)//存放文本
{
$r[$pf]=GetTxtFieldText($r[$pf]);
}
}
DelNewsFile($r[filename],$r[newspath],$r[classid],$r[$pf],$r[groupid]);
}
//jiuhecai end
即可。
进一步 随后的语句中
//更新信息附加表
UpdateSingleInfoOtherData($r['classid'],$id[$i],$to_classid,$r,0,0);
//jiuhecai add 生成新的信息表
GetHtml($to_classid,$id[$i],'',0,1);
//jiuhecai end
这样处理后,就可以生成新的信息了。
#T=用户- 验证
//验证用户
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
#T=友情链接js
自定义JS
select lname as title,lurl as titleurl from [!db.pre!]enewslink where classid=1 order by lid
然后JS模板
[!--empirenews.listtemp--]<li><a href="[!--titleurl--]" title="[!--title--]">[!--title--]</a></li>[!--empirenews.listtemp--]
#T=语言包 - 导入
require ECMS_PATH.'e/data/'.LoadLang('pub/fun.php');
/*
导入语言包文件地址是相对于 ../data/language/ 目录,例子:
(1)、如果程序文件在/e/extend/目录,比如:/e/extend/a.php,则导入语言包可以用:
require LoadLang('pub/fun.php');
(2)、如果程序文件在/e/extend/helloworld/目录,比如:/e/extend/helloworld/a.php,则导入语言包可以用:
require '../'.LoadLang('pub/fun.php');
(3)、如果程序文件在根目录,比如:/a.php,则导入语言包可以用:
require ECMS_PATH.'e/data/'.LoadLang('pub/fun.php');
*/
#T=找不见的操作
修改栏目目录后要重新更新信息页地址:后台-系统-数据更新-更新信息页地址
#T=专题 - 灵动标签
帝国CMS内置的专题调用标签总是不理想,调用不方便,还是灵动标签调用来得方便实在。
代码:
[e:loop={'select ztid,ztname,ztimg,maxnum,intro,onclick,ztpath from [!db.pre!]enewszt where showzt=1 order by ztid limit 8',10,24,0}]
<li>
<div class="i"><a href="<?=$public_r[newsurl]?><?=$bqr[ztpath]?>" target="_blank"><img src="<?=$bqr[ztimg]?>" alt="<?=$bqr[ztname]?>" width="150px" height="100px" /></a></div>
<div class="t"><a href="<?=$public_r[newsurl]?><?=$bqr[ztpath]?>" target="_blank"><?=$bqr[ztname]?></a></div>
<div class="s"><?=$bqr[intro]?></div>
<div class="s"><span class="l"><?=$bqr[onclick]?>次点击</span><span class="fr"><?=$bqr[maxnum]?>首</span></div>
</li>
[/e:loop]
enewszt 为专题表,要调用专题什么信息就查询什么字段。
showzt=1 为专题分类ID,如要调用多个专类分类, showzt=1 改成:showzt in(1,2,3,4,5,6,7)
#T=专题 - 专题地址 专题字段
专题地址用:/<?=$class_zr[$GLOBALS[navclassid]][ztpath]?>
使用内置调用专题自定义字段函数:ReturnZtAddField(专题ID,字段名),专题ID=0为当前专题ID。取多个字段内容可用逗号隔开,例子:
取得'classtext'字段内容:$value=ReturnZtAddField(0,'classtext'); //$value就是字段内容。
取得多个字段内容:$value=ReturnZtAddField(1,'ztid,classtext'); //$value['classtext']才是字段内容。
#T=自定义页面
/*
帝国CMS使用技巧之调用自定义页面
我们做单页(比如“公司介绍”、“联系我们”等页面)时一般采用自定义页面来做,而调用出自定义页面导航可以用标签SQL调用。如下:
<!--调用自定义页面分类ID=1的页面导航-->
[e:loop={'select id,path,title from [!db.pre!]enewspage where classid=1 order by id limit 20',24}]
<?php
$pageurl=$public_r['newsurl'].str_replace('../../','',$bqr['path']);
?>
<li><a href="<?=$pageurl?>"><?=$bqr[title]?></a></li>
[/e:loop]
例子2:调用自定义页面导航并识别当前自定义页面
[e:loop={'select id,path,title from [!db.pre!]enewspage where classid=1 order by id limit 20',0,24}]
<?php
$pageurl=$public_r['newsurl'].str_replace('../../','',$bqr['path']);
$css='pagecss';
if($classid=='page'.$bqr[id])
{
$css='selfpagecss';
}
?>
<li class="<?=$css?>"><a href="<?=$pageurl?>"><?=$bqr[title]?></a></li>
[/e:loop]
#T=字段 - 存文本 - 读取
<?php
if($emod_r[$mid]['savetxtf']&&$emod_r[$mid]['savetxtf']==$f)//存文本
{
$val=stripSlashes(GetTxtFieldText($val));
}
?>
#T=字段 - 用灵动复杂读取
[e:loop={34,1,0,0}]
<?php
$f='newstext';
$mid=$class_r[$bqr[classid]][modid];
$tbdataf=$emod_r[$mid][tbdataf];
if(strstr($tbdataf,','.$f.',')){
$tbname="{$dbtbpre}ecms_{$class_r[$bqr[classid]][tbname]}_data_{$bqr[stb]}";
}else{
$tbname="{$dbtbpre}ecms_{$class_r[$bqr[classid]][tbname]}";
}
$fr=$empire->fetch1("select newstext from $tbname where id='$bqr[id]'");?>
<?
if($emod_r[$mid]['savetxtf']&&$emod_r[$mid]['savetxtf']==$f)//存文本
{
$fr[newstext]=GetTxtFieldText($fr[newstext]);
}
echo esub(stripslashes($fr[newstext]),10000)
?>
[/e:loop]
#指定栏目或者当前栏目下随机信息
<?php
$classid=1; //指定id,当前为 $navclassid
$limit=7; // 七条
$tbname='news';
list(,$classids)=sys_ReturnMoreClass($classid,1);
$ids=$empire->gettotal("select group_concat(id) as total from {$dbtbpre}ecms_{$tbname} where $classids");
$idsr=explode(',',$ids);
$max=count($idsr)-1;
$ids=array();
$i=0;
while($i<$limit){
$key=rand(0,$max);
if(array_key_exists($key,$ids))continue;
$ids[$key]=$idsr[$key];$i++;
}
$rand=implode(',',$ids);
?>
[e:loop={"select * from {$dbtbpre}ecms_{$tbname} where id in($rand) limit $limit",0,24}]
<a href="<?=$bqsr['titleurl']?>"><?=$bqr[title]?></a>
[/e:loop]
#数据库插入
function r2sql($r)
$jhc='';
foreach($r as $key=>$value){if(!is_numeric($key))$jhc.=$key."='".$value."',";}
return rtrim($jhc,',');
}
#t=print
printerror2("DbError","history.go(-1)");
#t=tags
$infotagsr=explode(',',$r['infotags']);
$r[title]=addslashes($r[title]);
$sql=$empire->query("select tagname,tagid from {$dbtbpre}enewstags where locate(tagname,'$r[title]')>0");
while($jhcr=$empire->fetch($sql)){
if(in_array($jhcr[tagname],$infotagsr))continue;
$infotagsr[]=$jhcr[tagname];
$empire->query("update {$dbtbpre}enewstags set num=num+1 where tagid='$jhcr[tagid]'");
$classid=(int)$r[classid];
$mid=(int)$class_r[$classid][modid];
$empire->query("insert into {$dbtbpre}enewstagsdata set tagid={$jhcr[tagid]},classid=$classid,id={$r[id]},newstime='$r[newstime]',mid=$mid");
}
$r['infotags']=trim(implode(',',$infotagsr),',');
$listtemp='infotags';
#sql union
"SELECT titlepic AS titlepic,yuyan AS yuyan FROM www_jiuxz_com_ecms_azsoft where title like '%$guanjianci%' UNION SELECT titlepic AS titlepic,yuyan AS yuyan FROM www_jiuxz_com_ecms_azgame where title like '%$guanjianci%'"
# js 判断js是否屏蔽
<div id="NoJs" >你禁用了javascript。你真操蛋!我要给你看公告</div>
<script>document.getElementById("NoJs").style.display="none"; </script>
新闻资讯 更多
- 【帝国cms教程】帝国CMS模板变量$GLOBALS[navclassid]用法分析04-03
- 【帝国cms教程】鲜为人知帝国CMS内容页调用上一篇和下一篇的精华方法汇总04-03
- 【帝国cms教程】怎么快速找出帝国CMS数据库配置文件路径及迁移网站后修改技巧!04-03
- 【帝国cms教程】帝国CMS模板$GLOBALS[navclassid]用法详解04-03
- 【帝国cms教程】帝国cms 7.5版列表页分页样式修改笔记04-02
- 【帝国cms教程】解决帝国CMS搜索页面模板不支持灵动标签和万能标签的方法04-02
- 【帝国cms教程】帝国CMS只备份栏目和模板的方法04-02
- 【帝国cms教程】帝国CMS怎样删除清空数据库记录?04-02
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法