Discuz常用代码 [复制链接]

moqu8 2018-4-8

6 0
登录
  1. <a href="member.php?mod=logging&action=login" title="登录">登录</a>
复制代码

注册
  1. <a href="member.php?mod=register" title="立即注册">立即注册</a>
复制代码

忘记密码
  1. <a href="javascript:;" title="找回密码">找回密码</a>
复制代码

购买邀请码
  1. misc.php?mod=buyinvitecode
复制代码

切换配色
  1. <!--{if $_G['uid'] && !empty($_G['style']['extstyle'])}--><a id="sslct" href="javascript:;" onmouseover="delayShow(this, function() {showMenu({'ctrlid':'sslct','pos':'34!'})});">{lang changestyle}</a><!--{/if}-->
复制代码

切换宽窄屏
  1. <!--{if empty($_G['disabledwidthauto']) && $_G['setting']['switchwidthauto']}-->
  2. <a href="javascript:;" id="switchwidth" onclick="widthauto(this)" title="{if widthauto()}{lang switch_narrow}{else}{lang switch_wide}{/if}" class="switchwidth"><!--{if widthauto()}-->{lang switch_narrow}<!--{else}-->{lang switch_wide}<!--{/if}--></a>
  3. <!--{/if}-->
复制代码

空间链接
  1. home.php?mod=space&uid=
复制代码

帖子作者
  1. {$_G[froum_thread][authorid]}
  2. {$_G[froum_thread][author]}
复制代码

用户组颜色
  1. {if $post[groupcolor]} style="color: $post[groupcolor]"{/if}
复制代码

用户组名称
  1. {$post[authortitle]}
复制代码

头像地址
  1. uc_server/avatar.php?uid=1&size=big
复制代码

扩展路径
  1. $_G[style][styleimgdir]
复制代码

JS跳转
  1. onclick="window.location.href='home.php?mod=mobile&do=friend';"
复制代码

当前版块发帖按钮
  1. <!--{if !$_GET['archiveid']}--><a href="javascript:;" id="newspecialtmp" onmouseover="$('newspecial').id = 'newspecialtmp';this.id = 'newspecial';showMenu({'ctrlid':this.id})"{if !$_G['forum']['allowspecialonly'] && empty($_G['forum']['picstyle']) && !$_G['forum']['threadsorts']['required']} onclick="showWindow('newthread', 'forum.php?mod=post&action=newthread&fid=$_G[fid]')"{else} onclick="location.href='forum.php?mod=post&action=newthread&fid=$_G[fid]';return false;"{/if} title="{lang send_posts}"><img src="{IMGDIR}/pn_post.png" alt="{lang send_posts}" /></a><!--{/if}-->
复制代码

JS更换class的名称
  1. document.getElementById('idname').className='a';
  2. document.getElementById('idname').style.display='block';
  3. document.getElementById("idname").style.marginTop="30px";
复制代码

批量替换超链接
  1. href="[^"]*"
复制代码

过滤DZ代码
  1. preg_replace ("/\[[a-z][^\]]*\]|\[\/[a-z]+\]/i",'',preg_replace("/\[attach\]\d+\[\/attach\]/i",'',$message));
复制代码

调用单个数据
  1. $a = DB::result(DB::query("SELECT qi FROM ".DB::table('abc')." WHERE id = '1'"));
复制代码

调用统计数据
  1. $a = DB::result(DB::query("SELECT count(*) FROM ".DB::table('abc')." WHERE id = '1'"));
复制代码

单数据表调用
  1. $perpage = 20;
  2. $curpage = empty ( $_GET['page'] ) ? 1 : intval ( $_GET['page'] );
  3. $start = ($curpage-1)*$perpage;
  4. $askcount = DB::result(DB::query("SELECT COUNT(*) FROM ".DB::table('forum_thread')." WHERE fid = '2' AND authorid > 1"));
  5. //$asklist
  6. $asklist = array();
  7. if ($askcount) {
  8.         $query = DB::query("SELECT * FROM ".DB::table('forum_thread')." WHERE fid = '2' AND displayorder > -1 ORDER BY tid ASC LIMIT $start,$perpage");
  9.         while ($value = DB::fetch($query)) {
  10.                 $asklist[] = $value;
  11.         }
  12. }
  13. $multi = multi($askcount, $perpage, $curpage, "这里填写跳转地址");
复制代码

多数据表调用
  1. $perpage = 40;
  2. $curpage = empty ( $_GET['page'] ) ? 1 : intval ( $_GET['page'] );
  3. $start = ($curpage-1)*$perpage;
  4. $acount = DB::result(DB::query("SELECT count(*) FROM ".DB::table('forum_forum')." b LEFT JOIN ".DB::table('forum_forumfield')." bf ON bf.fid=b.fid WHERE b.type='sub' AND b.status = 3 AND bf.icon != ''"));
  5. //$alist
  6. $alist = array();
  7. if ($acount) {
  8.         $query = DB::query("SELECT bf.*, b.* FROM ".DB::table('forum_forum')." b LEFT JOIN ".DB::table('forum_forumfield')." bf ON bf.fid=b.fid WHERE b.type='sub' AND b.status = 3 AND bf.icon != '' ORDER BY bf.shoplevel DESC, b.commoncredits DESC, bf.fid DESC LIMIT $start,$perpage");
  9.         while ($value = DB::fetch($query)) {
  10.                 $alist[] = $value;
  11.         }
  12. }
  13. $multi = multi($acount, $perpage, $curpage, "这里填写跳转地址");
复制代码

前台数据显示
  1. <!--{loop $alist $key $value}-->
  2. <!--{eval $tupianfm = DB::result(DB::query("SELECT attachment FROM ".DB::table('forum_threadimage')." WHERE tid = '$value[tid]'"));}-->
  3. <img src="$tupianfm"><br>$value[authorid]
  4. <!--{/loop}-->
复制代码

取数据表中符合条件的第一条数据
  1. $app=array();
  2. $app=DB::fetch_first("select * from ".DB::table('abc')." where id='{$id}'");
复制代码

人性化时间戳
最新回复 (0)
返回
支持中心
邮箱:winkill2012@qqcom
新站优化中!部分功能尚未完善,敬请谅解!
支持中心